Browse Source

add nodelay

1.4
clowwindy 11 years ago
parent
commit
355307e5ef
  1. 3
      .gitignore
  2. 2
      shadowsocks/local.py
  3. 2
      shadowsocks/server.py

3
.gitignore

@ -25,3 +25,6 @@ pip-log.txt
#Mr Developer
.mr.developer.cfg
.DS_Store
.idea

2
shadowsocks/local.py

@ -121,6 +121,7 @@ class Socks5Server(SocketServer.StreamRequestHandler):
try:
self.encryptor = encrypt.Encryptor(KEY, METHOD)
sock = self.connection
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
data = sock.recv(262)
if not data:
sock.close()
@ -202,6 +203,7 @@ class Socks5Server(SocketServer.StreamRequestHandler):
# reply immediately
aServer, aPort = self.getServer()
remote = socket.create_connection((aServer, aPort))
remote.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
self.send_encrypt(remote, addr_to_send)
logging.info('connecting %s:%d' % (addr, port[0]))
except socket.error, e:

2
shadowsocks/server.py

@ -102,6 +102,7 @@ class Socks5Server(SocketServer.StreamRequestHandler):
self.encryptor = encrypt.Encryptor(self.server.key,
self.server.method)
sock = self.connection
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
iv_len = self.encryptor.iv_len()
data = sock.recv(iv_len)
if iv_len > 0 and not data:
@ -130,6 +131,7 @@ class Socks5Server(SocketServer.StreamRequestHandler):
try:
logging.info('connecting %s:%d' % (addr, port[0]))
remote = socket.create_connection((addr, port[0]))
remote.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
except socket.error, e:
# Connection refused
logging.warn(e)

Loading…
Cancel
Save