MCPcopy Create free account
hub / github.com/Tencent/CodeAnalysis / get_host_ip

Method get_host_ip

client/node/servertask/nodemgr.py:86–97  ·  view source on GitHub ↗

获取本机ip

(self)

Source from the content-addressed store, hash-verified

84 return result
85
86 def get_host_ip(self):
87 """获取本机ip"""
88 try:
89 net_info_list = self.get_net_if_addr()
90 for net_info in net_info_list:
91 mac = net_info["mac"]
92 ipv4 = net_info["ipv4"]
93 if mac and ipv4 and ipv4 != "127.0.0.1": # 有mac地址和ipv4地址,才算获取到当前在用的ip
94 return ipv4
95 except Exception as err:
96 LogPrinter.error("get host ip error: %s" % str(err))
97 return ""
98
99
100class HeartBeat(object):

Callers 1

_thread_beatMethod · 0.80

Calls 2

get_net_if_addrMethod · 0.95
errorMethod · 0.80

Tested by

no test coverage detected