コード例 #1
0
ファイル: transport_udp.py プロジェクト: vesellov/datahaven
 def doRestartUDPSession(self, arg):
     idurl = arg
     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
     address_local = self.remapAddress(address)
     for sess in transport_udp_session.sessions():
         if  sess.remote_idurl is not None and sess.remote_idurl == idurl and \
             ( sess.remote_address[0] == address[0] or sess.remote_address[0] == address_local[0] ) and \
             ( sess.remote_address[1] != address[1] or sess.remote_address[1] != address_local[1] ):
             self.addRedirection(sess.remote_address, address_local)
             sess.automat('shutdown')
             dhnio.Dprint(8, 'transport_udp.doRestartUDPSession "shutdown" to %s with [%s]' % (sess.name, nameurl.GetName(idurl)))
     def start_session(address_local, idurl):
         sess = transport_udp_session.open_session(address_local)
         dhnio.Dprint(8, 'transport_udp.doRestartUDPSession.start_session send "init" to %s with [%s]' % (sess.name, nameurl.GetName(idurl)))
         sess.automat('init', idurl)
     reactor.callLater(1, start_session, address_local, idurl)
コード例 #2
0
ファイル: transport_udp.py プロジェクト: vesellov/datahaven
 def doCloseDuplicatedUDPSession(self, arg):
     index, idurl = arg
     current_session = transport_udp_session.get_session_by_index(index)
     if current_session is None:
         dhnio.Dprint(6, 'transport_udp.doCloseDuplicatedUDPSession WARNING current session is None index=%d' % index)
         return
     for sess in transport_udp_session.sessions():
         if sess.index == index:
             continue
         if sess.remote_idurl is not None and sess.remote_idurl == idurl:
             self.addRedirection(sess.remote_address, current_session.remote_address)
             sess.automat('shutdown')
             dhnio.Dprint(8, 'transport_udp.doCloseDuplicatedUDPSession for [%s], redirect to %s, send "shutdown" to %s' % (
                 nameurl.GetName(idurl), current_session.name, sess.name))
コード例 #3
0
ファイル: transport_udp.py プロジェクト: vesellov/datahaven
 def isIPPortChanged(self, arg):
     idurl = arg
     ident = contacts.getContact(idurl)
     if ident is None:
         return False
     address = ident.getProtoContact('udp')
     if address is None:
         return False
     try:
         ip, port = address[6:].split(':')
         address = (ip, int(port))
     except:
         dhnio.DprintException()
         return False
     address_local = self.remapAddress(address)
     found = False
     for sess in transport_udp_session.sessions():
         if  sess.remote_idurl is not None and \
             sess.remote_idurl == idurl and \
             ( sess.remote_address[0] == address[0] or sess.remote_address[0] == address_local[0] ) and \
             ( sess.remote_address[1] != address[1] and sess.remote_address[1] != address_local[1] ):
             found = True
             dhnio.Dprint(6, 'transport_udp.isIPPortChanged found related session %s with [%s]' % (sess.name, sess.remote_name))
     return found