Browse Source

optimize

dev
破娃酱 8 years ago
parent
commit
1e85d14a48
  1. 2
      db_transfer.py
  2. 2
      shadowsocks/udprelay.py

2
db_transfer.py

@ -88,6 +88,7 @@ class TransferBase(object):
new_servers = {} new_servers = {}
allow_users = {} allow_users = {}
mu_servers = {} mu_servers = {}
config = shell.get_config(False)
for row in rows: for row in rows:
try: try:
allow = switchrule.isTurnOn(row) and row['enable'] == 1 and row['u'] + row['d'] < row['transfer_enable'] allow = switchrule.isTurnOn(row) and row['enable'] == 1 and row['u'] + row['d'] < row['transfer_enable']
@ -152,7 +153,6 @@ class TransferBase(object):
else: else:
self.new_server(port, passwd, cfg) self.new_server(port, passwd, cfg)
else: else:
config = shell.get_config(False)
if ServerPool.get_instance().server_is_run(port) > 0: if ServerPool.get_instance().server_is_run(port) > 0:
if config['additional_ports_only'] or not allow: if config['additional_ports_only'] or not allow:
logging.info('db stop server at port [%s]' % (port,)) logging.info('db stop server at port [%s]' % (port,))

2
shadowsocks/udprelay.py

@ -506,11 +506,11 @@ class UDPRelay(object):
try: try:
#logging.info('UDP handle_server sendto %s:%d %d bytes' % (common.to_str(server_addr), server_port, len(data))) #logging.info('UDP handle_server sendto %s:%d %d bytes' % (common.to_str(server_addr), server_port, len(data)))
client.sendto(data, (server_addr, server_port)) client.sendto(data, (server_addr, server_port))
self.add_transfer_u(client_uid, len(data))
if client_pair is None: # new request if client_pair is None: # new request
addr, port = client.getsockname()[:2] addr, port = client.getsockname()[:2]
common.connect_log('UDP data to %s:%d from %s:%d by UID %d' % common.connect_log('UDP data to %s:%d from %s:%d by UID %d' %
(common.to_str(server_addr), server_port, addr, port, user_id)) (common.to_str(server_addr), server_port, addr, port, user_id))
self.add_transfer_u(client_uid, len(data))
except IOError as e: except IOError as e:
err = eventloop.errno_from_exception(e) err = eventloop.errno_from_exception(e)
if err in (errno.EINPROGRESS, errno.EAGAIN): if err in (errno.EINPROGRESS, errno.EAGAIN):

Loading…
Cancel
Save