mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-06-19 22:58:03 +03:00
Feat: sniffer exclude domain & ip
This commit is contained in:
@ -1,5 +1,12 @@
|
||||
package proxyman
|
||||
|
||||
import (
|
||||
"github.com/xtls/xray-core/common/matcher/domain"
|
||||
"github.com/xtls/xray-core/common/matcher/geoip"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/xtls/xray-core/common/errors/errorgen
|
||||
|
||||
func (s *AllocationStrategy) GetConcurrencyValue() uint32 {
|
||||
if s == nil || s.Concurrency == nil {
|
||||
return 3
|
||||
@ -37,3 +44,28 @@ func (c *ReceiverConfig) GetEffectiveSniffingSettings() *SniffingConfig {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type SniffingMatcher struct {
|
||||
ExDomain *domain.DomainMatcher
|
||||
ExIP *geoip.MultiGeoIPMatcher
|
||||
}
|
||||
|
||||
func NewSniffingMatcher(sc *SniffingConfig) (*SniffingMatcher, error) {
|
||||
m := new(SniffingMatcher)
|
||||
|
||||
if sc.DomainsExcluded != nil {
|
||||
exDomain, err := domain.NewDomainMatcher(sc.DomainsExcluded)
|
||||
if err != nil {
|
||||
return nil, newError("failed to parse domain").Base(err)
|
||||
}
|
||||
m.ExDomain = exDomain
|
||||
}
|
||||
if sc.IpsExcluded != nil {
|
||||
exIP, err := geoip.NewMultiGeoIPMatcher(sc.IpsExcluded, true)
|
||||
if err != nil {
|
||||
return nil, newError("failed to parse ip").Base(err)
|
||||
}
|
||||
m.ExIP = exIP
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user