Ejemplo n.º 1
0
 def _onTimer( self ) :
     self.timerOp = None
     localIP = getLocalIP()
     if localIP is None :
         self._initTimer()
         return
     nodeAddrList = self.nodeTable.getLiveNodes()
     if not nodeAddrList :
         self._initTimer()
         return
     tcpListener = None
     udpSock = None
     for port in xrange(10001,20000) :
         addr = (localIP,port)
         try :
             tcpListener = tcpListen( addr, self.reactor, None )
         except sock_error :
             continue
         udpSock = socket( AF_INET, SOCK_DGRAM )
         try :
             udpSock.bind( addr )
         except sock_error :
             udpSock.close()
             tcpListener.close()
             udpSock = tcpListener = None
             continue
         break
     if tcpListener is None :
         self._initTimer()
         return
     self.rpcSock = RPCSocket( udpSock, self.reactor )
     self.tcpListener = tcpListener
     self.firewallOp = _testFirewall( self.tcpListener,
             self.rpcSock, nodeAddrList, localIP, self.reactor,
             self._onFirewallCheck )
Ejemplo n.º 2
0
 def _onTimer(self):
     self.timerOp = None
     localIP = getLocalIP()
     if localIP is None:
         self._initTimer()
         return
     nodeAddrList = self.nodeTable.getLiveNodes()
     if not nodeAddrList:
         self._initTimer()
         return
     tcpListener = None
     udpSock = None
     for port in xrange(10001, 20000):
         addr = (localIP, port)
         try:
             tcpListener = tcpListen(addr, self.reactor, None)
         except sock_error:
             continue
         udpSock = socket(AF_INET, SOCK_DGRAM)
         try:
             udpSock.bind(addr)
         except sock_error:
             udpSock.close()
             tcpListener.close()
             udpSock = tcpListener = None
             continue
         break
     if tcpListener is None:
         self._initTimer()
         return
     self.rpcSock = RPCSocket(udpSock, self.reactor)
     self.tcpListener = tcpListener
     self.firewallOp = _testFirewall(self.tcpListener, self.rpcSock,
                                     nodeAddrList, localIP, self.reactor,
                                     self._onFirewallCheck)
Ejemplo n.º 3
0
 def onRegister( routerList ) :
     obj.registerOp = None
     if not routerList :
         onError()
         return
     obj.routerList = routerList
     obj.localIP = getLocalIP()
     if obj.localIP is None :
         onError()
         return
     ipList = [ip for client,rid,ip in obj.routerList]
     obj.publicIP = _getMajority( ipList )
     obj.publishOp = _publishLocation( rsaKey, getLocation(),
             updateLevelStore, dhtClient, nodeTable, onPublish )
Ejemplo n.º 4
0
 def onRegister(routerList):
     obj.registerOp = None
     if not routerList:
         onError()
         return
     obj.routerList = routerList
     obj.localIP = getLocalIP()
     if obj.localIP is None:
         onError()
         return
     ipList = [ip for client, rid, ip in obj.routerList]
     obj.publicIP = _getMajority(ipList)
     obj.publishOp = _publishLocation(rsaKey, getLocation(),
                                      updateLevelStore, dhtClient,
                                      nodeTable, onPublish)