File size: 1,624 Bytes
4024ed7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import sys
sys.path.insert(0, '/workspace/sglang/python')

from sglang.utils import http_request

# 设置环境变量
os.environ['NO_PROXY'] = 'localhost,127.0.0.1,::1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16'
os.environ['no_proxy'] = 'localhost,127.0.0.1,::1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16'

print("Testing connection to http://10.10.101.31:30000/get_model_info")
print(f"NO_PROXY: {os.environ.get('NO_PROXY')}")

# Debug: test the pattern matching
from urllib.parse import urlparse
url = "http://10.10.101.31:30000/get_model_info"
parsed = urlparse(url)
hostname = parsed.hostname
print(f"Hostname: {hostname}")

# Test pattern matching
no_proxy = os.environ.get('NO_PROXY', '')
for pattern in no_proxy.split(','):
    pattern = pattern.strip()
    print(f"Testing pattern: {pattern}")
    if '/' in pattern:
        network_parts = pattern.split('/')[0].split('.')
        hostname_parts = hostname.split('.')
        cidr = int(pattern.split('/')[1])
        octets_to_check = (cidr + 7) // 8
        print(f"  Network parts: {network_parts[:octets_to_check]}")
        print(f"  Hostname parts: {hostname_parts[:octets_to_check]}")
        if hostname_parts[:octets_to_check] == network_parts[:octets_to_check]:
            print(f"  MATCH!")

print("\nActual request:")
try:
    res = http_request("http://10.10.101.31:30000/get_model_info")
    print(f"Status: {res.status_code}")
    if res.status_code == 200:
        print(f"Response: {res.json()}")
    else:
        print(f"Error: {res.text}")
except Exception as e:
    print(f"Exception: {e}")
    import traceback
    traceback.print_exc()