mirror of https://github.com/jumpserver/jumpserver
fix: 修改获取 rdp-file / client-url / smart-endpoint 时endpoint host后台处理为当前请求的host
parent
bdf59da0f6
commit
29656b1630
|
@ -91,11 +91,6 @@ 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': '',
|
||||
|
@ -145,9 +140,7 @@ class ConnectionTokenMixin:
|
|||
endpoint = self.get_smart_endpoint(
|
||||
protocol='rdp', asset=token.asset, application=token.application
|
||||
)
|
||||
# TODO 暂时获取一下host,后续优化
|
||||
host = self.get_host(endpoint)
|
||||
rdp_options['full address:s'] = f'{host}:{endpoint.rdp_port}'
|
||||
rdp_options['full address:s'] = f'{endpoint.host}:{endpoint.rdp_port}'
|
||||
|
||||
# 设置用户名
|
||||
rdp_options['username:s'] = '{}|{}'.format(token.user.username, str(token.id))
|
||||
|
@ -199,10 +192,8 @@ class ConnectionTokenMixin:
|
|||
endpoint = self.get_smart_endpoint(
|
||||
protocol='ssh', asset=token.asset, application=token.application
|
||||
)
|
||||
# TODO 暂时获取一下host,后续优化
|
||||
host = self.get_host(endpoint)
|
||||
data = {
|
||||
'ip': host,
|
||||
'ip': endpoint.host,
|
||||
'port': str(endpoint.ssh_port),
|
||||
'username': 'JMS-{}'.format(str(token.id)),
|
||||
'password': token.secret
|
||||
|
|
|
@ -63,8 +63,6 @@ class Endpoint(JMSModel):
|
|||
'http_port': 0,
|
||||
}
|
||||
endpoint, created = cls.objects.get_or_create(id=cls.default_id, defaults=data)
|
||||
if not endpoint.host and request:
|
||||
endpoint.host = request.get_host().split(':')[0]
|
||||
return endpoint
|
||||
|
||||
@classmethod
|
||||
|
@ -122,4 +120,7 @@ class EndpointRule(JMSModel):
|
|||
endpoint = endpoint_rule.endpoint
|
||||
else:
|
||||
endpoint = Endpoint.get_or_create_default(request)
|
||||
if not endpoint.host and request:
|
||||
# 动态添加 current request host
|
||||
endpoint.host = request.get_host().split(':')[0]
|
||||
return endpoint
|
||||
|
|
Loading…
Reference in New Issue