Files

154 lines
4.4 KiB
JavaScript
Raw Permalink Normal View History

2026-01-11 00:11:34 +08:00
let axios_config = require("./config")
import {ZeroCodeAxios} from "@/request/request"
const components = {}
const data = function () {
return {
waf_status: {
modsecurity_installed: false,
modsecurity_config: false,
owasp_crs: false,
},
ufw_status: false,
info_show: "",
ban_form: {
ip: "",
port: ""
}
}
}
function mounted() {
}
const methods = {
get_config_data(config_data) {
let new_data = config_data
new_data = this.format_data(config_data)
return new_data
},
format_data(dict) {
if (typeof dict == "string") {
dict = eval(dict)
} else {
for (const key in dict) {
let value = dict[key]
if (typeof value == "object") {
this.format_data(value)
} else {
if (typeof value == 'number') {
dict[key] = value
} else {
if (value.includes("this.")) {
if (dict.hasOwnProperty(key)) {
dict[key] = eval(value)
}
} else {
if (value.includes(".")) {
if (dict.hasOwnProperty(key)) {
dict[key] = eval(value)
}
} else {
dict[key] = value
}
}
}
}
}
}
return dict
},
get_waf_info() {
const {url, method, data: originalData, then} = axios_config.get_waf_info.axios;
const data = JSON.parse(JSON.stringify(originalData));
let new_data = this.get_config_data(data)
// 发起请求
ZeroCodeAxios({
method,
url,
data: new_data,
}).then(res => {
// 执行回调函数then回调
eval(then)
})
},
install_waf() {
const {url, method, data: originalData, then} = axios_config.install_waf.axios;
const data = JSON.parse(JSON.stringify(originalData));
let new_data = this.get_config_data(data)
// 发起请求
ZeroCodeAxios({
method,
url,
data: new_data,
}).then(res => {
// 执行回调函数then回调
eval(then)
})
},
open_ufw() {
const {url, method, data: originalData, then} = axios_config.open_ufw.axios;
const data = JSON.parse(JSON.stringify(originalData));
let new_data = this.get_config_data(data)
// 发起请求
ZeroCodeAxios({
method,
url,
data: new_data,
}).then(res => {
// 执行回调函数then回调
eval(then)
})
},
get_log_analyze() {
const {url, method, data: originalData, then} = axios_config.get_log_analyze.axios;
const data = JSON.parse(JSON.stringify(originalData));
let new_data = this.get_config_data(data)
// 发起请求
ZeroCodeAxios({
method,
url,
data: new_data,
}).then(res => {
// 执行回调函数then回调
eval(then)
})
},
ban_ip() {
const {url, method, data: originalData, then} = axios_config.ban_ip.axios;
const data = JSON.parse(JSON.stringify(originalData));
let new_data = this.get_config_data(data)
// 发起请求
ZeroCodeAxios({
method,
url,
data: new_data,
}).then(res => {
// 执行回调函数then回调
eval(then)
})
},
get_ufw_status() {
const {url, method, data: originalData, then} = axios_config.get_ufw_status.axios;
const data = JSON.parse(JSON.stringify(originalData));
let new_data = this.get_config_data(data)
// 发起请求
ZeroCodeAxios({
method,
url,
data: new_data,
}).then(res => {
// 执行回调函数then回调
eval(then)
})
},
}
export default {
data: data,
methods: methods,
mounted: mounted,
components: components,
}