mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-04 05:00:25 +08:00
阶段性提交
This commit is contained in:
@@ -28,6 +28,7 @@ type RPCClient struct {
|
||||
originNodeClients []pb.OriginServerServiceClient
|
||||
httpWebClients []pb.HTTPWebServiceClient
|
||||
reverseProxyClients []pb.ReverseProxyServiceClient
|
||||
httpGzipClients []pb.HTTPGzipServiceClient
|
||||
}
|
||||
|
||||
func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
|
||||
@@ -45,6 +46,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
|
||||
originNodeClients := []pb.OriginServerServiceClient{}
|
||||
httpWebClients := []pb.HTTPWebServiceClient{}
|
||||
reverseProxyClients := []pb.ReverseProxyServiceClient{}
|
||||
httpGzipClients := []pb.HTTPGzipServiceClient{}
|
||||
|
||||
conns := []*grpc.ClientConn{}
|
||||
for _, endpoint := range apiConfig.RPC.Endpoints {
|
||||
@@ -70,6 +72,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
|
||||
originNodeClients = append(originNodeClients, pb.NewOriginServerServiceClient(conn))
|
||||
httpWebClients = append(httpWebClients, pb.NewHTTPWebServiceClient(conn))
|
||||
reverseProxyClients = append(reverseProxyClients, pb.NewReverseProxyServiceClient(conn))
|
||||
httpGzipClients = append(httpGzipClients, pb.NewHTTPGzipServiceClient(conn))
|
||||
}
|
||||
|
||||
return &RPCClient{
|
||||
@@ -84,6 +87,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
|
||||
originNodeClients: originNodeClients,
|
||||
httpWebClients: httpWebClients,
|
||||
reverseProxyClients: reverseProxyClients,
|
||||
httpGzipClients: httpGzipClients,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -157,6 +161,13 @@ func (this *RPCClient) ReverseProxyRPC() pb.ReverseProxyServiceClient {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *RPCClient) HTTPGzipRPC() pb.HTTPGzipServiceClient {
|
||||
if len(this.httpGzipClients) > 0 {
|
||||
return this.httpGzipClients[rands.Int(0, len(this.httpGzipClients)-1)]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *RPCClient) Context(adminId int64) context.Context {
|
||||
ctx := context.Background()
|
||||
m := maps.Map{
|
||||
|
||||
@@ -19,8 +19,19 @@ func (this *AddPortPopupAction) Init() {
|
||||
|
||||
func (this *AddPortPopupAction) RunGet(params struct {
|
||||
ServerType string
|
||||
Protocol string
|
||||
}) {
|
||||
this.Data["protocols"] = serverconfigs.AllServerProtocolsForType(params.ServerType)
|
||||
protocols := serverconfigs.AllServerProtocolsForType(params.ServerType)
|
||||
if len(params.Protocol) > 0 {
|
||||
result := []maps.Map{}
|
||||
for _, p := range protocols {
|
||||
if p.GetString("code") == params.Protocol {
|
||||
result = append(result, p)
|
||||
}
|
||||
}
|
||||
protocols = result
|
||||
}
|
||||
this.Data["protocols"] = protocols
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
package gzip
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
@@ -16,7 +22,119 @@ func (this *IndexAction) Init() {
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
ServerId int64
|
||||
}) {
|
||||
// TODO
|
||||
server, _, isOk := serverutils.FindServer(&this.ParentAction, params.ServerId)
|
||||
if !isOk {
|
||||
return
|
||||
}
|
||||
|
||||
webId := server.WebId
|
||||
if webId <= 0 {
|
||||
resp, err := this.RPC().ServerRPC().InitServerWeb(this.AdminContext(), &pb.InitServerWebRequest{ServerId: params.ServerId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
webId = resp.WebId
|
||||
}
|
||||
|
||||
webResp, err := this.RPC().HTTPWebRPC().FindEnabledHTTPWeb(this.AdminContext(), &pb.FindEnabledHTTPWebRequest{WebId: webId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
web := webResp.Web
|
||||
if web == nil {
|
||||
this.ErrorPage(errors.New("web should not be nil"))
|
||||
return
|
||||
}
|
||||
this.Data["webId"] = web.Id
|
||||
|
||||
gzipId := web.GzipId
|
||||
gzipConfig := &serverconfigs.HTTPGzipConfig{
|
||||
Id: 0,
|
||||
IsOn: true,
|
||||
}
|
||||
if gzipId > 0 {
|
||||
resp, err := this.RPC().HTTPGzipRPC().FindEnabledHTTPGzipConfig(this.AdminContext(), &pb.FindEnabledGzipConfigRequest{GzipId: gzipId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal(resp.Config, gzipConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
this.Data["gzipConfig"] = gzipConfig
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunPost(params struct {
|
||||
WebId int64
|
||||
GzipId int64
|
||||
Level int
|
||||
MinLength string
|
||||
MaxLength string
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
if params.Level < 0 || params.Level > 9 {
|
||||
this.Fail("请选择正确的压缩级别")
|
||||
}
|
||||
|
||||
minLength := &pb.SizeCapacity{Count: -1}
|
||||
if len(params.MinLength) > 0 {
|
||||
err := json.Unmarshal([]byte(params.MinLength), minLength)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
maxLength := &pb.SizeCapacity{Count: -1}
|
||||
if len(params.MaxLength) > 0 {
|
||||
err := json.Unmarshal([]byte(params.MaxLength), maxLength)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if params.GzipId > 0 {
|
||||
_, err := this.RPC().HTTPGzipRPC().UpdateHTTPGzip(this.AdminContext(), &pb.UpdateHTTPGzipRequest{
|
||||
GzipId: params.GzipId,
|
||||
Level: int32(params.Level),
|
||||
MinLength: minLength,
|
||||
MaxLength: maxLength,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
resp, err := this.RPC().HTTPGzipRPC().CreateHTTPGzip(this.AdminContext(), &pb.CreateHTTPGzipRequest{
|
||||
Level: 0,
|
||||
MinLength: nil,
|
||||
MaxLength: nil,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
gzipId := resp.GzipId
|
||||
|
||||
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebGzip(this.AdminContext(), &pb.UpdateHTTPWebGzipRequest{
|
||||
WebId: params.WebId,
|
||||
GzipId: gzipId,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
}
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ func init() {
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(serverutils.NewServerHelper()).
|
||||
Prefix("/servers/server/settings/gzip").
|
||||
Get("", new(IndexAction)).
|
||||
GetPost("", new(IndexAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
@@ -16,7 +22,72 @@ func (this *IndexAction) Init() {
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
ServerId int64
|
||||
}) {
|
||||
// TODO
|
||||
server, _, isOk := serverutils.FindServer(&this.ParentAction, params.ServerId)
|
||||
if !isOk {
|
||||
return
|
||||
}
|
||||
httpConfig := &serverconfigs.HTTPProtocolConfig{}
|
||||
if len(server.HttpJSON) > 0 {
|
||||
err := json.Unmarshal(server.HttpJSON, httpConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
httpConfig.IsOn = true
|
||||
}
|
||||
|
||||
this.Data["serverType"] = server.Type
|
||||
this.Data["httpConfig"] = maps.Map{
|
||||
"isOn": httpConfig.IsOn,
|
||||
"addresses": httpConfig.Listen,
|
||||
}
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunPost(params struct {
|
||||
ServerId int64
|
||||
Addresses string
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
addresses := []*serverconfigs.NetworkAddressConfig{}
|
||||
err := json.Unmarshal([]byte(params.Addresses), &addresses)
|
||||
if err != nil {
|
||||
this.Fail("端口地址解析失败:" + err.Error())
|
||||
}
|
||||
|
||||
server, _, isOk := serverutils.FindServer(&this.ParentAction, params.ServerId)
|
||||
if !isOk {
|
||||
return
|
||||
}
|
||||
httpConfig := &serverconfigs.HTTPProtocolConfig{}
|
||||
if len(server.HttpJSON) > 0 {
|
||||
err = json.Unmarshal(server.HttpJSON, httpConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
httpConfig.IsOn = true
|
||||
}
|
||||
|
||||
httpConfig.Listen = addresses
|
||||
configData, err := json.Marshal(httpConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = this.RPC().ServerRPC().UpdateServerHTTP(this.AdminContext(), &pb.UpdateServerHTTPRequest{
|
||||
ServerId: params.ServerId,
|
||||
Config: configData,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ func init() {
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(serverutils.NewServerHelper()).
|
||||
Prefix("/servers/server/settings/http").
|
||||
Get("", new(IndexAction)).
|
||||
GetPost("", new(IndexAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
package https
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
@@ -16,5 +22,72 @@ func (this *IndexAction) Init() {
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
ServerId int64
|
||||
}) {
|
||||
server, _, isOk := serverutils.FindServer(&this.ParentAction, params.ServerId)
|
||||
if !isOk {
|
||||
return
|
||||
}
|
||||
httpsConfig := &serverconfigs.HTTPSProtocolConfig{}
|
||||
if len(server.HttpsJSON) > 0 {
|
||||
err := json.Unmarshal(server.HttpsJSON, httpsConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
httpsConfig.IsOn = true
|
||||
}
|
||||
|
||||
this.Data["serverType"] = server.Type
|
||||
this.Data["httpsConfig"] = maps.Map{
|
||||
"isOn": httpsConfig.IsOn,
|
||||
"addresses": httpsConfig.Listen,
|
||||
}
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunPost(params struct {
|
||||
ServerId int64
|
||||
Addresses string
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
addresses := []*serverconfigs.NetworkAddressConfig{}
|
||||
err := json.Unmarshal([]byte(params.Addresses), &addresses)
|
||||
if err != nil {
|
||||
this.Fail("端口地址解析失败:" + err.Error())
|
||||
}
|
||||
|
||||
server, _, isOk := serverutils.FindServer(&this.ParentAction, params.ServerId)
|
||||
if !isOk {
|
||||
return
|
||||
}
|
||||
httpsConfig := &serverconfigs.HTTPSProtocolConfig{}
|
||||
if len(server.HttpsJSON) > 0 {
|
||||
err = json.Unmarshal(server.HttpsJSON, httpsConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
httpsConfig.IsOn = true
|
||||
}
|
||||
|
||||
httpsConfig.Listen = addresses
|
||||
configData, err := json.Marshal(httpsConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = this.RPC().ServerRPC().UpdateServerHTTPS(this.AdminContext(), &pb.UpdateServerHTTPSRequest{
|
||||
ServerId: params.ServerId,
|
||||
Config: configData,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ func init() {
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(serverutils.NewServerHelper()).
|
||||
Prefix("/servers/server/settings/https").
|
||||
Get("", new(IndexAction)).
|
||||
GetPost("", new(IndexAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -29,12 +29,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
this.Data["serverType"] = server.Type
|
||||
this.Data["reverseProxyId"] = server.ReverseProxyId
|
||||
|
||||
if server.ReverseProxyId <= 0 {
|
||||
// TODO 应该在界面上提示用户开启
|
||||
this.ErrorPage(errors.New("reverse proxy should not be nil"))
|
||||
return
|
||||
}
|
||||
|
||||
isOn := false
|
||||
if server.ReverseProxyId > 0 {
|
||||
reverseProxyResp, err := this.RPC().ReverseProxyRPC().FindEnabledReverseProxy(this.AdminContext(), &pb.FindEnabledReverseProxyRequest{ReverseProxyId: server.ReverseProxyId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
@@ -46,6 +42,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
this.ErrorPage(errors.New("reverse proxy should not be nil"))
|
||||
return
|
||||
}
|
||||
isOn = true
|
||||
|
||||
primaryOrigins := []*serverconfigs.OriginServerConfig{}
|
||||
backupOrigins := []*serverconfigs.OriginServerConfig{}
|
||||
@@ -84,6 +81,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
}
|
||||
this.Data["primaryOrigins"] = primaryOriginMaps
|
||||
this.Data["backupOrigins"] = backupOriginMaps
|
||||
}
|
||||
this.Data["isOn"] = isOn
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ func init() {
|
||||
Get("", new(IndexAction)).
|
||||
GetPost("/scheduling", new(SchedulingAction)).
|
||||
GetPost("/updateSchedulingPopup", new(UpdateSchedulingPopupAction)).
|
||||
Post("/updateOn", new(UpdateOnAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package reverseProxy
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
)
|
||||
|
||||
type UpdateOnAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *UpdateOnAction) RunPost(params struct {
|
||||
ServerId int64
|
||||
ReverseProxyId int64
|
||||
IsOn bool
|
||||
}) {
|
||||
// 如果没有配置过,则配置
|
||||
if params.ReverseProxyId <= 0 {
|
||||
if !params.IsOn {
|
||||
this.Success()
|
||||
}
|
||||
|
||||
resp, err := this.RPC().ReverseProxyRPC().CreateReverseProxy(this.AdminContext(), &pb.CreateReverseProxyRequest{
|
||||
SchedulingJSON: nil,
|
||||
PrimaryOriginsJSON: nil,
|
||||
BackupOriginsJSON: nil,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
reverseProxyId := resp.ReverseProxyId
|
||||
_, err = this.RPC().ServerRPC().UpdateServerReverseProxy(this.AdminContext(), &pb.UpdateServerReverseProxyRequest{
|
||||
ServerId: params.ServerId,
|
||||
ReverseProxyId: reverseProxyId,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Success()
|
||||
}
|
||||
|
||||
// 如果已经配置过
|
||||
_, err := this.RPC().ReverseProxyRPC().UpdateReverseProxyIsOn(this.AdminContext(), &pb.UpdateReverseProxyIsOnRequest{
|
||||
ReverseProxyId: params.ReverseProxyId,
|
||||
IsOn: params.IsOn,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package serverNames
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
|
||||
// 域名管理
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.FirstMenu("index")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
ServerId int64
|
||||
}) {
|
||||
server, _, isOk := serverutils.FindServer(&this.ParentAction, params.ServerId)
|
||||
if !isOk {
|
||||
return
|
||||
}
|
||||
|
||||
serverNamesConfig := []*serverconfigs.ServerNameConfig{}
|
||||
if len(server.ServerNamesJON) > 0 {
|
||||
err := json.Unmarshal(server.ServerNamesJON, &serverNamesConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
this.Data["serverNames"] = serverNamesConfig
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunPost(params struct {
|
||||
ServerId int64
|
||||
ServerNames string
|
||||
Must *actions.Must
|
||||
}) {
|
||||
serverNames := []*serverconfigs.ServerNameConfig{}
|
||||
err := json.Unmarshal([]byte(params.ServerNames), &serverNames)
|
||||
if err != nil {
|
||||
this.Fail("域名解析失败:" + err.Error())
|
||||
}
|
||||
|
||||
_, err = this.RPC().ServerRPC().UpdateServerNames(this.AdminContext(), &pb.UpdateServerNamesRequest{
|
||||
ServerId: params.ServerId,
|
||||
Config: []byte(params.ServerNames),
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package serverNames
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||
server.
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(serverutils.NewServerHelper()).
|
||||
Data("mainTab", "setting").
|
||||
Data("secondMenuItem", "serverName").
|
||||
Prefix("/servers/server/settings/serverNames").
|
||||
GetPost("", new(IndexAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package tcp
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
@@ -23,21 +22,22 @@ func (this *IndexAction) Init() {
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
ServerId int64
|
||||
}) {
|
||||
server, config, isOk := serverutils.FindServer(&this.ParentAction, params.ServerId)
|
||||
server, _, isOk := serverutils.FindServer(&this.ParentAction, params.ServerId)
|
||||
if !isOk {
|
||||
return
|
||||
}
|
||||
if config.TCP == nil {
|
||||
this.ErrorPage(errors.New("there is no tcp setting"))
|
||||
return
|
||||
tcpConfig := &serverconfigs.TCPProtocolConfig{}
|
||||
if len(server.TcpJSON) > 0 {
|
||||
err := json.Unmarshal(server.TcpJSON, tcpConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
}
|
||||
|
||||
if config.TCP.Listen == nil {
|
||||
config.TCP.Listen = []*serverconfigs.NetworkAddressConfig{}
|
||||
} else {
|
||||
tcpConfig.IsOn = true
|
||||
}
|
||||
|
||||
this.Data["serverType"] = server.Type
|
||||
this.Data["addresses"] = config.TCP.Listen
|
||||
this.Data["tcpConfig"] = tcpConfig
|
||||
|
||||
this.Show()
|
||||
}
|
||||
@@ -49,8 +49,6 @@ func (this *IndexAction) RunPost(params struct {
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
serverId := params.ServerId
|
||||
|
||||
server, _, isOk := serverutils.FindServer(&this.ParentAction, params.ServerId)
|
||||
if !isOk {
|
||||
return
|
||||
@@ -62,189 +60,31 @@ func (this *IndexAction) RunPost(params struct {
|
||||
this.Fail("端口地址解析失败:" + err.Error())
|
||||
}
|
||||
|
||||
switch server.Type {
|
||||
case serverconfigs.ServerTypeHTTPProxy, serverconfigs.ServerTypeHTTPWeb:
|
||||
var httpConfig = &serverconfigs.HTTPProtocolConfig{}
|
||||
if len(server.HttpJSON) > 0 {
|
||||
err = json.Unmarshal(server.HttpJSON, httpConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
httpConfig.Listen = []*serverconfigs.NetworkAddressConfig{}
|
||||
} else {
|
||||
httpConfig.IsOn = true
|
||||
}
|
||||
|
||||
var httpsConfig = &serverconfigs.HTTPSProtocolConfig{}
|
||||
if len(server.HttpsJSON) > 0 {
|
||||
err = json.Unmarshal(server.HttpsJSON, httpsConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
httpsConfig.Listen = []*serverconfigs.NetworkAddressConfig{}
|
||||
} else {
|
||||
httpsConfig.IsOn = true
|
||||
}
|
||||
|
||||
for _, addr := range addresses {
|
||||
switch addr.Protocol.Primary() {
|
||||
case serverconfigs.ProtocolHTTP:
|
||||
httpConfig.AddListen(addr)
|
||||
case serverconfigs.ProtocolHTTPS:
|
||||
httpsConfig.AddListen(addr)
|
||||
}
|
||||
}
|
||||
|
||||
httpData, err := json.Marshal(httpConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
httpsData, err := json.Marshal(httpsConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
_, err = this.RPC().ServerRPC().UpdateServerHTTP(this.AdminContext(), &pb.UpdateServerHTTPRequest{
|
||||
ServerId: serverId,
|
||||
Config: httpData,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
_, err = this.RPC().ServerRPC().UpdateServerHTTPS(this.AdminContext(), &pb.UpdateServerHTTPSRequest{
|
||||
ServerId: serverId,
|
||||
Config: httpsData,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
case serverconfigs.ServerTypeTCPProxy:
|
||||
tcpProxy := &serverconfigs.TCPProtocolConfig{}
|
||||
tcpConfig := &serverconfigs.TCPProtocolConfig{}
|
||||
if len(server.TcpJSON) > 0 {
|
||||
err = json.Unmarshal(server.TcpJSON, tcpProxy)
|
||||
err := json.Unmarshal(server.TcpJSON, tcpConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
tcpProxy.Listen = []*serverconfigs.NetworkAddressConfig{}
|
||||
} else {
|
||||
tcpProxy.IsOn = true
|
||||
tcpConfig.IsOn = true
|
||||
}
|
||||
tcpConfig.Listen = addresses
|
||||
|
||||
tlsProxy := &serverconfigs.TLSProtocolConfig{}
|
||||
if len(server.TlsJSON) > 0 {
|
||||
err = json.Unmarshal(server.TlsJSON, tlsProxy)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
tlsProxy.Listen = []*serverconfigs.NetworkAddressConfig{}
|
||||
} else {
|
||||
tlsProxy.IsOn = true
|
||||
}
|
||||
|
||||
for _, addr := range addresses {
|
||||
switch addr.Protocol.Primary() {
|
||||
case serverconfigs.ProtocolTCP:
|
||||
tcpProxy.AddListen(addr)
|
||||
case serverconfigs.ProtocolTLS:
|
||||
tlsProxy.AddListen(addr)
|
||||
}
|
||||
}
|
||||
|
||||
tcpData, err := json.Marshal(tcpProxy)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
tlsData, err := json.Marshal(tlsProxy)
|
||||
configData, err := json.Marshal(tcpConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = this.RPC().ServerRPC().UpdateServerTCP(this.AdminContext(), &pb.UpdateServerTCPRequest{
|
||||
ServerId: serverId,
|
||||
Config: tcpData,
|
||||
ServerId: params.ServerId,
|
||||
Config: configData,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = this.RPC().ServerRPC().UpdateServerTLS(this.AdminContext(), &pb.UpdateServerTLSRequest{
|
||||
ServerId: serverId,
|
||||
Config: tlsData,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
case serverconfigs.ServerTypeUnixProxy:
|
||||
unixConfig := &serverconfigs.UnixProtocolConfig{}
|
||||
if len(server.UnixJSON) > 0 {
|
||||
err = json.Unmarshal(server.UnixJSON, unixConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
unixConfig.Listen = []*serverconfigs.NetworkAddressConfig{}
|
||||
}
|
||||
for _, addr := range addresses {
|
||||
switch addr.Protocol.Primary() {
|
||||
case serverconfigs.ProtocolUnix:
|
||||
unixConfig.AddListen(addr)
|
||||
}
|
||||
}
|
||||
unixData, err := json.Marshal(unixConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
_, err = this.RPC().ServerRPC().UpdateServerUnix(this.AdminContext(), &pb.UpdateServerUnixRequest{
|
||||
ServerId: serverId,
|
||||
Config: unixData,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
case serverconfigs.ServerTypeUDPProxy:
|
||||
udpConfig := &serverconfigs.UDPProtocolConfig{}
|
||||
if len(server.UdpJSON) > 0 {
|
||||
err = json.Unmarshal(server.UdpJSON, udpConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
udpConfig.Listen = []*serverconfigs.NetworkAddressConfig{}
|
||||
}
|
||||
for _, addr := range addresses {
|
||||
switch addr.Protocol.Primary() {
|
||||
case serverconfigs.ProtocolUDP:
|
||||
udpConfig.AddListen(addr)
|
||||
}
|
||||
}
|
||||
udpData, err := json.Marshal(udpConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
_, err = this.RPC().ServerRPC().UpdateServerUDP(this.AdminContext(), &pb.UpdateServerUDPRequest{
|
||||
ServerId: serverId,
|
||||
Config: udpData,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package tls
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
|
||||
// TLS设置
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("", "setting", "index")
|
||||
this.SecondMenu("tls")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
ServerId int64
|
||||
}) {
|
||||
server, _, isOk := serverutils.FindServer(&this.ParentAction, params.ServerId)
|
||||
if !isOk {
|
||||
return
|
||||
}
|
||||
tlsConfig := &serverconfigs.TLSProtocolConfig{}
|
||||
if len(server.TlsJSON) > 0 {
|
||||
err := json.Unmarshal(server.TlsJSON, tlsConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
}
|
||||
} else {
|
||||
tlsConfig.IsOn = true
|
||||
}
|
||||
|
||||
this.Data["serverType"] = server.Type
|
||||
this.Data["tlsConfig"] = tlsConfig
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunPost(params struct {
|
||||
ServerId int64
|
||||
ServerType string
|
||||
Addresses string
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
server, _, isOk := serverutils.FindServer(&this.ParentAction, params.ServerId)
|
||||
if !isOk {
|
||||
return
|
||||
}
|
||||
|
||||
addresses := []*serverconfigs.NetworkAddressConfig{}
|
||||
err := json.Unmarshal([]byte(params.Addresses), &addresses)
|
||||
if err != nil {
|
||||
this.Fail("端口地址解析失败:" + err.Error())
|
||||
}
|
||||
|
||||
tlsConfig := &serverconfigs.TLSProtocolConfig{}
|
||||
if len(server.TlsJSON) > 0 {
|
||||
err := json.Unmarshal(server.TlsJSON, tlsConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
}
|
||||
} else {
|
||||
tlsConfig.IsOn = true
|
||||
}
|
||||
tlsConfig.Listen = addresses
|
||||
|
||||
configData, err := json.Marshal(tlsConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = this.RPC().ServerRPC().UpdateServerTLS(this.AdminContext(), &pb.UpdateServerTLSRequest{
|
||||
ServerId: params.ServerId,
|
||||
Config: configData,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package tls
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||
server.
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(serverutils.NewServerHelper()).
|
||||
Prefix("/servers/server/settings/tls").
|
||||
GetPost("", new(IndexAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
@@ -2,6 +2,10 @@ package web
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
@@ -16,7 +20,70 @@ func (this *IndexAction) Init() {
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
ServerId int64
|
||||
}) {
|
||||
// TODO
|
||||
server, _, isOk := serverutils.FindServer(&this.ParentAction, params.ServerId)
|
||||
if !isOk {
|
||||
return
|
||||
}
|
||||
webId := server.WebId
|
||||
|
||||
webConfig := &serverconfigs.HTTPWebConfig{
|
||||
Id: webId,
|
||||
IsOn: true,
|
||||
}
|
||||
if webId > 0 {
|
||||
resp, err := this.RPC().HTTPWebRPC().FindEnabledHTTPWeb(this.AdminContext(), &pb.FindEnabledHTTPWebRequest{WebId: webId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if resp.Web != nil {
|
||||
web := resp.Web
|
||||
|
||||
webConfig.Id = webId
|
||||
webConfig.IsOn = web.IsOn
|
||||
webConfig.Root = web.Root
|
||||
}
|
||||
}
|
||||
|
||||
this.Data["webConfig"] = webConfig
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunPost(params struct {
|
||||
ServerId int64
|
||||
WebId int64
|
||||
Root string
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
if params.WebId <= 0 {
|
||||
resp, err := this.RPC().HTTPWebRPC().CreateHTTPWeb(this.AdminContext(), &pb.CreateHTTPWebRequest{
|
||||
Root: params.Root,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
webId := resp.WebId
|
||||
_, err = this.RPC().ServerRPC().UpdateServerWeb(this.AdminContext(), &pb.UpdateServerWebRequest{
|
||||
ServerId: params.ServerId,
|
||||
WebId: webId,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWeb(this.AdminContext(), &pb.UpdateHTTPWebRequest{
|
||||
WebId: params.WebId,
|
||||
Root: params.Root,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ func init() {
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(serverutils.NewServerHelper()).
|
||||
Prefix("/servers/server/settings/web").
|
||||
Get("", new(IndexAction)).
|
||||
GetPost("", new(IndexAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -141,6 +141,12 @@ func (this *ServerHelper) createSettingsMenu(secondMenuItem string, serverIdStri
|
||||
|
||||
// HTTP
|
||||
if serverConfig.IsHTTP() {
|
||||
menuItems = append(menuItems, maps.Map{
|
||||
"name": "域名",
|
||||
"url": "/servers/server/settings/serverNames?serverId=" + serverIdString,
|
||||
"isActive": secondMenuItem == "serverName",
|
||||
})
|
||||
|
||||
menuItems = append(menuItems, maps.Map{
|
||||
"name": "HTTP",
|
||||
"url": "/servers/server/settings/http?serverId=" + serverIdString,
|
||||
@@ -235,6 +241,11 @@ func (this *ServerHelper) createSettingsMenu(secondMenuItem string, serverIdStri
|
||||
"url": "/servers/server/settings/tcp?serverId=" + serverIdString,
|
||||
"isActive": secondMenuItem == "tcp",
|
||||
})
|
||||
menuItems = append(menuItems, maps.Map{
|
||||
"name": "TLS",
|
||||
"url": "/servers/server/settings/tls?serverId=" + serverIdString,
|
||||
"isActive": secondMenuItem == "tls",
|
||||
})
|
||||
menuItems = append(menuItems, maps.Map{
|
||||
"name": "反向代理",
|
||||
"url": "/servers/server/settings/reverseProxy?serverId=" + serverIdString,
|
||||
|
||||
@@ -38,8 +38,10 @@ import (
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/origins"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/pages"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/reverseProxy"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/serverNames"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/stat"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/tcp"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/tls"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/udp"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/unix"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/waf"
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
Vue.component("network-addresses-box", {
|
||||
props: ["vServerType", "vAddresses"],
|
||||
props: ["v-server-type", "v-addresses", "v-protocol"],
|
||||
data: function () {
|
||||
let addresses = this.vAddresses
|
||||
if (addresses == null) {
|
||||
addresses = []
|
||||
}
|
||||
let protocol = this.vProtocol
|
||||
if (protocol == null) {
|
||||
protocol = ""
|
||||
}
|
||||
return {
|
||||
addresses: addresses
|
||||
addresses: addresses,
|
||||
protocol: protocol
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -17,7 +22,7 @@ Vue.component("network-addresses-box", {
|
||||
methods: {
|
||||
addAddr: function () {
|
||||
let that = this
|
||||
teaweb.popup("/servers/addPortPopup?serverType=" + this.vServerType, {
|
||||
teaweb.popup("/servers/addPortPopup?serverType=" + this.vServerType + "&protocol=" + this.protocol, {
|
||||
callback: function (resp) {
|
||||
var addr = resp.data.address;
|
||||
that.addresses.push(addr);
|
||||
|
||||
46
web/public/js/components/common/size-capacity-box.js
Normal file
46
web/public/js/components/common/size-capacity-box.js
Normal file
@@ -0,0 +1,46 @@
|
||||
Vue.component("size-capacity-box", {
|
||||
props: ["v-name", "v-value", "v-count", "v-unit"],
|
||||
data: function () {
|
||||
let v = this.vValue
|
||||
if (v == null) {
|
||||
v = {
|
||||
count: this.vCount,
|
||||
unit: this.vUnit
|
||||
}
|
||||
}
|
||||
if (typeof (v["count"]) != "number") {
|
||||
v["count"] = -1
|
||||
}
|
||||
return {
|
||||
"size": v,
|
||||
countString: (v.count >= 0) ? v.count.toString() : ""
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
"countString": function (newValue) {
|
||||
let value = newValue.trim()
|
||||
if (value.length == 0) {
|
||||
this.size.count = -1
|
||||
return
|
||||
}
|
||||
let count = parseInt(value)
|
||||
if (!isNaN(count)) {
|
||||
this.size.count = count
|
||||
}
|
||||
}
|
||||
},
|
||||
template: `<div class="ui fields inline">
|
||||
<input type="hidden" :name="vName" :value="JSON.stringify(size)"/>
|
||||
<div class="ui field">
|
||||
<input type="text" v-model="countString" maxlength="11" size="11"/>
|
||||
</div>
|
||||
<div class="ui field">
|
||||
<select class="ui dropdown" v-model="size.unit">
|
||||
<option value="byte">字节</option>
|
||||
<option value="kb">KB</option>
|
||||
<option value="mb">MB</option>
|
||||
<option value="gb">GB</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>`
|
||||
})
|
||||
46
web/public/js/components/server/gzip-box.js
Normal file
46
web/public/js/components/server/gzip-box.js
Normal file
@@ -0,0 +1,46 @@
|
||||
Vue.component("gzip-box", {
|
||||
props: ["v-gzip-config"],
|
||||
data: function () {
|
||||
let gzip = this.vGzipConfig
|
||||
if (gzip == null) {
|
||||
gzip = {
|
||||
isOn: true,
|
||||
level: 0,
|
||||
minLength: null,
|
||||
maxLength: null
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
gzip: gzip,
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
<table class="ui table selectable definition">
|
||||
<tr>
|
||||
<td class="title">压缩级别</td>
|
||||
<td>
|
||||
<select class="dropdown auto-width" name="level" v-model="gzip.level">
|
||||
<option value="0">不压缩</option>
|
||||
<option v-for="i in 9" :value="i">{{i}}</option>
|
||||
</select>
|
||||
<p class="comment">级别越高,压缩比例越大。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Gzip内容最小长度</td>
|
||||
<td>
|
||||
<size-capacity-box :v-name="'minLength'" :v-value="gzip.minLength" :v-unit="'kb'"></size-capacity-box>
|
||||
<p class="comment">0表示不限制,内容长度从文件尺寸或Content-Length中获取。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Gzip内容最大长度</td>
|
||||
<td>
|
||||
<size-capacity-box :v-name="'maxLength'" :v-value="gzip.maxLength" :v-unit="'mb'"></size-capacity-box>
|
||||
<p class="comment">0表示不限制,内容长度从文件尺寸或Content-Length中获取。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>`
|
||||
})
|
||||
37
web/public/js/components/server/server-name-box.js
Normal file
37
web/public/js/components/server/server-name-box.js
Normal file
@@ -0,0 +1,37 @@
|
||||
Vue.component("server-name-box", {
|
||||
props: ["v-server-names"],
|
||||
data: function () {
|
||||
let serverNames = this.vServerNames;
|
||||
if (serverNames == null) {
|
||||
serverNames = []
|
||||
}
|
||||
return {
|
||||
serverNames: serverNames
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
addServerName: function () {
|
||||
let that = this
|
||||
teaweb.popup("/servers/addServerNamePopup", {
|
||||
callback: function (resp) {
|
||||
var serverName = resp.data.serverName
|
||||
that.serverNames.push(serverName)
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
removeServerName: function (index) {
|
||||
this.serverNames.$remove(index)
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
<input type="hidden" name="serverNames" :value="JSON.stringify(serverNames)"/>
|
||||
<div v-if="serverNames.length > 0">
|
||||
<div v-for="(serverName, index) in serverNames" class="ui label small">
|
||||
<em v-if="serverName.type != 'full'">{{serverName.type}}</em> {{serverName.name}} <a href="" title="删除" @click.prevent="removeServerName(index)"><i class="icon remove"></i></a>
|
||||
</div>
|
||||
<div class="ui divider"></div>
|
||||
</div>
|
||||
<a href="" @click.prevent="addServerName()">[添加域名绑定]</a>
|
||||
</div>`
|
||||
})
|
||||
@@ -54,14 +54,7 @@
|
||||
<tr v-if="serverType == 'httpProxy' || serverType == 'httpWeb'">
|
||||
<td>绑定域名</td>
|
||||
<td>
|
||||
<input type="hidden" name="serverNames" :value="JSON.stringify(serverNames)"/>
|
||||
<div v-if="serverNames.length > 0">
|
||||
<div v-for="(serverName, index) in serverNames" class="ui label small">
|
||||
<em v-if="serverName.type != 'full'">{{serverName.type}}</em> {{serverName.name}} <a href="" title="删除" @click.prevent="removeServerName(index)"><i class="icon remove"></i></a>
|
||||
</div>
|
||||
<div class="ui divider"></div>
|
||||
</div>
|
||||
<a href="" @click.prevent="addServerName()">[添加域名绑定]</a>
|
||||
<server-name-box></server-name-box>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
Tea.context(function () {
|
||||
this.serverType = "httpProxy";
|
||||
this.tlsProtocolName = ""
|
||||
|
||||
this.serverNames = [];
|
||||
this.origins = [];
|
||||
|
||||
|
||||
this.success = NotifySuccess("保存成功", "/servers");
|
||||
|
||||
this.changeServerType = function () {
|
||||
@@ -13,19 +10,6 @@ Tea.context(function () {
|
||||
this.tlsProtocolName = "";
|
||||
};
|
||||
|
||||
this.addServerName = function () {
|
||||
teaweb.popup("/servers/addServerNamePopup", {
|
||||
callback: function (resp) {
|
||||
var serverName = resp.data.serverName;
|
||||
this.serverNames.push(serverName);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.removeServerName = function (index) {
|
||||
this.serverNames.$remove(index);
|
||||
};
|
||||
|
||||
this.addOrigin = function () {
|
||||
teaweb.popup("/servers/addOriginPopup?serverType=" + this.serverType, {
|
||||
callback: function (resp) {
|
||||
|
||||
@@ -3,5 +3,13 @@
|
||||
{$template "/left_menu"}
|
||||
|
||||
<div class="right-box">
|
||||
<p class="ui message">此功能暂未开放,敬请期待。</p>
|
||||
<form class="ui form" data-tea-success="success" data-tea-action="$">
|
||||
<input type="hidden" name="webId" :value="webId"/>
|
||||
<input type="hidden" name="gzipId" :value="gzipConfig.id"/>
|
||||
|
||||
<gzip-box :v-gzip-config="gzipConfig"></gzip-box>
|
||||
|
||||
<div class="margin"></div>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
</div>
|
||||
3
web/views/@default/servers/server/settings/gzip/index.js
Normal file
3
web/views/@default/servers/server/settings/gzip/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
Tea.context(function () {
|
||||
this.success = NotifyReloadSuccess("保存成功")
|
||||
})
|
||||
@@ -3,5 +3,17 @@
|
||||
{$template "/left_menu"}
|
||||
|
||||
<div class="right-box">
|
||||
<p class="ui message">此功能暂未开放,敬请期待。</p>
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<input type="hidden" name="serverId" :value="serverId"/>
|
||||
<input type="hidden" name="serverType" :value="serverType"/>
|
||||
<table class="ui table selectable definition">
|
||||
<tr>
|
||||
<td class="title">绑定端口 *</td>
|
||||
<td>
|
||||
<network-addresses-box :v-server-type="serverType" :v-addresses="httpConfig.addresses" :v-protocol="'http'"></network-addresses-box>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
</div>
|
||||
3
web/views/@default/servers/server/settings/http/index.js
Normal file
3
web/views/@default/servers/server/settings/http/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
Tea.context(function () {
|
||||
this.success = NotifyReloadSuccess("保存成功")
|
||||
})
|
||||
@@ -3,5 +3,17 @@
|
||||
{$template "/left_menu"}
|
||||
|
||||
<div class="right-box">
|
||||
<p class="ui message">此功能暂未开放,敬请期待。</p>
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<input type="hidden" name="serverId" :value="serverId"/>
|
||||
<input type="hidden" name="serverType" :value="serverType"/>
|
||||
<table class="ui table selectable definition">
|
||||
<tr>
|
||||
<td class="title">绑定端口 *</td>
|
||||
<td>
|
||||
<network-addresses-box :v-server-type="serverType" :v-addresses="httpsConfig.addresses" :v-protocol="'https'"></network-addresses-box>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,3 @@
|
||||
Tea.context(function () {
|
||||
this.success = NotifyReloadSuccess("保存成功")
|
||||
})
|
||||
@@ -2,7 +2,12 @@
|
||||
{$template "/left_menu"}
|
||||
|
||||
<div class="right-box">
|
||||
{$ if not .isOn}
|
||||
<div class="ui message">暂未启用反向代理功能,<a href="" @click.prevent="updateOn(true)">[启用]</a>。</div>
|
||||
{$end}
|
||||
{$ if .isOn}
|
||||
{$template "menu"}
|
||||
|
||||
<origin-list-box :v-primary-origins="primaryOrigins" :v-backup-origins="backupOrigins" :v-server-type="serverType" :v-params="'type=server&serverId=' + serverId + '&reverseProxyId=' + reverseProxyId"></origin-list-box>
|
||||
{$end}
|
||||
</div>
|
||||
@@ -0,0 +1,15 @@
|
||||
Tea.context(function () {
|
||||
this.updateOn = function (b) {
|
||||
teaweb.confirm(b ? "确定要启用反向代理服务吗?" : "确定要停用反向代理服务吗?", function () {
|
||||
this.$post(".updateOn")
|
||||
.params({
|
||||
"serverId": this.serverId,
|
||||
"isOn": b ? 1 : 0,
|
||||
"reverseProxyId": this.reverseProxyId
|
||||
})
|
||||
.success(function () {
|
||||
window.location.reload()
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,17 @@
|
||||
{$layout}
|
||||
{$template "/left_menu"}
|
||||
|
||||
<div class="right-box">
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<input type="hidden" name="serverId" :value="serverId"/>
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">已绑定的域名</td>
|
||||
<td>
|
||||
<server-name-box :v-server-names="serverNames"></server-name-box>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,3 @@
|
||||
Tea.context(function () {
|
||||
this.success = NotifyReloadSuccess("保存成功")
|
||||
})
|
||||
@@ -10,7 +10,7 @@
|
||||
<tr>
|
||||
<td class="title">绑定端口 *</td>
|
||||
<td>
|
||||
<network-addresses-box :v-server-type="serverType" :v-addresses="addresses"></network-addresses-box>
|
||||
<network-addresses-box :v-server-type="serverType" :v-addresses="tcpConfig.listen" :v-protocol="'tcp'"></network-addresses-box>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
undefined
|
||||
19
web/views/@default/servers/server/settings/tls/index.html
Normal file
19
web/views/@default/servers/server/settings/tls/index.html
Normal file
@@ -0,0 +1,19 @@
|
||||
{$layout}
|
||||
|
||||
{$template "/left_menu"}
|
||||
|
||||
<div class="right-box">
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<input type="hidden" name="serverId" :value="serverId"/>
|
||||
<input type="hidden" name="serverType" :value="serverType"/>
|
||||
<table class="ui table selectable definition">
|
||||
<tr>
|
||||
<td class="title">绑定端口 *</td>
|
||||
<td>
|
||||
<network-addresses-box :v-server-type="serverType" :v-addresses="tlsConfig.listen" :v-protocol="'tls'"></network-addresses-box>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
</div>
|
||||
3
web/views/@default/servers/server/settings/tls/index.js
Normal file
3
web/views/@default/servers/server/settings/tls/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
Tea.context(function () {
|
||||
this.success = NotifyReloadSuccess("保存成功")
|
||||
})
|
||||
@@ -3,5 +3,17 @@
|
||||
{$template "/left_menu"}
|
||||
|
||||
<div class="right-box">
|
||||
<p class="ui message">此功能暂未开放,敬请期待。</p>
|
||||
<form class="ui form" data-tea-success="success" data-tea-action="$">
|
||||
<input type="hidden" name="serverId" :value="serverId"/>
|
||||
<input type="hidden" name="webId" :value="webConfig.id"/>
|
||||
<table class="ui table selectable definition">
|
||||
<tr>
|
||||
<td class="title">Web目录</td>
|
||||
<td>
|
||||
<input type="text" name="root" v-model="webConfig.root"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
</div>
|
||||
3
web/views/@default/servers/server/settings/web/index.js
Normal file
3
web/views/@default/servers/server/settings/web/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
Tea.context(function () {
|
||||
this.success = NotifyReloadSuccess("保存成功")
|
||||
})
|
||||
Reference in New Issue
Block a user