当前位置: 首页>>代码示例>>Python>>正文


Python ipdiscover.get_local_ip函数代码示例

本文整理汇总了Python中nattraverso.ipdiscover.get_local_ip函数的典型用法代码示例。如果您正苦于以下问题:Python get_local_ip函数的具体用法?Python get_local_ip怎么用?Python get_local_ip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_local_ip函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: upnp_thread

 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))
开发者ID:gyver,项目名称:p2pool,代码行数:12,代码来源:main.py

示例2: upnp_thread

 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))
开发者ID:and-then,项目名称:p2pool-rav,代码行数:13,代码来源:main.py

示例3: map

 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)
开发者ID:0xDEADFACE,项目名称:p2pool,代码行数:14,代码来源:upnp.py

示例4: get_external_ip

	(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()

开发者ID:jhargis,项目名称:nattraverso,代码行数:29,代码来源:ipdiscover.py


注:本文中的nattraverso.ipdiscover.get_local_ip函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。