mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-03 04:10:25 +08:00
智能DNS支持自定义端口
This commit is contained in:
6255
build/rpc.json
6255
build/rpc.json
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,10 @@
|
||||
|
||||
package dnsconfigs
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
)
|
||||
|
||||
type NSNodeConfig struct {
|
||||
Id int64 `yaml:"id" json:"id"`
|
||||
@@ -12,6 +15,10 @@ type NSNodeConfig struct {
|
||||
AccessLogRef *NSAccessLogRef `yaml:"accessLogRef" json:"accessLogRef"`
|
||||
RecursionConfig *RecursionConfig `yaml:"recursionConfig" json:"recursionConfig"`
|
||||
|
||||
TCP *serverconfigs.TCPProtocolConfig `yaml:"tcp" json:"tcp"` // TCP配置
|
||||
TLS *serverconfigs.TLSProtocolConfig `yaml:"tls" json:"tls"` // TLS配置
|
||||
UDP *serverconfigs.UDPProtocolConfig `yaml:"udp" json:"udp"` // UDP配置
|
||||
|
||||
paddedId string
|
||||
}
|
||||
|
||||
@@ -26,6 +33,30 @@ func (this *NSNodeConfig) Init() error {
|
||||
}
|
||||
}
|
||||
|
||||
// tcp
|
||||
if this.TCP != nil {
|
||||
err := this.TCP.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// tls
|
||||
if this.TLS != nil {
|
||||
err := this.TLS.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// udp
|
||||
if this.UDP != nil {
|
||||
err := this.UDP.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,9 @@ type NSCluster struct {
|
||||
IsOn bool `protobuf:"varint,2,opt,name=isOn,proto3" json:"isOn,omitempty"`
|
||||
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
|
||||
InstallDir string `protobuf:"bytes,4,opt,name=installDir,proto3" json:"installDir,omitempty"`
|
||||
TcpJSON []byte `protobuf:"bytes,5,opt,name=tcpJSON,proto3" json:"tcpJSON,omitempty"`
|
||||
TlsJSON []byte `protobuf:"bytes,6,opt,name=tlsJSON,proto3" json:"tlsJSON,omitempty"`
|
||||
UdpJSON []byte `protobuf:"bytes,7,opt,name=udpJSON,proto3" json:"udpJSON,omitempty"`
|
||||
}
|
||||
|
||||
func (x *NSCluster) Reset() {
|
||||
@@ -97,19 +100,45 @@ func (x *NSCluster) GetInstallDir() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *NSCluster) GetTcpJSON() []byte {
|
||||
if x != nil {
|
||||
return x.TcpJSON
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *NSCluster) GetTlsJSON() []byte {
|
||||
if x != nil {
|
||||
return x.TlsJSON
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *NSCluster) GetUdpJSON() []byte {
|
||||
if x != nil {
|
||||
return x.UdpJSON
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_models_model_ns_cluster_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_models_model_ns_cluster_proto_rawDesc = []byte{
|
||||
0x0a, 0x1d, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x6e,
|
||||
0x73, 0x5f, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
|
||||
0x02, 0x70, 0x62, 0x22, 0x63, 0x0a, 0x09, 0x4e, 0x53, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72,
|
||||
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, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x6e, 0x73, 0x74,
|
||||
0x61, 0x6c, 0x6c, 0x44, 0x69, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e,
|
||||
0x73, 0x74, 0x61, 0x6c, 0x6c, 0x44, 0x69, 0x72, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62,
|
||||
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x02, 0x70, 0x62, 0x22, 0xb1, 0x01, 0x0a, 0x09, 0x4e, 0x53, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65,
|
||||
0x72, 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, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x6e, 0x73,
|
||||
0x74, 0x61, 0x6c, 0x6c, 0x44, 0x69, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69,
|
||||
0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x44, 0x69, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x63, 0x70,
|
||||
0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x74, 0x63, 0x70, 0x4a,
|
||||
0x53, 0x4f, 0x4e, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x6c, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x06,
|
||||
0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x74, 0x6c, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x18, 0x0a,
|
||||
0x07, 0x75, 0x64, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07,
|
||||
0x75, 0x64, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62,
|
||||
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,4 +9,7 @@ message NSCluster {
|
||||
bool isOn = 2;
|
||||
string name = 3;
|
||||
string installDir = 4;
|
||||
bytes tcpJSON = 5;
|
||||
bytes tlsJSON = 6;
|
||||
bytes udpJSON = 7;
|
||||
}
|
||||
@@ -40,6 +40,24 @@ service NSClusterService {
|
||||
|
||||
// 读取递归DNS配置
|
||||
rpc findNSClusterRecursionConfig(FindNSClusterRecursionConfigRequest) returns (FindNSClusterRecursionConfigResponse);
|
||||
|
||||
// 查找集群的TCP设置
|
||||
rpc findNSClusterTCPConfig(FindNSClusterTCPConfigRequest) returns (FindNSClusterTCPConfigResponse);
|
||||
|
||||
// 修改集群的TCP设置
|
||||
rpc updateNSClusterTCP (UpdateNSClusterTCPRequest) returns (RPCSuccess);
|
||||
|
||||
// 查找集群的TLS设置
|
||||
rpc findNSClusterTLSConfig(FindNSClusterTLSConfigRequest) returns (FindNSClusterTLSConfigResponse);
|
||||
|
||||
// 修改集群的TLS设置
|
||||
rpc updateNSClusterTLS (UpdateNSClusterTLSRequest) returns (RPCSuccess);
|
||||
|
||||
// 查找集群的UDP设置
|
||||
rpc findNSClusterUDPConfig(FindNSClusterUDPConfigRequest) returns (FindNSClusterUDPConfigResponse);
|
||||
|
||||
// 修改集群的UDP设置
|
||||
rpc updateNSClusterUDP (UpdateNSClusterUDPRequest) returns (RPCSuccess);
|
||||
}
|
||||
|
||||
// 创建集群
|
||||
@@ -124,4 +142,49 @@ message FindNSClusterRecursionConfigRequest {
|
||||
|
||||
message FindNSClusterRecursionConfigResponse {
|
||||
bytes recursionJSON = 1;
|
||||
}
|
||||
|
||||
// 查找集群的TCP设置
|
||||
message FindNSClusterTCPConfigRequest {
|
||||
int64 nsClusterId = 1;
|
||||
}
|
||||
|
||||
message FindNSClusterTCPConfigResponse {
|
||||
bytes tcpJSON = 1;
|
||||
}
|
||||
|
||||
// 查找集群的TLS设置
|
||||
message FindNSClusterTLSConfigRequest {
|
||||
int64 nsClusterId = 1;
|
||||
}
|
||||
|
||||
message FindNSClusterTLSConfigResponse {
|
||||
bytes tlsJSON = 1;
|
||||
}
|
||||
|
||||
// 查找集群的UDP设置
|
||||
message FindNSClusterUDPConfigRequest {
|
||||
int64 nsClusterId = 1;
|
||||
}
|
||||
|
||||
message FindNSClusterUDPConfigResponse {
|
||||
bytes udpJSON = 1;
|
||||
}
|
||||
|
||||
// 修改集群的TCP设置
|
||||
message UpdateNSClusterTCPRequest {
|
||||
int64 nsClusterId = 1;
|
||||
bytes tcpJSON = 2;
|
||||
}
|
||||
|
||||
// 修改集群的TLS设置
|
||||
message UpdateNSClusterTLSRequest {
|
||||
int64 nsClusterId = 1;
|
||||
bytes tlsJSON = 2;
|
||||
}
|
||||
|
||||
// 修改集群的UDP设置
|
||||
message UpdateNSClusterUDPRequest {
|
||||
int64 nsClusterId = 1;
|
||||
bytes udpJSON = 2;
|
||||
}
|
||||
@@ -16,7 +16,7 @@ func NewHTTPSProtocolConfigFromJSON(configJSON []byte) (*HTTPSProtocolConfig, er
|
||||
return config, nil
|
||||
}
|
||||
|
||||
// HTTPS协议配置
|
||||
// HTTPSProtocolConfig HTTPS协议配置
|
||||
type HTTPSProtocolConfig struct {
|
||||
BaseProtocol `yaml:",inline"`
|
||||
|
||||
@@ -24,7 +24,7 @@ type HTTPSProtocolConfig struct {
|
||||
SSLPolicy *sslconfigs.SSLPolicy `yaml:"sslPolicy" json:"sslPolicy"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
// Init 初始化
|
||||
func (this *HTTPSProtocolConfig) Init() error {
|
||||
err := this.InitBase()
|
||||
if err != nil {
|
||||
@@ -41,7 +41,7 @@ func (this *HTTPSProtocolConfig) Init() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 转换为JSON
|
||||
// AsJSON 转换为JSON
|
||||
func (this *HTTPSProtocolConfig) AsJSON() ([]byte, error) {
|
||||
return json.Marshal(this)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ func (this *TCPProtocolConfig) Init() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 转换为JSON
|
||||
// AsJSON 转换为JSON
|
||||
func (this *TCPProtocolConfig) AsJSON() ([]byte, error) {
|
||||
return json.Marshal(this)
|
||||
}
|
||||
|
||||
@@ -55,9 +55,9 @@ func FindServerType(code string) maps.Map {
|
||||
return nil
|
||||
}
|
||||
|
||||
// AllServerProtocolsForType 获取所有协议
|
||||
func AllServerProtocolsForType(serverType ServerType) []maps.Map {
|
||||
protocols := []maps.Map{
|
||||
// FindAllServerProtocols 查找所有协议
|
||||
func FindAllServerProtocols() []maps.Map {
|
||||
return []maps.Map{
|
||||
{
|
||||
"name": "HTTP",
|
||||
"code": "http",
|
||||
@@ -89,10 +89,13 @@ func AllServerProtocolsForType(serverType ServerType) []maps.Map {
|
||||
"serverTypes": []ServerType{ServerTypeUDPProxy},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
result := []maps.Map{}
|
||||
for _, p := range protocols {
|
||||
serverTypes := p.GetSlice("serverTypes")
|
||||
// FindAllServerProtocolsForType 获取所有协议
|
||||
func FindAllServerProtocolsForType(serverType ServerType) []maps.Map {
|
||||
var result = []maps.Map{}
|
||||
for _, p := range FindAllServerProtocols() {
|
||||
var serverTypes = p.GetSlice("serverTypes")
|
||||
if lists.Contains(serverTypes, serverType) {
|
||||
result = append(result, p)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user