本文整理汇总了Python中twisted.protocols.policies.WrappingFactory.buildProtocol方法的典型用法代码示例。如果您正苦于以下问题:Python WrappingFactory.buildProtocol方法的具体用法?Python WrappingFactory.buildProtocol怎么用?Python WrappingFactory.buildProtocol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.protocols.policies.WrappingFactory
的用法示例。
在下文中一共展示了WrappingFactory.buildProtocol方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: buildProtocol
# 需要导入模块: from twisted.protocols.policies import WrappingFactory [as 别名]
# 或者: from twisted.protocols.policies.WrappingFactory import buildProtocol [as 别名]
def buildProtocol(self, addr):
remote_ip = ip_address(addr.host)
if any(remote_ip in network for network in self.whitelist):
return WrappingFactory.buildProtocol(self, addr)
else:
log.info("Attempted submission from non-whitelisted %s" % str(addr))
return None
示例2: buildProtocol
# 需要导入模块: from twisted.protocols.policies import WrappingFactory [as 别名]
# 或者: from twisted.protocols.policies.WrappingFactory import buildProtocol [as 别名]
def buildProtocol(self, addr):
try:
remote_ip = ip_address(addr.host)
if not any(remote_ip in network for network in self.whitelist):
log.info(f"Attempted {self.connection_type} from "
f"non-whitelisted {addr}")
return None
except AttributeError:
log.warn(f"Bypassing whitelist for {self.connection_type} "
f"from {addr}")
return WrappingFactory.buildProtocol(self, addr)
示例3: buildProtocol
# 需要导入模块: from twisted.protocols.policies import WrappingFactory [as 别名]
# 或者: from twisted.protocols.policies.WrappingFactory import buildProtocol [as 别名]
def buildProtocol(self, addr):
if self.ht.connectionCount == 0:
if self.ht.readLimit is not None:
self.ht.checkReadBandwidth()
if self.ht.writeLimit is not None:
self.ht.checkWriteBandwidth()
if self.connectionCount < self.maxConnectionCount:
self.connectionCount += 1
self.ht.connectionCount += 1
return WrappingFactory.buildProtocol(self, addr)
else:
log.msg("Max connection count reached!")
return None
示例4: buildProtocol
# 需要导入模块: from twisted.protocols.policies import WrappingFactory [as 别名]
# 或者: from twisted.protocols.policies.WrappingFactory import buildProtocol [as 别名]
def buildProtocol(self, addr):
protocol = WrappingFactory.buildProtocol(self, addr)
protocol.setWriteLimit(self.writeLimit)
return protocol