pull/632/head
Mr Chen 6 months ago
parent d8bf989f83
commit 9f6cd75893
  1. 4
      web/admin/firewall/__init__.py
  2. 62
      web/static/app/firewall.js
  3. 12
      web/utils/firewall.py

@ -93,9 +93,9 @@ def set_fw():
status = request.form.get('status', '1')
return MwFirewall.instance().setFw(status)
@blueprint.route('/set_fw', endpoint='set_fw', methods=['POST'])
@blueprint.route('/set_ssh_pass_status', endpoint='set_ssh_pass_status', methods=['POST'])
@panel_login_required
def set_fw():
def set_ssh_pass_status():
if mw.isAppleSystem():
return mw.returnData(True, '开发机不能设置!')
status = request.form.get('status', '1')

@ -53,33 +53,43 @@ function sshMgr(){
$.post('/firewall/get_ssh_info', '', function(rdata){
var ssh_status = rdata.status ? 'checked':'';
var pass_prohibit_status = rdata.pass_prohibit_status ? 'checked':'';
var pubkey_prohibit_status = rdata.pubkey_prohibit_status ? 'checked':'';
var con = '<div class="pd15">\
<div class="divtable">\
<table class="table table-hover waftable">\
<thead><tr><th>名称</th><th width="80"></th></tr></thead>\
<tbody>\
<tr>\
<td>启动SSH</td>\
<td>\
<div class="ssh-item" style="margin-left:0">\
<input class="btswitch btswitch-ios" id="sshswitch" type="checkbox" '+ssh_status+'>\
<label class="btswitch-btn" for="sshswitch" onclick=\'setMstscStatus()\'></label>\
</div>\
</td>\
</tr>\
<tr>\
<td>禁止密码登陆</td>\
<td>\
<div class="ssh-item" style="margin-left:0">\
<input class="btswitch btswitch-ios" id="pass_status" type="checkbox" '+pass_prohibit_status+'>\
<label class="btswitch-btn" for="pass_status" onclick=\'setSshPassStatus()\'></label>\
</div>\
</td>\
</tr>\
</tbody>\
</table>\
</div>\
</div>';
<div class="divtable">\
<table class="table table-hover waftable">\
<thead><tr><th>名称</th><th width="80"></th></tr></thead>\
<tbody>\
<tr>\
<td>启动SSH</td>\
<td>\
<div class="ssh-item" style="margin-left:0">\
<input class="btswitch btswitch-ios" id="sshswitch" type="checkbox" '+ssh_status+'>\
<label class="btswitch-btn" for="sshswitch" onclick=\'setMstscStatus()\'></label>\
</div>\
</td>\
</tr>\
<tr>\
<td>禁止密码登陆</td>\
<td>\
<div class="ssh-item" style="margin-left:0">\
<input class="btswitch btswitch-ios" id="pass_status" type="checkbox" '+pass_prohibit_status+'>\
<label class="btswitch-btn" for="pass_status" onclick=\'setSshPassStatus()\'></label>\
</div>\
</td>\
</tr>\
<tr>\
<td>禁止密钥登陆</td>\
<td>\
<div class="ssh-item" style="margin-left:0">\
<input class="btswitch btswitch-ios" id="pass_status" type="checkbox" '+pubkey_prohibit_status+'>\
<label class="btswitch-btn" for="pass_status" onclick=\'setSshPassStatus()\'></label>\
</div>\
</td>\
</tr>\
</tbody>\
</table>\
</div>\
</div>';
layer.open({
type: 1,
title: "SSH管理",

@ -157,8 +157,8 @@ class Firewall(object):
if ssh_status[0] != '':
status = False
data['pass_prohibit_status'] = False
# 密码登陆配置检查
data['pass_prohibit_status'] = False
pass_rep = r"PasswordAuthentication\s+(\w*)\s*\n"
pass_status = re.search(pass_rep, conf)
if pass_status:
@ -167,6 +167,16 @@ class Firewall(object):
else:
data['pass_prohibit_status'] = True
# 密钥登陆配置检查
data['pubkey_prohibit_status'] = False
pass_rep = r"PubkeyAuthentication\s+(\w*)\s*\n"
pass_status = re.search(pass_rep, conf)
if pass_status:
if pass_status and pass_status.groups(0)[0].strip() == 'no':
data['pubkey_prohibit_status'] = True
else:
data['pubkey_prohibit_status'] = True
data['port'] = port
data['status'] = status
data['ping'] = isPing

Loading…
Cancel
Save