mirror of
https://github.com/3proxy/3proxy.git
synced 2026-09-02 12:55:49 +08:00
tcppm and udppm forward a port each, so test both directions of each: a request through the TCP mapper reaching its target, a datagram through the UDP one coming back answered, and a mapper whose rules deny the client answering nothing. tlspr takes its destination from the name in the handshake, so point that name at 127.0.0.1 with nsrecord and give the certificate the same name: the name then both chooses where the request goes and is what the client checks. dnspr answers from its cache, including the documented 0.0.0.0 record, which is handed out as an address rather than withheld. auto is asked to serve an HTTP proxy request, SOCKS4, SOCKS5 and a TLS handshake on one port, and to make nothing of a request that is none of them. Its protocols reach different places, so there are two origins. The SOCKS UDP association was only checked for the port it binds. Send datagrams through it as well, large and small, and check a second association gets its own port - and that one bound inside an intport range still relays. A UDP service has no socket to connect to, so readiness is found by asking until it answers rather than racing it.
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
"""tlspr: the destination comes from the name in the TLS handshake."""
|
|
|
|
|
|
def run(t):
|
|
certs = t.certs()
|
|
if not certs:
|
|
t.skip("tlspr (openssl is not available to generate certificates)")
|
|
return
|
|
|
|
origin = t.free_port()
|
|
sni = t.free_port()
|
|
|
|
server = t.start("tlspr", f"""
|
|
log
|
|
ssl_server_cert {certs.server}
|
|
ssl_server_key {certs.server_key}
|
|
ssl_serv
|
|
auth iponly
|
|
allow *
|
|
http * /echo* echo
|
|
httpsrv -p{origin}
|
|
|
|
flush
|
|
ssl_noserv
|
|
nserver 127.0.0.1
|
|
nscache 1024
|
|
nsrecord sni.test 127.0.0.1
|
|
auth iponly
|
|
allow *
|
|
tlspr -p{sni} -P{origin}
|
|
""", ports=[origin, sni])
|
|
|
|
if "Unknown command" in server.output():
|
|
t.skip("tlspr (this build has no SSL support)")
|
|
return
|
|
|
|
# The certificate names sni.test, so the name in the handshake is both
|
|
# what picks the destination and what the client checks.
|
|
r = t.https(f"https://sni.test:{sni}/echo", ca=certs.ca, strict=False,
|
|
connect_to=("127.0.0.1", sni))
|
|
t.eq(200, r.status, "the name in the handshake reaches its destination")
|
|
t.contains(r, "path=/echo", "the request arrives at the origin")
|
|
|
|
# a name the proxy cannot resolve has nowhere to go
|
|
r = t.https(f"https://nowhere.test:{sni}/echo", ca=certs.ca, strict=False,
|
|
verify_name=False, connect_to=("127.0.0.1", sni))
|
|
t.ne(200, r.status, "a name that does not resolve is refused")
|