grab the remote end's IP address
authorburris <burris>
Mon, 23 Sep 2002 22:09:52 +0000 (22:09 +0000)
committerburris <burris>
Mon, 23 Sep 2002 22:09:52 +0000 (22:09 +0000)
xmlrpcclient.py

index 7b50917df8b63243c3056e886d13a014cff28a2c..fef7d24ffdaf1fc2e89a090be513e93d1dff564d 100644 (file)
@@ -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):