实现源站端口跟随功能

This commit is contained in:
GoEdgeLab
2022-06-29 21:55:37 +08:00
parent 99fecb2bfc
commit 140b322e9a
6 changed files with 3150 additions and 3116 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -37,6 +37,7 @@ type Origin struct {
Description string `protobuf:"bytes,5,opt,name=description,proto3" json:"description,omitempty"`
Domains []string `protobuf:"bytes,6,rep,name=domains,proto3" json:"domains,omitempty"`
Host string `protobuf:"bytes,7,opt,name=host,proto3" json:"host,omitempty"`
FollowPort bool `protobuf:"varint,8,opt,name=followPort,proto3" json:"followPort,omitempty"`
}
func (x *Origin) Reset() {
@@ -120,6 +121,13 @@ func (x *Origin) GetHost() string {
return ""
}
func (x *Origin) GetFollowPort() bool {
if x != nil {
return x.FollowPort
}
return false
}
var File_models_model_origin_proto protoreflect.FileDescriptor
var file_models_model_origin_proto_rawDesc = []byte{
@@ -127,7 +135,7 @@ var file_models_model_origin_proto_rawDesc = []byte{
0x72, 0x69, 0x67, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a,
0x22, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x6e, 0x65,
0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x22, 0xb8, 0x01, 0x0a, 0x06, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x12, 0x0e,
0x6f, 0x74, 0x6f, 0x22, 0xd8, 0x01, 0x0a, 0x06, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x12, 0x0e,
0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12,
0x0a, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73,
0x4f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09,
@@ -138,7 +146,9 @@ var file_models_model_origin_proto_rawDesc = []byte{
0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e,
0x12, 0x18, 0x0a, 0x07, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28,
0x09, 0x52, 0x07, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f,
0x73, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x42, 0x06,
0x73, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x1e,
0x0a, 0x0a, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x50, 0x6f, 0x72, 0x74, 0x18, 0x08, 0x20, 0x01,
0x28, 0x08, 0x52, 0x0a, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x50, 0x6f, 0x72, 0x74, 0x42, 0x06,
0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}

View File

@@ -48,6 +48,7 @@ type CreateOriginRequest struct {
Domains []string `protobuf:"bytes,11,rep,name=domains,proto3" json:"domains,omitempty"`
CertRefJSON []byte `protobuf:"bytes,12,opt,name=certRefJSON,proto3" json:"certRefJSON,omitempty"`
Host string `protobuf:"bytes,13,opt,name=host,proto3" json:"host,omitempty"`
FollowPort bool `protobuf:"varint,14,opt,name=followPort,proto3" json:"followPort,omitempty"`
}
func (x *CreateOriginRequest) Reset() {
@@ -173,6 +174,13 @@ func (x *CreateOriginRequest) GetHost() string {
return ""
}
func (x *CreateOriginRequest) GetFollowPort() bool {
if x != nil {
return x.FollowPort
}
return false
}
type CreateOriginResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -240,6 +248,7 @@ type UpdateOriginRequest struct {
Domains []string `protobuf:"bytes,12,rep,name=domains,proto3" json:"domains,omitempty"`
CertRefJSON []byte `protobuf:"bytes,13,opt,name=certRefJSON,proto3" json:"certRefJSON,omitempty"`
Host string `protobuf:"bytes,14,opt,name=host,proto3" json:"host,omitempty"`
FollowPort bool `protobuf:"varint,15,opt,name=followPort,proto3" json:"followPort,omitempty"`
}
func (x *UpdateOriginRequest) Reset() {
@@ -372,6 +381,13 @@ func (x *UpdateOriginRequest) GetHost() string {
return ""
}
func (x *UpdateOriginRequest) GetFollowPort() bool {
if x != nil {
return x.FollowPort
}
return false
}
// 查找单个源站信息
type FindEnabledOriginRequest struct {
state protoimpl.MessageState
@@ -572,7 +588,7 @@ var file_service_origin_proto_rawDesc = []byte{
0x64, 0x65, 0x6c, 0x5f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x61, 0x64, 0x64, 0x72,
0x65, 0x73, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x6d, 0x6f, 0x64, 0x65, 0x6c,
0x73, 0x2f, 0x72, 0x70, 0x63, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x22, 0xad, 0x03, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f,
0x72, 0x6f, 0x74, 0x6f, 0x22, 0xcd, 0x03, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f,
0x72, 0x69, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04,
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65,
0x12, 0x26, 0x0a, 0x04, 0x61, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12,
@@ -599,10 +615,12 @@ var file_service_origin_proto_rawDesc = []byte{
0x0a, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x52, 0x65, 0x66, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0c, 0x20,
0x01, 0x28, 0x0c, 0x52, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x52, 0x65, 0x66, 0x4a, 0x53, 0x4f, 0x4e,
0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
0x68, 0x6f, 0x73, 0x74, 0x22, 0x32, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72,
0x68, 0x6f, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x50, 0x6f,
0x72, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77,
0x50, 0x6f, 0x72, 0x74, 0x22, 0x32, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72,
0x69, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08,
0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08,
0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x22, 0xc9, 0x03, 0x0a, 0x13, 0x55, 0x70, 0x64,
0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x22, 0xe9, 0x03, 0x0a, 0x13, 0x55, 0x70, 0x64,
0x61, 0x74, 0x65, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x03, 0x52, 0x08, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04,
@@ -631,7 +649,9 @@ var file_service_origin_proto_rawDesc = []byte{
0x0a, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x52, 0x65, 0x66, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0d, 0x20,
0x01, 0x28, 0x0c, 0x52, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x52, 0x65, 0x66, 0x4a, 0x53, 0x4f, 0x4e,
0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
0x68, 0x6f, 0x73, 0x74, 0x22, 0x36, 0x0a, 0x18, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62,
0x68, 0x6f, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x50, 0x6f,
0x72, 0x74, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77,
0x50, 0x6f, 0x72, 0x74, 0x22, 0x36, 0x0a, 0x18, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62,
0x6c, 0x65, 0x64, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x03, 0x52, 0x08, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x22, 0x3f, 0x0a, 0x19,

View File

@@ -13,4 +13,5 @@ message Origin {
string description = 5;
repeated string domains = 6;
string host = 7;
bool followPort = 8;
}

View File

@@ -37,6 +37,7 @@ message CreateOriginRequest {
repeated string domains = 11;
bytes certRefJSON = 12;
string host = 13;
bool followPort = 14;
}
message CreateOriginResponse {
@@ -59,6 +60,7 @@ message UpdateOriginRequest {
repeated string domains = 12;
bytes certRefJSON = 13;
string host = 14;
bool followPort = 15;
}
// 查找单个源站信息

View File

@@ -33,6 +33,7 @@ type OriginConfig struct {
StripPrefix string `yaml:"stripPrefix" json:"stripPrefix"` // 去除URL前缀
RequestURI string `yaml:"requestURI" json:"requestURI"` // 转发后的请求URI TODO
RequestHost string `yaml:"requestHost" json:"requestHost"` // 自定义主机名
FollowPort bool `yaml:"followPort" json:"followPort"` // 端口跟随
RequestHeaderPolicyRef *shared.HTTPHeaderPolicyRef `yaml:"requestHeaderPolicyRef" json:"requestHeaderPolicyRef"` // 请求Header
RequestHeaderPolicy *shared.HTTPHeaderPolicy `yaml:"requestHeaderPolicy" json:"requestHeaderPolicy"` // 请求Header策略
@@ -50,7 +51,7 @@ type OriginConfig struct {
FTPServerRef *FTPServerRef `yaml:"ftpServerRef" json:"ftpServerRef"` // TODO
FTPServer *FTPServerConfig `yaml:"ftpServer" json:"ftpServer"` // TODO
IsOk bool `yaml:"isOk" json:"isOk"` // 是否可以正常访问
IsOk bool `yaml:"isOk" json:"isOk"` // 是否可以正常访问,仅仅用于运行时检查
connTimeoutDuration time.Duration
readTimeoutDuration time.Duration