#!/usr/bin/env python3 """Quick individual test of IP-gated ZTE hosts with short timeout, plus try direct IP + Host header, and http/https variants.""" import socket, ssl, json, time KEY = "2abd02c3-4e11-4a3b-88cf-341497e35892" HOSTS = ["api.zx.zte.com.cn","apigw.zte.com.cn","aip.zte.com.cn", "maas-apigateway.dt.zte.com.cn"] def raw_tcp(host, port, payload, timeout=6, use_tls=False, sni=None): try: ip = socket.gethostbyname(host) except Exception as e: return f"DNS fail: {e}" s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(timeout) try: s.connect((ip, port)) if use_tls: ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE s = ctx.wrap_socket(s, server_hostname=sni or host) s.sendall(payload) chunks = [] while True: try: d = s.recv(4096) if not d: break chunks.append(d) if sum(len(c) for c in chunks) > 8000: break except socket.timeout: break return b"".join(chunks).decode("utf-8","replace") except Exception as e: return f"{type(e).__name__}: {e}" finally: try: s.close() except Exception: pass for host in HOSTS: print(f"\n===== {host} =====", flush=True) try: ip = socket.gethostbyname(host) print(f" DNS -> {ip}", flush=True) except Exception as e: print(f" DNS fail: {e}", flush=True); continue # HTTPS with Host header for port in (443, 80): for tls in (True, False) if port == 443 else (False,): # Simple HTTP request payload = ( f"GET / HTTP/1.1\r\nHost: {host}\r\n" f"Authorization: Bearer {KEY}\r\n" f"User-Agent: curl/8.4\r\nAccept: */*\r\nConnection: close\r\n\r\n" ).encode() t0=time.time() r = raw_tcp(host, port, payload, timeout=6, use_tls=tls) dt=time.time()-t0 first = r.split("\r\n\r\n",1)[0][:200] if isinstance(r,str) else r[:200] body = r.split("\r\n\r\n",1)[1][:300] if isinstance(r,str) and "\r\n\r\n" in r else "" print(f" [{port}/{'tls' if tls else 'http'} {dt:.1f}s] {first!r}", flush=True) if body: print(f" body: {body!r}", flush=True) # Try the known model path payload = ( f"POST /model/qwen3-coder-480b/v1/chat/completions HTTP/1.1\r\n" f"Host: {host}\r\nAuthorization: Bearer {KEY}\r\n" f"Content-Type: application/json\r\nContent-Length: 78\r\n" f"Connection: close\r\n\r\n" f'{{"model":"qwen3-coder-480b","messages":[{{"role":"user","content":"hi"}}],"max_tokens":5}}' ).encode() t0=time.time() r = raw_tcp(host, 443, payload, timeout=8, use_tls=True) dt=time.time()-t0 first = r.split("\r\n\r\n",1)[0][:300] if isinstance(r,str) else str(r)[:300] body = r.split("\r\n\r\n",1)[1][:500] if isinstance(r,str) and "\r\n\r\n" in r else "" print(f" [POST model path {dt:.1f}s] {first!r}", flush=True) if body: print(f" body: {body!r}", flush=True)