mirror of https://github.com/jumpserver/jumpserver
fix: 修复host为空情况
parent
2ca72a4bff
commit
5055d140fd
|
@ -91,6 +91,11 @@ class ConnectionTokenMixin:
|
|||
"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):
|
||||
rdp_options = {
|
||||
'full address:s': '',
|
||||
|
@ -140,7 +145,9 @@ class ConnectionTokenMixin:
|
|||
endpoint = self.get_smart_endpoint(
|
||||
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))
|
||||
|
@ -192,8 +199,10 @@ class ConnectionTokenMixin:
|
|||
endpoint = self.get_smart_endpoint(
|
||||
protocol='ssh', asset=token.asset, application=token.application
|
||||
)
|
||||
# TODO 暂时获取一下host,后续优化
|
||||
host = self.get_host(endpoint)
|
||||
data = {
|
||||
'ip': endpoint.host,
|
||||
'ip': host,
|
||||
'port': str(endpoint.ssh_port),
|
||||
'username': 'JMS-{}'.format(str(token.id)),
|
||||
'password': token.secret
|
||||
|
|
Loading…
Reference in New Issue