当前位置: 首页>>代码示例>>Python>>正文


Python common.PortRange方法代码示例

本文整理汇总了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 
开发者ID:hao35954514,项目名称:shadowsocksR-b,代码行数:24,代码来源:db_transfer.py

示例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("")) 
开发者ID:PaperDashboard,项目名称:shadowsocks,代码行数:28,代码来源:udprelay.py

示例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) 
开发者ID:PaperDashboard,项目名称:shadowsocks,代码行数:38,代码来源:tcprelay.py


注:本文中的shadowsocks.common.PortRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。