diff --git a/build/build.sh b/build/build.sh index c7e71941..a988dd50 100755 --- a/build/build.sh +++ b/build/build.sh @@ -57,9 +57,11 @@ function build() { if [ "$(which uglifyjs)" ]; then echo "compress to component.js ..." uglifyjs --compress --mangle -- "${JS_ROOT}"/components.src.js > "${JS_ROOT}"/components.js + uglifyjs --compress --mangle -- "${JS_ROOT}"/utils.js > "${JS_ROOT}"/utils.min.js else echo "copy to component.js ..." cp "${JS_ROOT}"/components.src.js "${JS_ROOT}"/components.js + cp "${JS_ROOT}"/utils.js "${JS_ROOT}"/utils.min.js fi # create dir & copy files diff --git a/build/generate.sh b/build/generate.sh index 517a4336..546584ea 100755 --- a/build/generate.sh +++ b/build/generate.sh @@ -2,15 +2,21 @@ JS_ROOT=../web/public/js -echo "generate component.src.js ..." +echo "generating component.src.js ..." go run -tags=community ../cmd/edge-admin/main.go generate -if [ `which uglifyjs` ]; then +if [ "$(which uglifyjs)" ]; then echo "compress to component.js ..." uglifyjs --compress --mangle -- ${JS_ROOT}/components.src.js > ${JS_ROOT}/components.js + + echo "compress to utils.min.js ..." + uglifyjs --compress --mangle -- ${JS_ROOT}/utils.js > ${JS_ROOT}/utils.min.js else echo "copy to component.js ..." cp ${JS_ROOT}/components.src.js ${JS_ROOT}/components.js + + echo "copy to utils.min.js ..." + cp ${JS_ROOT}/utils.js ${JS_ROOT}/utils.min.js fi echo "ok" \ No newline at end of file diff --git a/internal/web/actions/default/servers/server/settings/cache/index.go b/internal/web/actions/default/servers/server/settings/cache/index.go index 95c91901..2fa314a7 100644 --- a/internal/web/actions/default/servers/server/settings/cache/index.go +++ b/internal/web/actions/default/servers/server/settings/cache/index.go @@ -2,11 +2,13 @@ package cache import ( "encoding/json" + "github.com/TeaOSLab/EdgeAdmin/internal/utils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeCommon/pkg/langs/codes" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" "github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" @@ -51,10 +53,20 @@ func (this *IndexAction) RunGet(params struct { return } if cachePolicy != nil { + var maxBytes = &shared.SizeCapacity{} + if !utils.JSONIsNull(cachePolicy.MaxBytesJSON) { + err = json.Unmarshal(cachePolicy.MaxBytesJSON, maxBytes) + if err != nil { + this.ErrorPage(err) + return + } + } + this.Data["cachePolicy"] = maps.Map{ - "id": cachePolicy.Id, - "name": cachePolicy.Name, - "isOn": cachePolicy.IsOn, + "id": cachePolicy.Id, + "name": cachePolicy.Name, + "isOn": cachePolicy.IsOn, + "maxBytes": maxBytes, } } else { this.Data["cachePolicy"] = nil @@ -73,7 +85,7 @@ func (this *IndexAction) RunPost(params struct { defer this.CreateLogInfo(codes.ServerCache_LogUpdateCacheSettings, params.WebId) // 校验配置 - cacheConfig := &serverconfigs.HTTPCacheConfig{} + var cacheConfig = &serverconfigs.HTTPCacheConfig{} err := json.Unmarshal(params.CacheJSON, cacheConfig) if err != nil { this.ErrorPage(err) diff --git a/internal/web/actions/default/servers/server/settings/locations/cache/index.go b/internal/web/actions/default/servers/server/settings/locations/cache/index.go index 1f4e6c1c..faaff31a 100644 --- a/internal/web/actions/default/servers/server/settings/locations/cache/index.go +++ b/internal/web/actions/default/servers/server/settings/locations/cache/index.go @@ -2,11 +2,13 @@ package cache import ( "encoding/json" + "github.com/TeaOSLab/EdgeAdmin/internal/utils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeCommon/pkg/langs/codes" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" "github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/maps" ) @@ -38,10 +40,20 @@ func (this *IndexAction) RunGet(params struct { return } if cachePolicy != nil { + var maxBytes = &shared.SizeCapacity{} + if !utils.JSONIsNull(cachePolicy.MaxBytesJSON) { + err = json.Unmarshal(cachePolicy.MaxBytesJSON, maxBytes) + if err != nil { + this.ErrorPage(err) + return + } + } + this.Data["cachePolicy"] = maps.Map{ - "id": cachePolicy.Id, - "name": cachePolicy.Name, - "isOn": cachePolicy.IsOn, + "id": cachePolicy.Id, + "name": cachePolicy.Name, + "isOn": cachePolicy.IsOn, + "maxBytes": maxBytes, } } else { this.Data["cachePolicy"] = nil diff --git a/web/public/js/components.js b/web/public/js/components.js index 371d4fe5..d5bc4f40 100644 --- a/web/public/js/components.js +++ b/web/public/js/components.js @@ -1040,7 +1040,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio -`}),Vue.component("plan-price-config-box",{props:["v-price-type","v-monthly-price","v-seasonally-price","v-yearly-price","v-traffic-price","v-bandwidth-price","v-disable-period"],data:function(){let e=this.vPriceType,t=(null==e&&(e="bandwidth"),0),i=this.vMonthlyPrice,n=(null==i||i<=0?i="":(i=i.toString(),t=parseFloat(i),isNaN(t)&&(t=0)),0),s=this.vSeasonallyPrice,o=(null==s||s<=0?s="":(s=s.toString(),n=parseFloat(s),isNaN(n)&&(n=0)),0),a=this.vYearlyPrice,l=(null==a||a<=0?a="":(a=a.toString(),o=parseFloat(a),isNaN(o)&&(o=0)),this.vTrafficPrice),c=0,r=(null!=l?c=l.base:l={base:0},""),d=(0 +`}),Vue.component("plan-price-config-box",{props:["v-price-type","v-monthly-price","v-seasonally-price","v-yearly-price","v-traffic-price","v-bandwidth-price","v-disable-period"],data:function(){let e=this.vPriceType,t=(null==e&&(e="bandwidth"),0),i=this.vMonthlyPrice,n=(null==i||i<=0?i="":(i=i.toString(),t=parseFloat(i),isNaN(t)&&(t=0)),0),s=this.vSeasonallyPrice,o=(null==s||s<=0?s="":(s=s.toString(),n=parseFloat(s),isNaN(n)&&(n=0)),0),a=this.vYearlyPrice,l=(null==a||a<=0?a="":(a=a.toString(),o=parseFloat(a),isNaN(o)&&(o=0)),this.vTrafficPrice),r=0,c=(null!=l?r=l.base:l={base:0},""),d=(0 @@ -1703,8 +1703,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio 缓存条件 - 分组关系 - 缓存时间 + 缓存时间 @@ -1721,16 +1720,11 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio {{cacheRef.methods.join(", ")}} Expires 状态码:{{cacheRef.status.map(function(v) {return v.toString()}).join(", ")}} - 区间缓存 + 分片缓存 + Range回源 If-None-Match If-Modified-Since - - - - - - - + 支持异步 {{cacheRef.life.count}} {{timeUnitName(cacheRef.life.unit)}} @@ -1844,7 +1838,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio

所有规则匹配顺序为从上到下,可以拖动左侧的排序。

-`}),Vue.component("http-cache-ref-box",{props:["v-cache-ref","v-is-reverse"],mounted:function(){this.$refs.variablesDescriber.update(this.ref.key),null!=this.ref.simpleCond?(this.condType=this.ref.simpleCond.type,this.changeCondType(this.ref.simpleCond.type,!0),this.condCategory="simple"):null!=this.ref.conds&&null!=this.ref.conds.groups&&(this.condCategory="complex"),this.changeCondCategory(this.condCategory)},data:function(){let e=this.vCacheRef;null==(e=null==e?{isOn:!0,cachePolicyId:0,key:"${scheme}://${host}${requestPath}${isArgs}${args}",life:{count:2,unit:"hour"},status:[200],maxSize:{count:32,unit:"mb"},minSize:{count:0,unit:"kb"},skipCacheControlValues:["private","no-cache","no-store"],skipSetCookie:!0,enableRequestCachePragma:!1,conds:null,simpleCond:null,allowChunkedEncoding:!0,allowPartialContent:!0,forcePartialContent:!1,enableIfNoneMatch:!1,enableIfModifiedSince:!1,isReverse:this.vIsReverse,methods:[],expiresTime:{isPrior:!1,isOn:!1,overwrite:!0,autoCalculate:!0,duration:{count:-1,unit:"hour"}}}:e).key&&(e.key=""),null==e.methods&&(e.methods=[]),null==e.life&&(e.life={count:2,unit:"hour"}),null==e.maxSize&&(e.maxSize={count:32,unit:"mb"}),null==e.minSize&&(e.minSize={count:0,unit:"kb"});var t=window.REQUEST_COND_COMPONENTS.$find(function(e,t){return"url-extension"==t.type});return{ref:e,keyIgnoreArgs:"string"==typeof e.key&&e.key.indexOf("${args}")<0,moreOptionsVisible:!1,condCategory:"simple",condType:"url-extension",condComponent:t,condIsCaseInsensitive:null==e.simpleCond||e.simpleCond.isCaseInsensitive,components:window.REQUEST_COND_COMPONENTS}},watch:{keyIgnoreArgs:function(e){"string"==typeof this.ref.key&&(e?this.ref.key=this.ref.key.replace("${isArgs}${args}",""):(this.ref.key.indexOf("${isArgs}")<0&&(this.ref.key=this.ref.key+"${isArgs}"),this.ref.key.indexOf("${args}")<0&&(this.ref.key=this.ref.key+"${args}")))}},methods:{changeOptionsVisible:function(e){this.moreOptionsVisible=e},changeLife:function(e){this.ref.life=e},changeMaxSize:function(e){this.ref.maxSize=e},changeMinSize:function(e){this.ref.minSize=e},changeConds:function(e){this.ref.conds=e,this.ref.simpleCond=null},changeStatusList:function(e){let t=[];e.forEach(function(e){e=parseInt(e);isNaN(e)||e<100||999 +`}),Vue.component("http-cache-ref-box",{props:["v-cache-ref","v-is-reverse"],mounted:function(){this.$refs.variablesDescriber.update(this.ref.key),null!=this.ref.simpleCond?(this.condType=this.ref.simpleCond.type,this.changeCondType(this.ref.simpleCond.type,!0),this.condCategory="simple"):null!=this.ref.conds&&null!=this.ref.conds.groups&&(this.condCategory="complex"),this.changeCondCategory(this.condCategory)},data:function(){let e=this.vCacheRef;null==(e=null==e?{isOn:!0,cachePolicyId:0,key:"${scheme}://${host}${requestPath}${isArgs}${args}",life:{count:2,unit:"hour"},status:[200],maxSize:{count:32,unit:"mb"},minSize:{count:0,unit:"kb"},skipCacheControlValues:["private","no-cache","no-store"],skipSetCookie:!0,enableRequestCachePragma:!1,conds:null,simpleCond:null,allowChunkedEncoding:!0,allowPartialContent:!0,forcePartialContent:!1,enableIfNoneMatch:!1,enableIfModifiedSince:!1,enableReadingOriginAsync:!1,isReverse:this.vIsReverse,methods:[],expiresTime:{isPrior:!1,isOn:!1,overwrite:!0,autoCalculate:!0,duration:{count:-1,unit:"hour"}}}:e).key&&(e.key=""),null==e.methods&&(e.methods=[]),null==e.life&&(e.life={count:2,unit:"hour"}),null==e.maxSize&&(e.maxSize={count:32,unit:"mb"}),null==e.minSize&&(e.minSize={count:0,unit:"kb"});var t=window.REQUEST_COND_COMPONENTS.$find(function(e,t){return"url-extension"==t.type});return{ref:e,keyIgnoreArgs:"string"==typeof e.key&&e.key.indexOf("${args}")<0,moreOptionsVisible:!1,condCategory:"simple",condType:"url-extension",condComponent:t,condIsCaseInsensitive:null==e.simpleCond||e.simpleCond.isCaseInsensitive,components:window.REQUEST_COND_COMPONENTS}},watch:{keyIgnoreArgs:function(e){"string"==typeof this.ref.key&&(e?this.ref.key=this.ref.key.replace("${isArgs}${args}",""):(this.ref.key.indexOf("${isArgs}")<0&&(this.ref.key=this.ref.key+"${isArgs}"),this.ref.key.indexOf("${args}")<0&&(this.ref.key=this.ref.key+"${args}")))}},methods:{changeOptionsVisible:function(e){this.moreOptionsVisible=e},changeLife:function(e){this.ref.life=e},changeMaxSize:function(e){this.ref.maxSize=e},changeMinSize:function(e){this.ref.minSize=e},changeConds:function(e){this.ref.conds=e,this.ref.simpleCond=null},changeStatusList:function(e){let t=[];e.forEach(function(e){e=parseInt(e);isNaN(e)||e<100||999 条件类型 * @@ -1938,24 +1932,24 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio - 支持分片内容 + 支持缓存分片内容 - -

选中后,Gzip等压缩后的Chunked内容可以直接缓存,无需检查内容长度。

+ +

选中后,支持缓存源站返回的某个分片的内容,该内容通过206 Partial Content状态码返回。

+ + + + 强制返回分片内容 + + +

选中后,表示无论客户端是否发送Range报头,都会优先尝试返回已缓存的分片内容;如果你的应用有不支持分片内容的客户端(比如有些下载软件不支持206 Partial Content),请务必关闭此功能。

- 支持缓存区间内容 + 强制Range回源 - -

选中后,支持缓存源站返回的某个区间的内容,该内容通过206 Partial Content状态码返回。

- - - - 强制返回区间内容 - - -

选中后,表示无论客户端是否发送Range报头,都会优先尝试返回已缓存的区间内容;如果你的应用有不支持区间内容的客户端(比如有些下载软件不支持206 Partial Content),请务必关闭此功能。

+ +

选中后,表示把所有包含Range报头的请求都转发到源站,而不是尝试从缓存中读取。

@@ -2006,6 +2000,20 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio

特殊情况下才需要开启,可能会降低缓存命中率。

+ + 允许异步读取源站 + + +

试验功能。允许客户端中断连接后,仍然继续尝试从源站读取内容并缓存。

+ + + + 支持分段内容 + + +

选中后,Gzip等压缩后的Chunked内容可以直接缓存,无需检查内容长度。

+ + @@ -2115,7 +2123,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio 全局WAF策略
{{vFirewallPolicy.name}}   [{{vFirewallPolicy.modeInfo.name}}]  -

当前服务所在集群的设置。

+

当前网站所在集群的设置。

当前集群没有设置WAF策略,当前配置无法生效。 @@ -2156,7 +2164,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio

{{chart.name}} ({{valueTypeName}})

-`}),Vue.component("metric-board",{template:"
"}),Vue.component("http-cache-config-box",{props:["v-cache-config","v-is-location","v-is-group","v-cache-policy","v-web-id"],data:function(){let e=this.vCacheConfig;return null==(e=null==e?{isPrior:!1,isOn:!1,addStatusHeader:!0,addAgeHeader:!1,enableCacheControlMaxAge:!1,cacheRefs:[],purgeIsOn:!1,purgeKey:"",disablePolicyRefs:!1}:e).cacheRefs&&(e.cacheRefs=[]),{cacheConfig:e,moreOptionsVisible:!1,enablePolicyRefs:!e.disablePolicyRefs}},watch:{enablePolicyRefs:function(e){this.cacheConfig.disablePolicyRefs=!e}},methods:{isOn:function(){return(!this.vIsLocation&&!this.vIsGroup||this.cacheConfig.isPrior)&&this.cacheConfig.isOn},isPlus:function(){return Tea.Vue.teaIsPlus},generatePurgeKey:function(){let e=Math.random().toString()+Math.random().toString(),t=e.replace(/0\./g,"").replace(/\./g,""),i="";for(let e=0;e +`}),Vue.component("metric-board",{template:"
"}),Vue.component("http-cache-config-box",{props:["v-cache-config","v-is-location","v-is-group","v-cache-policy","v-web-id"],data:function(){let e=this.vCacheConfig;null==(e=null==e?{isPrior:!1,isOn:!1,addStatusHeader:!0,addAgeHeader:!1,enableCacheControlMaxAge:!1,cacheRefs:[],purgeIsOn:!1,purgeKey:"",disablePolicyRefs:!1}:e).cacheRefs&&(e.cacheRefs=[]);var t=null;return null!=this.vCachePolicy&&null!=this.vCachePolicy.maxBytes&&(t=this.vCachePolicy.maxBytes),{cacheConfig:e,moreOptionsVisible:!1,enablePolicyRefs:!e.disablePolicyRefs,maxBytes:t}},watch:{enablePolicyRefs:function(e){this.cacheConfig.disablePolicyRefs=!e}},methods:{isOn:function(){return(!this.vIsLocation&&!this.vIsGroup||this.cacheConfig.isPrior)&&this.cacheConfig.isOn},isPlus:function(){return Tea.Vue.teaIsPlus},generatePurgeKey:function(){let e=Math.random().toString()+Math.random().toString(),t=e.replace(/0\./g,"").replace(/\./g,""),i="";for(let e=0;e @@ -2164,7 +2172,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio @@ -2244,7 +2252,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio

缓存条件   [添加]

- +
`});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 e=null,t=null;var i;null!=window.parent.UPDATING_RULE&&(null!=(i=window.parent.UPDATING_RULE.checkpointOptions).headers&&Array.$isArray(i.headers)&&(e=i.headers),null!=i.length&&(t=i.length)),null==e&&(e=defaultGeneralHeaders),null==t&&(t=128);let n=this;return setTimeout(function(){n.change()},100),{headers:e,length:t}},watch:{length:function(e){let t=parseInt(e);(t=isNaN(t)?0:t)<0&&(t=0),this.length=t,this.change()}},methods:{change:function(){this.vCheckpoint.options=[{code:"headers",value:this.headers},{code:"length",value:this.length}]}},template:`
@@ -2354,7 +2362,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio 分表{{p.code+1}}       |
-`}),Vue.component("http-cache-refs-config-box",{props:["v-cache-refs","v-cache-config","v-cache-policy-id","v-web-id"],mounted:function(){let n=this;sortTable(function(e){let i=[];e.forEach(function(t){n.refs.forEach(function(e){e.id==t&&i.push(e)})}),n.updateRefs(i),n.change()})},data:function(){let e=this.vCacheRefs,t=(null==e&&(e=[]),0);return e.forEach(function(e){t++,e.id=t}),{refs:e,id:t}},methods:{addRef:function(e){window.UPDATING_CACHE_REF=null;let t=window.innerHeight,s=(500 +`}),Vue.component("http-cache-refs-config-box",{props:["v-cache-refs","v-cache-config","v-cache-policy-id","v-web-id","v-max-bytes"],mounted:function(){let n=this;sortTable(function(e){let i=[];e.forEach(function(t){n.refs.forEach(function(e){e.id==t&&i.push(e)})}),n.updateRefs(i),n.change()})},data:function(){let e=this.vCacheRefs,t=(null==e&&(e=[]),this.vMaxBytes),i=0;return e.forEach(function(e){i++,e.id=i,null!=e.maxSize&&null!=t&&0
@@ -2364,8 +2372,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
- - + @@ -2378,24 +2385,23 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio 忽略URI参数 + {{cacheRef.minSize.count}}{{cacheRef.minSize.unit}} - - {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit}} + - {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit.toUpperCase()}} - 0 - {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit}} + 0 - {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit.toUpperCase()}} + + 系统限制{{cacheRef.overMaxSize.count}}{{cacheRef.overMaxSize.unit.toUpperCase()}} + {{cacheRef.methods.join(", ")}}Expires状态码:{{cacheRef.status.map(function(v) {return v.toString()}).join(", ")}} - 区间缓存 + 分片缓存 + Range回源If-None-MatchIf-Modified-Since - - @@ -3768,7 +3774,7 @@ example2.com
全局缓存策略
{{vCachePolicy.name}} -

使用当前服务所在集群的设置。

+

使用当前网站所在集群的设置。

当前集群没有设置缓存策略,当前配置无法生效。
缓存条件分组关系缓存时间缓存时间 操作
- - - - - + 支持异步 {{cacheRef.life.count}} {{timeUnitName(cacheRef.life.unit)}} @@ -3383,7 +3389,7 @@ example2.com
`}),Vue.component("user-selector",{props:["v-user-id","data-url"],data:function(){let e=this.vUserId,t=(null==e&&(e=0),this.dataUrl);return null!=t&&0!=t.length||(t="/servers/users/options"),{users:[],userId:e,dataURL:t}},methods:{change:function(e){null!=e?this.$emit("change",e.id):this.$emit("change",0)},clear:function(){this.$refs.comboBox.clear()}},template:`
-
`}),Vue.component("http-header-policy-box",{props:["v-request-header-policy","v-request-header-ref","v-response-header-policy","v-response-header-ref","v-params","v-is-location","v-is-group","v-has-group-request-config","v-has-group-response-config","v-group-setting-url"],data:function(){let e="response";"#request"==window.location.hash&&(e="request");let t=this.vRequestHeaderRef,i=(null==t&&(t={isPrior:!1,isOn:!0,headerPolicyId:0}),this.vResponseHeaderRef),n=(null==i&&(i={isPrior:!1,isOn:!0,headerPolicyId:0}),[]),s=[],o=[];var a=this.vRequestHeaderPolicy;null!=a&&(null!=a.setHeaders&&(n=a.setHeaders),null!=a.deleteHeaders&&(s=a.deleteHeaders),null!=a.nonStandardHeaders&&(o=a.nonStandardHeaders));let l=[],c=[],r=[];a=this.vResponseHeaderPolicy;null!=a&&(null!=a.setHeaders&&(l=a.setHeaders),null!=a.deleteHeaders&&(c=a.deleteHeaders),null!=a.nonStandardHeaders&&(r=a.nonStandardHeaders));let d={isOn:!1};return null!=a.cors&&(d=a.cors),{type:e,typeName:"request"==e?"请求":"响应",requestHeaderRef:t,responseHeaderRef:i,requestSettingHeaders:n,requestDeletingHeaders:s,requestNonStandardHeaders:o,responseSettingHeaders:l,responseDeletingHeaders:c,responseNonStandardHeaders:r,responseCORS:d}},methods:{selectType:function(e){this.type=e,window.location.hash="#"+e,window.location.reload()},addSettingHeader:function(e){teaweb.popup("/servers/server/settings/headers/createSetPopup?"+this.vParams+"&headerPolicyId="+e+"&type="+this.type,{callback:function(){teaweb.successRefresh("保存成功")}})},addDeletingHeader:function(e,t){teaweb.popup("/servers/server/settings/headers/createDeletePopup?"+this.vParams+"&headerPolicyId="+e+"&type="+t,{callback:function(){teaweb.successRefresh("保存成功")}})},addNonStandardHeader:function(e,t){teaweb.popup("/servers/server/settings/headers/createNonStandardPopup?"+this.vParams+"&headerPolicyId="+e+"&type="+t,{callback:function(){teaweb.successRefresh("保存成功")}})},updateSettingPopup:function(e,t){teaweb.popup("/servers/server/settings/headers/updateSetPopup?"+this.vParams+"&headerPolicyId="+e+"&headerId="+t+"&type="+this.type,{callback:function(){teaweb.successRefresh("保存成功")}})},deleteDeletingHeader:function(e,t){teaweb.confirm("确定要删除'"+t+"'吗?",function(){Tea.action("/servers/server/settings/headers/deleteDeletingHeader").params({headerPolicyId:e,headerName:t}).post().refresh()})},deleteNonStandardHeader:function(e,t){teaweb.confirm("确定要删除'"+t+"'吗?",function(){Tea.action("/servers/server/settings/headers/deleteNonStandardHeader").params({headerPolicyId:e,headerName:t}).post().refresh()})},deleteHeader:function(e,t,i){teaweb.confirm("确定要删除此报头吗?",function(){this.$post("/servers/server/settings/headers/delete").params({headerPolicyId:e,type:t,headerId:i}).refresh()})},updateCORS:function(e){teaweb.popup("/servers/server/settings/headers/updateCORSPopup?"+this.vParams+"&headerPolicyId="+e+"&type="+this.type,{height:"30em",callback:function(){teaweb.successRefresh("保存成功")}})}},template:`
+
`}),Vue.component("http-header-policy-box",{props:["v-request-header-policy","v-request-header-ref","v-response-header-policy","v-response-header-ref","v-params","v-is-location","v-is-group","v-has-group-request-config","v-has-group-response-config","v-group-setting-url"],data:function(){let e="response";"#request"==window.location.hash&&(e="request");let t=this.vRequestHeaderRef,i=(null==t&&(t={isPrior:!1,isOn:!0,headerPolicyId:0}),this.vResponseHeaderRef),n=(null==i&&(i={isPrior:!1,isOn:!0,headerPolicyId:0}),[]),s=[],o=[];var a=this.vRequestHeaderPolicy;null!=a&&(null!=a.setHeaders&&(n=a.setHeaders),null!=a.deleteHeaders&&(s=a.deleteHeaders),null!=a.nonStandardHeaders&&(o=a.nonStandardHeaders));let l=[],r=[],c=[];a=this.vResponseHeaderPolicy;null!=a&&(null!=a.setHeaders&&(l=a.setHeaders),null!=a.deleteHeaders&&(r=a.deleteHeaders),null!=a.nonStandardHeaders&&(c=a.nonStandardHeaders));let d={isOn:!1};return null!=a.cors&&(d=a.cors),{type:e,typeName:"request"==e?"请求":"响应",requestHeaderRef:t,responseHeaderRef:i,requestSettingHeaders:n,requestDeletingHeaders:s,requestNonStandardHeaders:o,responseSettingHeaders:l,responseDeletingHeaders:r,responseNonStandardHeaders:c,responseCORS:d}},methods:{selectType:function(e){this.type=e,window.location.hash="#"+e,window.location.reload()},addSettingHeader:function(e){teaweb.popup("/servers/server/settings/headers/createSetPopup?"+this.vParams+"&headerPolicyId="+e+"&type="+this.type,{callback:function(){teaweb.successRefresh("保存成功")}})},addDeletingHeader:function(e,t){teaweb.popup("/servers/server/settings/headers/createDeletePopup?"+this.vParams+"&headerPolicyId="+e+"&type="+t,{callback:function(){teaweb.successRefresh("保存成功")}})},addNonStandardHeader:function(e,t){teaweb.popup("/servers/server/settings/headers/createNonStandardPopup?"+this.vParams+"&headerPolicyId="+e+"&type="+t,{callback:function(){teaweb.successRefresh("保存成功")}})},updateSettingPopup:function(e,t){teaweb.popup("/servers/server/settings/headers/updateSetPopup?"+this.vParams+"&headerPolicyId="+e+"&headerId="+t+"&type="+this.type,{callback:function(){teaweb.successRefresh("保存成功")}})},deleteDeletingHeader:function(e,t){teaweb.confirm("确定要删除'"+t+"'吗?",function(){Tea.action("/servers/server/settings/headers/deleteDeletingHeader").params({headerPolicyId:e,headerName:t}).post().refresh()})},deleteNonStandardHeader:function(e,t){teaweb.confirm("确定要删除'"+t+"'吗?",function(){Tea.action("/servers/server/settings/headers/deleteNonStandardHeader").params({headerPolicyId:e,headerName:t}).post().refresh()})},deleteHeader:function(e,t,i){teaweb.confirm("确定要删除此报头吗?",function(){this.$post("/servers/server/settings/headers/delete").params({headerPolicyId:e,type:t,headerId:i}).refresh()})},updateCORS:function(e){teaweb.popup("/servers/server/settings/headers/updateCORSPopup?"+this.vParams+"&headerPolicyId="+e+"&type="+this.type,{height:"30em",callback:function(){teaweb.successRefresh("保存成功")}})}},template:`
支持Partial
Content
-

支持对分区内容(PartialContent)的压缩;除非客户端有特殊要求,一般不需要启用。

+

支持对分片内容(PartialContent)的压缩;除非客户端有特殊要求,一般不需要启用。

-`}),Vue.component("http-cc-config-box",{props:["v-cc-config","v-is-location","v-is-group"],data:function(){let e=this.vCcConfig;return"boolean"!=typeof(e=null==e?{isPrior:!1,isOn:!1,enableFingerprint:!0,enableGET302:!0,onlyURLPatterns:[],exceptURLPatterns:[]}:e).enableFingerprint&&(e.enableFingerprint=!0),"boolean"!=typeof e.enableGET302&&(e.enableGET302=!0),null==e.onlyURLPatterns&&(e.onlyURLPatterns=[]),null==e.exceptURLPatterns&&(e.exceptURLPatterns=[]),{config:e,moreOptionsVisible:!1,minQPSPerIP:e.minQPSPerIP}},watch:{minQPSPerIP:function(e){let t=parseInt(e.toString());(isNaN(t)||t<0)&&(t=0),this.config.minQPSPerIP=t}},methods:{showMoreOptions:function(){this.moreOptionsVisible=!this.moreOptionsVisible}},template:`
+
`}),Vue.component("http-cc-config-box",{props:["v-cc-config","v-is-location","v-is-group"],data:function(){let e=this.vCcConfig;return null!=(e=null==e?{isPrior:!1,isOn:!1,enableFingerprint:!0,enableGET302:!0,onlyURLPatterns:[],exceptURLPatterns:[],useDefaultThresholds:!0}:e).thresholds&&0!=e.thresholds.length||(e.thresholds=[{maxRequests:0},{maxRequests:0},{maxRequests:0}]),"boolean"!=typeof e.enableFingerprint&&(e.enableFingerprint=!0),"boolean"!=typeof e.enableGET302&&(e.enableGET302=!0),null==e.onlyURLPatterns&&(e.onlyURLPatterns=[]),null==e.exceptURLPatterns&&(e.exceptURLPatterns=[]),{config:e,moreOptionsVisible:!1,minQPSPerIP:e.minQPSPerIP,useCustomThresholds:!e.useDefaultThresholds,thresholdMaxRequests0:this.maxRequestsStringAtThresholdIndex(e,0),thresholdMaxRequests1:this.maxRequestsStringAtThresholdIndex(e,1),thresholdMaxRequests2:this.maxRequestsStringAtThresholdIndex(e,2)}},watch:{minQPSPerIP:function(e){let t=parseInt(e.toString());(isNaN(t)||t<0)&&(t=0),this.config.minQPSPerIP=t},thresholdMaxRequests0:function(e){this.setThresholdMaxRequests(0,e)},thresholdMaxRequests1:function(e){this.setThresholdMaxRequests(1,e)},thresholdMaxRequests2:function(e){this.setThresholdMaxRequests(2,e)},useCustomThresholds:function(e){this.config.useDefaultThresholds=!e}},methods:{maxRequestsStringAtThresholdIndex:function(t,i){if(null==t.thresholds)return"";if(i @@ -3825,6 +3831,39 @@ example2.com

选中后,表示自动通过GET302方法来校验客户端。

+ + + + + + + +
使用自定义阈值 + +
自定义阈值设置 +
+
+ 单IP每5秒最多 + + 请求 +
+
+ +
+
+ 单IP每60秒 + + 请求 +
+
+
+
+ 单IP每300秒 + + 请求 +
+
+
@@ -3956,7 +3995,7 @@ example2.com - 耗时:{{formatCost(accessLog.requestTime)}} ms   ({{accessLog.humanTime}})   -`});var punycode=new function(){this.utf16={decode:function(e){for(var t,i,n=[],s=0,o=e.length;s>>10&1023|55296)),t=56320|1023&t),i.push(String.fromCharCode(t))}return i.join("")}};var b=2147483647;function y(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function w(e,t,i){var n;for(e=i?Math.floor(e/700):e>>1,e+=Math.floor(e/t),n=0;455= 0x80");d.push(e.charCodeAt(n))}for(s=0Math.floor((b-v)/a))throw RangeError("punycode_overflow(1)");if(v+=r*a,r<(r=l<=m?1:m+26<=l?26:l-m))break;if(a>Math.floor(b/(36-r)))throw RangeError("punycode_overflow(2)");a*=36-r}if(m=w(v-o,i=d.length+1,0===o),Math.floor(v/i)>b-h)throw RangeError("punycode_overflow(3)");h+=Math.floor(v/i),v%=i,t&&p.splice(v,0,e.charCodeAt(s-1)-65<26),d.splice(v,0,h),v++}if(t)for(v=0,c=d.length;vMath.floor((b-m)/(i+1)))throw RangeError("punycode_overflow (1)");for(m+=(s-v)*(i+1),v=s,g=0;gb)return Error("punycode_overflow(2)");if(c==v){for(o=m,a=36;!(o<(l=a<=f?1:f+26<=a?26:a-f));a+=36)h.push(String.fromCharCode(y(l+(o-l)%(36-l),0))),o=Math.floor((o-l)/(36-l));h.push(String.fromCharCode(y(o,t&&r[g]?1:0))),f=w(m,i+1,i==n),m=0,++i}}++m,++v}return h.join("")},this.ToASCII=function(e){for(var t=e.split("."),i=[],n=0;n +`});var punycode=new function(){this.utf16={decode:function(e){for(var t,i,n=[],s=0,o=e.length;s>>10&1023|55296)),t=56320|1023&t),i.push(String.fromCharCode(t))}return i.join("")}};var b=2147483647;function y(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function x(e,t,i){var n;for(e=i?Math.floor(e/700):e>>1,e+=Math.floor(e/t),n=0;455= 0x80");d.push(e.charCodeAt(n))}for(s=0Math.floor((b-v)/a))throw RangeError("punycode_overflow(1)");if(v+=c*a,c<(c=l<=m?1:m+26<=l?26:l-m))break;if(a>Math.floor(b/(36-c)))throw RangeError("punycode_overflow(2)");a*=36-c}if(m=x(v-o,i=d.length+1,0===o),Math.floor(v/i)>b-h)throw RangeError("punycode_overflow(3)");h+=Math.floor(v/i),v%=i,t&&p.splice(v,0,e.charCodeAt(s-1)-65<26),d.splice(v,0,h),v++}if(t)for(v=0,r=d.length;vMath.floor((b-m)/(i+1)))throw RangeError("punycode_overflow (1)");for(m+=(s-v)*(i+1),v=s,g=0;gb)return Error("punycode_overflow(2)");if(r==v){for(o=m,a=36;!(o<(l=a<=f?1:f+26<=a?26:a-f));a+=36)h.push(String.fromCharCode(y(l+(o-l)%(36-l),0))),o=Math.floor((o-l)/(36-l));h.push(String.fromCharCode(y(o,t&&c[g]?1:0))),f=x(m,i+1,i==n),m=0,++i}}++m,++v}return h.join("")},this.ToASCII=function(e){for(var t=e.split("."),i=[],n=0;n 默认设置
状态码:{{options.statusCode}} / 提示内容:[{{options.body.length}}字符][无] / 超时时间:{{options.timeout}}秒 / 最大封禁时长:{{options.timeoutMax}}秒 @@ -4305,7 +4344,7 @@ example2.com - 是否自动刷新缓存区(AutoFlush) + 自动刷新缓存区(AutoFlush)
diff --git a/web/public/js/components.src.js b/web/public/js/components.src.js index 61ceef66..3d35c956 100755 --- a/web/public/js/components.src.js +++ b/web/public/js/components.src.js @@ -4641,8 +4641,7 @@ Vue.component("http-cache-refs-box", { 缓存条件 - 分组关系 - 缓存时间 + 缓存时间 @@ -4659,16 +4658,11 @@ Vue.component("http-cache-refs-box", { {{cacheRef.methods.join(", ")}} Expires 状态码:{{cacheRef.status.map(function(v) {return v.toString()}).join(", ")}} - 区间缓存 + 分片缓存 + Range回源 If-None-Match If-Modified-Since - - - - - - - + 支持异步 {{cacheRef.life.count}} {{timeUnitName(cacheRef.life.unit)}} @@ -5063,6 +5057,7 @@ Vue.component("http-cache-ref-box", { forcePartialContent: false, enableIfNoneMatch: false, enableIfModifiedSince: false, + enableReadingOriginAsync: false, isReverse: this.vIsReverse, methods: [], expiresTime: { @@ -5179,7 +5174,7 @@ Vue.component("http-cache-ref-box", { } switch (condCategory) { case "simple": - dialog.style.width = "40em" + dialog.style.width = "45em" break case "complex": let width = window.parent.innerWidth @@ -5297,24 +5292,24 @@ Vue.component("http-cache-ref-box", { - 支持分片内容 + 支持缓存分片内容 - -

选中后,Gzip等压缩后的Chunked内容可以直接缓存,无需检查内容长度。

+ +

选中后,支持缓存源站返回的某个分片的内容,该内容通过206 Partial Content状态码返回。

+ + + + 强制返回分片内容 + + +

选中后,表示无论客户端是否发送Range报头,都会优先尝试返回已缓存的分片内容;如果你的应用有不支持分片内容的客户端(比如有些下载软件不支持206 Partial Content),请务必关闭此功能。

- 支持缓存区间内容 + 强制Range回源 - -

选中后,支持缓存源站返回的某个区间的内容,该内容通过206 Partial Content状态码返回。

- - - - 强制返回区间内容 - - -

选中后,表示无论客户端是否发送Range报头,都会优先尝试返回已缓存的区间内容;如果你的应用有不支持区间内容的客户端(比如有些下载软件不支持206 Partial Content),请务必关闭此功能。

+ +

选中后,表示把所有包含Range报头的请求都转发到源站,而不是尝试从缓存中读取。

@@ -5365,6 +5360,20 @@ Vue.component("http-cache-ref-box", {

特殊情况下才需要开启,可能会降低缓存命中率。

+ + 允许异步读取源站 + + +

试验功能。允许客户端中断连接后,仍然继续尝试从源站读取内容并缓存。

+ + + + 支持分段内容 + + +

选中后,Gzip等压缩后的Chunked内容可以直接缓存,无需检查内容长度。

+ + @@ -5672,7 +5681,7 @@ Vue.component("http-firewall-config-box", { 全局WAF策略
{{vFirewallPolicy.name}}   [{{vFirewallPolicy.modeInfo.name}}]  -

当前服务所在集群的设置。

+

当前网站所在集群的设置。

当前集群没有设置WAF策略,当前配置无法生效。 @@ -6153,10 +6162,16 @@ Vue.component("http-cache-config-box", { cacheConfig.cacheRefs = [] } + var maxBytes = null + if (this.vCachePolicy != null && this.vCachePolicy.maxBytes != null) { + maxBytes = this.vCachePolicy.maxBytes + } + return { cacheConfig: cacheConfig, moreOptionsVisible: false, - enablePolicyRefs: !cacheConfig.disablePolicyRefs + enablePolicyRefs: !cacheConfig.disablePolicyRefs, + maxBytes: maxBytes } }, watch: { @@ -6196,7 +6211,7 @@ Vue.component("http-cache-config-box", { 全局缓存策略
{{vCachePolicy.name}} -

使用当前服务所在集群的设置。

+

使用当前网站所在集群的设置。

当前集群没有设置缓存策略,当前配置无法生效。 @@ -6276,7 +6291,7 @@ Vue.component("http-cache-config-box", {

缓存条件   [添加]

- +
` @@ -6773,7 +6788,7 @@ Vue.component("http-access-log-partitions-box", { }) Vue.component("http-cache-refs-config-box", { - props: ["v-cache-refs", "v-cache-config", "v-cache-policy-id", "v-web-id"], + props: ["v-cache-refs", "v-cache-config", "v-cache-policy-id", "v-web-id", "v-max-bytes"], mounted: function () { let that = this sortTable(function (ids) { @@ -6795,10 +6810,17 @@ Vue.component("http-cache-refs-config-box", { refs = [] } + let maxBytes = this.vMaxBytes + let id = 0 refs.forEach(function (ref) { id++ ref.id = id + + // check max size + if (ref.maxSize != null && maxBytes != null && teaweb.compareSizeCapacity(ref.maxSize, maxBytes) > 0) { + ref.overMaxSize = maxBytes + } }) return { refs: refs, @@ -6941,8 +6963,7 @@ Vue.component("http-cache-refs-config-box", { 缓存条件 - 分组关系 - 缓存时间 + 缓存时间 操作 @@ -6955,24 +6976,23 @@ Vue.component("http-cache-refs-config-box", { 忽略URI参数 + {{cacheRef.minSize.count}}{{cacheRef.minSize.unit}} - - {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit}} + - {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit.toUpperCase()}} - 0 - {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit}} + 0 - {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit.toUpperCase()}} + + 系统限制{{cacheRef.overMaxSize.count}}{{cacheRef.overMaxSize.unit.toUpperCase()}} + {{cacheRef.methods.join(", ")}} Expires 状态码:{{cacheRef.status.map(function(v) {return v.toString()}).join(", ")}} - 区间缓存 + 分片缓存 + Range回源 If-None-Match If-Modified-Since - - - - - - - + 支持异步 {{cacheRef.life.count}} {{timeUnitName(cacheRef.life.unit)}} @@ -10444,7 +10464,7 @@ Vue.component("http-compression-config-box", { 支持Partial
Content -

支持对分区内容(PartialContent)的压缩;除非客户端有特殊要求,一般不需要启用。

+

支持对分片内容(PartialContent)的压缩;除非客户端有特殊要求,一般不需要启用。

@@ -10471,10 +10491,25 @@ Vue.component("http-cc-config-box", { enableFingerprint: true, enableGET302: true, onlyURLPatterns: [], - exceptURLPatterns: [] + exceptURLPatterns: [], + useDefaultThresholds: 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 } @@ -10491,7 +10526,12 @@ Vue.component("http-cc-config-box", { return { config: config, moreOptionsVisible: false, - minQPSPerIP: config.minQPSPerIP + minQPSPerIP: config.minQPSPerIP, + useCustomThresholds: !config.useDefaultThresholds, + + thresholdMaxRequests0: this.maxRequestsStringAtThresholdIndex(config, 0), + thresholdMaxRequests1: this.maxRequestsStringAtThresholdIndex(config, 1), + thresholdMaxRequests2: this.maxRequestsStringAtThresholdIndex(config, 2) } }, watch: { @@ -10501,9 +10541,43 @@ Vue.component("http-cc-config-box", { 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 } @@ -10565,6 +10639,39 @@ Vue.component("http-cc-config-box", {

选中后,表示自动通过GET302方法来校验客户端。

+ + 使用自定义阈值 + + + + + + 自定义阈值设置 + +
+
+ 单IP每5秒最多 + + 请求 +
+
+ +
+
+ 单IP每60秒 + + 请求 +
+
+
+
+ 单IP每300秒 + + 请求 +
+
+ + @@ -12074,7 +12181,7 @@ Vue.component("reverse-proxy-box", { - 是否自动刷新缓存区(AutoFlush) + 自动刷新缓存区(AutoFlush)
diff --git a/web/public/js/components/server/http-cache-config-box.js b/web/public/js/components/server/http-cache-config-box.js index c93aa884..8bf2b35a 100644 --- a/web/public/js/components/server/http-cache-config-box.js +++ b/web/public/js/components/server/http-cache-config-box.js @@ -19,10 +19,16 @@ Vue.component("http-cache-config-box", { cacheConfig.cacheRefs = [] } + var maxBytes = null + if (this.vCachePolicy != null && this.vCachePolicy.maxBytes != null) { + maxBytes = this.vCachePolicy.maxBytes + } + return { cacheConfig: cacheConfig, moreOptionsVisible: false, - enablePolicyRefs: !cacheConfig.disablePolicyRefs + enablePolicyRefs: !cacheConfig.disablePolicyRefs, + maxBytes: maxBytes } }, watch: { @@ -62,7 +68,7 @@ Vue.component("http-cache-config-box", { 全局缓存策略
{{vCachePolicy.name}} -

使用当前服务所在集群的设置。

+

使用当前网站所在集群的设置。

当前集群没有设置缓存策略,当前配置无法生效。 @@ -142,7 +148,7 @@ Vue.component("http-cache-config-box", {

缓存条件   [添加]

- +
` diff --git a/web/public/js/components/server/http-cache-refs-config-box.js b/web/public/js/components/server/http-cache-refs-config-box.js index 671c740e..469f5e4f 100644 --- a/web/public/js/components/server/http-cache-refs-config-box.js +++ b/web/public/js/components/server/http-cache-refs-config-box.js @@ -1,5 +1,5 @@ Vue.component("http-cache-refs-config-box", { - props: ["v-cache-refs", "v-cache-config", "v-cache-policy-id", "v-web-id"], + props: ["v-cache-refs", "v-cache-config", "v-cache-policy-id", "v-web-id", "v-max-bytes"], mounted: function () { let that = this sortTable(function (ids) { @@ -21,10 +21,17 @@ Vue.component("http-cache-refs-config-box", { refs = [] } + let maxBytes = this.vMaxBytes + let id = 0 refs.forEach(function (ref) { id++ ref.id = id + + // check max size + if (ref.maxSize != null && maxBytes != null && maxBytes.count > 0 && teaweb.compareSizeCapacity(ref.maxSize, maxBytes) > 0) { + ref.overMaxSize = maxBytes + } }) return { refs: refs, @@ -180,11 +187,15 @@ Vue.component("http-cache-refs-config-box", { 忽略URI参数 + {{cacheRef.minSize.count}}{{cacheRef.minSize.unit}} - - {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit}} + - {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit.toUpperCase()}} - 0 - {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit}} + 0 - {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit.toUpperCase()}} + + 系统限制{{cacheRef.overMaxSize.count}}{{cacheRef.overMaxSize.unit.toUpperCase()}} + {{cacheRef.methods.join(", ")}} Expires 状态码:{{cacheRef.status.map(function(v) {return v.toString()}).join(", ")}} diff --git a/web/public/js/components/server/http-firewall-config-box.js b/web/public/js/components/server/http-firewall-config-box.js index 70a2b7bb..c8b236b6 100644 --- a/web/public/js/components/server/http-firewall-config-box.js +++ b/web/public/js/components/server/http-firewall-config-box.js @@ -35,7 +35,7 @@ Vue.component("http-firewall-config-box", { 全局WAF策略
{{vFirewallPolicy.name}}   [{{vFirewallPolicy.modeInfo.name}}]  -

当前服务所在集群的设置。

+

当前网站所在集群的设置。

当前集群没有设置WAF策略,当前配置无法生效。 diff --git a/web/public/js/utils.js b/web/public/js/utils.js index a18535dd..8e336b2a 100644 --- a/web/public/js/utils.js +++ b/web/public/js/utils.js @@ -1061,6 +1061,45 @@ window.teaweb = { }).catch(function (e) { console.log(e.message); }) + }, + convertSizeCapacityToBytes: function (c) { + if (c == null) { + return 0 + } + switch (c.unit) { + case "byte": + return c.count + case "kb": + return c.count * 1024 + case "mb": + return c.count * Math.pow(1024, 2) + case "gb": + return c.count * Math.pow(1024, 3) + case "tb": + return c.count * Math.pow(1024, 4) + case "pb": + return c.count * Math.pow(1024, 5) + case "eb": + return c.count * Math.pow(1024, 6) + } + return 0 + }, + compareSizeCapacity: function (c1, c2) { + let b1 = this.convertSizeCapacityToBytes(c1) + let b2 = this.convertSizeCapacityToBytes(c2) + if (b1 == b2) { + return 0 + } + if (b1 > b2) { + return 1 + } + return -1 + }, + convertSizeCapacityToString: function (c) { + if (c == null || c.count == null || c.unit == null) { + return "" + } + return c.count + c.unit.toString().toUpperCase() } } diff --git a/web/public/js/utils.min.js b/web/public/js/utils.min.js index 9c01152e..2d3d394c 100644 --- a/web/public/js/utils.min.js +++ b/web/public/js/utils.min.js @@ -1 +1 @@ -window.teaweb={set:function(t,e){localStorage.setItem(t,JSON.stringify(e))},get:function(t){t=localStorage.getItem(t);return null==t||0==t.length?null:JSON.parse(t)},getString:function(t){t=this.get(t);return"string"==typeof t?t:""},getBool:function(t){return Boolean(this.get(t))},remove:function(t){localStorage.removeItem(t)},match:function(t,e){if(null==t)return!1;if(null==e)return!0;if(t=t.trim(),0==(e=e.trim()).length)return!0;if(0==t.length)return!1;for(var n=e.split(/\s+/),o=0;o=Math.pow(1024,6)?(o="E",n=Math.pow(1024,6)):t>=Math.pow(1024,5)?(o="P",n=Math.pow(1024,5)):t>=Math.pow(1024,4)?(o="T",n=Math.pow(1024,4)):t>=Math.pow(1024,3)?(o="G",n=Math.pow(1024,3)):t>=Math.pow(1024,2)?(o="M",n=Math.pow(1024,2)):t>=Math.pow(1024,1)&&(o="K",n=Math.pow(1024,1)),{unit:o,divider:n}},bitsAxis:function(t,e){t=this.bytesAxis(t,e);let n=t.unit;return"B"==n?n="bps":n+="bps",{unit:n,divider:t.divider}},countAxis:function(t,e){t=Math.max.apply(this,t.map(e));let n=1,o="";return 1e9<=t?(o="B",n=1e9):1e6<=t?(o="M",n=1e6):1e3<=t&&(o="K",n=1e3),{unit:o,divider:n,max:t}},splitFormat:function(t){t=t.match(/^([0-9.]+)([a-zA-Z]+)$/);return[parseFloat(t[1]),t[2]]},popup:function(t,e){null!=t&&0',width:n,padding:"0.5em",showConfirmButton:!1,showCloseButton:!0,focusConfirm:!1,onClose:function(t){"function"==typeof e.onClose&&e.onClose.apply(Tea.Vue,arguments)}})},popupSuccess:function(t,e,n){let o={};null!=e&&(o.width=e),null!=n&&(o.height=n),o.callback=function(){teaweb.success("保存成功",function(){teaweb.reload()})},this.popup(t,o)},popupFinish:function(){null!=window.POPUP_CALLBACK&&window.POPUP_CALLBACK.apply(window,arguments)},popupTip:function(t){Swal.fire({html:'
'+t+"
",width:"34em",padding:"4em",showConfirmButton:!1,showCloseButton:!0,focusConfirm:!1})},isPopup:function(){var t=window.location.hash;return null!=t&&t.startsWith("#popup")},closePopup:function(){this.isPopup()&&window.parent.Swal.close()},Swal:function(){return(this.isPopup()?window.parent:window).Swal},hasPopup:function(){return 0{b} : {c}"+u},series:[{name:r,max:l,type:"gauge",radius:"100%",detail:{formatter:"{value}",show:!1,valueAnimation:!0},data:[{value:a,name:r}],pointer:{show:!1},splitLine:{show:!1},axisTick:{show:!1},axisLine:{show:!0,lineStyle:{width:4}},progress:{show:!0,width:4,itemStyle:{color:i}},splitNumber:{show:!1},title:{show:!1},startAngle:270,endAngle:-90}]};null!=s&&e.series.push({name:n,max:l,type:"gauge",radius:"100%",detail:{formatter:"{value}",show:!1,valueAnimation:!0},data:[{value:s,name:n}],pointer:{show:!1},splitLine:{show:!1},axisTick:{show:!1},axisLine:{show:!0,lineStyle:{width:4}},progress:{show:!0,width:4,itemStyle:{color:c,opacity:.3}},splitNumber:{show:!1},title:{show:!1},startAngle:270,endAngle:-90}),t.setOption(e)}},xRotation:function(t,e){t=t.getWidth();let n=0;return e.forEach(function(t){n+=10*t.length}),n<=t?null:[40,-20]},chartMap:{},initChart:function(t,e){"boolean"!=typeof e&&(e=!0);var n=t.getAttribute("id");if(null!=n&&0/g,">")).replace(/"/g,""")},chartColor:function(t){return t="green"==(t="blue"==(t="yellow"==(t="red"==(t=null!=t&&0!=t.length?t:"#5470c6")?"#ee6666":t)?"#fac858":t)?"#5470c6":t)?"#3ba272":t},DefaultChartColor:"#9DD3E8",validateIP:function(n){if("string"!=typeof n)return!1;if(0==n.length)return!1;if(0<=n.indexOf(":")){let t=n.split(":");if(8',document.body.appendChild(t),t.play().then(function(){setTimeout(function(){document.body.removeChild(t)},2e3)}).catch(function(t){console.log(t.message)})}},String.prototype.quoteIP=function(){let t=this.toString();return 0==t.length?"":t.indexOf(":")<0||"["==t.substring(0,1)?t:"["+t+"]"}; +window.teaweb={set:function(t,e){localStorage.setItem(t,JSON.stringify(e))},get:function(t){t=localStorage.getItem(t);return null==t||0==t.length?null:JSON.parse(t)},getString:function(t){t=this.get(t);return"string"==typeof t?t:""},getBool:function(t){return Boolean(this.get(t))},remove:function(t){localStorage.removeItem(t)},match:function(t,e){if(null==t)return!1;if(null==e)return!0;if(t=t.trim(),0==(e=e.trim()).length)return!0;if(0==t.length)return!1;for(var n=e.split(/\s+/),o=0;o=Math.pow(1024,6)?(o="E",n=Math.pow(1024,6)):t>=Math.pow(1024,5)?(o="P",n=Math.pow(1024,5)):t>=Math.pow(1024,4)?(o="T",n=Math.pow(1024,4)):t>=Math.pow(1024,3)?(o="G",n=Math.pow(1024,3)):t>=Math.pow(1024,2)?(o="M",n=Math.pow(1024,2)):t>=Math.pow(1024,1)&&(o="K",n=Math.pow(1024,1)),{unit:o,divider:n}},bitsAxis:function(t,e){t=this.bytesAxis(t,e);let n=t.unit;return"B"==n?n="bps":n+="bps",{unit:n,divider:t.divider}},countAxis:function(t,e){t=Math.max.apply(this,t.map(e));let n=1,o="";return 1e9<=t?(o="B",n=1e9):1e6<=t?(o="M",n=1e6):1e3<=t&&(o="K",n=1e3),{unit:o,divider:n,max:t}},splitFormat:function(t){t=t.match(/^([0-9.]+)([a-zA-Z]+)$/);return[parseFloat(t[1]),t[2]]},popup:function(t,e){null!=t&&0',width:n,padding:"0.5em",showConfirmButton:!1,showCloseButton:!0,focusConfirm:!1,onClose:function(t){"function"==typeof e.onClose&&e.onClose.apply(Tea.Vue,arguments)}})},popupSuccess:function(t,e,n){let o={};null!=e&&(o.width=e),null!=n&&(o.height=n),o.callback=function(){teaweb.success("保存成功",function(){teaweb.reload()})},this.popup(t,o)},popupFinish:function(){null!=window.POPUP_CALLBACK&&window.POPUP_CALLBACK.apply(window,arguments)},popupTip:function(t){Swal.fire({html:'
'+t+"
",width:"34em",padding:"4em",showConfirmButton:!1,showCloseButton:!0,focusConfirm:!1})},isPopup:function(){var t=window.location.hash;return null!=t&&t.startsWith("#popup")},closePopup:function(){this.isPopup()&&window.parent.Swal.close()},Swal:function(){return(this.isPopup()?window.parent:window).Swal},hasPopup:function(){return 0{b} : {c}"+u},series:[{name:r,max:l,type:"gauge",radius:"100%",detail:{formatter:"{value}",show:!1,valueAnimation:!0},data:[{value:a,name:r}],pointer:{show:!1},splitLine:{show:!1},axisTick:{show:!1},axisLine:{show:!0,lineStyle:{width:4}},progress:{show:!0,width:4,itemStyle:{color:i}},splitNumber:{show:!1},title:{show:!1},startAngle:270,endAngle:-90}]};null!=s&&e.series.push({name:n,max:l,type:"gauge",radius:"100%",detail:{formatter:"{value}",show:!1,valueAnimation:!0},data:[{value:s,name:n}],pointer:{show:!1},splitLine:{show:!1},axisTick:{show:!1},axisLine:{show:!0,lineStyle:{width:4}},progress:{show:!0,width:4,itemStyle:{color:c,opacity:.3}},splitNumber:{show:!1},title:{show:!1},startAngle:270,endAngle:-90}),t.setOption(e)}},xRotation:function(t,e){t=t.getWidth();let n=0;return e.forEach(function(t){n+=10*t.length}),n<=t?null:[40,-20]},chartMap:{},initChart:function(t,e){"boolean"!=typeof e&&(e=!0);var n=t.getAttribute("id");if(null!=n&&0/g,">")).replace(/"/g,""")},chartColor:function(t){return t="green"==(t="blue"==(t="yellow"==(t="red"==(t=null!=t&&0!=t.length?t:"#5470c6")?"#ee6666":t)?"#fac858":t)?"#5470c6":t)?"#3ba272":t},DefaultChartColor:"#9DD3E8",validateIP:function(n){if("string"!=typeof n)return!1;if(0==n.length)return!1;if(0<=n.indexOf(":")){let t=n.split(":");if(8',document.body.appendChild(t),t.play().then(function(){setTimeout(function(){document.body.removeChild(t)},2e3)}).catch(function(t){console.log(t.message)})},convertSizeCapacityToBytes:function(t){if(null==t)return 0;switch(t.unit){case"byte":return t.count;case"kb":return 1024*t.count;case"mb":return t.count*Math.pow(1024,2);case"gb":return t.count*Math.pow(1024,3);case"tb":return t.count*Math.pow(1024,4);case"pb":return t.count*Math.pow(1024,5);case"eb":return t.count*Math.pow(1024,6)}return 0},compareSizeCapacity:function(t,e){t=this.convertSizeCapacityToBytes(t),e=this.convertSizeCapacityToBytes(e);return t==e?0:e