mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-06-13 21:54:13 +08:00
Add sniff info
This commit is contained in:
parent
afde16ef64
commit
4a66ad7093
@ -5,6 +5,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/sagernet/sing-box/adapter"
|
"github.com/sagernet/sing-box/adapter"
|
||||||
|
C "github.com/sagernet/sing-box/constant"
|
||||||
"github.com/sagernet/sing/common"
|
"github.com/sagernet/sing/common"
|
||||||
"github.com/sagernet/sing/common/atomic"
|
"github.com/sagernet/sing/common/atomic"
|
||||||
"github.com/sagernet/sing/common/bufio"
|
"github.com/sagernet/sing/common/bufio"
|
||||||
@ -41,6 +42,19 @@ func (t TrackerMetadata) MarshalJSON() ([]byte, error) {
|
|||||||
} else {
|
} else {
|
||||||
domain = t.Metadata.Destination.Fqdn
|
domain = t.Metadata.Destination.Fqdn
|
||||||
}
|
}
|
||||||
|
var sniffURL string
|
||||||
|
if t.Metadata.Protocol != "" {
|
||||||
|
sniffURL = t.Metadata.Protocol
|
||||||
|
if t.Metadata.Client != "" {
|
||||||
|
sniffURL += ":" + t.Metadata.Client
|
||||||
|
}
|
||||||
|
if t.Metadata.Domain != "" {
|
||||||
|
switch t.Metadata.Protocol {
|
||||||
|
case C.ProtocolHTTP, C.ProtocolQUIC, C.ProtocolTLS:
|
||||||
|
sniffURL += "://" + t.Metadata.Domain
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
var processPath string
|
var processPath string
|
||||||
if t.Metadata.ProcessInfo != nil {
|
if t.Metadata.ProcessInfo != nil {
|
||||||
if t.Metadata.ProcessInfo.ProcessPath != "" {
|
if t.Metadata.ProcessInfo.ProcessPath != "" {
|
||||||
@ -74,6 +88,7 @@ func (t TrackerMetadata) MarshalJSON() ([]byte, error) {
|
|||||||
"sourcePort": F.ToString(t.Metadata.Source.Port),
|
"sourcePort": F.ToString(t.Metadata.Source.Port),
|
||||||
"destinationPort": F.ToString(t.Metadata.Destination.Port),
|
"destinationPort": F.ToString(t.Metadata.Destination.Port),
|
||||||
"host": domain,
|
"host": domain,
|
||||||
|
"sniffHost": sniffURL,
|
||||||
"dnsMode": "normal",
|
"dnsMode": "normal",
|
||||||
"processPath": processPath,
|
"processPath": processPath,
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user