Files
proxypool/proxy/base.go
2020-08-16 11:35:28 +08:00

34 lines
727 B
Go

package proxy
type Base struct {
Name string `yaml:"name" json:"name"`
Server string `yaml:"server" json:"server"`
Port int `yaml:"port" json:"port"`
Type string `yaml:"type" json:"type"`
UDP bool `yaml:"udp,omitempty" json:"udp,omitempty"`
}
type Proxy interface {
String() string
ToClash() string
ToSurge() string
Identifier() string
SetName(name string)
Type() string
BaseInfo() *Base
}
func Deduplication(src []Proxy) []Proxy {
result := make([]Proxy, 0, len(src))
temp := map[string]struct{}{}
for _, item := range src {
if item != nil {
if _, ok := temp[item.Identifier()]; !ok {
temp[item.Identifier()] = struct{}{}
result = append(result, item)
}
}
}
return result
}