智能DNS支持自定义端口

This commit is contained in:
刘祥超
2022-07-27 16:56:32 +08:00
parent f6b3a0b829
commit 262dcf0c8d
9 changed files with 4285 additions and 3187 deletions

View File

@@ -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)
}

View File

@@ -26,7 +26,7 @@ func (this *TCPProtocolConfig) Init() error {
return nil
}
// 转换为JSON
// AsJSON 转换为JSON
func (this *TCPProtocolConfig) AsJSON() ([]byte, error) {
return json.Marshal(this)
}

View File

@@ -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)
}