Created
February 19, 2022 20:59
-
-
Save Evernow/346350964a82320a60ab7637d83ca368 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ssl, socket | |
# Key stores what we are checking, value stores what we expect. | |
check_if_blocked = {"events.gfe.nvidia.com" : "gfe.nvidia.com", "services.gfe.nvidia.com" : "services.gfe.nvidia.com", | |
"gfwsl.geforce.com" : "gfwsl.geforce.com" | |
, "telemetry.gfe.nvidia.com" : "gfe.nvidia.com", | |
"rds-assets.nvidia.com" : "services.gfe.nvidia.com" | |
} | |
def checkpiholes(): | |
string = "" | |
for hostname in check_if_blocked.keys(): | |
try: | |
ctx = ssl.create_default_context() | |
with ctx.wrap_socket(socket.socket(), server_hostname=hostname) as s: | |
s.connect((hostname, 443)) | |
cert = s.getpeercert() | |
subject = dict(x[0] for x in cert['subject']) | |
issued_to = subject['commonName'] | |
if issued_to == check_if_blocked[hostname]: # Counters bullshit host or Pihole redirects. | |
string += "Successfully connected to " + hostname + "\n" | |
else: | |
string += "Connection was redirected to " + issued_to + " when connecting to " + hostname + "\n" | |
except Exception as f: | |
string += "Failed to connect to " + hostname + " with " + str(f) + "\n" | |
return(string) | |
print(checkpiholes()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment