From 002e17f1a9498dbe87631170046b84e573d4e62a Mon Sep 17 00:00:00 2001 From: burris Date: Mon, 23 Sep 2002 22:09:52 +0000 Subject: [PATCH] grab the remote end's IP address --- xmlrpcclient.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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): -- 2.39.5