From 47195e2c444ac02792079d7d808d8cbacbcd34e1 Mon Sep 17 00:00:00 2001 From: Bai Date: Wed, 19 Jul 2023 18:10:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E6=96=B9=E5=BC=8F=E8=AE=BF=E9=97=AE=E8=B5=84=E4=BA=A7?= =?UTF-8?q?=20Endpoint=20=E6=A0=87=E7=AD=BE=E5=8C=B9=E9=85=8D=E7=AD=96?= =?UTF-8?q?=E7=95=A5=E4=B8=8D=E7=94=9F=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/authentication/api/connection_token.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/authentication/api/connection_token.py b/apps/authentication/api/connection_token.py index d6a872841..94bed4f28 100644 --- a/apps/authentication/api/connection_token.py +++ b/apps/authentication/api/connection_token.py @@ -23,7 +23,7 @@ from common.utils.http import is_true, is_false from orgs.mixins.api import RootOrgViewMixin from perms.models import ActionChoices from terminal.connect_methods import NativeClient, ConnectMethodUtil -from terminal.models import EndpointRule +from terminal.models import EndpointRule, Endpoint from ..models import ConnectionToken, date_expired_default from ..serializers import ( ConnectionTokenSerializer, ConnectionTokenSecretSerializer, @@ -166,11 +166,13 @@ class RDPFileClientProtocolURLMixin: return data def get_smart_endpoint(self, protocol, asset=None): - target_ip = asset.get_target_ip() if asset else '' - endpoint = EndpointRule.match_endpoint( - target_instance=asset, target_ip=target_ip, - protocol=protocol, request=self.request - ) + endpoint = Endpoint.match_by_instance_label(asset, protocol) + if not endpoint: + target_ip = asset.get_target_ip() if asset else '' + endpoint = EndpointRule.match_endpoint( + target_instance=asset, target_ip=target_ip, + protocol=protocol, request=self.request + ) return endpoint