本文整理汇总了Python中shadowsocks.common.PortRange方法的典型用法代码示例。如果您正苦于以下问题:Python common.PortRange方法的具体用法?Python common.PortRange怎么用?Python common.PortRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shadowsocks.common
的用法示例。
在下文中一共展示了common.PortRange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pull_db_all_user
# 需要导入模块: from shadowsocks import common [as 别名]
# 或者: from shadowsocks.common import PortRange [as 别名]
def pull_db_all_user(self):
import json
rows = None
config_path = get_config().MUDB_FILE
with open(config_path, 'rb+') as f:
rows = json.loads(f.read().decode('utf8'))
for row in rows:
try:
if 'forbidden_ip' in row:
row['forbidden_ip'] = common.IPNetwork(row['forbidden_ip'])
except Exception as e:
logging.error(e)
try:
if 'forbidden_port' in row:
row['forbidden_port'] = common.PortRange(row['forbidden_port'])
except Exception as e:
logging.error(e)
if not rows:
logging.warn('no user in json file')
return rows
示例2: modify_multi_user_table
# 需要导入模块: from shadowsocks import common [as 别名]
# 或者: from shadowsocks.common import PortRange [as 别名]
def modify_multi_user_table(self, new_table):
self.multi_user_table = new_table.copy()
self.multi_user_host_table = {}
self._protocol.obfs.server_info.users = self.multi_user_table
for id in self.multi_user_table:
self.multi_user_host_table[common.get_mu_host(
id, self.multi_user_table[id]['md5'])] = id
if self.multi_user_table[id]['forbidden_ip'] is not None:
self.multi_user_table[id]['_forbidden_iplist'] = IPNetwork(
str(self.multi_user_table[id]['forbidden_ip']))
else:
self.multi_user_table[id][
'_forbidden_iplist'] = IPNetwork(str(""))
if self.multi_user_table[id]['disconnect_ip'] is not None:
self.multi_user_table[id]['_disconnect_ipset'] = IPNetwork(
str(self.multi_user_table[id]['disconnect_ip']))
else:
self.multi_user_table[id]['_disconnect_ipset'] = None
if self.multi_user_table[id]['forbidden_port'] is not None:
self.multi_user_table[id]['_forbidden_portset'] = PortRange(
str(self.multi_user_table[id]['forbidden_port']))
else:
self.multi_user_table[id][
'_forbidden_portset'] = PortRange(str(""))
示例3: modify_multi_user_table
# 需要导入模块: from shadowsocks import common [as 别名]
# 或者: from shadowsocks.common import PortRange [as 别名]
def modify_multi_user_table(self, new_table):
self.multi_user_table = new_table.copy()
self.multi_user_host_table = {}
for id in self.multi_user_table:
if id not in self.mu_reset_time:
self.mu_reset_time[id] = time.time()
self.multi_user_host_table[common.get_mu_host(
id, self.multi_user_table[id]['md5'])] = id
if self.multi_user_table[id]['forbidden_ip'] is not None:
self.multi_user_table[id]['_forbidden_iplist'] = IPNetwork(
str(self.multi_user_table[id]['forbidden_ip']))
else:
self.multi_user_table[id][
'_forbidden_iplist'] = IPNetwork(str(""))
if self.multi_user_table[id]['disconnect_ip'] is not None:
self.multi_user_table[id]['_disconnect_ipset'] = IPNetwork(
str(self.multi_user_table[id]['disconnect_ip']))
else:
self.multi_user_table[id]['_disconnect_ipset'] = None
if self.multi_user_table[id]['forbidden_port'] is not None:
self.multi_user_table[id]['_forbidden_portset'] = PortRange(
str(self.multi_user_table[id]['forbidden_port']))
else:
self.multi_user_table[id][
'_forbidden_portset'] = PortRange(str(""))
if 'node_speedlimit' not in self.multi_user_table[id]:
bandwidth = 0
else:
bandwidth = float(
self.multi_user_table[id]['node_speedlimit']) * 128
self.mu_speed_tester_u[id] = SpeedTester(bandwidth)
self.mu_speed_tester_d[id] = SpeedTester(bandwidth)