直接上代码:
#!/usr/bin/python
# filename s5.py
# python dynamic socks5 proxy
# usage: python s5.py 1080
# background run: nohup python s5.py 1080 &
import socket, sys, select, socketserver, struct, time
class threadingtcpserver(socketserver.threadingmixin, socketserver.tcpserver): pass
class socks5server(socketserver.streamrequesthandler):
def handle_tcp(self, sock, remote):
fdset = [sock, remote]
while true:
r, w, e = select.select(fdset, [], [])
if sock in r:
if remote.send(sock.recv(4096))