-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathacp_diag2.sh
More file actions
66 lines (62 loc) · 1.82 KB
/
acp_diag2.sh
File metadata and controls
66 lines (62 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
echo "=== ACP 端口数据层诊断 v2 ==="
TARGET="33.229.113.196"
python3 - << PYEOF
import socket, time
target = "33.229.113.196"
# 详细测试 8080
print("── 8080 详细诊断 ──")
for path in ["/", "/health", "/acp/test"]:
s = socket.socket()
s.settimeout(5)
try:
s.connect((target, 8080))
req = f"GET {path} HTTP/1.1\r\nHost: {target}\r\nConnection: close\r\n\r\n"
s.sendall(req.encode())
time.sleep(2)
try:
data = b""
while True:
chunk = s.recv(4096)
if not chunk: break
data += chunk
except: pass
if data:
lines = data.split(b'\r\n')
print(f" GET {path} -> {lines[0].decode(errors='replace')}")
for l in lines[1:6]:
if l: print(f" {l.decode(errors='replace')}")
else:
print(f" GET {path} -> (empty)")
s.close()
except Exception as e:
print(f" GET {path} -> ❌ {e}")
# WebSocket 升级测试 8080
print("")
print("── 8080 WebSocket 测试 ──")
s = socket.socket()
s.settimeout(5)
try:
s.connect((target, 8080))
req = (
"GET /acp/tok_c04abe90fafa4049 HTTP/1.1\r\n"
f"Host: {target}\r\n"
"Upgrade: websocket\r\n"
"Connection: Upgrade\r\n"
"Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"
"Sec-WebSocket-Version: 13\r\n\r\n"
)
s.sendall(req.encode())
time.sleep(2)
try:
resp = s.recv(4096)
first = resp.split(b'\r\n')[0].decode(errors='replace')
print(f" WS upgrade -> {first}")
if b'101' in resp:
print(" ✅ WebSocket 101 成功!")
except socket.timeout:
print(" ❌ WS 握手超时")
s.close()
except Exception as e:
print(f" ❌ {e}")
PYEOF