From a63709002d64131c4d11a8a05b0d798c56eba97c Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 16 Feb 2023 16:51:42 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=20gateway=20?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/accounts/serializers/account/account.py | 8 ++++---- apps/assets/models/asset/common.py | 8 +++++--- apps/authentication/api/connection_token.py | 1 - apps/authentication/models/connection_token.py | 8 ++++---- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/apps/accounts/serializers/account/account.py b/apps/accounts/serializers/account/account.py index e2d2f358d..4062d7fe9 100644 --- a/apps/accounts/serializers/account/account.py +++ b/apps/accounts/serializers/account/account.py @@ -12,19 +12,19 @@ from .base import BaseAccountSerializer class AccountSerializerCreateValidateMixin: - id: str + from_id: str template: bool push_now: bool replace_attrs: callable def to_internal_value(self, data): - _id = data.pop('id', None) + from_id = data.pop('id', None) ret = super().to_internal_value(data) - self.id = _id + self.from_id = from_id return ret def set_secret(self, attrs): - _id = self.id + _id = self.from_id template = attrs.pop('template', None) if _id and template: diff --git a/apps/assets/models/asset/common.py b/apps/assets/models/asset/common.py index fdf23f20e..23ff26488 100644 --- a/apps/assets/models/asset/common.py +++ b/apps/assets/models/asset/common.py @@ -234,9 +234,11 @@ class Asset(NodesRelationMixin, AbsConnectivity, JMSOrgBaseModel): @lazyproperty def gateway(self): - if self.domain_id: - return self.domain.select_gateway() - return None + if not self.domain_id: + return + if not self.platform.domain_enabled: + return + return self.domain.select_gateway() def as_node(self): from assets.models import Node diff --git a/apps/authentication/api/connection_token.py b/apps/authentication/api/connection_token.py index ca6e2f642..c14898cee 100644 --- a/apps/authentication/api/connection_token.py +++ b/apps/authentication/api/connection_token.py @@ -151,7 +151,6 @@ class RDPFileClientProtocolURLMixin: } }) else: - print("Connect method: {}".format(connect_method_dict)) endpoint = self.get_smart_endpoint( protocol=connect_method_dict['endpoint_protocol'], asset=token.asset diff --git a/apps/authentication/models/connection_token.py b/apps/authentication/models/connection_token.py index 99a55616e..fa9fd64c6 100644 --- a/apps/authentication/models/connection_token.py +++ b/apps/authentication/models/connection_token.py @@ -228,16 +228,16 @@ class ConnectionToken(JMSOrgBaseModel): @lazyproperty def domain(self): + if not self.asset.platform.domain_enabled: + return domain = self.asset.domain if self.asset else None return domain @lazyproperty def gateway(self): - from assets.models import Domain - if not self.domain: + if not self.asset: return - self.domain: Domain - return self.domain.select_gateway() + return self.asset.gateway @lazyproperty def command_filter_acls(self):