From 6e50890f4f4411572e5aa4f7f586de52907d6d81 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Thu, 24 Apr 2014 00:10:45 +0800 Subject: [PATCH] add connect --- shadowsocks/udprelay.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shadowsocks/udprelay.py b/shadowsocks/udprelay.py index 7783e03..5982bb8 100644 --- a/shadowsocks/udprelay.py +++ b/shadowsocks/udprelay.py @@ -183,6 +183,8 @@ class UDPRelay(object): data = encrypt.encrypt_all(self._password, self._method, 1, data) if not data: return + # prevent from recv other sources + client.connect((server_addr, server_port)) client.sendto(data, (server_addr, server_port)) def _handle_client(self, sock): @@ -212,10 +214,9 @@ class UDPRelay(object): if client_addr: self._server_socket.sendto(response, client_addr) else: + # this packet is from somewhere else we know + # simply drop that packet pass - # self._eventloop.remove(sock) - # sock.close() - # TODO remove it from cache else we can't close it def _run(self): server_socket = self._server_socket