github.com/imannamdari/v2ray-core/v5@v5.0.5/infra/conf/cfgcommon/sniffer/sniffer.go (about) 1 package sniffer 2 3 import ( 4 "strings" 5 6 "github.com/imannamdari/v2ray-core/v5/app/proxyman" 7 "github.com/imannamdari/v2ray-core/v5/infra/conf/cfgcommon" 8 ) 9 10 //go:generate go run github.com/imannamdari/v2ray-core/v5/common/errors/errorgen 11 12 type SniffingConfig struct { 13 Enabled bool `json:"enabled"` 14 DestOverride *cfgcommon.StringList `json:"destOverride"` 15 MetadataOnly bool `json:"metadataOnly"` 16 } 17 18 // Build implements Buildable. 19 func (c *SniffingConfig) Build() (*proxyman.SniffingConfig, error) { 20 var p []string 21 if c.DestOverride != nil { 22 for _, domainOverride := range *c.DestOverride { 23 switch strings.ToLower(domainOverride) { 24 case "http": 25 p = append(p, "http") 26 case "tls", "https", "ssl": 27 p = append(p, "tls") 28 case "quic": 29 p = append(p, "quic") 30 case "fakedns": 31 p = append(p, "fakedns") 32 case "fakedns+others": 33 p = append(p, "fakedns+others") 34 default: 35 return nil, newError("unknown protocol: ", domainOverride) 36 } 37 } 38 } 39 40 return &proxyman.SniffingConfig{ 41 Enabled: c.Enabled, 42 DestinationOverride: p, 43 MetadataOnly: c.MetadataOnly, 44 }, nil 45 }