我知道我们可以在建立连接后获得客户端(主机)IP,因为那时我们将具有传输属性:
self.transport.getPeer()
Run Code Online (Sandbox Code Playgroud)
但是当它断开与服务器的连接时,如何在扭曲的TCP服务器中获取客户端的IP地址.
Mar*_*ski 10
它有点晚了.我建议你保存这些信息.例如:
class YourProtocol(protocol.Protocol):
def connectionMade(self):
self._peer = self.transport.getPeer()
def connectionLost(self):
print 'Lost connection from', self._peer
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5050 次 |
| 最近记录: |