mirror of
https://github.com/jellyfin/jellyfin-mpv-shim.git
synced 2024-11-23 05:59:43 +00:00
Add timeout to external calls.
This commit is contained in:
parent
96bfea0ccf
commit
825126f398
@ -21,7 +21,7 @@ class UpdateChecker:
|
||||
def _check_updates(self):
|
||||
log.info("Checking for updates...")
|
||||
try:
|
||||
response = requests.get(release_url + "latest", allow_redirects=False)
|
||||
response = requests.get(release_url + "latest", allow_redirects=False, timeout=(3, 10))
|
||||
version = response.headers["location"][len(release_url)+5:]
|
||||
if CLIENT_VERSION != version:
|
||||
self.new_version = version
|
||||
|
@ -1,6 +1,6 @@
|
||||
import socket
|
||||
import ipaddress
|
||||
import urllib.request
|
||||
import requests
|
||||
import urllib.parse
|
||||
from threading import Lock
|
||||
import logging
|
||||
@ -63,8 +63,7 @@ def is_local_domain(client):
|
||||
if not is_local:
|
||||
if addr_info[0] == socket.AddressFamily.AF_INET:
|
||||
try:
|
||||
wan_ip = (urllib.request.urlopen("https://checkip.amazonaws.com/")
|
||||
.read().decode('ascii').replace('\n','').replace('\r',''))
|
||||
wan_ip = requests.get("https://checkip.amazonaws.com/", timeout=(3, 10)).text.strip("\r\n")
|
||||
return ip == wan_ip
|
||||
except Exception:
|
||||
log.warning("checkip.amazonaws.com is unavailable. Assuming potential WAN ip is remote.", exc_info=True)
|
||||
|
Loading…
Reference in New Issue
Block a user