qwj / python-proxy

HTTP/HTTP2/HTTP3/Socks4/Socks5/Shadowsocks/ShadowsocksR/SSH/Redirect/Pf TCP/UDP asynchronous tunnel proxy implemented in Python 3 asyncio.
MIT License
2.01k stars 338 forks source link

print effective port when port is automatic (zero) #143

Closed milahu closed 2 years ago

milahu commented 2 years ago

fix #142

example output

$ pproxy
Serving on ipv4 0.0.0.0:8080 by http,socks4,socks5 
Serving on ipv6 :::8080 by http,socks4,socks5

$ pproxy -l http://127.0.0.1:0/
Serving on ipv4 127.0.0.1:35847 by http 

$ pproxy -l http://127.0.0.1:0/ 
Serving on ipv4 127.0.0.1:35041 by http 

$ pproxy -l http://127.0.0.1:0/ 
Serving on ipv4 127.0.0.1:41479 by http 
milahu commented 2 years ago

thanks for merging : )

note to future: this could be made better

ipversion = "ipv4" if f == "AddressFamily.AF_INET" else ("ipv6" if f == "AddressFamily.AF_INET6" else "ipv?") # TODO better

https://docs.python.org/3/library/socket.html#socket-families