more log
This commit is contained in:
parent
e811bdb891
commit
46d23bf0d4
3 changed files with 16 additions and 5 deletions
|
@ -199,9 +199,10 @@ class EventLoop(object):
|
|||
except (OSError, IOError) as e:
|
||||
if errno_from_exception(e) == errno.EPIPE:
|
||||
# Happens when the client closes the connection
|
||||
logging.error('poll:%s', e)
|
||||
continue
|
||||
else:
|
||||
logging.error(e)
|
||||
logging.error('poll:%s', e)
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
continue
|
||||
|
|
|
@ -589,9 +589,9 @@ class TCPRelay(object):
|
|||
|
||||
def _handle_events(self, events):
|
||||
for sock, fd, event in events:
|
||||
# if sock:
|
||||
# logging.debug('fd %d %s', fd,
|
||||
# eventloop.EVENT_NAMES.get(event, event))
|
||||
if sock:
|
||||
logging.debug('fd %d %s', fd,
|
||||
eventloop.EVENT_NAMES.get(event, event))
|
||||
if sock == self._server_socket:
|
||||
if event & eventloop.POLL_ERR:
|
||||
# TODO
|
||||
|
|
|
@ -133,6 +133,8 @@ class UDPRelay(object):
|
|||
def _handle_server(self):
|
||||
server = self._server_socket
|
||||
data, r_addr = server.recvfrom(BUF_SIZE)
|
||||
if not data:
|
||||
logging.debug('UDP handle_server: data is empty')
|
||||
if self._is_local:
|
||||
frag = ord(data[2])
|
||||
if frag != 0:
|
||||
|
@ -141,9 +143,10 @@ class UDPRelay(object):
|
|||
else:
|
||||
data = data[3:]
|
||||
else:
|
||||
# decrypt data
|
||||
data = encrypt.encrypt_all(self._password, self._method, 0, data)
|
||||
# decrypt data
|
||||
if not data:
|
||||
logging.debug('UDP handle_server: data is empty after decrypt')
|
||||
return
|
||||
header_result = parse_header(data)
|
||||
if header_result is None:
|
||||
|
@ -191,6 +194,9 @@ class UDPRelay(object):
|
|||
|
||||
def _handle_client(self, sock):
|
||||
data, r_addr = sock.recvfrom(BUF_SIZE)
|
||||
if not data:
|
||||
logging.debug('UDP handle_client: data is empty')
|
||||
return
|
||||
if not self._is_local:
|
||||
addrlen = len(r_addr[0])
|
||||
if addrlen > 255:
|
||||
|
@ -235,8 +241,12 @@ class UDPRelay(object):
|
|||
def _handle_events(self, events):
|
||||
for sock, fd, event in events:
|
||||
if sock == self._server_socket:
|
||||
if event & eventloop.POLL_ERR:
|
||||
logging.error('UDP server_socket err')
|
||||
self._handle_server()
|
||||
elif sock and (fd in self._sockets):
|
||||
if event & eventloop.POLL_ERR:
|
||||
logging.error('UDP client_socket err')
|
||||
self._handle_client(sock)
|
||||
now = time.time()
|
||||
if now - self._last_time > 3.5:
|
||||
|
|
Loading…
Reference in a new issue