This commit is contained in:
clowwindy 2014-05-01 13:43:00 +08:00
parent 355307e5ef
commit 0b9ff0557f
2 changed files with 10 additions and 2 deletions

View file

@ -202,9 +202,13 @@ class Socks5Server(SocketServer.StreamRequestHandler):
self.wfile.write(reply)
# reply immediately
aServer, aPort = self.getServer()
remote = socket.create_connection((aServer, aPort))
MSG_FASTOPEN = 0x20000000
remote = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# remote = socket.create_connection((aServer, aPort))
remote.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
self.send_encrypt(remote, addr_to_send)
data = self.encrypt(addr_to_send)
remote.sendto(data, MSG_FASTOPEN, (aServer, aPort))
# self.send_encrypt(remote, addr_to_send)
logging.info('connecting %s:%d' % (addr, port[0]))
except socket.error, e:
logging.warn(e)

View file

@ -65,6 +65,10 @@ def send_all(sock, data):
class ThreadingTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
allow_reuse_address = True
def server_activate(self):
self.socket.setsockopt(socket.SOL_TCP, 23, 5)
self.socket.listen(self.request_queue_size)
class Socks5Server(SocketServer.StreamRequestHandler):
def handle_tcp(self, sock, remote):