Browse Source

log client address

dev
BreakWa11 9 years ago
parent
commit
3c64e849b0
  1. 2
      shadowsocks/eventloop.py
  2. 10
      shadowsocks/tcprelay.py

2
shadowsocks/eventloop.py

@ -220,7 +220,7 @@ class EventLoop(object):
addr = sock.getpeername()[:2] addr = sock.getpeername()[:2]
logging.error('exception peer name %s:%d' % (addr[0], addr[1])) logging.error('exception peer name %s:%d' % (addr[0], addr[1]))
except: except:
pass logging.error('no peer name')
now = time.time() now = time.time()
if asap or now - self._last_time >= TIMEOUT_PRECISION: if asap or now - self._last_time >= TIMEOUT_PRECISION:
for callback in self._periodic_callbacks: for callback in self._periodic_callbacks:

10
shadowsocks/tcprelay.py

@ -768,22 +768,24 @@ class TCPRelayHandler(object):
logging.debug('got local error') logging.debug('got local error')
if self._local_sock: if self._local_sock:
logging.error(eventloop.get_sock_error(self._local_sock)) logging.error(eventloop.get_sock_error(self._local_sock))
logging.error("exception from %s:%d" % (self._client_address[0], self._client_address[1]))
try: try:
addr = self._local_sock.getpeername()[:2] addr = self._local_sock.getpeername()
logging.error('local exception peer name %s:%d' % (addr[0], addr[1])) logging.error('local exception peer name %s:%d' % (addr[0], addr[1]))
except: except:
pass logging.error('no peer name')
self.destroy() self.destroy()
def _on_remote_error(self): def _on_remote_error(self):
logging.debug('got remote error') logging.debug('got remote error')
if self._remote_sock: if self._remote_sock:
logging.error(eventloop.get_sock_error(self._remote_sock)) logging.error(eventloop.get_sock_error(self._remote_sock))
logging.error("exception from %s:%d" % (self._client_address[0], self._client_address[1]))
try: try:
addr = self._remote_sock.getpeername()[:2] addr = self._remote_sock.getpeername()
logging.error('remote exception peer name %s:%d' % (addr[0], addr[1])) logging.error('remote exception peer name %s:%d' % (addr[0], addr[1]))
except: except:
pass logging.error('no peer name')
self.destroy() self.destroy()
def handle_event(self, sock, event): def handle_event(self, sock, event):

Loading…
Cancel
Save