Created
July 16, 2023 15:03
-
-
Save tuhin47/fe95fa4f51c10d50e3d10ab51538eccd to your computer and use it in GitHub Desktop.
Find Dynamic Public IP in my router
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 socket | |
import concurrent.futures | |
def ping_ip_port(ip, port): | |
try: | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.settimeout(2) | |
s.connect((ip, port)) | |
print("http://{}:{}".format(ip,port)) | |
return True | |
except Exception: | |
return False | |
# TODO Update port and ip pattern | |
port_number = 8080 | |
ip_format="127.0.0.{0}" | |
executor = concurrent.futures.ThreadPoolExecutor(max_workers=255) | |
futures = [] | |
for ip_int in range(0, 255 + 1): | |
ip=ip_format.format(ip_int) | |
future = executor.submit(ping_ip_port, ip, port_number) | |
futures.append(future) | |
for future in concurrent.futures.as_completed(futures): | |
future.result() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment