daemon/core/broker.py
def handlelinkmsg(self, msg):
        ''' Determine and return the servers to which this link message should
            be forwarded. Also build tunnels between different servers or add
            opaque data to the link message before forwarding.
        '''
        serverlist = []
        handle_locally = False

        # determine link message destination using non-network nodes
        nn = msg.nodenumbers()
        if nn[0] in self.nets:
            if nn[1] in self.nets:
                # two network nodes linked together - prevent loops caused by
                # the automatic tunnelling
                handle_locally = True
            else:
                serverlist = self.getserversbynode(nn[1])
        elif nn[1] in self.nets:
            serverlist = self.getserversbynode(nn[0])
        else:
            serverset1 = set(self.getserversbynode(nn[0]))
            serverset2 = set(self.getserversbynode(nn[1]))
            # nodes are on two different servers, build tunnels as needed
            if serverset1 != serverset2:
                localn = None
                if len(serverset1) == 0 or len(serverset2) == 0:
                    handle_locally = True
                serverlist = list(serverset1 | serverset2)
                host = None
                # get the IP of remote server and decide which node number
                # is for a local node
                for server in serverlist:
                    (host, port, sock) = self.getserver(server)
                    if host is None:
                        # named server is local
                        handle_locally = True
                        if server in serverset1:
                            localn = nn[0]
                        else:
                            localn = nn[1]
                if handle_locally and localn is None:
                    # having no local node at this point indicates local node is
                    # the one with the empty serverset
                    if len(serverset1) == 0:
                        localn = nn[0]
                    elif len(serverset2) == 0:
                        localn = nn[1]
                if host is None:
                    host = self.getlinkendpoint(msg, localn == nn[0])
                if localn is None:
                    msg = self.addlinkendpoints(msg, serverset1, serverset2)
                elif msg.flags & coreapi.CORE_API_ADD_FLAG:
                    self.addtunnel(host, nn[0], nn[1], localn)
                elif msg.flags & coreapi.CORE_API_DEL_FLAG:
                    self.deltunnel(nn[0], nn[1])
                    handle_locally = False
            else:
                serverlist = list(serverset1 | serverset2)

        return (handle_locally, serverlist, msg)
 Determine and return the servers to which this link message should
            be forwarded. Also build tunnels between different servers or add
            opaque data to the link message before forwarding.
        
Determine and return the servers to which this link message should
be forwarded. Also build tunnels between different servers or add
opaque data to the link message before forwarding.
Determine and return the servers to which this link message should be forwarded . Also build tunnels between different servers or add opaque data to the link message before forwarding .
def handlelinkmsg(self, msg):
        serverlist = []
        handle_locally = False
        nn = msg.nodenumbers()
        if nn[0] in self.nets:
            if nn[1] in self.nets:
                handle_locally = True
            else:
                serverlist = self.getserversbynode(nn[1])
        elif nn[1] in self.nets:
            serverlist = self.getserversbynode(nn[0])
        else:
            serverset1 = set(self.getserversbynode(nn[0]))
            serverset2 = set(self.getserversbynode(nn[1]))
            if serverset1 != serverset2:
                localn = None
                if len(serverset1) == 0 or len(serverset2) == 0:
                    handle_locally = True
                serverlist = list(serverset1 | serverset2)
                host = None
                for server in serverlist:
                    (host, port, sock) = self.getserver(server)
                    if host is None:
                        handle_locally = True
                        if server in serverset1:
                            localn = nn[0]
                        else:
                            localn = nn[1]
                if handle_locally and localn is None:
                    if len(serverset1) == 0:
                        localn = nn[0]
                    elif len(serverset2) == 0:
                        localn = nn[1]
                if host is None:
                    host = self.getlinkendpoint(msg, localn == nn[0])
                if localn is None:
                    msg = self.addlinkendpoints(msg, serverset1, serverset2)
                elif msg.flags & coreapi.CORE_API_ADD_FLAG:
                    self.addtunnel(host, nn[0], nn[1], localn)
                elif msg.flags & coreapi.CORE_API_DEL_FLAG:
                    self.deltunnel(nn[0], nn[1])
                    handle_locally = False
            else:
                serverlist = list(serverset1 | serverset2)
        return (handle_locally, serverlist, msg)
def handlelinkmsg ( self , msg ) : serverlist = [ ] handle_locally = False nn = msg . nodenumbers ( ) if nn [ 0 ] in self . nets : if nn [ 1 ] in self . nets : handle_locally = True else : serverlist = self . getserversbynode ( nn [ 1 ] ) elif nn [ 1 ] in self . nets : serverlist = self . getserversbynode ( nn [ 0 ] ) else : serverset1 = set ( self . getserversbynode ( nn [ 0 ] ) ) serverset2 = set ( self . getserversbynode ( nn [ 1 ] ) ) if serverset1 != serverset2 : localn = None if len ( serverset1 ) == 0 or len ( serverset2 ) == 0 : handle_locally = True serverlist = list ( serverset1 | serverset2 ) host = None for server in serverlist : ( host , port , sock ) = self . getserver ( server ) if host is None : handle_locally = True if server in serverset1 : localn = nn [ 0 ] else : localn = nn [ 1 ] if handle_locally and localn is None : if len ( serverset1 ) == 0 : localn = nn [ 0 ] elif len ( serverset2 ) == 0 : localn = nn [ 1 ] if host is None : host = self . getlinkendpoint ( msg , localn == nn [ 0 ] ) if localn is None : msg = self . addlinkendpoints ( msg , serverset1 , serverset2 ) elif msg . flags & coreapi . CORE_API_ADD_FLAG : self . addtunnel ( host , nn [ 0 ] , nn [ 1 ] , localn ) elif msg . flags & coreapi . CORE_API_DEL_FLAG : self . deltunnel ( nn [ 0 ] , nn [ 1 ] ) handle_locally = False else : serverlist = list ( serverset1 | serverset2 ) return ( handle_locally , serverlist , msg )
Determine and return the servers to which this link message should
be forwarded.
Determine and return the servers to which this link message should be forwarded .
''' Determine and return the servers to which this link message should
            be forwarded. Also build tunnels between different servers or add
            opaque data to the link message before forwarding.
        ''' # determine link message destination using non-network nodes # two network nodes linked together - prevent loops caused by # the automatic tunnelling # nodes are on two different servers, build tunnels as needed # get the IP of remote server and decide which node number # is for a local node # named server is local # having no local node at this point indicates local node is # the one with the empty serverset
self
msg