From 63d0bc54ec0edbf9a8fb357053e5f674e4f0f425 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Fri, 16 Nov 2007 08:41:24 +0000 Subject: [PATCH] cache incoming zeroconf connections. fixes #3561 --- src/common/zeroconf/client_zeroconf.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/common/zeroconf/client_zeroconf.py b/src/common/zeroconf/client_zeroconf.py index 92d25a6f1..ff9308162 100644 --- a/src/common/zeroconf/client_zeroconf.py +++ b/src/common/zeroconf/client_zeroconf.py @@ -79,7 +79,16 @@ class ZeroconfListener(IdleObject): def pollin(self): ''' accept a new incomming connection and notify queue''' sock = self.accept_conn() - P2PClient(sock[0], sock[1][0], sock[1][1], self.conn_holder) + ''' loop through roster to find who has connected to us''' + from_jid = None + nameinfo = socket.getnameinfo(sock[1], 0) + ipaddr = socket.gethostbyname(nameinfo[0]) + for jid in self.conn_holder.getRoster().keys(): + entry = self.conn_holder.getRoster().getItem(jid) + if (entry['address'] == ipaddr): + from_jid = jid + break; + P2PClient(sock[0], sock[1][0], sock[1][1], self.conn_holder, [], from_jid) def disconnect(self): ''' free all resources, we are not listening anymore '''