Files
AILab/bbit_ai/app_mcp/utils/util.py
T
2025-11-05 18:06:40 +08:00

14 lines
317 B
Python

import socket
def get_local_ip():
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Connect to Google's DNS servers
s.connect(("8.8.8.8", 80))
local_ip = s.getsockname()[0]
s.close()
return local_ip
except Exception as e:
return "127.0.0.1"