mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-06-06 19:25:34 +00:00
failproof online check (fixes vpns and dns tunnels)
This commit is contained in:
parent
c153247918
commit
bc51150e47
@ -1,12 +1,14 @@
|
|||||||
import socket as Socket
|
import socket as Socket
|
||||||
|
|
||||||
|
|
||||||
def has_connection(host="8.8.8.8", port=53, timeout=3):
|
def has_connection(host="google.it", port=80, timeout=3):
|
||||||
"""
|
"""
|
||||||
|
# REVIEW Was:
|
||||||
Host: 8.8.8.8 (google-public-dns-a.google.com)
|
Host: 8.8.8.8 (google-public-dns-a.google.com)
|
||||||
OpenPort: 53/tcp
|
OpenPort: 53/tcp
|
||||||
Service: domain (DNS/TCP)
|
Service: domain (DNS/TCP)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
Socket.setdefaulttimeout(timeout)
|
Socket.setdefaulttimeout(timeout)
|
||||||
Socket.socket(Socket.AF_INET, Socket.SOCK_STREAM).connect((host, port))
|
Socket.socket(Socket.AF_INET, Socket.SOCK_STREAM).connect((host, port))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user