mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-08 11:20:26 +08:00
源站支持HTTP/2
This commit is contained in:
@@ -104,7 +104,8 @@ func (this *OriginDAO) CreateOrigin(tx *dbs.Tx,
|
|||||||
certRef *sslconfigs.SSLCertRef,
|
certRef *sslconfigs.SSLCertRef,
|
||||||
domains []string,
|
domains []string,
|
||||||
host string,
|
host string,
|
||||||
followPort bool) (originId int64, err error) {
|
followPort bool,
|
||||||
|
http2Enabled bool) (originId int64, err error) {
|
||||||
var op = NewOriginOperator()
|
var op = NewOriginOperator()
|
||||||
op.AdminId = adminId
|
op.AdminId = adminId
|
||||||
op.UserId = userId
|
op.UserId = userId
|
||||||
@@ -182,6 +183,7 @@ func (this *OriginDAO) CreateOrigin(tx *dbs.Tx,
|
|||||||
|
|
||||||
op.Host = host
|
op.Host = host
|
||||||
op.FollowPort = followPort
|
op.FollowPort = followPort
|
||||||
|
op.Http2Enabled = http2Enabled
|
||||||
|
|
||||||
op.State = OriginStateEnabled
|
op.State = OriginStateEnabled
|
||||||
err = this.Save(tx, op)
|
err = this.Save(tx, op)
|
||||||
@@ -208,7 +210,8 @@ func (this *OriginDAO) UpdateOrigin(tx *dbs.Tx,
|
|||||||
certRef *sslconfigs.SSLCertRef,
|
certRef *sslconfigs.SSLCertRef,
|
||||||
domains []string,
|
domains []string,
|
||||||
host string,
|
host string,
|
||||||
followPort bool) error {
|
followPort bool,
|
||||||
|
http2Enabled bool) error {
|
||||||
if originId <= 0 {
|
if originId <= 0 {
|
||||||
return errors.New("invalid originId")
|
return errors.New("invalid originId")
|
||||||
}
|
}
|
||||||
@@ -290,6 +293,7 @@ func (this *OriginDAO) UpdateOrigin(tx *dbs.Tx,
|
|||||||
|
|
||||||
op.Host = host
|
op.Host = host
|
||||||
op.FollowPort = followPort
|
op.FollowPort = followPort
|
||||||
|
op.Http2Enabled = http2Enabled
|
||||||
|
|
||||||
err := this.Save(tx, op)
|
err := this.Save(tx, op)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -353,6 +357,7 @@ func (this *OriginDAO) CloneOrigin(tx *dbs.Tx, fromOriginId int64) (newOriginId
|
|||||||
op.Domains = origin.Domains
|
op.Domains = origin.Domains
|
||||||
}
|
}
|
||||||
op.FollowPort = origin.FollowPort
|
op.FollowPort = origin.FollowPort
|
||||||
|
op.Http2Enabled = origin.Http2Enabled
|
||||||
op.State = origin.State
|
op.State = origin.State
|
||||||
return this.SaveInt64(tx, op)
|
return this.SaveInt64(tx, op)
|
||||||
}
|
}
|
||||||
@@ -391,6 +396,7 @@ func (this *OriginDAO) ComposeOriginConfig(tx *dbs.Tx, originId int64, dataMap *
|
|||||||
RequestHost: origin.Host,
|
RequestHost: origin.Host,
|
||||||
Domains: origin.DecodeDomains(),
|
Domains: origin.DecodeDomains(),
|
||||||
FollowPort: origin.FollowPort,
|
FollowPort: origin.FollowPort,
|
||||||
|
HTTP2Enabled: origin.Http2Enabled,
|
||||||
}
|
}
|
||||||
|
|
||||||
// addr
|
// addr
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ type Origin struct {
|
|||||||
Domains dbs.JSON `field:"domains"` // 所属域名
|
Domains dbs.JSON `field:"domains"` // 所属域名
|
||||||
FollowPort bool `field:"followPort"` // 端口跟随
|
FollowPort bool `field:"followPort"` // 端口跟随
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
|
Http2Enabled bool `field:"http2Enabled"` // 是否支持HTTP/2
|
||||||
}
|
}
|
||||||
|
|
||||||
type OriginOperator struct {
|
type OriginOperator struct {
|
||||||
@@ -63,6 +64,7 @@ type OriginOperator struct {
|
|||||||
Domains any // 所属域名
|
Domains any // 所属域名
|
||||||
FollowPort any // 端口跟随
|
FollowPort any // 端口跟随
|
||||||
State any // 状态
|
State any // 状态
|
||||||
|
Http2Enabled any // 是否支持HTTP/2
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewOriginOperator() *OriginOperator {
|
func NewOriginOperator() *OriginOperator {
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ func (this *OriginService) CreateOrigin(ctx context.Context, req *pb.CreateOrigi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
originId, err := models.SharedOriginDAO.CreateOrigin(tx, adminId, userId, req.Name, addrMap.AsJSON(), ossConfig, req.Description, req.Weight, req.IsOn, connTimeout, readTimeout, idleTimeout, req.MaxConns, req.MaxIdleConns, certRef, req.Domains, req.Host, req.FollowPort)
|
originId, err := models.SharedOriginDAO.CreateOrigin(tx, adminId, userId, req.Name, addrMap.AsJSON(), ossConfig, req.Description, req.Weight, req.IsOn, connTimeout, readTimeout, idleTimeout, req.MaxConns, req.MaxIdleConns, certRef, req.Domains, req.Host, req.FollowPort, req.Http2Enabled)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -166,7 +166,7 @@ func (this *OriginService) UpdateOrigin(ctx context.Context, req *pb.UpdateOrigi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = models.SharedOriginDAO.UpdateOrigin(tx, req.OriginId, req.Name, addrMap.AsJSON(), ossConfig, req.Description, req.Weight, req.IsOn, connTimeout, readTimeout, idleTimeout, req.MaxConns, req.MaxIdleConns, certRef, req.Domains, req.Host, req.FollowPort)
|
err = models.SharedOriginDAO.UpdateOrigin(tx, req.OriginId, req.Name, addrMap.AsJSON(), ossConfig, req.Description, req.Weight, req.IsOn, connTimeout, readTimeout, idleTimeout, req.MaxConns, req.MaxIdleConns, certRef, req.Domains, req.Host, req.FollowPort, req.Http2Enabled)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -204,7 +204,7 @@ func (this *OriginService) FindEnabledOrigin(ctx context.Context, req *pb.FindEn
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result := &pb.Origin{
|
return &pb.FindEnabledOriginResponse{Origin: &pb.Origin{
|
||||||
Id: int64(origin.Id),
|
Id: int64(origin.Id),
|
||||||
IsOn: origin.IsOn,
|
IsOn: origin.IsOn,
|
||||||
Name: origin.Name,
|
Name: origin.Name,
|
||||||
@@ -215,8 +215,9 @@ func (this *OriginService) FindEnabledOrigin(ctx context.Context, req *pb.FindEn
|
|||||||
},
|
},
|
||||||
Description: origin.Description,
|
Description: origin.Description,
|
||||||
Domains: origin.DecodeDomains(),
|
Domains: origin.DecodeDomains(),
|
||||||
}
|
FollowPort: origin.FollowPort,
|
||||||
return &pb.FindEnabledOriginResponse{Origin: result}, nil
|
Http2Enabled: origin.Http2Enabled,
|
||||||
|
}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindEnabledOriginConfig 查找源站配置
|
// FindEnabledOriginConfig 查找源站配置
|
||||||
|
|||||||
@@ -392,7 +392,7 @@ func (this *ServerService) CreateBasicHTTPServer(ctx context.Context, req *pb.Cr
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
originId, err := models.SharedOriginDAO.CreateOrigin(tx, adminId, req.UserId, "", addrJSON, nil, "", 10, true, nil, nil, nil, 0, 0, nil, nil, u.Host, false)
|
originId, err := models.SharedOriginDAO.CreateOrigin(tx, adminId, req.UserId, "", addrJSON, nil, "", 10, true, nil, nil, nil, 0, 0, nil, nil, u.Host, false, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -651,7 +651,7 @@ func (this *ServerService) CreateBasicTCPServer(ctx context.Context, req *pb.Cre
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
originId, err := models.SharedOriginDAO.CreateOrigin(tx, adminId, req.UserId, "", addrJSON, nil, "", 10, true, nil, nil, nil, 0, 0, nil, nil, "", false)
|
originId, err := models.SharedOriginDAO.CreateOrigin(tx, adminId, req.UserId, "", addrJSON, nil, "", 10, true, nil, nil, nil, 0, 0, nil, nil, "", false, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user