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 @@