// 通用Header长度
let defaultGeneralHeaders = ["Cache-Control", "Connection", "Date", "Pragma", "Trailer", "Transfer-Encoding", "Upgrade", "Via", "Warning"]
Vue.component("http-cond-general-header-length", {
props: ["v-checkpoint"],
data: function () {
let headers = null
let length = null
if (window.parent.UPDATING_RULE != null) {
let options = window.parent.UPDATING_RULE.checkpointOptions
if (options.headers != null && Array.$isArray(options.headers)) {
headers = options.headers
}
if (options.length != null) {
length = options.length
}
}
if (headers == null) {
headers = defaultGeneralHeaders
}
if (length == null) {
length = 128
}
let that = this
setTimeout(function () {
that.change()
}, 100)
return {
headers: headers,
length: length
}
},
watch: {
length: function (v) {
let len = parseInt(v)
if (isNaN(len)) {
len = 0
}
if (len < 0) {
len = 0
}
this.length = len
this.change()
}
},
methods: {
change: function () {
this.vCheckpoint.options = [
{
code: "headers",
value: this.headers
},
{
code: "length",
value: this.length
}
]
}
},
template: `
`
})
// CC
Vue.component("http-firewall-checkpoint-cc", {
props: ["v-checkpoint"],
data: function () {
let keys = []
let period = 60
let threshold = 1000
let ignoreCommonFiles = false
let options = {}
if (window.parent.UPDATING_RULE != null) {
options = window.parent.UPDATING_RULE.checkpointOptions
}
if (options == null) {
options = {}
}
if (options.keys != null) {
keys = options.keys
}
if (keys.length == 0) {
keys = ["${remoteAddr}", "${requestPath}"]
}
if (options.period != null) {
period = options.period
}
if (options.threshold != null) {
threshold = options.threshold
}
if (options.ignoreCommonFiles != null && typeof (options.ignoreCommonFiles) == "boolean") {
ignoreCommonFiles = options.ignoreCommonFiles
}
let that = this
setTimeout(function () {
that.change()
}, 100)
return {
keys: keys,
period: period,
threshold: threshold,
ignoreCommonFiles: ignoreCommonFiles,
options: {},
value: threshold
}
},
watch: {
period: function () {
this.change()
},
threshold: function () {
this.change()
},
ignoreCommonFiles: function () {
this.change()
}
},
methods: {
changeKeys: function (keys) {
this.keys = keys
this.change()
},
change: function () {
let period = parseInt(this.period.toString())
if (isNaN(period) || period <= 0) {
period = 60
}
let threshold = parseInt(this.threshold.toString())
if (isNaN(threshold) || threshold <= 0) {
threshold = 1000
}
this.value = threshold
let ignoreCommonFiles = this.ignoreCommonFiles
if (typeof ignoreCommonFiles != "boolean") {
ignoreCommonFiles = false
}
this.vCheckpoint.options = [
{
code: "keys",
value: this.keys
},
{
code: "period",
value: period,
},
{
code: "threshold",
value: threshold
},
{
code: "ignoreCommonFiles",
value: ignoreCommonFiles
}
]
},
thresholdTooLow: function () {
let threshold = parseInt(this.threshold.toString())
if (isNaN(threshold) || threshold <= 0) {
threshold = 1000
}
return threshold > 0 && threshold < 5
}
},
template: ``
})
// 防盗链
Vue.component("http-firewall-checkpoint-referer-block", {
props: ["v-checkpoint"],
data: function () {
let allowEmpty = true
let allowSameDomain = true
let allowDomains = []
let denyDomains = []
let options = {}
if (window.parent.UPDATING_RULE != null) {
options = window.parent.UPDATING_RULE.checkpointOptions
}
if (options == null) {
options = {}
}
if (typeof (options.allowEmpty) == "boolean") {
allowEmpty = options.allowEmpty
}
if (typeof (options.allowSameDomain) == "boolean") {
allowSameDomain = options.allowSameDomain
}
if (options.allowDomains != null && typeof (options.allowDomains) == "object") {
allowDomains = options.allowDomains
}
if (options.denyDomains != null && typeof (options.denyDomains) == "object") {
denyDomains = options.denyDomains
}
let that = this
setTimeout(function () {
that.change()
}, 100)
return {
allowEmpty: allowEmpty,
allowSameDomain: allowSameDomain,
allowDomains: allowDomains,
denyDomains: denyDomains,
options: {},
value: 0
}
},
watch: {
allowEmpty: function () {
this.change()
},
allowSameDomain: function () {
this.change()
}
},
methods: {
changeAllowDomains: function (values) {
this.allowDomains = values
this.change()
},
changeDenyDomains: function (values) {
this.denyDomains = values
this.change()
},
change: function () {
this.vCheckpoint.options = [
{
code: "allowEmpty",
value: this.allowEmpty
},
{
code: "allowSameDomain",
value: this.allowSameDomain,
},
{
code: "allowDomains",
value: this.allowDomains
},
{
code: "denyDomains",
value: this.denyDomains
},
]
}
},
template: `
| 来源域名允许为空 |
|
| 来源域名允许一致 |
|
| 允许的来源域名 |
|
| 禁止的来源域名 |
|
`
})