2020-11-22 16:54:31 +08:00
|
|
|
|
Vue.component("http-firewall-block-options", {
|
|
|
|
|
|
props: ["v-block-options"],
|
|
|
|
|
|
data: function () {
|
|
|
|
|
|
return {
|
2024-04-07 14:20:17 +08:00
|
|
|
|
options: this.vBlockOptions,
|
2021-09-29 20:12:27 +08:00
|
|
|
|
statusCode: this.vBlockOptions.statusCode,
|
2022-01-10 19:54:29 +08:00
|
|
|
|
timeout: this.vBlockOptions.timeout,
|
2023-03-01 18:59:42 +08:00
|
|
|
|
timeoutMax: this.vBlockOptions.timeoutMax,
|
2022-01-10 19:54:29 +08:00
|
|
|
|
isEditing: false
|
2020-11-22 16:54:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
statusCode: function (v) {
|
|
|
|
|
|
let statusCode = parseInt(v)
|
|
|
|
|
|
if (isNaN(statusCode)) {
|
2024-04-07 14:20:17 +08:00
|
|
|
|
this.options.statusCode = 403
|
2020-11-22 16:54:31 +08:00
|
|
|
|
} else {
|
2024-04-07 14:20:17 +08:00
|
|
|
|
this.options.statusCode = statusCode
|
2020-11-22 16:54:31 +08:00
|
|
|
|
}
|
2021-09-29 20:12:27 +08:00
|
|
|
|
},
|
|
|
|
|
|
timeout: function (v) {
|
|
|
|
|
|
let timeout = parseInt(v)
|
|
|
|
|
|
if (isNaN(timeout)) {
|
2024-04-07 14:20:17 +08:00
|
|
|
|
this.options.timeout = 0
|
2021-09-29 20:12:27 +08:00
|
|
|
|
} else {
|
2024-04-07 14:20:17 +08:00
|
|
|
|
this.options.timeout = timeout
|
2021-09-29 20:12:27 +08:00
|
|
|
|
}
|
2023-03-01 18:59:42 +08:00
|
|
|
|
},
|
|
|
|
|
|
timeoutMax: function (v) {
|
|
|
|
|
|
let timeoutMax = parseInt(v)
|
|
|
|
|
|
if (isNaN(timeoutMax)) {
|
2024-04-07 14:20:17 +08:00
|
|
|
|
this.options.timeoutMax = 0
|
2023-03-01 18:59:42 +08:00
|
|
|
|
} else {
|
2024-04-07 14:20:17 +08:00
|
|
|
|
this.options.timeoutMax = timeoutMax
|
2023-03-01 18:59:42 +08:00
|
|
|
|
}
|
2020-11-22 16:54:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-01-10 19:54:29 +08:00
|
|
|
|
methods: {
|
|
|
|
|
|
edit: function () {
|
|
|
|
|
|
this.isEditing = !this.isEditing
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-11-22 16:54:31 +08:00
|
|
|
|
template: `<div>
|
2024-04-07 14:20:17 +08:00
|
|
|
|
<input type="hidden" name="blockOptionsJSON" :value="JSON.stringify(options)"/>
|
|
|
|
|
|
<a href="" @click.prevent="edit">状态码:{{statusCode}} / 提示内容:<span v-if="options.body != null && options.body.length > 0">[{{options.body.length}}字符]</span><span v-else class="disabled">[无]</span> <span v-if="timeout > 0"> / 封禁时长:{{timeout}}秒</span>
|
2023-03-01 18:59:42 +08:00
|
|
|
|
<span v-if="timeoutMax > timeout"> / 最大封禁时长:{{timeoutMax}}秒</span>
|
2024-04-07 14:20:17 +08:00
|
|
|
|
<span v-if="options.failBlockScopeAll"> / 尝试全局封禁</span>
|
2023-03-01 18:59:42 +08:00
|
|
|
|
<i class="icon angle" :class="{up: isEditing, down: !isEditing}"></i></a>
|
2022-01-10 19:54:29 +08:00
|
|
|
|
<table class="ui table" v-show="isEditing">
|
2020-11-22 16:54:31 +08:00
|
|
|
|
<tr>
|
|
|
|
|
|
<td class="title">状态码</td>
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<input type="text" v-model="statusCode" style="width:4.5em" maxlength="3"/>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
<td>提示内容</td>
|
|
|
|
|
|
<td>
|
2024-04-07 14:20:17 +08:00
|
|
|
|
<textarea rows="3" v-model="options.body"></textarea>
|
2020-11-22 16:54:31 +08:00
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
2021-09-29 20:12:27 +08:00
|
|
|
|
<tr>
|
2023-03-01 18:59:42 +08:00
|
|
|
|
<td>封禁时长</td>
|
2021-09-29 20:12:27 +08:00
|
|
|
|
<td>
|
|
|
|
|
|
<div class="ui input right labeled">
|
|
|
|
|
|
<input type="text" v-model="timeout" style="width: 5em" maxlength="6"/>
|
|
|
|
|
|
<span class="ui label">秒</span>
|
|
|
|
|
|
</div>
|
2023-03-01 18:59:42 +08:00
|
|
|
|
<p class="comment">触发阻止动作时,封禁客户端IP的时间。</p>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
<td>最大封禁时长</td>
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<div class="ui input right labeled">
|
|
|
|
|
|
<input type="text" v-model="timeoutMax" style="width: 5em" maxlength="6"/>
|
|
|
|
|
|
<span class="ui label">秒</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<p class="comment">如果最大封禁时长大于封禁时长({{timeout}}秒),那么表示每次封禁的时候,将会在这两个时长数字之间随机选取一个数字作为最终的封禁时长。</p>
|
2021-09-29 20:12:27 +08:00
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
2024-04-07 14:20:17 +08:00
|
|
|
|
<tr>
|
|
|
|
|
|
<td>失败全局封禁</td>
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<checkbox v-model="options.failBlockScopeAll"></checkbox>
|
|
|
|
|
|
<p class="comment">选中后,表示允许系统尝试全局封禁某个IP,以提升封禁性能。</p>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
2020-11-22 16:54:31 +08:00
|
|
|
|
</table>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
`
|
|
|
|
|
|
})
|