mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 09:18:34 +00:00
Feature: Exclude some domains in sniffing destOverride (#151)
Co-authored-by: RPRX <63339210+rprx@users.noreply.github.com>
This commit is contained in:
parent
7f5e34c857
commit
0b4858d016
6 changed files with 127 additions and 94 deletions
|
@ -58,29 +58,38 @@ func toProtocolList(s []string) ([]proxyman.KnownProtocols, error) {
|
|||
}
|
||||
|
||||
type SniffingConfig struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
DestOverride *StringList `json:"destOverride"`
|
||||
Enabled bool `json:"enabled"`
|
||||
DestOverride *StringList `json:"destOverride"`
|
||||
DomainsExcluded *StringList `json:"domainsExcluded"`
|
||||
}
|
||||
|
||||
// Build implements Buildable.
|
||||
func (c *SniffingConfig) Build() (*proxyman.SniffingConfig, error) {
|
||||
var p []string
|
||||
if c.DestOverride != nil {
|
||||
for _, domainOverride := range *c.DestOverride {
|
||||
switch strings.ToLower(domainOverride) {
|
||||
for _, protocol := range *c.DestOverride {
|
||||
switch strings.ToLower(protocol) {
|
||||
case "http":
|
||||
p = append(p, "http")
|
||||
case "tls", "https", "ssl":
|
||||
p = append(p, "tls")
|
||||
default:
|
||||
return nil, newError("unknown protocol: ", domainOverride)
|
||||
return nil, newError("unknown protocol: ", protocol)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var d []string
|
||||
if c.DomainsExcluded != nil {
|
||||
for _, domain := range *c.DomainsExcluded {
|
||||
d = append(d, strings.ToLower(domain))
|
||||
}
|
||||
}
|
||||
|
||||
return &proxyman.SniffingConfig{
|
||||
Enabled: c.Enabled,
|
||||
DestinationOverride: p,
|
||||
DomainsExcluded: d,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue