mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-06 20:28:40 +00:00
Feat: sniffer exclude domain & ip
This commit is contained in:
parent
14189eba07
commit
06fc82bad1
31 changed files with 653 additions and 411 deletions
|
@ -91,13 +91,20 @@ func NewAlwaysOnInboundHandler(ctx context.Context, tag string, receiverConfig *
|
|||
if net.HasNetwork(nl, net.Network_UNIX) {
|
||||
newError("creating unix domain socket worker on ", address).AtDebug().WriteToLog()
|
||||
|
||||
sc := receiverConfig.GetEffectiveSniffingSettings()
|
||||
sm, err := proxyman.NewSniffingMatcher(sc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
worker := &dsWorker{
|
||||
address: address,
|
||||
proxy: p,
|
||||
stream: mss,
|
||||
tag: tag,
|
||||
dispatcher: h.mux,
|
||||
sniffingConfig: receiverConfig.GetEffectiveSniffingSettings(),
|
||||
sniffingConfig: sc,
|
||||
sniffingMatcher: sm,
|
||||
uplinkCounter: uplinkCounter,
|
||||
downlinkCounter: downlinkCounter,
|
||||
ctx: ctx,
|
||||
|
@ -110,6 +117,12 @@ func NewAlwaysOnInboundHandler(ctx context.Context, tag string, receiverConfig *
|
|||
if net.HasNetwork(nl, net.Network_TCP) {
|
||||
newError("creating stream worker on ", address, ":", port).AtDebug().WriteToLog()
|
||||
|
||||
sc := receiverConfig.GetEffectiveSniffingSettings()
|
||||
sm, err := proxyman.NewSniffingMatcher(sc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
worker := &tcpWorker{
|
||||
address: address,
|
||||
port: net.Port(port),
|
||||
|
@ -118,7 +131,8 @@ func NewAlwaysOnInboundHandler(ctx context.Context, tag string, receiverConfig *
|
|||
recvOrigDest: receiverConfig.ReceiveOriginalDestination,
|
||||
tag: tag,
|
||||
dispatcher: h.mux,
|
||||
sniffingConfig: receiverConfig.GetEffectiveSniffingSettings(),
|
||||
sniffingConfig: sc,
|
||||
sniffingMatcher: sm,
|
||||
uplinkCounter: uplinkCounter,
|
||||
downlinkCounter: downlinkCounter,
|
||||
ctx: ctx,
|
||||
|
|
|
@ -39,6 +39,7 @@ type tcpWorker struct {
|
|||
tag string
|
||||
dispatcher routing.Dispatcher
|
||||
sniffingConfig *proxyman.SniffingConfig
|
||||
sniffingMatcher *proxyman.SniffingMatcher
|
||||
uplinkCounter stats.Counter
|
||||
downlinkCounter stats.Counter
|
||||
|
||||
|
@ -97,7 +98,8 @@ func (w *tcpWorker) callback(conn internet.Connection) {
|
|||
if w.sniffingConfig != nil {
|
||||
content.SniffingRequest.Enabled = w.sniffingConfig.Enabled
|
||||
content.SniffingRequest.OverrideDestinationForProtocol = w.sniffingConfig.DestinationOverride
|
||||
content.SniffingRequest.ExcludeForDomain = w.sniffingConfig.DomainsExcluded
|
||||
content.SniffingRequest.ExcludedDomainMatcher = w.sniffingMatcher.ExDomain
|
||||
content.SniffingRequest.ExcludedIPMatcher = w.sniffingMatcher.ExIP
|
||||
content.SniffingRequest.MetadataOnly = w.sniffingConfig.MetadataOnly
|
||||
}
|
||||
ctx = session.ContextWithContent(ctx, content)
|
||||
|
@ -428,6 +430,7 @@ type dsWorker struct {
|
|||
tag string
|
||||
dispatcher routing.Dispatcher
|
||||
sniffingConfig *proxyman.SniffingConfig
|
||||
sniffingMatcher *proxyman.SniffingMatcher
|
||||
uplinkCounter stats.Counter
|
||||
downlinkCounter stats.Counter
|
||||
|
||||
|
@ -459,7 +462,8 @@ func (w *dsWorker) callback(conn internet.Connection) {
|
|||
if w.sniffingConfig != nil {
|
||||
content.SniffingRequest.Enabled = w.sniffingConfig.Enabled
|
||||
content.SniffingRequest.OverrideDestinationForProtocol = w.sniffingConfig.DestinationOverride
|
||||
content.SniffingRequest.ExcludeForDomain = w.sniffingConfig.DomainsExcluded
|
||||
content.SniffingRequest.ExcludedDomainMatcher = w.sniffingMatcher.ExDomain
|
||||
content.SniffingRequest.ExcludedIPMatcher = w.sniffingMatcher.ExIP
|
||||
content.SniffingRequest.MetadataOnly = w.sniffingConfig.MetadataOnly
|
||||
}
|
||||
ctx = session.ContextWithContent(ctx, content)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue