mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] timeout on get_public_ip otherwish dyndns update is stucked
This commit is contained in:
parent
b46fb46768
commit
43b10298fc
1 changed files with 5 additions and 3 deletions
|
@ -21,7 +21,9 @@
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
from urllib import urlopen
|
import requests
|
||||||
|
|
||||||
|
from requests import ConnectionError
|
||||||
|
|
||||||
logger = logging.getLogger('yunohost.utils.network')
|
logger = logging.getLogger('yunohost.utils.network')
|
||||||
|
|
||||||
|
@ -37,8 +39,8 @@ def get_public_ip(protocol=4):
|
||||||
raise ValueError("invalid protocol version")
|
raise ValueError("invalid protocol version")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return urlopen(url).read().strip()
|
return requests.get(url, timeout=30).content.strip()
|
||||||
except IOError:
|
except ConnectionError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue