From 9ffb0320bbfa97a9150bb305a8073d228ce49030 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Thu, 24 Apr 2014 00:15:18 +0800 Subject: [PATCH] move connect to a proper place --- shadowsocks/udprelay.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shadowsocks/udprelay.py b/shadowsocks/udprelay.py index 5982bb8..36cd411 100644 --- a/shadowsocks/udprelay.py +++ b/shadowsocks/udprelay.py @@ -176,6 +176,10 @@ class UDPRelay(object): return self._eventloop.add(client, eventloop.MODE_IN) + # prevent from recv other sources + if self._is_local: + client.connect((server_addr, server_port)) + data = data[header_length:] if not data: return @@ -183,8 +187,6 @@ 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):