mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-13 11:53:34 +08:00
初步实现对象存储源站
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
"net/url"
|
||||
"regexp"
|
||||
@@ -27,6 +28,8 @@ func (this *AddOriginPopupAction) RunGet(params struct {
|
||||
}) {
|
||||
this.Data["serverType"] = params.ServerType
|
||||
|
||||
this.getOSSHook()
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
@@ -40,6 +43,36 @@ func (this *AddOriginPopupAction) RunPost(params struct {
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
ossConfig, goNext, err := this.postOSSHook(params.Protocol)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if !goNext {
|
||||
return
|
||||
}
|
||||
|
||||
// 初始化
|
||||
var pbAddr = &pb.NetworkAddress{
|
||||
Protocol: params.Protocol,
|
||||
}
|
||||
var addrConfig = &serverconfigs.NetworkAddressConfig{
|
||||
Protocol: serverconfigs.Protocol(params.Protocol),
|
||||
}
|
||||
var ossJSON []byte
|
||||
|
||||
if ossConfig != nil { // OSS
|
||||
ossJSON, err = json.Marshal(ossConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
err = ossConfig.Init()
|
||||
if err != nil {
|
||||
this.Fail("校验OSS配置时出错:" + err.Error())
|
||||
return
|
||||
}
|
||||
} else { // 普通源站
|
||||
params.Must.
|
||||
Field("addr", params.Addr).
|
||||
Require("请输入源站地址")
|
||||
@@ -87,6 +120,19 @@ func (this *AddOriginPopupAction) RunPost(params struct {
|
||||
}
|
||||
}
|
||||
|
||||
pbAddr = &pb.NetworkAddress{
|
||||
Protocol: params.Protocol,
|
||||
Host: host,
|
||||
PortRange: port,
|
||||
}
|
||||
|
||||
addrConfig = &serverconfigs.NetworkAddressConfig{
|
||||
Protocol: serverconfigs.Protocol(params.Protocol),
|
||||
Host: host,
|
||||
PortRange: port,
|
||||
}
|
||||
}
|
||||
|
||||
// 专属域名
|
||||
var domains = []string{}
|
||||
if len(params.DomainsJSON) > 0 {
|
||||
@@ -104,11 +150,8 @@ func (this *AddOriginPopupAction) RunPost(params struct {
|
||||
|
||||
resp, err := this.RPC().OriginRPC().CreateOrigin(this.AdminContext(), &pb.CreateOriginRequest{
|
||||
Name: "",
|
||||
Addr: &pb.NetworkAddress{
|
||||
Protocol: params.Protocol,
|
||||
Host: host,
|
||||
PortRange: port,
|
||||
},
|
||||
Addr: pbAddr,
|
||||
OssJSON: ossJSON,
|
||||
Description: "",
|
||||
Weight: 10,
|
||||
IsOn: true,
|
||||
@@ -124,14 +167,16 @@ func (this *AddOriginPopupAction) RunPost(params struct {
|
||||
var origin = &serverconfigs.OriginConfig{
|
||||
Id: resp.OriginId,
|
||||
IsOn: true,
|
||||
Addr: &serverconfigs.NetworkAddressConfig{
|
||||
Protocol: serverconfigs.Protocol(params.Protocol),
|
||||
Host: host,
|
||||
PortRange: port,
|
||||
},
|
||||
Addr: addrConfig,
|
||||
OSS: ossConfig,
|
||||
}
|
||||
|
||||
this.Data["origin"] = origin
|
||||
this.Data["origin"] = maps.Map{
|
||||
"id": resp.OriginId,
|
||||
"isOn": true,
|
||||
"addr": addrConfig,
|
||||
"addrSummary": origin.AddrSummary(),
|
||||
}
|
||||
|
||||
// 创建日志
|
||||
defer this.CreateLog(oplogs.LevelInfo, "创建源站 %d", resp.OriginId)
|
||||
|
||||
18
internal/web/actions/default/servers/addOriginPopup_ext.go
Normal file
18
internal/web/actions/default/servers/addOriginPopup_ext.go
Normal file
@@ -0,0 +1,18 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package servers
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ossconfigs"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
func (this *AddOriginPopupAction) getOSSHook() {
|
||||
this.Data["ossTypes"] = []maps.Map{}
|
||||
}
|
||||
|
||||
func (this *AddOriginPopupAction) postOSSHook(protocol string) (config *ossconfigs.OSSConfig, goNext bool, err error) {
|
||||
goNext = true
|
||||
return
|
||||
}
|
||||
@@ -59,7 +59,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
var m = maps.Map{
|
||||
"id": originConfig.Id,
|
||||
"weight": originConfig.Weight,
|
||||
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
|
||||
"addr": originConfig.AddrSummary(),
|
||||
"isOSS": originConfig.IsOSS(),
|
||||
"name": originConfig.Name,
|
||||
"isOn": originConfig.IsOn,
|
||||
"domains": originConfig.Domains,
|
||||
@@ -76,7 +77,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
var m = maps.Map{
|
||||
"id": originConfig.Id,
|
||||
"weight": originConfig.Weight,
|
||||
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
|
||||
"addr": originConfig.AddrSummary(),
|
||||
"isOSS": originConfig.IsOSS(),
|
||||
"name": originConfig.Name,
|
||||
"isOn": originConfig.IsOn,
|
||||
"domains": originConfig.Domains,
|
||||
|
||||
@@ -59,7 +59,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
m := maps.Map{
|
||||
"id": originConfig.Id,
|
||||
"weight": originConfig.Weight,
|
||||
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
|
||||
"addr": originConfig.AddrSummary(),
|
||||
"isOSS": originConfig.IsOSS(),
|
||||
"name": originConfig.Name,
|
||||
"isOn": originConfig.IsOn,
|
||||
"domains": originConfig.Domains,
|
||||
@@ -76,7 +77,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
m := maps.Map{
|
||||
"id": originConfig.Id,
|
||||
"weight": originConfig.Weight,
|
||||
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
|
||||
"addr": originConfig.AddrSummary(),
|
||||
"isOSS": originConfig.IsOSS(),
|
||||
"name": originConfig.Name,
|
||||
"isOn": originConfig.IsOn,
|
||||
"domains": originConfig.Domains,
|
||||
|
||||
@@ -59,7 +59,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
var m = maps.Map{
|
||||
"id": originConfig.Id,
|
||||
"weight": originConfig.Weight,
|
||||
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
|
||||
"addr": originConfig.AddrSummary(),
|
||||
"isOSS": originConfig.IsOSS(),
|
||||
"name": originConfig.Name,
|
||||
"isOn": originConfig.IsOn,
|
||||
"domains": originConfig.Domains,
|
||||
@@ -76,7 +77,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
var m = maps.Map{
|
||||
"id": originConfig.Id,
|
||||
"weight": originConfig.Weight,
|
||||
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
|
||||
"addr": originConfig.AddrSummary(),
|
||||
"isOSS": originConfig.IsOSS(),
|
||||
"name": originConfig.Name,
|
||||
"isOn": originConfig.IsOn,
|
||||
"domains": originConfig.Domains,
|
||||
|
||||
@@ -60,7 +60,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
var m = maps.Map{
|
||||
"id": originConfig.Id,
|
||||
"weight": originConfig.Weight,
|
||||
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
|
||||
"addr": originConfig.AddrSummary(),
|
||||
"isOSS": originConfig.IsOSS(),
|
||||
"name": originConfig.Name,
|
||||
"isOn": originConfig.IsOn,
|
||||
"domains": originConfig.Domains,
|
||||
@@ -77,7 +78,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
var m = maps.Map{
|
||||
"id": originConfig.Id,
|
||||
"weight": originConfig.Weight,
|
||||
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
|
||||
"addr": originConfig.AddrSummary(),
|
||||
"isOSS": originConfig.IsOSS(),
|
||||
"name": originConfig.Name,
|
||||
"isOn": originConfig.IsOn,
|
||||
"domains": originConfig.Domains,
|
||||
|
||||
@@ -47,6 +47,9 @@ func (this *AddPopupAction) RunGet(params struct {
|
||||
// 是否为HTTP
|
||||
this.Data["isHTTP"] = serverType == "httpProxy" || serverType == "httpWeb"
|
||||
|
||||
// OSS
|
||||
this.getOSSHook()
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
@@ -76,6 +79,37 @@ func (this *AddPopupAction) RunPost(params struct {
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
ossConfig, goNext, err := this.postOSSHook(params.Protocol)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if !goNext {
|
||||
return
|
||||
}
|
||||
|
||||
// 初始化
|
||||
var pbAddr = &pb.NetworkAddress{
|
||||
Protocol: params.Protocol,
|
||||
}
|
||||
var connTimeoutJSON []byte
|
||||
var readTimeoutJSON []byte
|
||||
var idleTimeoutJSON []byte
|
||||
var certRefJSON []byte
|
||||
|
||||
var ossJSON []byte = nil
|
||||
if ossConfig != nil { // OSS
|
||||
ossJSON, err = json.Marshal(ossConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
err = ossConfig.Init()
|
||||
if err != nil {
|
||||
this.Fail("校验OSS配置时出错:" + err.Error())
|
||||
return
|
||||
}
|
||||
} else { // 普通源站
|
||||
params.Must.
|
||||
Field("addr", params.Addr).
|
||||
Require("请输入源站地址")
|
||||
@@ -124,7 +158,7 @@ func (this *AddPopupAction) RunPost(params struct {
|
||||
}
|
||||
}
|
||||
|
||||
connTimeoutJSON, err := (&shared.TimeDuration{
|
||||
connTimeoutJSON, err = (&shared.TimeDuration{
|
||||
Count: int64(params.ConnTimeout),
|
||||
Unit: shared.TimeDurationUnitSecond,
|
||||
}).AsJSON()
|
||||
@@ -133,7 +167,7 @@ func (this *AddPopupAction) RunPost(params struct {
|
||||
return
|
||||
}
|
||||
|
||||
readTimeoutJSON, err := (&shared.TimeDuration{
|
||||
readTimeoutJSON, err = (&shared.TimeDuration{
|
||||
Count: int64(params.ReadTimeout),
|
||||
Unit: shared.TimeDurationUnitSecond,
|
||||
}).AsJSON()
|
||||
@@ -142,7 +176,7 @@ func (this *AddPopupAction) RunPost(params struct {
|
||||
return
|
||||
}
|
||||
|
||||
idleTimeoutJSON, err := (&shared.TimeDuration{
|
||||
idleTimeoutJSON, err = (&shared.TimeDuration{
|
||||
Count: int64(params.IdleTimeout),
|
||||
Unit: shared.TimeDurationUnitSecond,
|
||||
}).AsJSON()
|
||||
@@ -160,7 +194,7 @@ func (this *AddPopupAction) RunPost(params struct {
|
||||
return
|
||||
}
|
||||
}
|
||||
var certRefJSON []byte
|
||||
|
||||
if len(certIds) > 0 {
|
||||
var certId = certIds[0]
|
||||
if certId > 0 {
|
||||
@@ -176,6 +210,13 @@ func (this *AddPopupAction) RunPost(params struct {
|
||||
}
|
||||
}
|
||||
|
||||
pbAddr = &pb.NetworkAddress{
|
||||
Protocol: params.Protocol,
|
||||
Host: host,
|
||||
PortRange: port,
|
||||
}
|
||||
}
|
||||
|
||||
// 专属域名
|
||||
var domains = []string{}
|
||||
if len(params.DomainsJSON) > 0 {
|
||||
@@ -193,11 +234,8 @@ func (this *AddPopupAction) RunPost(params struct {
|
||||
|
||||
createResp, err := this.RPC().OriginRPC().CreateOrigin(this.AdminContext(), &pb.CreateOriginRequest{
|
||||
Name: params.Name,
|
||||
Addr: &pb.NetworkAddress{
|
||||
Protocol: params.Protocol,
|
||||
Host: host,
|
||||
PortRange: port,
|
||||
},
|
||||
Addr: pbAddr,
|
||||
OssJSON: ossJSON,
|
||||
Description: params.Description,
|
||||
Weight: params.Weight,
|
||||
IsOn: params.IsOn,
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package origins
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ossconfigs"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
func (this *AddPopupAction) getOSSHook() {
|
||||
this.Data["ossTypes"] = []maps.Map{}
|
||||
}
|
||||
|
||||
func (this *AddPopupAction) postOSSHook(protocol string) (config *ossconfigs.OSSConfig, goNext bool, err error) {
|
||||
goNext = true
|
||||
return
|
||||
}
|
||||
@@ -94,10 +94,14 @@ func (this *UpdatePopupAction) RunGet(params struct {
|
||||
config.Cert.KeyData = nil
|
||||
}
|
||||
|
||||
var addr = ""
|
||||
if len(config.Addr.Host) > 0 && len(config.Addr.PortRange) > 0 {
|
||||
addr = config.Addr.Host + ":" + config.Addr.PortRange
|
||||
}
|
||||
this.Data["origin"] = maps.Map{
|
||||
"id": config.Id,
|
||||
"protocol": config.Addr.Protocol,
|
||||
"addr": config.Addr.Host + ":" + config.Addr.PortRange,
|
||||
"addr": addr,
|
||||
"weight": config.Weight,
|
||||
"name": config.Name,
|
||||
"description": config.Description,
|
||||
@@ -111,8 +115,12 @@ func (this *UpdatePopupAction) RunGet(params struct {
|
||||
"domains": config.Domains,
|
||||
"host": config.RequestHost,
|
||||
"followPort": config.FollowPort,
|
||||
"oss": config.OSS,
|
||||
}
|
||||
|
||||
// OSS
|
||||
this.getOSSHook()
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
@@ -143,6 +151,36 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
ossConfig, goNext, err := this.postOSSHook(params.Protocol)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if !goNext {
|
||||
return
|
||||
}
|
||||
|
||||
var ossJSON []byte = nil
|
||||
var connTimeoutJSON []byte
|
||||
var readTimeoutJSON []byte
|
||||
var idleTimeoutJSON []byte
|
||||
var certRefJSON []byte
|
||||
var pbAddr = &pb.NetworkAddress{
|
||||
Protocol: params.Protocol,
|
||||
}
|
||||
|
||||
if ossConfig != nil { // OSS
|
||||
ossJSON, err = json.Marshal(ossConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
err = ossConfig.Init()
|
||||
if err != nil {
|
||||
this.Fail("校验OSS配置时出错:" + err.Error())
|
||||
return
|
||||
}
|
||||
} else { // 普通源站
|
||||
params.Must.
|
||||
Field("addr", params.Addr).
|
||||
Require("请输入源站地址")
|
||||
@@ -175,22 +213,32 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
// 检查端口号
|
||||
if port == "0" {
|
||||
this.FailField("addr", "源站端口号不能为0")
|
||||
return
|
||||
}
|
||||
if !configutils.HasVariables(port) {
|
||||
// 必须是整数
|
||||
if !regexp.MustCompile(`^\d+$`).MatchString(port) {
|
||||
this.FailField("addr", "源站端口号只能为整数")
|
||||
return
|
||||
}
|
||||
var portInt = types.Int(port)
|
||||
if portInt == 0 {
|
||||
this.FailField("addr", "源站端口号不能为0")
|
||||
return
|
||||
}
|
||||
if portInt > 65535 {
|
||||
this.FailField("addr", "源站端口号不能大于65535")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
connTimeoutJSON, err := (&shared.TimeDuration{
|
||||
pbAddr = &pb.NetworkAddress{
|
||||
Protocol: params.Protocol,
|
||||
Host: host,
|
||||
PortRange: port,
|
||||
}
|
||||
|
||||
connTimeoutJSON, err = (&shared.TimeDuration{
|
||||
Count: int64(params.ConnTimeout),
|
||||
Unit: shared.TimeDurationUnitSecond,
|
||||
}).AsJSON()
|
||||
@@ -199,7 +247,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
return
|
||||
}
|
||||
|
||||
readTimeoutJSON, err := (&shared.TimeDuration{
|
||||
readTimeoutJSON, err = (&shared.TimeDuration{
|
||||
Count: int64(params.ReadTimeout),
|
||||
Unit: shared.TimeDurationUnitSecond,
|
||||
}).AsJSON()
|
||||
@@ -208,7 +256,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
return
|
||||
}
|
||||
|
||||
idleTimeoutJSON, err := (&shared.TimeDuration{
|
||||
idleTimeoutJSON, err = (&shared.TimeDuration{
|
||||
Count: int64(params.IdleTimeout),
|
||||
Unit: shared.TimeDurationUnitSecond,
|
||||
}).AsJSON()
|
||||
@@ -226,7 +274,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
return
|
||||
}
|
||||
}
|
||||
var certRefJSON []byte
|
||||
|
||||
if len(certIds) > 0 {
|
||||
var certId = certIds[0]
|
||||
if certId > 0 {
|
||||
@@ -241,6 +289,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 专属域名
|
||||
var domains = []string{}
|
||||
@@ -260,11 +309,8 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
_, err = this.RPC().OriginRPC().UpdateOrigin(this.AdminContext(), &pb.UpdateOriginRequest{
|
||||
OriginId: params.OriginId,
|
||||
Name: params.Name,
|
||||
Addr: &pb.NetworkAddress{
|
||||
Protocol: params.Protocol,
|
||||
Host: host,
|
||||
PortRange: port,
|
||||
},
|
||||
Addr: pbAddr,
|
||||
OssJSON: ossJSON,
|
||||
Description: params.Description,
|
||||
Weight: params.Weight,
|
||||
IsOn: params.IsOn,
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package origins
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ossconfigs"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
func (this *UpdatePopupAction) getOSSHook() {
|
||||
this.Data["ossTypes"] = []maps.Map{}
|
||||
}
|
||||
|
||||
func (this *UpdatePopupAction) postOSSHook(protocol string) (config *ossconfigs.OSSConfig, goNext bool, err error) {
|
||||
goNext = true
|
||||
return
|
||||
}
|
||||
@@ -87,7 +87,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
var m = maps.Map{
|
||||
"id": originConfig.Id,
|
||||
"weight": originConfig.Weight,
|
||||
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
|
||||
"addr": originConfig.AddrSummary(),
|
||||
"isOSS": originConfig.IsOSS(),
|
||||
"name": originConfig.Name,
|
||||
"isOn": originConfig.IsOn,
|
||||
"domains": originConfig.Domains,
|
||||
@@ -104,7 +105,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
var m = maps.Map{
|
||||
"id": originConfig.Id,
|
||||
"weight": originConfig.Weight,
|
||||
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
|
||||
"addr": originConfig.AddrSummary(),
|
||||
"isOSS": originConfig.IsOSS(),
|
||||
"name": originConfig.Name,
|
||||
"isOn": originConfig.IsOn,
|
||||
"domains": originConfig.Domains,
|
||||
|
||||
@@ -103,6 +103,7 @@ Vue.component("origin-list-table", {
|
||||
<td :class="{disabled:!origin.isOn}">
|
||||
<a href="" @click.prevent="updateOrigin(origin.id)" :class="{disabled:!origin.isOn}">{{origin.addr}} <i class="icon expand small"></i></a>
|
||||
<div style="margin-top: 0.3em">
|
||||
<tiny-basic-label v-if="origin.isOSS"><i class="icon hdd outline"></i>对象存储</tiny-basic-label>
|
||||
<tiny-basic-label v-if="origin.name.length > 0">{{origin.name}}</tiny-basic-label>
|
||||
<tiny-basic-label v-if="origin.hasCert">证书</tiny-basic-label>
|
||||
<tiny-basic-label v-if="origin.host != null && origin.host.length > 0">主机名: {{origin.host}}</tiny-basic-label>
|
||||
|
||||
@@ -5,12 +5,16 @@
|
||||
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<table class="ui table selectable definition">
|
||||
<tr>
|
||||
<td>源站协议 *</td>
|
||||
<td class="title">源站协议 *</td>
|
||||
<td>
|
||||
<!-- HTTP -->
|
||||
<select class="ui dropdown auto-width" name="protocol" v-if="serverType == 'httpProxy' || serverType == 'httpWeb'" @change="changeProtocol" v-model="protocol">
|
||||
<option value="http">HTTP</option>
|
||||
<option value="https">HTTPS</option>
|
||||
|
||||
<!-- 对象存储 -->
|
||||
<optgroup label="对象存储" v-if="ossTypes.length > 0"></optgroup>
|
||||
<option v-for="ossType in ossTypes" :value="ossType.code">{{ossType.name}}</option>
|
||||
</select>
|
||||
|
||||
<!-- TCP -->
|
||||
@@ -25,20 +29,56 @@
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
<!-- 普通源站 -->
|
||||
<tr v-show="!isOSS">
|
||||
<td class="title">源站地址 *</td>
|
||||
<td>
|
||||
<input type="text" name="addr" ref="focus" v-model="addr" @input="changeAddr"/>
|
||||
<p class="comment"><span class="red" v-if="addrError.length > 0">{{addrError}}</span>源站服务器地址,通常是一个IP(或域名)加端口<span v-if="serverType == 'httpProxy'">,不需要加 http:// 或 https://</span>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="isHTTP || protocol == 'tls'">
|
||||
<tr v-if="(isHTTP || protocol == 'tls') && !isOSS">
|
||||
<td>回源主机名</td>
|
||||
<td>
|
||||
<input type="text" name="host" placeholder="比如example.com" maxlength="100"/>
|
||||
<p class="comment">请求源站时的Host字段值,用于设置访问源站的站点域名<span v-if="isHTTP">,支持请求变量</span>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- OSS -->
|
||||
<!-- 腾讯云COS -->
|
||||
<tbody v-if="protocol == 'oss:tencentCOS'">
|
||||
<tr>
|
||||
<td>密钥ID *<br/><em>(Secret Id)</em></td>
|
||||
<td>
|
||||
<input type="text" name="tencentCOSSecretId" maxlength="100"/>
|
||||
<p class="comment">访问存储桶需要的密钥ID。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>密钥Key *<br/><em>(Secret Key)</em></td>
|
||||
<td>
|
||||
<input type="text" name="tencentCOSSecretKey" maxlength="100"/>
|
||||
<p class="comment">访问存储桶需要的密钥Key。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>存储桶名称 *</td>
|
||||
<td>
|
||||
<input type="text" name="tencentCOSBucketName" maxlength="100"/>
|
||||
<p class="comment">存储桶名称,类似于<code-label>example-12345678</code-label>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>所属区域代号 *</td>
|
||||
<td>
|
||||
<input type="text" name="tencentCOSRegion" maxlength="100"/>
|
||||
<p class="comment">COS服务所属区域代号,类似于<code-label>ap-beijing</code-label>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<tr>
|
||||
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
||||
</tr>
|
||||
@@ -56,7 +96,7 @@
|
||||
<p class="comment">默认不需要填写,表示支持所有域名。如果填写了专属域名,表示这些源站只会在所列的专属域名被访问时才生效。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr v-show="!isOSS">
|
||||
<td>端口跟随</td>
|
||||
<td>
|
||||
<checkbox name="followPort"></checkbox>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
Tea.context(function () {
|
||||
this.addr = ""
|
||||
this.protocol = ""
|
||||
this.isOSS = false
|
||||
|
||||
this.addrError = ""
|
||||
|
||||
@@ -15,6 +16,8 @@ Tea.context(function () {
|
||||
}
|
||||
|
||||
this.changeProtocol = function () {
|
||||
this.isOSS = this.protocol.startsWith("oss:")
|
||||
|
||||
this.checkPort()
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,8 @@
|
||||
<input type="hidden" name="origins" :value="JSON.stringify(origins)"/>
|
||||
<div v-if="origins.length > 0">
|
||||
<div v-for="(origin, index) in origins" class="ui label small basic">
|
||||
{{origin.addr.protocol}}://{{origin.addr.host}}:{{origin.addr.portRange}}
|
||||
<span v-if="origin.addrSummary != null && origin.addrSummary.length > 0">{{origin.addrSummary}}</span>
|
||||
<span v-else>{{origin.addr.protocol}}://{{origin.addr.host}}:{{origin.addr.portRange}}</span>
|
||||
<a href="" title="删除" @click.prevent="removeOrigin(index)"><i class="icon remove"></i></a>
|
||||
</div>
|
||||
<div class="ui divider"></div>
|
||||
|
||||
@@ -7,12 +7,16 @@
|
||||
<input type="hidden" name="originType" :value="originType"/>
|
||||
<table class="ui table selectable definition">
|
||||
<tr>
|
||||
<td>源站协议</td>
|
||||
<td class="title">源站协议</td>
|
||||
<td>
|
||||
<!-- HTTP -->
|
||||
<select class="ui dropdown auto-width" name="protocol" v-model="protocol" v-if="serverType == 'httpProxy' || serverType == 'httpWeb'" @change="changeProtocol">
|
||||
<option value="http">HTTP</option>
|
||||
<option value="https">HTTPS</option>
|
||||
|
||||
<!-- 对象存储 -->
|
||||
<optgroup label="对象存储" v-if="ossTypes.length > 0"></optgroup>
|
||||
<option v-for="ossType in ossTypes" :value="ossType.code">{{ossType.name}}</option>
|
||||
</select>
|
||||
|
||||
<!-- TCP -->
|
||||
@@ -27,7 +31,9 @@
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
<!-- 普通源站 -->
|
||||
<tr v-show="!isOSS">
|
||||
<td class="title">源站地址 *</td>
|
||||
<td>
|
||||
<input type="text" name="addr" ref="focus" v-model="addr" @input="changeAddr"/>
|
||||
@@ -35,13 +41,47 @@
|
||||
源站服务器地址,通常是一个IP(或域名)加端口<span v-if="serverType == 'httpProxy'">,不需要加 http:// 或 https://</span>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="isHTTP || protocol == 'tls'">
|
||||
<tr v-if="(isHTTP || protocol == 'tls') && !isOSS">
|
||||
<td>回源主机名</td>
|
||||
<td>
|
||||
<input type="text" name="host" placeholder="比如example.com" maxlength="100"/>
|
||||
<p class="comment">请求源站时的Host字段值,用于设置访问源站的站点域名<span v-if="isHTTP">,支持请求变量</span>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- OSS -->
|
||||
<!-- 腾讯云COS -->
|
||||
<tbody v-if="protocol == 'oss:tencentCOS'">
|
||||
<tr>
|
||||
<td>密钥ID *<br/><em>(Secret Id)</em></td>
|
||||
<td>
|
||||
<input type="text" name="tencentCOSSecretId" maxlength="100"/>
|
||||
<p class="comment">访问存储桶需要的密钥ID。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>密钥Key *<br/><em>(Secret Key)</em></td>
|
||||
<td>
|
||||
<input type="text" name="tencentCOSSecretKey" maxlength="100"/>
|
||||
<p class="comment">访问存储桶需要的密钥Key。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>存储桶名称 *</td>
|
||||
<td>
|
||||
<input type="text" name="tencentCOSBucketName" maxlength="100"/>
|
||||
<p class="comment">存储桶名称,类似于<code-label>example-12345678</code-label>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>所属区域代号 *</td>
|
||||
<td>
|
||||
<input type="text" name="tencentCOSRegion" maxlength="100"/>
|
||||
<p class="comment">COS服务所属区域代号,类似于<code-label>ap-beijing</code-label>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<tr>
|
||||
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
||||
</tr>
|
||||
@@ -59,7 +99,7 @@
|
||||
<p class="comment">默认不需要填写,表示支持所有域名。如果填写了专属域名,表示这些源站只会在所列的专属域名被访问时才生效。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr v-show="!isOSS">
|
||||
<td>端口跟随</td>
|
||||
<td>
|
||||
<checkbox name="followPort"></checkbox>
|
||||
@@ -80,7 +120,7 @@
|
||||
<p class="comment">给当前源站起一个容易识别的名称。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr v-show="!isOSS">
|
||||
<td>连接失败超时时间</td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
@@ -94,7 +134,7 @@
|
||||
<p class="comment">连接源站失败的最大超时时间,0表示不限制。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="isHTTP">
|
||||
<tr v-if="isHTTP && !isOSS">
|
||||
<td>读取超时时间</td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
@@ -108,7 +148,7 @@
|
||||
<p class="comment">读取内容时的最大超时时间,0表示不限制。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="isHTTP">
|
||||
<tr v-if="isHTTP && !isOSS">
|
||||
<td>最大并发连接数</td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
@@ -119,7 +159,7 @@
|
||||
<p class="comment">源站可以接受到的最大并发连接数,0表示使用系统默认。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="isHTTP">
|
||||
<tr v-if="isHTTP && !isOSS">
|
||||
<td>最大空闲连接数</td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
@@ -130,7 +170,7 @@
|
||||
<p class="comment">当没有请求时,源站保持等待的最大空闲连接数量,0表示使用系统默认。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="isHTTP">
|
||||
<tr v-if="isHTTP && !isOSS">
|
||||
<td>最大空闲超时时间</td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
@@ -151,7 +191,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>是否启用</td>
|
||||
<td>启用当前源站</td>
|
||||
<td>
|
||||
<checkbox name="isOn" :value="true"></checkbox>
|
||||
</td>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
Tea.context(function () {
|
||||
this.addr = ""
|
||||
this.protocol = ""
|
||||
this.isOSS = false
|
||||
|
||||
this.addrError = ""
|
||||
|
||||
@@ -13,6 +14,8 @@ Tea.context(function () {
|
||||
}
|
||||
|
||||
this.changeProtocol = function () {
|
||||
this.isOSS = this.protocol.startsWith("oss:")
|
||||
|
||||
this.checkPort()
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,16 @@
|
||||
|
||||
<table class="ui table selectable definition">
|
||||
<tr>
|
||||
<td>源站协议</td>
|
||||
<td class="title">源站协议</td>
|
||||
<td>
|
||||
<!-- HTTP -->
|
||||
<select class="ui dropdown auto-width" name="protocol" v-model="origin.protocol" v-if="serverType == 'httpProxy' || serverType == 'httpWeb'" @change="changeProtocol">
|
||||
<option value="http">HTTP</option>
|
||||
<option value="https">HTTPS</option>
|
||||
|
||||
<!-- 对象存储 -->
|
||||
<optgroup label="对象存储" v-if="ossTypes.length > 0"></optgroup>
|
||||
<option v-for="ossType in ossTypes" :value="ossType.code">{{ossType.name}}</option>
|
||||
</select>
|
||||
|
||||
<!-- TCP -->
|
||||
@@ -29,20 +33,56 @@
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
<!-- 普通源站 -->
|
||||
<tr v-show="!isOSS">
|
||||
<td class="title">源站地址 *</td>
|
||||
<td>
|
||||
<input type="text" name="addr" ref="focus" v-model="origin.addr" @input="changeAddr"/>
|
||||
<p class="comment"><span class="red" v-if="addrError.length > 0">{{addrError}}</span>源站服务器地址,通常是一个IP(或域名)加端口<span v-if="serverType == 'httpProxy'">,不需要加 http:// 或 https://</span>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="isHTTP || origin.protocol == 'tls'">
|
||||
<tr v-if="(isHTTP || origin.protocol == 'tls') && !isOSS">
|
||||
<td>回源主机名</td>
|
||||
<td>
|
||||
<input type="text" name="host" v-model="origin.host" placeholder="比如example.com" maxlength="100"/>
|
||||
<p class="comment">请求源站时的Host字段值,用于设置访问源站的站点域名<span v-if="isHTTP">,支持请求变量</span>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- OSS -->
|
||||
<!-- 腾讯云COS -->
|
||||
<tbody v-if="origin.protocol == 'oss:tencentCOS'">
|
||||
<tr>
|
||||
<td>密钥ID *<br/><em>(Secret Id)</em></td>
|
||||
<td>
|
||||
<input type="text" name="tencentCOSSecretId" maxlength="100" v-model="origin.oss.options.secretId"/>
|
||||
<p class="comment">访问存储桶需要的密钥ID。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>密钥Key *<br/><em>(Secret Key)</em></td>
|
||||
<td>
|
||||
<input type="text" name="tencentCOSSecretKey" maxlength="100" v-model="origin.oss.options.secretKey"/>
|
||||
<p class="comment">访问存储桶需要的密钥Key。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>存储桶名称 *</td>
|
||||
<td>
|
||||
<input type="text" name="tencentCOSBucketName" maxlength="100" v-model="origin.oss.options.bucketName"/>
|
||||
<p class="comment">存储桶名称,类似于<code-label>example-12345678</code-label>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>所属区域代号 *</td>
|
||||
<td>
|
||||
<input type="text" name="tencentCOSRegion" maxlength="100" v-model="origin.oss.options.region"/>
|
||||
<p class="comment">COS服务所属区域代号,类似于<code-label>ap-beijing</code-label>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<tr>
|
||||
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
||||
</tr>
|
||||
@@ -60,7 +100,7 @@
|
||||
<p class="comment">默认不需要填写,表示支持所有域名。如果填写了专属域名,表示这些源站只会在所列的专属域名被访问时才生效。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr v-show="!isOSS">
|
||||
<td>端口跟随</td>
|
||||
<td>
|
||||
<checkbox name="followPort" v-model="origin.followPort"></checkbox>
|
||||
@@ -81,7 +121,7 @@
|
||||
<p class="comment">给当前源站起一个容易识别的名称。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr v-show="!isOSS">
|
||||
<td>连接失败超时时间</td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
@@ -95,7 +135,7 @@
|
||||
<p class="comment">连接源站失败的最大超时时间,0表示不限制。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="isHTTP">
|
||||
<tr v-if="isHTTP && !isOSS">
|
||||
<td>读取超时时间</td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
@@ -109,7 +149,7 @@
|
||||
<p class="comment">读取内容时的最大超时时间,0表示不限制。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="isHTTP">
|
||||
<tr v-if="isHTTP && !isOSS">
|
||||
<td>最大并发连接数</td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
@@ -120,7 +160,7 @@
|
||||
<p class="comment">源站可以接受到的最大并发连接数,0表示使用系统默认。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="isHTTP">
|
||||
<tr v-if="isHTTP && !isOSS">
|
||||
<td>最大空闲连接数</td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
@@ -131,7 +171,7 @@
|
||||
<p class="comment">当没有请求时,源站保持等待的最大空闲连接数量,0表示使用系统默认。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="isHTTP">
|
||||
<tr v-if="isHTTP && !isOSS">
|
||||
<td>最大空闲超时时间</td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
@@ -152,7 +192,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>是否启用</td>
|
||||
<td>启用当前源站</td>
|
||||
<td>
|
||||
<checkbox name="isOn" :value="origin.isOn"></checkbox>
|
||||
</td>
|
||||
|
||||
@@ -1,11 +1,22 @@
|
||||
Tea.context(function () {
|
||||
this.addrError = ""
|
||||
this.isOSS = this.origin != null && this.origin.protocol != null && this.origin.protocol.startsWith("oss:")
|
||||
|
||||
// 预先设置oss选项
|
||||
if (!this.isOSS) {
|
||||
this.origin.oss = {
|
||||
type: "",
|
||||
options: {}
|
||||
}
|
||||
}
|
||||
|
||||
this.$delay(function () {
|
||||
this.checkPort()
|
||||
})
|
||||
|
||||
this.changeProtocol = function () {
|
||||
this.isOSS = this.origin.protocol.startsWith("oss:")
|
||||
|
||||
this.checkPort()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user