Example #1
0
def start(arguments):
    defaults = OpenBazaarContext.get_defaults()
    network_util.set_stun_servers()

    # Turn off checks that don't make sense in development mode
    if arguments.dev_mode:
        print "DEVELOPMENT MODE! (Disable STUN check and UPnP mappings)"
        arguments.disable_stun_check = True
        arguments.disable_upnp = True

    # Try to get NAT escape UDP port
    nat_status = None
    if not arguments.disable_stun_check:
        print "Checking NAT Status..."
        nat_status = network_util.get_NAT_status()
    elif not arguments.dev_mode and network_util.is_private_ip_address(
            arguments.server_ip):
        print "openbazaar: Could not start. The given/default server IP address",
        print arguments.server_ip, "is not a public ip address."
        print "(Try './openbazaar help' and read about the '--server-ip', '-i' options)"
        sys.exit(1)

    ob_ctxs = create_openbazaar_contexts(arguments, nat_status)

    for ob_ctx in ob_ctxs:
        ensure_database_setup(ob_ctx, defaults)

    if hasattr(sys, 'frozen'):
        start_node(ob_ctxs[0])
    else:
        p = multiprocessing.Process(target=node_starter, args=(ob_ctxs, ))
        p.start()
Example #2
0
def start(arguments):
    defaults = OpenBazaarContext.get_defaults()
    network_util.set_stun_servers()

    # Turn off checks that don't make sense in development mode
    if arguments.dev_mode:
        print "DEVELOPMENT MODE! (Disable STUN check and UPnP mappings)"
        arguments.disable_stun_check = True
        arguments.disable_upnp = True

    # Try to get NAT escape UDP port
    nat_status = None
    if not arguments.disable_stun_check:
        print "Checking NAT Status..."
        nat_status = network_util.get_NAT_status()
    elif not arguments.dev_mode and network_util.is_private_ip_address(arguments.server_ip):
        print "openbazaar: Could not start. The given/default server IP address",
        print arguments.server_ip, "is not a public ip address."
        print "(Try './openbazaar help' and read about the '--server-ip', '-i' options)"
        sys.exit(1)

    ob_ctxs = create_openbazaar_contexts(arguments, nat_status)

    for ob_ctx in ob_ctxs:
        ensure_database_setup(ob_ctx, defaults)

    if hasattr(sys, 'frozen'):
        start_node(ob_ctxs[0])
    else:
        p = multiprocessing.Process(target=node_starter,
                                    args=(ob_ctxs,))
        p.start()
    def test_is_private_ip_address(self):
        self.assertTrue(network_util.is_private_ip_address('localhost'))
        self.assertTrue(network_util.is_private_ip_address('127.0.0.1'))
        self.assertTrue(network_util.is_private_ip_address('192.168.1.1'))
        self.assertTrue(network_util.is_private_ip_address('172.16.1.1'))
        self.assertTrue(network_util.is_private_ip_address('10.1.1.1'))

        self.assertFalse(network_util.is_private_ip_address('8.8.8.8'))
Example #4
0
    def test_is_private_ip_address(self):
        self.assertTrue(network_util.is_private_ip_address('localhost'))
        self.assertTrue(network_util.is_private_ip_address('127.0.0.1'))
        self.assertTrue(network_util.is_private_ip_address('192.168.1.1'))
        self.assertTrue(network_util.is_private_ip_address('172.16.1.1'))
        self.assertTrue(network_util.is_private_ip_address('10.1.1.1'))

        self.assertFalse(network_util.is_private_ip_address('8.8.8.8'))