文件清理

This commit is contained in:
robin
2026-02-14 17:12:38 +08:00
parent f38505e210
commit 4259026c6e
22 changed files with 152 additions and 63 deletions

View File

@@ -5,6 +5,7 @@ import (
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ossconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
@@ -14,6 +15,7 @@ import (
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/lists"
"github.com/iwind/TeaGo/maps"
"github.com/iwind/TeaGo/types"
"net"
"strings"
)
@@ -145,9 +147,9 @@ func (this *CreateAction) RunPost(params struct {
return
}
// 协议
// 协议:未选择时默认 HTTP
if len(params.Protocols) == 0 {
this.Fail("请选择至少一个域名协议")
params.Protocols = []string{"http"}
}
httpConfig := &serverconfigs.HTTPProtocolConfig{}
@@ -551,25 +553,108 @@ func (this *CreateAction) RunPost(params struct {
return
}
// 统计
if userServerConfig != nil && userServerConfig.EnableStat {
var statConfig = &serverconfigs.HTTPStatRef{
IsPrior: false,
IsOn: true,
}
statJSON, err := json.Marshal(statConfig)
if err != nil {
this.ErrorPage(err)
return
}
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebStat(this.UserContext(), &pb.UpdateHTTPWebStatRequest{
HttpWebId: webId,
StatJSON: statJSON,
})
if err != nil {
this.ErrorPage(err)
return
}
// ========== 默认开启的功能 ==========
// 1. 访问日志
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebAccessLog(this.UserContext(), &pb.UpdateHTTPWebAccessLogRequest{
HttpWebId: webId,
AccessLogJSON: []byte(`{
"isPrior": false,
"isOn": true,
"fields": [1, 2, 6, 7],
"status1": true,
"status2": true,
"status3": true,
"status4": true,
"status5": true,
"storageOnly": false,
"storagePolicies": [],
"firewallOnly": false
}`),
})
if err != nil {
this.ErrorPage(err)
return
}
// 2. WebSocket
createWebSocketResp, err := this.RPC().HTTPWebsocketRPC().CreateHTTPWebsocket(this.UserContext(), &pb.CreateHTTPWebsocketRequest{
HandshakeTimeoutJSON: []byte(`{"count": 30, "unit": "second"}`),
AllowAllOrigins: true,
AllowedOrigins: nil,
RequestSameOrigin: true,
RequestOrigin: "",
})
if err != nil {
this.ErrorPage(err)
return
}
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebWebsocket(this.UserContext(), &pb.UpdateHTTPWebWebsocketRequest{
HttpWebId: webId,
WebsocketJSON: []byte(`{"isPrior": false, "isOn": true, "websocketId": ` + types.String(createWebSocketResp.WebsocketId) + `}`),
})
if err != nil {
this.ErrorPage(err)
return
}
// 3. WAF 防火墙
var firewallRef = &firewallconfigs.HTTPFirewallRef{
IsPrior: false,
IsOn: true,
FirewallPolicyId: 0,
}
firewallRefJSON, err := json.Marshal(firewallRef)
if err != nil {
this.ErrorPage(err)
return
}
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebFirewall(this.UserContext(), &pb.UpdateHTTPWebFirewallRequest{
HttpWebId: webId,
FirewallJSON: firewallRefJSON,
})
if err != nil {
this.ErrorPage(err)
return
}
// 4. 从上级代理中读取IP
var remoteAddrConfig = &serverconfigs.HTTPRemoteAddrConfig{
IsOn: true,
Value: "${remoteAddr}",
Type: serverconfigs.HTTPRemoteAddrTypeProxy,
}
remoteAddrConfigJSON, err := json.Marshal(remoteAddrConfig)
if err != nil {
this.ErrorPage(err)
return
}
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebRemoteAddr(this.UserContext(), &pb.UpdateHTTPWebRemoteAddrRequest{
HttpWebId: webId,
RemoteAddrJSON: remoteAddrConfigJSON,
})
if err != nil {
this.ErrorPage(err)
return
}
// 5. 统计
var statConfig = &serverconfigs.HTTPStatRef{
IsPrior: false,
IsOn: true,
}
statJSON, err := json.Marshal(statConfig)
if err != nil {
this.ErrorPage(err)
return
}
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebStat(this.UserContext(), &pb.UpdateHTTPWebStatRequest{
HttpWebId: webId,
StatJSON: statJSON,
})
if err != nil {
this.ErrorPage(err)
return
}
// 绑定套餐

View File

@@ -325,7 +325,7 @@ func (this *userMustAuth) modules(userId int64, isVerified bool, isIdentified bo
"code": "dns",
"name": "域名解析",
"icon": "globe",
"isOn": true,
"isOn": false,
//"subItems": []maps.Map{
// {
// "name": "域名管理",

View File

@@ -11247,7 +11247,7 @@ Vue.component("http-hls-config-box", {
<table class="ui table definition selectable" v-show="isOn()">
<tbody>
<tr>
<td class="title">启用HLS加密</td>
<td class="title">启用HLS加密配置</td>
<td>
<checkbox v-model="encryptingConfig.isOn"></checkbox>
<p class="comment">启用后,系统会自动在<code-label>.m3u8</code-label>文件中加入<code-label>#EXT-X-KEY:METHOD=AES-128...</code-label>,并将其中的<code-label>.ts</code-label>文件内容进行加密。</p>
@@ -11280,6 +11280,7 @@ Vue.component("http-hls-config-box", {
</div>`
})
Vue.component("http-host-redirect-box", {
props: ["v-redirects"],
mounted: function () {

View File

@@ -11247,7 +11247,7 @@ Vue.component("http-hls-config-box", {
<table class="ui table definition selectable" v-show="isOn()">
<tbody>
<tr>
<td class="title">启用HLS加密</td>
<td class="title">启用HLS加密配置</td>
<td>
<checkbox v-model="encryptingConfig.isOn"></checkbox>
<p class="comment">启用后,系统会自动在<code-label>.m3u8</code-label>文件中加入<code-label>#EXT-X-KEY:METHOD=AES-128...</code-label>,并将其中的<code-label>.ts</code-label>文件内容进行加密。</p>
@@ -11280,6 +11280,7 @@ Vue.component("http-hls-config-box", {
</div>`
})
Vue.component("http-host-redirect-box", {
props: ["v-redirects"],
mounted: function () {

View File

@@ -43,7 +43,7 @@ Vue.component("http-hls-config-box", {
<table class="ui table definition selectable" v-show="isOn()">
<tbody>
<tr>
<td class="title">启用HLS加密</td>
<td class="title">启用HLS加密配置</td>
<td>
<checkbox v-model="encryptingConfig.isOn"></checkbox>
<p class="comment">启用后,系统会自动在<code-label>.m3u8</code-label>文件中加入<code-label>#EXT-X-KEY:METHOD=AES-128...</code-label>,并将其中的<code-label>.ts</code-label>文件内容进行加密。</p>
@@ -74,4 +74,4 @@ Vue.component("http-hls-config-box", {
</table>
<div class="margin"></div>
</div>`
})
})

View File

@@ -1,3 +1,3 @@
<first-menu>
<menu-item code="hls" :href="'.hls?serverId=' + server.id">HLS</menu-item>
</first-menu>
<menu-item code="hls" :href="'.hls?serverId=' + server.id">启用HLS加密配</menu-item>
</first-menu>

View File

@@ -3,14 +3,12 @@
{$template "/left_menu_with_menu"}
<div class="right-box with-menu">
{$template "menu"}
<form class="ui form" data-tea-success="success" data-tea-action="$">
<csrf-token></csrf-token>
<input type="hidden" name="webId" :value="webId"/>
<h4>HLS加密设置</h4>
<http-hls-config-box v-model="hlsConfig"></http-hls-config-box>
<submit-btn></submit-btn>
</form>
</div>
</div>