文件清理

This commit is contained in:
robin
2026-02-14 17:28:12 +08:00
parent 4259026c6e
commit eafac7a204
3 changed files with 130 additions and 82 deletions

View File

@@ -78,6 +78,14 @@ func (this *CreateAction) RunGet(params struct{}) {
this.Data["ossTypes"] = ossconfigs.FindAllOSSTypes() this.Data["ossTypes"] = ossconfigs.FindAllOSSTypes()
this.Data["ossBucketParams"] = ossconfigs.FindAllOSSBucketParamDefinitions() this.Data["ossBucketParams"] = ossconfigs.FindAllOSSBucketParamDefinitions()
// 默认开启的选择
this.Data["accessLogIsOn"] = true
this.Data["websocketIsOn"] = true
this.Data["cacheIsOn"] = true
this.Data["wafIsOn"] = true
this.Data["remoteAddrIsOn"] = true
this.Data["statIsOn"] = true
this.Show() this.Show()
} }
@@ -93,6 +101,13 @@ func (this *CreateAction) RunPost(params struct {
GroupIds []int64 GroupIds []int64
UserPlanId int64 UserPlanId int64
AccessLogIsOn bool
WebsocketIsOn bool
CacheIsOn bool
WafIsOn bool
RemoteAddrIsOn bool
StatIsOn bool
Must *actions.Must Must *actions.Must
CSRF *actionutils.CSRF CSRF *actionutils.CSRF
}) { }) {
@@ -556,9 +571,10 @@ func (this *CreateAction) RunPost(params struct {
// ========== 默认开启的功能 ========== // ========== 默认开启的功能 ==========
// 1. 访问日志 // 1. 访问日志
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebAccessLog(this.UserContext(), &pb.UpdateHTTPWebAccessLogRequest{ if params.AccessLogIsOn {
HttpWebId: webId, _, err = this.RPC().HTTPWebRPC().UpdateHTTPWebAccessLog(this.UserContext(), &pb.UpdateHTTPWebAccessLogRequest{
AccessLogJSON: []byte(`{ HttpWebId: webId,
AccessLogJSON: []byte(`{
"isPrior": false, "isPrior": false,
"isOn": true, "isOn": true,
"fields": [1, 2, 6, 7], "fields": [1, 2, 6, 7],
@@ -571,90 +587,99 @@ func (this *CreateAction) RunPost(params struct {
"storagePolicies": [], "storagePolicies": [],
"firewallOnly": false "firewallOnly": false
}`), }`),
}) })
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)
return return
}
} }
// 2. WebSocket // 2. WebSocket
createWebSocketResp, err := this.RPC().HTTPWebsocketRPC().CreateHTTPWebsocket(this.UserContext(), &pb.CreateHTTPWebsocketRequest{ if params.WebsocketIsOn {
HandshakeTimeoutJSON: []byte(`{"count": 30, "unit": "second"}`), createWebSocketResp, err := this.RPC().HTTPWebsocketRPC().CreateHTTPWebsocket(this.UserContext(), &pb.CreateHTTPWebsocketRequest{
AllowAllOrigins: true, HandshakeTimeoutJSON: []byte(`{"count": 30, "unit": "second"}`),
AllowedOrigins: nil, AllowAllOrigins: true,
RequestSameOrigin: true, AllowedOrigins: nil,
RequestOrigin: "", RequestSameOrigin: true,
}) RequestOrigin: "",
if err != nil { })
this.ErrorPage(err) if err != nil {
return this.ErrorPage(err)
} return
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebWebsocket(this.UserContext(), &pb.UpdateHTTPWebWebsocketRequest{ }
HttpWebId: webId, _, err = this.RPC().HTTPWebRPC().UpdateHTTPWebWebsocket(this.UserContext(), &pb.UpdateHTTPWebWebsocketRequest{
WebsocketJSON: []byte(`{"isPrior": false, "isOn": true, "websocketId": ` + types.String(createWebSocketResp.WebsocketId) + `}`), HttpWebId: webId,
}) WebsocketJSON: []byte(`{"isPrior": false, "isOn": true, "websocketId": ` + types.String(createWebSocketResp.WebsocketId) + `}`),
if err != nil { })
this.ErrorPage(err) if err != nil {
return this.ErrorPage(err)
return
}
} }
// 3. WAF 防火墙 // 3. WAF 防火墙
var firewallRef = &firewallconfigs.HTTPFirewallRef{ if params.WafIsOn {
IsPrior: false, var firewallRef = &firewallconfigs.HTTPFirewallRef{
IsOn: true, IsPrior: false,
FirewallPolicyId: 0, IsOn: true,
} FirewallPolicyId: 0,
firewallRefJSON, err := json.Marshal(firewallRef) }
if err != nil { firewallRefJSON, err := json.Marshal(firewallRef)
this.ErrorPage(err) if err != nil {
return this.ErrorPage(err)
} return
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebFirewall(this.UserContext(), &pb.UpdateHTTPWebFirewallRequest{ }
HttpWebId: webId, _, err = this.RPC().HTTPWebRPC().UpdateHTTPWebFirewall(this.UserContext(), &pb.UpdateHTTPWebFirewallRequest{
FirewallJSON: firewallRefJSON, HttpWebId: webId,
}) FirewallJSON: firewallRefJSON,
if err != nil { })
this.ErrorPage(err) if err != nil {
return this.ErrorPage(err)
return
}
} }
// 4. 从上级代理中读取IP // 4. 从上级代理中读取IP
var remoteAddrConfig = &serverconfigs.HTTPRemoteAddrConfig{ if params.RemoteAddrIsOn {
IsOn: true, var remoteAddrConfig = &serverconfigs.HTTPRemoteAddrConfig{
Value: "${remoteAddr}", IsOn: true,
Type: serverconfigs.HTTPRemoteAddrTypeProxy, Value: "${remoteAddr}",
} Type: serverconfigs.HTTPRemoteAddrTypeProxy,
remoteAddrConfigJSON, err := json.Marshal(remoteAddrConfig) }
if err != nil { remoteAddrConfigJSON, err := json.Marshal(remoteAddrConfig)
this.ErrorPage(err) if err != nil {
return this.ErrorPage(err)
} return
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebRemoteAddr(this.UserContext(), &pb.UpdateHTTPWebRemoteAddrRequest{ }
HttpWebId: webId, _, err = this.RPC().HTTPWebRPC().UpdateHTTPWebRemoteAddr(this.UserContext(), &pb.UpdateHTTPWebRemoteAddrRequest{
RemoteAddrJSON: remoteAddrConfigJSON, HttpWebId: webId,
}) RemoteAddrJSON: remoteAddrConfigJSON,
if err != nil { })
this.ErrorPage(err) if err != nil {
return this.ErrorPage(err)
return
}
} }
// 5. 统计 // 5. 统计
var statConfig = &serverconfigs.HTTPStatRef{ if params.StatIsOn {
IsPrior: false, var statConfig = &serverconfigs.HTTPStatRef{
IsOn: true, IsPrior: false,
} IsOn: true,
statJSON, err := json.Marshal(statConfig) }
if err != nil { statJSON, err := json.Marshal(statConfig)
this.ErrorPage(err) if err != nil {
return this.ErrorPage(err)
} return
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebStat(this.UserContext(), &pb.UpdateHTTPWebStatRequest{ }
HttpWebId: webId, _, err = this.RPC().HTTPWebRPC().UpdateHTTPWebStat(this.UserContext(), &pb.UpdateHTTPWebStatRequest{
StatJSON: statJSON, HttpWebId: webId,
}) StatJSON: statJSON,
if err != nil { })
this.ErrorPage(err) if err != nil {
return this.ErrorPage(err)
return
}
} }
// 绑定套餐 // 绑定套餐

View File

@@ -5,7 +5,8 @@
需要管理员在后台设置当前用户所属集群后才能继续操作。 需要管理员在后台设置当前用户所属集群后才能继续操作。
</p> </p>
<form class="ui form" method="post" data-tea-action="$" data-tea-success="success" data-tea-fail="fail" v-show="clusterId > 0"> <form class="ui form" method="post" data-tea-action="$" data-tea-success="success" data-tea-fail="fail"
v-show="clusterId > 0">
<csrf-token></csrf-token> <csrf-token></csrf-token>
<table class="ui table definition selectable"> <table class="ui table definition selectable">
@@ -41,12 +42,13 @@
<radio name="requestHostType" :v-value="1" v-model="requestHostType">跟随源站</radio> &nbsp; <radio name="requestHostType" :v-value="1" v-model="requestHostType">跟随源站</radio> &nbsp;
<radio name="requestHostType" :v-value="2" v-model="requestHostType">自定义</radio> <radio name="requestHostType" :v-value="2" v-model="requestHostType">自定义</radio>
<div v-show="requestHostType == 2" style="margin-top: 0.8em"> <div v-show="requestHostType == 2" style="margin-top: 0.8em">
<input type="text" name="requestHost" placeholder="比如example.com" v-model="requestHost"/> <input type="text" name="requestHost" placeholder="比如example.com" v-model="requestHost" />
</div> </div>
<p class="comment">请求源站时的Host用于设置访问源站的站点域名 <p class="comment">请求源站时的Host用于设置访问源站的站点域名
<span v-if="requestHostType == 0">"跟随CDN服务"是指访问源站的站点域名和当前CDN服务保持一致</span> <span v-if="requestHostType == 0">"跟随CDN服务"是指访问源站的站点域名和当前CDN服务保持一致</span>
<span v-if="requestHostType == 1">"跟随源站"是指访问源站的站点域名仍然是填写的源站地址中的信息不随CDN服务域名改变而改变</span> <span v-if="requestHostType == 1">"跟随源站"是指访问源站的站点域名仍然是填写的源站地址中的信息不随CDN服务域名改变而改变</span>
<span v-if="requestHostType == 2">自定义Host内容中支持请求变量</span></p> <span v-if="requestHostType == 2">自定义Host内容中支持请求变量</span>
</p>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -55,17 +57,31 @@
<cache-cond-box></cache-cond-box> <cache-cond-box></cache-cond-box>
</td> </td>
</tr> </tr>
<tr>
<td>功能开关</td>
<td>
<checkbox name="accessLogIsOn" v-model="accessLogIsOn">访问日志</checkbox> &nbsp; &nbsp;
<checkbox name="websocketIsOn" v-model="websocketIsOn">Websocket</checkbox> &nbsp; &nbsp;
<checkbox name="cacheIsOn" v-model="cacheIsOn">缓存</checkbox> &nbsp; &nbsp;
<checkbox name="wafIsOn" v-model="wafIsOn">WAF</checkbox> &nbsp; &nbsp;
<checkbox name="remoteAddrIsOn" v-model="remoteAddrIsOn">从上级代理中读取IP</checkbox> &nbsp; &nbsp;
<checkbox name="statIsOn" v-model="statIsOn">统计</checkbox>
<p class="comment">这些功能建议保持开启状态,以获得更好的加速和安全防护效果。</p>
</td>
</tr>
<tr v-show="requirePlan || userPlans.length > 0"> <tr v-show="requirePlan || userPlans.length > 0">
<td>绑定套餐 <span v-if="requirePlan">*</span></td> <td>绑定套餐 <span v-if="requirePlan">*</span></td>
<td> <td>
<input type="hidden" name="isChanged" value="1"/> <input type="hidden" name="isChanged" value="1" />
<span v-if="userPlans.length == 0 && !requirePlan" class="disabled">当前还没有可以使用的套餐。</span> <span v-if="userPlans.length == 0 && !requirePlan" class="disabled">当前还没有可以使用的套餐。</span>
<span v-if="userPlans.length == 0 && requirePlan" class="red"><a href="/plans"><span class="red">当前还没有可以使用的套餐,请先购买套餐</span></a></span> <span v-if="userPlans.length == 0 && requirePlan" class="red"><a href="/plans"><span
class="red">当前还没有可以使用的套餐,请先购买套餐</span></a></span>
<div v-else> <div v-else>
<select class="ui dropdown auto-width" name="userPlanId"> <select class="ui dropdown auto-width" name="userPlanId">
<option value="0" v-if="!requirePlan">[不使用套餐]</option> <option value="0" v-if="!requirePlan">[不使用套餐]</option>
<option value="0" v-if="requirePlan">[选择套餐]</option> <option value="0" v-if="requirePlan">[选择套餐]</option>
<option v-for="userPlan in userPlans" :value="userPlan.id">{{userPlan.name}}{{userPlan.dayTo}}</option> <option v-for="userPlan in userPlans" :value="userPlan.id">{{userPlan.name}}{{userPlan.dayTo}}
</option>
</select> </select>
</div> </div>
</td> </td>
@@ -79,4 +95,4 @@
</table> </table>
<submit-btn></submit-btn> <submit-btn></submit-btn>
</form> </form>

View File

@@ -3,6 +3,13 @@ Tea.context(function () {
this.requestHostType = 0 this.requestHostType = 0
this.requestHost = "" this.requestHost = ""
this.accessLogIsOn = true
this.websocketIsOn = true
this.cacheIsOn = true
this.wafIsOn = true
this.remoteAddrIsOn = true
this.statIsOn = true
this.success = function (resp) { this.success = function (resp) {
if (resp.data.hasOSS) { if (resp.data.hasOSS) {
NotifySuccess("保存成功", "/servers/server/settings/reverseProxy?serverId=" + resp.data.serverId)() NotifySuccess("保存成功", "/servers/server/settings/reverseProxy?serverId=" + resp.data.serverId)()