Files
proxypool/proxy/base.go
2020-08-12 17:58:51 +08:00

31 lines
676 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
Identifier() string
SetName(name string)
}
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
}