mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-03 20:40:25 +08:00
删除一直未实现的Unix协议相关内容
This commit is contained in:
@@ -73,10 +73,6 @@ func (this *NetworkAddressConfig) Init() error {
|
||||
|
||||
// Addresses 所有的地址列表,不包括scheme
|
||||
func (this *NetworkAddressConfig) Addresses() []string {
|
||||
if this.Protocol == ProtocolUnix {
|
||||
return []string{this.Host}
|
||||
}
|
||||
|
||||
result := []string{}
|
||||
for i := this.MinPort; i <= this.MaxPort; i++ {
|
||||
host := this.Host
|
||||
@@ -87,10 +83,6 @@ func (this *NetworkAddressConfig) Addresses() []string {
|
||||
|
||||
// FullAddresses 所有的地址列表,包含scheme
|
||||
func (this *NetworkAddressConfig) FullAddresses() []string {
|
||||
if this.Protocol == ProtocolUnix {
|
||||
return []string{this.Protocol.String() + ":" + this.Host}
|
||||
}
|
||||
|
||||
result := []string{}
|
||||
for i := this.MinPort; i <= this.MaxPort; i++ {
|
||||
host := this.Host
|
||||
|
||||
@@ -9,10 +9,10 @@ const (
|
||||
ProtocolHTTPS Protocol = "https"
|
||||
ProtocolTCP Protocol = "tcp"
|
||||
ProtocolTLS Protocol = "tls"
|
||||
ProtocolUnix Protocol = "unix"
|
||||
ProtocolUDP Protocol = "udp"
|
||||
|
||||
// 子协议
|
||||
|
||||
ProtocolHTTP4 Protocol = "http4"
|
||||
ProtocolHTTP6 Protocol = "http6"
|
||||
|
||||
@@ -27,7 +27,7 @@ const (
|
||||
)
|
||||
|
||||
func AllProtocols() []Protocol {
|
||||
return []Protocol{ProtocolHTTP, ProtocolHTTPS, ProtocolTCP, ProtocolTLS, ProtocolUnix, ProtocolUDP, ProtocolHTTP4, ProtocolHTTP6, ProtocolHTTPS4, ProtocolHTTPS6, ProtocolTCP4, ProtocolTCP6, ProtocolTLS4, ProtocolTLS6}
|
||||
return []Protocol{ProtocolHTTP, ProtocolHTTPS, ProtocolTCP, ProtocolTLS, ProtocolUDP, ProtocolHTTP4, ProtocolHTTP6, ProtocolHTTPS4, ProtocolHTTPS6, ProtocolTCP4, ProtocolTCP6, ProtocolTLS4, ProtocolTLS6}
|
||||
}
|
||||
|
||||
func (this Protocol) IsHTTPFamily() bool {
|
||||
@@ -46,10 +46,6 @@ func (this Protocol) IsTLSFamily() bool {
|
||||
return this == ProtocolTLS || this == ProtocolTLS4 || this == ProtocolTLS6
|
||||
}
|
||||
|
||||
func (this Protocol) IsUnixFamily() bool {
|
||||
return this == ProtocolUnix
|
||||
}
|
||||
|
||||
func (this Protocol) IsUDPFamily() bool {
|
||||
return this == ProtocolUDP
|
||||
}
|
||||
@@ -69,8 +65,6 @@ func (this Protocol) Primary() Protocol {
|
||||
return ProtocolTCP
|
||||
case ProtocolTLS, ProtocolTLS4, ProtocolTLS6:
|
||||
return ProtocolTLS
|
||||
case ProtocolUnix:
|
||||
return ProtocolUnix
|
||||
case ProtocolUDP:
|
||||
return ProtocolUDP
|
||||
default:
|
||||
|
||||
@@ -17,6 +17,5 @@ func TestProtocol_IsHTTPFamily(t *testing.T) {
|
||||
a.IsTrue(ProtocolTCP.IsTCPFamily())
|
||||
a.IsTrue(ProtocolTCP.IsTCPFamily())
|
||||
a.IsTrue(ProtocolTCP6.IsTCPFamily())
|
||||
a.IsTrue(ProtocolUnix.IsUnixFamily())
|
||||
a.IsTrue(ProtocolUDP.IsUDPFamily())
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package serverconfigs
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type UnixProtocolConfig struct {
|
||||
BaseProtocol `yaml:",inline"`
|
||||
}
|
||||
|
||||
func (this *UnixProtocolConfig) Init() error {
|
||||
err := this.InitBase()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// 转换为JSON
|
||||
func (this *UnixProtocolConfig) AsJSON() ([]byte, error) {
|
||||
return json.Marshal(this)
|
||||
}
|
||||
@@ -86,9 +86,6 @@ func (this *ServerAddressGroup) Protocol() Protocol {
|
||||
// Addr 获取当前分组的地址
|
||||
func (this *ServerAddressGroup) Addr() string {
|
||||
protocol := this.Protocol()
|
||||
if protocol == ProtocolUnix {
|
||||
return strings.TrimPrefix(this.fullAddr, protocol.String()+":")
|
||||
}
|
||||
return strings.TrimPrefix(this.fullAddr, protocol.String()+"://")
|
||||
}
|
||||
|
||||
@@ -121,12 +118,6 @@ func (this *ServerAddressGroup) IsTLS() bool {
|
||||
return p == ProtocolTLS || p == ProtocolTLS4 || p == ProtocolTLS6
|
||||
}
|
||||
|
||||
// IsUnix 判断当前分组是否为Unix
|
||||
func (this *ServerAddressGroup) IsUnix() bool {
|
||||
p := this.Protocol()
|
||||
return p == ProtocolUnix
|
||||
}
|
||||
|
||||
// IsUDP 判断当前分组是否为UDP
|
||||
func (this *ServerAddressGroup) IsUDP() bool {
|
||||
p := this.Protocol()
|
||||
|
||||
@@ -27,12 +27,6 @@ func TestServerAddressGroup_Protocol(t *testing.T) {
|
||||
a.IsTrue(group.Protocol() == ProtocolHTTP)
|
||||
a.IsTrue(group.Addr() == "127.0.0.1:1234")
|
||||
}
|
||||
|
||||
{
|
||||
group := NewServerAddressGroup("unix:/tmp/my.sock")
|
||||
a.IsTrue(group.Protocol() == ProtocolUnix)
|
||||
a.IsTrue(group.Addr() == "/tmp/my.sock")
|
||||
}
|
||||
}
|
||||
|
||||
func TestServerAddressGroup_MatchServerName(t *testing.T) {
|
||||
|
||||
@@ -32,7 +32,6 @@ type ServerConfig struct {
|
||||
HTTPS *HTTPSProtocolConfig `yaml:"https" json:"https"` // HTTPS配置
|
||||
TCP *TCPProtocolConfig `yaml:"tcp" json:"tcp"` // TCP配置
|
||||
TLS *TLSProtocolConfig `yaml:"tls" json:"tls"` // TLS配置
|
||||
Unix *UnixProtocolConfig `yaml:"unix" json:"unix"` // Unix配置
|
||||
UDP *UDPProtocolConfig `yaml:"udp" json:"udp"` // UDP配置
|
||||
|
||||
// Web配置
|
||||
@@ -214,13 +213,6 @@ func (this *ServerConfig) Init(ctx context.Context) (results []error) {
|
||||
}
|
||||
}
|
||||
|
||||
if this.Unix != nil {
|
||||
err := this.Unix.Init()
|
||||
if err != nil {
|
||||
results = append(results, err)
|
||||
}
|
||||
}
|
||||
|
||||
if this.UDP != nil {
|
||||
err := this.UDP.Init()
|
||||
if err != nil {
|
||||
@@ -295,9 +287,6 @@ func (this *ServerConfig) FullAddresses() []string {
|
||||
if this.TLS != nil && this.TLS.IsOn {
|
||||
result = append(result, this.TLS.FullAddresses()...)
|
||||
}
|
||||
if this.Unix != nil && this.Unix.IsOn {
|
||||
result = append(result, this.Unix.FullAddresses()...)
|
||||
}
|
||||
if this.UDP != nil && this.UDP.IsOn {
|
||||
result = append(result, this.UDP.FullAddresses()...)
|
||||
}
|
||||
@@ -319,9 +308,6 @@ func (this *ServerConfig) Listen() []*NetworkAddressConfig {
|
||||
if this.TLS != nil {
|
||||
result = append(result, this.TLS.Listen...)
|
||||
}
|
||||
if this.Unix != nil {
|
||||
result = append(result, this.Unix.Listen...)
|
||||
}
|
||||
if this.UDP != nil {
|
||||
result = append(result, this.UDP.Listen...)
|
||||
}
|
||||
@@ -340,10 +326,6 @@ func (this *ServerConfig) IsTCPFamily() bool {
|
||||
return this.TCP != nil || this.TLS != nil
|
||||
}
|
||||
|
||||
func (this *ServerConfig) IsUnixFamily() bool {
|
||||
return this.Unix != nil
|
||||
}
|
||||
|
||||
func (this *ServerConfig) IsUDPFamily() bool {
|
||||
return this.UDP != nil
|
||||
}
|
||||
|
||||
@@ -22,16 +22,6 @@ func TestServerConfig_Protocols(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}}
|
||||
server.HTTPS = &HTTPSProtocolConfig{BaseProtocol: BaseProtocol{
|
||||
IsOn: true,
|
||||
Listen: []*NetworkAddressConfig{
|
||||
{
|
||||
Protocol: ProtocolUnix,
|
||||
Host: "/hello.sock",
|
||||
PortRange: "1235",
|
||||
},
|
||||
},
|
||||
}}
|
||||
server.TCP = &TCPProtocolConfig{BaseProtocol: BaseProtocol{
|
||||
IsOn: true,
|
||||
Listen: []*NetworkAddressConfig{
|
||||
@@ -50,15 +40,6 @@ func TestServerConfig_Protocols(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}}
|
||||
server.Unix = &UnixProtocolConfig{BaseProtocol: BaseProtocol{
|
||||
IsOn: true,
|
||||
Listen: []*NetworkAddressConfig{
|
||||
{
|
||||
Protocol: ProtocolTLS,
|
||||
PortRange: "1234",
|
||||
},
|
||||
},
|
||||
}}
|
||||
server.UDP = &UDPProtocolConfig{BaseProtocol: BaseProtocol{
|
||||
IsOn: true,
|
||||
Listen: []*NetworkAddressConfig{
|
||||
|
||||
Reference in New Issue
Block a user