mirror of https://github.com/jumpserver/jumpserver
perf: 优化修改获取Hostname
parent
43f30b37da
commit
f129f99faa
|
@ -23,9 +23,16 @@ class BaseTerminal(object):
|
||||||
name = f'[{suffix_name}]-{hostname}'
|
name = f'[{suffix_name}]-{hostname}'
|
||||||
self.name = name
|
self.name = name
|
||||||
self.interval = 30
|
self.interval = 30
|
||||||
self.remote_addr = socket.gethostbyname(hostname)
|
self.remote_addr = self.get_remote_addr(hostname)
|
||||||
self.type = _type
|
self.type = _type
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_remote_addr(hostname):
|
||||||
|
try:
|
||||||
|
return socket.gethostbyname(hostname)
|
||||||
|
except socket.gaierror:
|
||||||
|
return '127.0.0.1'
|
||||||
|
|
||||||
def start_heartbeat_thread(self):
|
def start_heartbeat_thread(self):
|
||||||
print(f'- Start heartbeat thread => ({self.name})')
|
print(f'- Start heartbeat thread => ({self.name})')
|
||||||
t = threading.Thread(target=self.start_heartbeat)
|
t = threading.Thread(target=self.start_heartbeat)
|
||||||
|
|
Loading…
Reference in New Issue