增加SysLockerService等;提供多个便捷函数
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
package serverconfigs
|
||||
|
||||
const (
|
||||
DefaultTCPPortRangeMin = 10000
|
||||
DefaultTCPPortRangeMax = 40000
|
||||
)
|
||||
|
||||
// 服务相关的全局设置
|
||||
type GlobalConfig struct {
|
||||
// HTTP & HTTPS相关配置
|
||||
@@ -14,11 +19,15 @@ type GlobalConfig struct {
|
||||
|
||||
HTTP struct{} `yaml:"http" json:"http"`
|
||||
HTTPS struct{} `yaml:"https" json:"https"`
|
||||
TCPAll struct{} `yaml:"tcpAll" json:"tcpAll"`
|
||||
TCP struct{} `yaml:"tcp" json:"tcp"`
|
||||
TLS struct{} `yaml:"tls" json:"tls"`
|
||||
Unix struct{} `yaml:"unix" json:"unix"`
|
||||
UDP struct{} `yaml:"udp" json:"udp"`
|
||||
TCPAll struct {
|
||||
PortRangeMin int `yaml:"portRangeMin" json:"portRangeMin"` // 最小端口
|
||||
PortRangeMax int `yaml:"portRangeMax" json:"portRangeMax"` // 最大端口
|
||||
DenyPorts []int `yaml:"denyPorts" json:"denyPorts"` // 禁止使用的端口
|
||||
} `yaml:"tcpAll" json:"tcpAll"`
|
||||
TCP struct{} `yaml:"tcp" json:"tcp"`
|
||||
TLS struct{} `yaml:"tls" json:"tls"`
|
||||
Unix struct{} `yaml:"unix" json:"unix"`
|
||||
UDP struct{} `yaml:"udp" json:"udp"`
|
||||
|
||||
// IP库相关配置
|
||||
IPLibrary struct {
|
||||
|
||||
@@ -2,6 +2,17 @@ package serverconfigs
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
func NewTCPProtocolConfigFromJSON(configJSON []byte) (*TCPProtocolConfig, error) {
|
||||
config := &TCPProtocolConfig{}
|
||||
if len(configJSON) > 0 {
|
||||
err := json.Unmarshal(configJSON, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return config, nil
|
||||
}
|
||||
|
||||
type TCPProtocolConfig struct {
|
||||
BaseProtocol `yaml:",inline"`
|
||||
}
|
||||
|
||||
@@ -1,6 +1,20 @@
|
||||
package serverconfigs
|
||||
|
||||
import "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
|
||||
)
|
||||
|
||||
func NewTLSProtocolConfigFromJSON(configJSON []byte) (*TLSProtocolConfig, error) {
|
||||
config := &TLSProtocolConfig{}
|
||||
if len(configJSON) > 0 {
|
||||
err := json.Unmarshal(configJSON, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return config, nil
|
||||
}
|
||||
|
||||
// TLS协议配置
|
||||
type TLSProtocolConfig struct {
|
||||
@@ -26,3 +40,8 @@ func (this *TLSProtocolConfig) Init() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// 转换为JSON
|
||||
func (this *TLSProtocolConfig) AsJSON() ([]byte, error) {
|
||||
return json.Marshal(this)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package serverconfigs
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type UDPProtocolConfig struct {
|
||||
BaseProtocol `yaml:",inline"`
|
||||
}
|
||||
@@ -12,3 +14,8 @@ func (this *UDPProtocolConfig) Init() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// 转换为JSON
|
||||
func (this *UDPProtocolConfig) AsJSON() ([]byte, error) {
|
||||
return json.Marshal(this)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package serverconfigs
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type UnixProtocolConfig struct {
|
||||
BaseProtocol `yaml:",inline"`
|
||||
}
|
||||
@@ -12,3 +14,8 @@ func (this *UnixProtocolConfig) Init() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// 转换为JSON
|
||||
func (this *UnixProtocolConfig) AsJSON() ([]byte, error) {
|
||||
return json.Marshal(this)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user