Initial commit (code only without large binaries)

This commit is contained in:
robin
2026-02-15 18:58:44 +08:00
commit 35df75498f
9442 changed files with 1495866 additions and 0 deletions

View File

@@ -0,0 +1,207 @@
// HTTP CC防护配置
Vue.component("http-cc-config-box", {
props: ["v-cc-config", "v-is-location", "v-is-group"],
data: function () {
let config = this.vCcConfig
if (config == null) {
config = {
isPrior: false,
isOn: false,
enableFingerprint: true,
enableGET302: true,
onlyURLPatterns: [],
exceptURLPatterns: [],
useDefaultThresholds: true,
ignoreCommonFiles: true
}
}
if (config.thresholds == null || config.thresholds.length == 0) {
config.thresholds = [
{
maxRequests: 0
},
{
maxRequests: 0
},
{
maxRequests: 0
}
]
}
if (typeof config.enableFingerprint != "boolean") {
config.enableFingerprint = true
}
if (typeof config.enableGET302 != "boolean") {
config.enableGET302 = true
}
if (config.onlyURLPatterns == null) {
config.onlyURLPatterns = []
}
if (config.exceptURLPatterns == null) {
config.exceptURLPatterns = []
}
return {
config: config,
moreOptionsVisible: false,
minQPSPerIP: config.minQPSPerIP,
useCustomThresholds: !config.useDefaultThresholds,
thresholdMaxRequests0: this.maxRequestsStringAtThresholdIndex(config, 0),
thresholdMaxRequests1: this.maxRequestsStringAtThresholdIndex(config, 1),
thresholdMaxRequests2: this.maxRequestsStringAtThresholdIndex(config, 2)
}
},
watch: {
minQPSPerIP: function (v) {
let qps = parseInt(v.toString())
if (isNaN(qps) || qps < 0) {
qps = 0
}
this.config.minQPSPerIP = qps
},
thresholdMaxRequests0: function (v) {
this.setThresholdMaxRequests(0, v)
},
thresholdMaxRequests1: function (v) {
this.setThresholdMaxRequests(1, v)
},
thresholdMaxRequests2: function (v) {
this.setThresholdMaxRequests(2, v)
},
useCustomThresholds: function (b) {
this.config.useDefaultThresholds = !b
}
},
methods: {
maxRequestsStringAtThresholdIndex: function (config, index) {
if (config.thresholds == null) {
return ""
}
if (index < config.thresholds.length) {
let s = config.thresholds[index].maxRequests.toString()
if (s == "0") {
s = ""
}
return s
}
return ""
},
setThresholdMaxRequests: function (index, v) {
let maxRequests = parseInt(v)
if (isNaN(maxRequests) || maxRequests < 0) {
maxRequests = 0
}
if (index < this.config.thresholds.length) {
this.config.thresholds[index].maxRequests = maxRequests
}
},
showMoreOptions: function () {
this.moreOptionsVisible = !this.moreOptionsVisible
}
},
template: `<div>
<input type="hidden" name="ccJSON" :value="JSON.stringify(config)"/>
<table class="ui table definition selectable">
<prior-checkbox :v-config="config" v-if="vIsLocation || vIsGroup"></prior-checkbox>
<tbody v-show="((!vIsLocation && !vIsGroup) || config.isPrior)">
<tr>
<td class="title">启用CC无感防护</td>
<td>
<checkbox v-model="config.isOn"></checkbox>
<p class="comment"><plus-label></plus-label>启用后自动检测并拦截CC攻击。</p>
</td>
</tr>
</tbody>
<tbody v-show="config.isOn">
<tr>
<td colspan="2"><more-options-indicator @change="showMoreOptions"></more-options-indicator></td>
</tr>
</tbody>
<tbody v-show="moreOptionsVisible && config.isOn">
<tr>
<td>例外URL</td>
<td>
<url-patterns-box v-model="config.exceptURLPatterns"></url-patterns-box>
<p class="comment">如果填写了例外URL表示这些URL跳过CC防护不做处理。</p>
</td>
</tr>
<tr>
<td>限制URL</td>
<td>
<url-patterns-box v-model="config.onlyURLPatterns"></url-patterns-box>
<p class="comment">如果填写了限制URL表示只对这些URL进行CC防护处理如果不填则表示支持所有的URL。</p>
</td>
</tr>
<tr>
<td>忽略常用文件</td>
<td>
<checkbox v-model="config.ignoreCommonFiles"></checkbox>
<p class="comment">忽略js、css、jpg等常在网页里被引用的文件名即对这些文件的访问不加入计数可以减少误判几率。</p>
</td>
</tr>
<tr>
<td>检查请求来源指纹</td>
<td>
<checkbox v-model="config.enableFingerprint"></checkbox>
<p class="comment">在接收到HTTPS请求时尝试检查请求来源的指纹用来检测代理服务和爬虫攻击如果你在网站前面放置了别的反向代理服务请取消此选项。</p>
</td>
</tr>
<tr>
<td>启用GET302校验</td>
<td>
<checkbox v-model="config.enableGET302"></checkbox>
<p class="comment">选中后表示自动通过GET302方法来校验客户端。</p>
</td>
</tr>
<tr>
<td>单IP最低QPS</td>
<td>
<div class="ui input right labeled">
<input type="text" name="minQPSPerIP" maxlength="6" style="width: 6em" v-model="minQPSPerIP"/>
<span class="ui label">请求数/秒</span>
</div>
<p class="comment">当某个IP在1分钟内平均QPS达到此值时才会开始检测如果设置为0表示任何访问都会检测。注意这里设置的是检测开启阈值不是拦截阈值拦截阈值在当前表单下方可以设置</p>
</td>
</tr>
<tr>
<td class="color-border">使用自定义拦截阈值</td>
<td>
<checkbox v-model="useCustomThresholds"></checkbox>
</td>
</tr>
<tr v-show="!config.useDefaultThresholds">
<td class="color-border">自定义拦截阈值设置</td>
<td>
<div>
<div class="ui input left right labeled">
<span class="ui label basic">单IP每5秒最多</span>
<input type="text" style="width: 6em" maxlength="6" v-model="thresholdMaxRequests0"/>
<span class="ui label basic">请求</span>
</div>
</div>
<div style="margin-top: 1em">
<div class="ui input left right labeled">
<span class="ui label basic">单IP每60秒</span>
<input type="text" style="width: 6em" maxlength="6" v-model="thresholdMaxRequests1"/>
<span class="ui label basic">请求</span>
</div>
</div>
<div style="margin-top: 1em">
<div class="ui input left right labeled">
<span class="ui label basic">单IP每300秒</span>
<input type="text" style="width: 6em" maxlength="6" v-model="thresholdMaxRequests2"/>
<span class="ui label basic">请求</span>
</div>
</div>
</td>
</tr>
</tr>
</tbody>
</table>
<div class="margin"></div>
</div>`
})