Exemplo n.º 1
0
    def get_nat_type(self, callback=None):
        """ Return the type of Network Address Translator (NAT) detected.

        When a callback parameter is supplied it will always be
        called. When the NAT-type is already known the callback will
        be made instantly. Otherwise, the callback will be made when
        the NAT discovery has finished.

        The callback will be called by a popup thread which can be used
        indefinitely (within reason) by the higher level code.

        Return values:
        "Blocked"
        "Open Internet"
        "Restricted Cone Firewall"
        "Port Restricted Cone Firewall"
        "Full Cone NAT"
        "Restricted Cone NAT"
        "Port Restricted Cone NAT"
        "Symmetric NAT"
        "Unknown NAT/Firewall"

        @param callback Optional callback used to notify the NAT type
        @return String 
        """
        # TODO: define constants in simpledefs for these
        # Called by any thread
        self.sesslock.acquire()
        try:
            from BaseLib.Core.NATFirewall.ConnectionCheck import ConnectionCheck
            
            return ConnectionCheck.getInstance(self).get_nat_type(callback=callback)
        finally:
            self.sesslock.release()
Exemplo n.º 2
0
    def get_nat_type(self, callback=None):
        """ Return the type of Network Address Translator (NAT) detected.

        When a callback parameter is supplied it will always be
        called. When the NAT-type is already known the callback will
        be made instantly. Otherwise, the callback will be made when
        the NAT discovery has finished.

        The callback will be called by a popup thread which can be used
        indefinitely (within reason) by the higher level code.

        Return values:
        "Blocked"
        "Open Internet"
        "Restricted Cone Firewall"
        "Port Restricted Cone Firewall"
        "Full Cone NAT"
        "Restricted Cone NAT"
        "Port Restricted Cone NAT"
        "Symmetric NAT"
        "Unknown NAT/Firewall"

        @param callback Optional callback used to notify the NAT type
        @return String 
        """
        # TODO: define constants in simpledefs for these
        # Called by any thread
        self.sesslock.acquire()
        try:
            from BaseLib.Core.NATFirewall.ConnectionCheck import ConnectionCheck

            return ConnectionCheck.getInstance(self).get_nat_type(
                callback=callback)
        finally:
            self.sesslock.release()
Exemplo n.º 3
0
    def gotDoNatCheckMessage(self, sender_permid, selversion, channel_id, payload, reply_callback):
        """
        The handle-request callback
        """

        self.doNatCheckSender = sender_permid
        self.crawler_reply_callbacks.append(reply_callback)

        try:
            if DEBUG:
                print >>sys.stderr,"NatCheckMsgHandler: start_nat_type_detect()"
            conn_check = ConnectionCheck.getInstance(self.session)
            conn_check.try_start(self.natthreadcb_natCheckReplyCallback)
        except:
            print_exc()
            return False

        return True
Exemplo n.º 4
0
    def gotDoNatCheckMessage(self, sender_permid, selversion, channel_id,
                             payload, reply_callback):
        """
        The handle-request callback
        """

        self.doNatCheckSender = sender_permid
        self.crawler_reply_callbacks.append(reply_callback)

        try:
            if DEBUG:
                print >> sys.stderr, "NatCheckMsgHandler: start_nat_type_detect()"
            conn_check = ConnectionCheck.getInstance(self.session)
            conn_check.try_start(self.natthreadcb_natCheckReplyCallback)
        except:
            print_exc()
            return False

        return True