From 87f45787a8e765bc53916f239c1fbfc4419d0e01 Mon Sep 17 00:00:00 2001 From: "StarsL.cn" Date: Wed, 23 Feb 2022 02:43:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=81=E8=AE=B8SID=E4=BD=BF=E7=94=A8/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flask-consul/units/blackbox_manager.py | 2 ++ flask-consul/units/consul_manager.py | 4 +++- vue-consul/src/layout/components/Navbar.vue | 2 +- vue-consul/src/router/index.js | 5 +++++ vue-consul/src/views/blackbox/index.vue | 7 +++++-- vue-consul/src/views/consul/instances.vue | 5 +++-- vue-consul/src/views/consul/services.vue | 1 + vue-consul/src/views/login/index.vue | 2 +- 8 files changed, 21 insertions(+), 7 deletions(-) diff --git a/flask-consul/units/blackbox_manager.py b/flask-consul/units/blackbox_manager.py index e660edd..0ce4673 100644 --- a/flask-consul/units/blackbox_manager.py +++ b/flask-consul/units/blackbox_manager.py @@ -40,6 +40,8 @@ def get_service(): def add_service(module,company,project,env,name,instance): sid = f"{module}/{company}/{project}/{env}@{name}" + if '//' in sid or sid.startswith('/') or sid.endswith('/'): + return {"code": 50000, "data": f"服务ID【{sid}】首尾不能包含'/',并且不能包含两个连续的'/'"} data = { "id": sid, "name": 'blackbox_exporter', diff --git a/flask-consul/units/consul_manager.py b/flask-consul/units/consul_manager.py index 9b0988e..a69c067 100644 --- a/flask-consul/units/consul_manager.py +++ b/flask-consul/units/consul_manager.py @@ -77,6 +77,9 @@ def del_instance(service_id): return {"code": 50000, "data": f"{reg.status_code}【{service_id}】{reg.text}"} def add_instance(instance_dict): + sid = instance_dict['ID'] + if '//' in sid or sid.startswith('/') or sid.endswith('/'): + return {"code": 50000, "data": f"服务ID【{sid}】首尾不能包含'/',并且不能包含两个连续的'/'"} isMeta = instance_dict['metaInfo']['isMeta'] isCheck = instance_dict['checkInfo']['isCheck'] address = instance_dict['address'] @@ -112,7 +115,6 @@ def add_instance(instance_dict): print(instance_dict) reg = requests.put(f'{consul_url}/agent/service/register', headers=headers, data=json.dumps(instance_dict)) - sid = instance_dict['ID'] if reg.status_code == 200: return {"code": 20000, "data": f"【{sid}】增加成功!"} else: diff --git a/vue-consul/src/layout/components/Navbar.vue b/vue-consul/src/layout/components/Navbar.vue index 4f07d14..4e99188 100644 --- a/vue-consul/src/layout/components/Navbar.vue +++ b/vue-consul/src/layout/components/Navbar.vue @@ -16,7 +16,7 @@ 首页 - + GitHub diff --git a/vue-consul/src/router/index.js b/vue-consul/src/router/index.js index 1b12312..7221e86 100644 --- a/vue-consul/src/router/index.js +++ b/vue-consul/src/router/index.js @@ -112,7 +112,12 @@ export const constantRoutes = [ { path: 'https://starsl.cn/static/img/qr.png', meta: { title: '我的公众号', icon: 'el-icon-chat-dot-round' } + }, + { + path: 'https://element.eleme.cn', + meta: { title: 'Element', icon: 'el-icon-eleme' } } + ] }, diff --git a/vue-consul/src/views/blackbox/index.vue b/vue-consul/src/views/blackbox/index.vue index b58f7ca..0c40023 100644 --- a/vue-consul/src/views/blackbox/index.vue +++ b/vue-consul/src/views/blackbox/index.vue @@ -1,5 +1,8 @@