Browse Source

remove keep alive

dev
破娃酱 8 years ago
parent
commit
1e2445061f
  1. 16
      shadowsocks/tcprelay.py

16
shadowsocks/tcprelay.py

@ -564,22 +564,6 @@ class TCPRelayHandler(object):
remote_sock_v6.setblocking(False) remote_sock_v6.setblocking(False)
else: else:
remote_sock.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 1) remote_sock.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 1)
remote_sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
if self._is_local:
val_idle = 60
val_intvl = 5
else:
val_idle = 120
val_intvl = 20
if platform.system() in ['Linux']:
remote_sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPIDLE, val_idle)
remote_sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPINTVL, val_intvl)
remote_sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPCNT, 5)
elif platform.system() in ['Windows']:
remote_sock.ioctl(socket.SIO_KEEPALIVE_VALS, (1, 1000 * val_idle, 1000 * val_intvl))
elif platform.system() in ["Darwin"]: #OSX
TCP_KEEPALIVE = 0x10
remote_sock.setsockopt(socket.SOL_TCP, TCP_KEEPALIVE, val_intvl * 2)
if not self._is_local: if not self._is_local:
bind_addr = '' bind_addr = ''

Loading…
Cancel
Save