コード例 #1
0
ファイル: tornadoloop.py プロジェクト: bowlingb/OpenBazaar
    def setup_upnp_port_mappings(self, http_port, p2p_port):
        upnp.PortMapper.DEBUG = False
        print "Setting up UPnP Port Map Entry..."
        # TODO: Add some setting whether or not to use UPnP
        # if Settings.get(Settings.USE_UPNP_PORT_MAPPINGS):
        self.upnp_mapper = upnp.PortMapper()
        # TODO: Add some setting whether or not to clean all previous port
        # mappings left behind by us
        # if Settings.get(Settings.CLEAN_UPNP_PORT_MAPPINGS_ON_START):
        #    upnp_mapper.cleanMyMappings()

        # for now let's always clean mappings every time.
        self.upnp_mapper.clean_my_mappings()
        result_http_port_mapping = self.upnp_mapper.add_port_mapping(
            http_port, http_port)
        print("UPnP HTTP Port Map configuration done (%s -> %s) => %s" %
              (str(http_port), str(http_port), str(result_http_port_mapping)))

        result_tcp_p2p_mapping = self.upnp_mapper.add_port_mapping(
            p2p_port, p2p_port)
        print("UPnP TCP P2P Port Map configuration done (%s -> %s) => %s" %
              (str(p2p_port), str(p2p_port), str(result_tcp_p2p_mapping)))

        result_udp_p2p_mapping = self.upnp_mapper.add_port_mapping(
            p2p_port, p2p_port, 'UDP')
        print("UPnP UDP P2P Port Map configuration done (%s -> %s) => %s" %
              (str(p2p_port), str(p2p_port), str(result_udp_p2p_mapping)))

        return result_http_port_mapping and \
            result_tcp_p2p_mapping and \
            result_udp_p2p_mapping
コード例 #2
0
    def setup_upnp_port_mappings(self, http_port, p2p_port):
        upnp.PortMapper.DEBUG = False
        print "Setting up UPnP Port Map Entry..."
        # TODO: Add some setting whether or not to use UPnP
        # if Settings.get(Settings.USE_UPNP_PORT_MAPPINGS):
        self.upnp_mapper = upnp.PortMapper()
        # TODO: Add some setting whether or not to clean all previous port
        # mappings left behind by us
        # if Settings.get(Settings.CLEAN_UPNP_PORT_MAPPINGS_ON_START):
        #    upnp_mapper.cleanMyMappings()

        # for now let's always clean mappings every time.
        self.upnp_mapper.clean_my_mappings(p2p_port)
        # result_http_port_mapping = self.upnp_mapper.add_port_mapping(http_port,
        #                                                             http_port)
        # print ("UPnP HTTP Port Map configuration done (%s -> %s) => %s" %
        #        (str(http_port), str(http_port), str(result_http_port_mapping)))

        result_tcp_p2p_mapping = self.upnp_mapper.add_port_mapping(p2p_port,
                                                                   p2p_port)
        print ("UPnP TCP P2P Port Map configuration done (%s -> %s) => %s" %
               (str(p2p_port), str(p2p_port), str(result_tcp_p2p_mapping)))

        result_udp_p2p_mapping = self.upnp_mapper.add_port_mapping(p2p_port,
                                                                   p2p_port,
                                                                   'UDP')
        print ("UPnP UDP P2P Port Map configuration done (%s -> %s) => %s" %
               (str(p2p_port), str(p2p_port), str(result_udp_p2p_mapping)))

        result = result_tcp_p2p_mapping and result_udp_p2p_mapping
        if not result:
            print "Warning: UPnP was not setup correctly. Try doing a port forward on %s and start the node again with -j" % p2p_port

        return result
コード例 #3
0
    def setup_upnp_port_mappings(self, p2p_port):
        result = False

        if not self.ob_ctx.disable_upnp:
            upnp.PortMapper.DEBUG = False
            print "Setting up UPnP Port Map Entry..."
            self.upnp_mapper = upnp.PortMapper()
            self.upnp_mapper.clean_my_mappings(p2p_port)

            result_tcp_p2p_mapping = self.upnp_mapper.add_port_mapping(
                p2p_port, p2p_port)
            print "UPnP TCP P2P Port Map configuration done ",
            print "(%s -> %s) => %s" % (p2p_port, p2p_port,
                                        result_tcp_p2p_mapping)

            result_udp_p2p_mapping = self.upnp_mapper.add_port_mapping(
                p2p_port, p2p_port, 'UDP')
            print "UPnP UDP P2P Port Map configuration done ",
            print "(%s -> %s) => %s" % (p2p_port, p2p_port,
                                        result_udp_p2p_mapping)

            result = result_tcp_p2p_mapping and result_udp_p2p_mapping
            if not result:
                print "Warning: UPnP was not setup correctly. ",
                print "Ports could not be automatically mapped."

        return result
コード例 #4
0
    def setup_upnp_port_mapping(self, internal_port):
        upnp.PortMapper.DEBUG = False
        print "Setting up UPnP Port Map Entry..."
        #TODO: Add some setting whether or not to use UPnP
        #if Settings.get(Settings.USE_UPNP_PORT_MAPPINGS):
        self.upnp_mapper = upnp.PortMapper()
        #TODO: Add some setting whether or not to clean all previous port mappings left behind by us
        #if Settings.get(Settings.CLEAN_UPNP_PORT_MAPPINGS_ON_START):
        #    upnp_mapper.cleanMyMappings()

        #for now let's always clean mappings every time.
        self.upnp_mapper.clean_my_mappings()
        result = self.upnp_mapper.add_port_mapping(12345, internal_port)
        print "UPnP Port Map configuration finished (" + str(
            internal_port) + " -> 12345) => " + str(result)
        return result