mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 05:59:25 +08:00
OP防火墙优化
This commit is contained in:
@@ -1311,6 +1311,30 @@ def getWafConf():
|
||||
return mw.readFile(conf)
|
||||
|
||||
|
||||
def areaLimitSwitch():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['area_limit'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
path_config = getJsonPath('config')
|
||||
|
||||
config_contents = mw.readFile(path_config)
|
||||
config_contents = json.loads(config_contents)
|
||||
|
||||
msg = '关闭成功!'
|
||||
if args['area_limit'] == 'on':
|
||||
msg = '开启成功!'
|
||||
config_contents['area_limit'] = True
|
||||
else:
|
||||
config_contents['area_limit'] = False
|
||||
|
||||
mw.writeFile(path_config, json.dumps(config_contents))
|
||||
|
||||
autoMakeConfig(True, True)
|
||||
return mw.returnJson(True, msg)
|
||||
|
||||
|
||||
def getAreaLimit():
|
||||
conf = getJsonPath('area_limit')
|
||||
if not os.path.exists(conf):
|
||||
@@ -1537,6 +1561,8 @@ if __name__ == "__main__":
|
||||
print(getWafSrceen())
|
||||
elif func == 'waf_conf':
|
||||
print(getWafConf())
|
||||
elif func == 'area_limit_switch':
|
||||
print(areaLimitSwitch())
|
||||
elif func == 'get_area_limit':
|
||||
print(getAreaLimit())
|
||||
elif func == 'add_area_limit':
|
||||
|
||||
@@ -24,5 +24,5 @@
|
||||
"home":"https://github.com/loveshell/ngx_lua_waf",
|
||||
"date":"2019-04-21",
|
||||
"pid": "1",
|
||||
"versions": ["0.3.2"]
|
||||
"versions": ["0.4.1"]
|
||||
}
|
||||
@@ -1718,10 +1718,36 @@ function wafAreaLimitRender(){
|
||||
});
|
||||
}
|
||||
|
||||
function wafAreaLimitSwitch(){
|
||||
owPostN('waf_conf', {}, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
if (rdata['area_limit']){
|
||||
$('#area_limit_switch').prop('checked', true);
|
||||
} else{
|
||||
$('#area_limit_switch').prop('checked',false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setWafAreaLimitSwitch(){
|
||||
var area_limit_switch = $('#area_limit_switch').prop('checked');
|
||||
// console.log(area_limit_switch);
|
||||
var area_limit = 'off';
|
||||
if (!area_limit_switch){
|
||||
area_limit = 'on';
|
||||
}
|
||||
owPostN('area_limit_switch', {'area_limit': area_limit}, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
|
||||
});
|
||||
}
|
||||
|
||||
// 地区限制
|
||||
function wafAreaLimit(){
|
||||
var con = '<div class="safe bgw">\
|
||||
<button id="create_area_limit" class="btn btn-success btn-sm" type="button" style="margin-right: 5px;">添加地区限制</button>\
|
||||
<input class="btswitch btswitch-ios" id="area_limit_switch" type="checkbox">\
|
||||
<label class="btswitch-btn" for="area_limit_switch" onclick="setWafAreaLimitSwitch();" style="display: inline-flex;line-height:38px;margin-left: 4px;float: right;"></label>\
|
||||
<div class="divtable mtb10">\
|
||||
<div class="tablescroll">\
|
||||
<table id="con_list" class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0" style="border: 0 none;">\
|
||||
@@ -1736,6 +1762,7 @@ function wafAreaLimit(){
|
||||
</div>';
|
||||
$(".soft-man-con").html(con);
|
||||
wafAreaLimitRender();
|
||||
wafAreaLimitSwitch();
|
||||
|
||||
$('#create_area_limit').click(function(){
|
||||
var site_list;
|
||||
|
||||
@@ -660,9 +660,11 @@ function run_app_waf()
|
||||
min_route()
|
||||
-- C:D("min_route")
|
||||
-- country limit
|
||||
local waf_country = get_country()
|
||||
if waf_country then
|
||||
if area_limit(waf_country, server_name, site_config[server_name]['open']) then return true end
|
||||
if config['area_limit'] then
|
||||
local waf_country = get_country()
|
||||
if waf_country then
|
||||
if area_limit(waf_country, server_name, site_config[server_name]['open']) then return true end
|
||||
end
|
||||
end
|
||||
|
||||
if site_config[server_name] and site_config[server_name]['open'] then
|
||||
|
||||
Reference in New Issue
Block a user