def isend(self): if not self.invite: print('No invite') return if not self.sock: if self.invite.v6: self.sock=socket(AF_INET6, SOCK_DGRAM) else: self.sock=socket(AF_INET, SOCK_DGRAM) if self.address: try: self.sock.bind(self.address) except: if self.invite.v6: self.sock.bind(('::',self.address[1])) else: self.sock.bind(('',self.address[1])) packet=IntroPacket() packet.createIntroPacket(self.invite.secret, self.invite.id, self.pubkey, self.keys.entropy) addr=(self.invite.ip, self.invite.port) self.sock.sendto(packet.packet, 0, addr) self.invite=None # Invites are single use only
def acceptIntroduction(self, data, addr): print('Introducing', addr) intro=IntroPacket() intro.decodeIntroPacket(self.keys.incomingInvites, data) if intro.intro: self.keys.addHost(addr, intro.intro.pubkey) return intro else: print('Could not read intro packet') return None