More robust connection check

main
Mateus Melchiades 2 years ago
parent be2603bbe4
commit 0b713e284e
No known key found for this signature in database
GPG Key ID: B4F90D80232FD9C4

@ -14,8 +14,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import socket
import subprocess
from urllib.request import urlopen
from urllib.error import URLError
from gi.repository import Gtk, GLib, Adw
@ -52,22 +52,10 @@ class VanillaDefaultConnCheck(Adw.Bin):
def __start_conn_check(self):
def async_fn():
try:
host = socket.gethostbyname("8.8.8.8")
s = socket.create_connection((host, 53), 2)
s.close()
urlopen("http://google.com", timeout=1)
return True
except:
try:
host = '2001:4860:4860::8888'
s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
s.settimeout(2)
s.connect((host, 53))
s.close()
return True
except:
pass
return False
except URLError:
return False
def callback(res, *args):
if res:

Loading…
Cancel
Save