callisto/utils/network.py

12 lines
247 B
Python
Raw Permalink Normal View History

2025-05-16 15:39:31 +02:00
import socket
def get_ip():
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
ip = s.getsockname()[0]
s.close()
2025-05-16 18:28:37 +02:00
return ip
2025-05-16 15:39:31 +02:00
except Exception:
2025-05-16 18:28:37 +02:00
return "No IP"