33 lines
848 B
Python
33 lines
848 B
Python
#!/usr/bin/env python3
|
|
import socket
|
|
|
|
ports = [5001, 11434, 8000, 8080, 9000, 3000, 11433]
|
|
host = "localhost"
|
|
|
|
print("检测 OpenClaw agent 端口...\n")
|
|
|
|
for port in ports:
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
sock.settimeout(2)
|
|
try:
|
|
result = sock.connect_ex((host, port))
|
|
if result == 0:
|
|
print(f"✅ 端口 {port} - OPEN")
|
|
else:
|
|
print(f"❌ 端口 {port} - closed")
|
|
except Exception as e:
|
|
print(f"❌ 端口 {port} - {e}")
|
|
sock.close()
|
|
|
|
print("\n再试试 127.0.0.1...")
|
|
for port in ports:
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
sock.settimeout(2)
|
|
try:
|
|
result = sock.connect_ex(("127.0.0.1", port))
|
|
if result == 0:
|
|
print(f"✅ 端口 {port} - OPEN")
|
|
except:
|
|
pass
|
|
sock.close()
|