From: burris Date: Mon, 23 Sep 2002 22:09:52 +0000 (+0000) Subject: grab the remote end's IP address X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=002e17f1a9498dbe87631170046b84e573d4e62a;p=quix0rs-apt-p2p.git grab the remote end's IP address --- diff --git a/xmlrpcclient.py b/xmlrpcclient.py index 7b50917..fef7d24 100644 --- a/xmlrpcclient.py +++ b/xmlrpcclient.py @@ -3,6 +3,7 @@ from twisted.protocols.http import HTTPClient from twisted.internet.defer import Deferred from xmlrpclib import loads, dumps +import socket USER_AGENT = 'Python/Twisted XMLRPC 0.1' class XMLRPCClient(HTTPClient): @@ -17,6 +18,10 @@ class XMLRPCClient(HTTPClient): self.transport.write('\r\n') def handleResponse(self, buf): + try: + self.thehost = self.transport.getHost()[1] + except: + self.thehost = None try: args, name = loads(buf) except Exception, e: @@ -26,7 +31,7 @@ class XMLRPCClient(HTTPClient): l = [] for i in args: l.append(i) - l.append({'host' : self.transport.getHost()[1]}) + l.append({'host' : self.thehost}) apply(self.d.callback, (l,)) class XMLRPCClientFactory(ClientFactory):