Пример #1
0
 def upnp_thread():
     while True:
         try:
             is_lan, lan_ip = yield ipdiscover.get_local_ip()
             if not is_lan:
                 continue
             pm = yield portmapper.get_port_mapper()
             yield pm._upnp.add_port_mapping(lan_ip, args.net.P2P_PORT, args.net.P2P_PORT, 'p2pool', 'TCP')
         except:
             if p2pool_init.DEBUG:
                 log.err()
         yield deferral.sleep(random.expovariate(1/120))
Пример #2
0
 def upnp_thread():
     while True:
         try:
             is_lan, lan_ip = yield ipdiscover.get_local_ip()
             if is_lan:
                 pm = yield portmapper.get_port_mapper()
                 yield pm._upnp.add_port_mapping(lan_ip, args.p2pool_port, args.p2pool_port, 'p2pool', 'TCP')
         except defer.TimeoutError:
             pass
         except:
             if p2pool.DEBUG:
                 log.err(None, 'UPnP error:')
         yield deferral.sleep(random.expovariate(1/120))
Пример #3
0
 def upnp_thread():
     while True:
         try:
             is_lan, lan_ip = yield ipdiscover.get_local_ip()
             if is_lan:
                 pm = yield portmapper.get_port_mapper()
                 yield pm._upnp.add_port_mapping(lan_ip, args.p2pool_port, args.p2pool_port, 'p2pool', 'TCP')
         except defer.TimeoutError:
             pass
         except:
             if p2pool.DEBUG:
                 log.err(None, 'UPnP error:')
         yield deferral.sleep(random.expovariate(1/120))
Пример #4
0
    def map(self, port):
        """
        See interface
        """
        self._check_valid_port(port)

        #Port is already mapped
        if port in self._mapped:
            return defer.succeed(self._mapped[port])

        #Trigger a new mapping creation, first fetch local ip.
        result = ipdiscover.get_local_ip()
        self._mapped[port] = result
        return result.addCallback(self._map_got_local_ip, port)
Пример #5
0
 def map(self, port):
     """
     See interface
     """
     self._check_valid_port(port)
     
     #Port is already mapped
     if port in self._mapped:
         return defer.succeed(self._mapped[port])
     
     #Trigger a new mapping creation, first fetch local ip.
     result = ipdiscover.get_local_ip()
     self._mapped[port] = result
     return result.addCallback(self._map_got_local_ip, port)
Пример #6
0
    (local_ok, local_result), (external_ok, external_result) = result

    if local_ok:
        print 'Result of get_local_ip', local_result
        local, ip = local_result
        if local:
            print "\tLAN IP address:", ip
        else:
            print "\tWAN IP address:", ip
    else:
        print 'Failed to get_local_ip', local_result

    if external_ok:
        print 'Result of get_external_ip', external_result
        wan, ip = external_result
        if wan == None:
            print "\tLocalhost IP address:", ip
        elif not wan:
            print "\tLAN IP address:", ip
        else:
            print "\tWAN IP address:", ip
    else:
        print 'Failed to get_external_ip', external_result


list = defer.DeferredList([get_local_ip(), get_external_ip()])
list.addCallback(got_local_ip).addBoth(lambda x: reactor.stop())

print 'Attempting to use get_local_ip() and get_external_ip()'
reactor.run()
Пример #7
0
	(local_ok, local_result), (external_ok, external_result) = result
	
	if local_ok:
		print 'Result of get_local_ip', local_result
		local, ip = local_result
		if local:
			print "\tLAN IP address:", ip
		else:
			print "\tWAN IP address:", ip
	else:
		print 'Failed to get_local_ip', local_result

	if external_ok:
		print 'Result of get_external_ip', external_result
		wan, ip = external_result
		if wan == None:
			print "\tLocalhost IP address:", ip
		elif not wan:
			print "\tLAN IP address:", ip
		else:
			print "\tWAN IP address:", ip
	else:
		print 'Failed to get_external_ip', external_result
		
list = defer.DeferredList([get_local_ip(), get_external_ip()])
list.addCallback(got_local_ip).addBoth(lambda x:reactor.stop())

print 'Attempting to use get_local_ip() and get_external_ip()'
reactor.run()