fix: 修复host为空情况

pull/8609/head
feng626 2 years ago committed by 老广
parent 2ca72a4bff
commit 5055d140fd

@ -91,6 +91,11 @@ class ConnectionTokenMixin:
"config": rdp_config "config": rdp_config
} }
def get_host(self, endpoint):
if not endpoint.host:
return self.request.get_host()
return endpoint.host
def get_rdp_file_info(self, token: ConnectionToken): def get_rdp_file_info(self, token: ConnectionToken):
rdp_options = { rdp_options = {
'full address:s': '', 'full address:s': '',
@ -140,7 +145,9 @@ class ConnectionTokenMixin:
endpoint = self.get_smart_endpoint( endpoint = self.get_smart_endpoint(
protocol='rdp', asset=token.asset, application=token.application protocol='rdp', asset=token.asset, application=token.application
) )
rdp_options['full address:s'] = f'{endpoint.host}:{endpoint.rdp_port}' # TODO 暂时获取一下host后续优化
host = self.get_host(endpoint)
rdp_options['full address:s'] = f'{host}:{endpoint.rdp_port}'
# 设置用户名 # 设置用户名
rdp_options['username:s'] = '{}|{}'.format(token.user.username, str(token.id)) rdp_options['username:s'] = '{}|{}'.format(token.user.username, str(token.id))
@ -192,8 +199,10 @@ class ConnectionTokenMixin:
endpoint = self.get_smart_endpoint( endpoint = self.get_smart_endpoint(
protocol='ssh', asset=token.asset, application=token.application protocol='ssh', asset=token.asset, application=token.application
) )
# TODO 暂时获取一下host后续优化
host = self.get_host(endpoint)
data = { data = {
'ip': endpoint.host, 'ip': host,
'port': str(endpoint.ssh_port), 'port': str(endpoint.ssh_port),
'username': 'JMS-{}'.format(str(token.id)), 'username': 'JMS-{}'.format(str(token.id)),
'password': token.secret 'password': token.secret

Loading…
Cancel
Save