Exemple #1
0
 def doRemoveOldUDPSession(self, arg):
     for idurl in arg[0]:
         if idurl == misc.getLocalID():
             continue
         if idurl not in arg[1]:
             ident = contacts.getContact(idurl)
             if ident is None:
                 continue
             address = ident.getProtoContact('udp')
             if address is None:
                 continue
             try:
                 ip, port = address[6:].split(':')
                 address = (ip, int(port))
             except:
                 dhnio.DprintException()
                 continue
             if transport_udp_session.is_session_opened(address):
                 dhnio.Dprint(8, 'transport_udp.doRemoveOldUDPSession shutdown %s with [%s]' % (str(address), nameurl.GetName(idurl)))
                 reactor.callLater(0, transport_udp_session.A, address, 'shutdown')
             address_local = self.remapAddress(address)
             if address_local != address:
                 if transport_udp_session.is_session_opened(address_local):
                     dhnio.Dprint(8, 'transport_udp.doRemoveOldUDPSession shutdown %s with local peer [%s]' % (str(address_local), nameurl.GetName(idurl)))
                     self.eraseRedirection(address_local)
                     reactor.callLater(0, transport_udp_session.A, address_local, 'shutdown')
             self.eraseRedirection(address)
             self.eraseRedirection(address_local)
Exemple #2
0
 def doClientOutboxFile(self, arg):
     address = arg[0]
     filename, fast, description = arg[1]
     address = self.remapAddress(address)
     if transport_udp_session.is_session_opened(address):
         transport_udp_session.outbox_file(address, filename, fast, description)
     else:
         if self.redirections.has_key(address) and transport_udp_session.is_session_opened(self.redirections[address]):
             transport_udp_session.outbox_file(self.redirections[address], filename, fast, description)
         else:
             dhnio.Dprint(6, 'transport_udp.doClientOutboxFile WARNING not found session for: ' + str(address))
             transport_udp_session.file_sent(address, filename, 'failed', 'udp', None, 'session not found')
Exemple #3
0
 def recreate(idurl, count):
     if count > 5:
         return
     ident = contacts.getContact(idurl)
     if ident is None:
         return
     address = ident.getProtoContact('udp')
     if address is None:
         return
     try:
         ip, port = address[6:].split(':')
         address = (ip, int(port))
     except:
         dhnio.DprintException()
         return
     if transport_udp_session.is_session_opened(address):
         reactor.callLater(1, recreate, idurl, count+1)
         dhnio.Dprint(8, 'transport_udp.doRecreateUDPSession.recreate wait 1 second to finish old session with %s' % str(address))
         return
     address_local = self.remapAddress(address)
     sess = transport_udp_session.open_session(address_local)
     dhnio.Dprint(8, 'transport_udp.doRecreateUDPSession init %s with [%s]' % (sess.name, nameurl.GetName(idurl)))
     sess.automat('init', idurl)