From a5485011c8f1837009f7c55545e3a779c1686d25 Mon Sep 17 00:00:00 2001 From: jym503558564 <503558564@qq.com> Date: Tue, 3 Dec 2019 11:24:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[Update]=20=E4=BF=AE=E5=A4=8D=E7=BD=91?= =?UTF-8?q?=E5=85=B3=E6=90=9C=E7=B4=A2=E6=8A=A5500=E9=94=99=E8=AF=AF?= =?UTF-8?q?=EF=BC=9B=E5=AF=86=E7=A0=81=E4=B8=BA=E7=A9=BA=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=BF=9E=E6=8E=A5=E6=8A=A5500=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/api/domain.py | 2 +- apps/assets/models/domain.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/assets/api/domain.py b/apps/assets/api/domain.py index e6f6c0550..e032c41bb 100644 --- a/apps/assets/api/domain.py +++ b/apps/assets/api/domain.py @@ -27,7 +27,7 @@ class DomainViewSet(OrgBulkModelViewSet): class GatewayViewSet(OrgBulkModelViewSet): model = Gateway - filter_fields = ("domain__name", "name", "username", "ip", "domain") + filter_fields = ("domain__name", "name", "username", "ip", "domain__id") search_fields = filter_fields permission_classes = (IsOrgAdmin,) serializer_class = serializers.GatewaySerializer diff --git a/apps/assets/models/domain.py b/apps/assets/models/domain.py index 99e677a07..af3fe612f 100644 --- a/apps/assets/models/domain.py +++ b/apps/assets/models/domain.py @@ -63,8 +63,9 @@ class Gateway(AssetUser): def test_connective(self, local_port=None): if local_port is None: local_port = self.port - if not re.match(r'\w+$', self.password): - return False, _("Password should not contain special characters") + if self.password is not None: + if not re.match(r'\w+$', self.password): + return False, _("Password should not contain special characters") client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) From 15b8a2efb9aa2f52588493abe6caa687905506fb Mon Sep 17 00:00:00 2001 From: jym503558564 <503558564@qq.com> Date: Tue, 3 Dec 2019 12:03:18 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9=E5=B0=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/models/domain.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/assets/models/domain.py b/apps/assets/models/domain.py index af3fe612f..b89c3b128 100644 --- a/apps/assets/models/domain.py +++ b/apps/assets/models/domain.py @@ -63,9 +63,8 @@ class Gateway(AssetUser): def test_connective(self, local_port=None): if local_port is None: local_port = self.port - if self.password is not None: - if not re.match(r'\w+$', self.password): - return False, _("Password should not contain special characters") + if self.password and not re.match(r'\w+$', self.password): + return False, _("Password should not contain special characters") client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy())