cache incoming zeroconf connections. fixes #3561

This commit is contained in:
Yann Leboulanger 2007-11-16 08:41:24 +00:00
parent 6c5f65ddf0
commit 63d0bc54ec
1 changed files with 10 additions and 1 deletions

View File

@ -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 '''