mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-14 21:31:16 +08:00
Feature: connections add rule payload
This commit is contained in:
parent
fb628e9c62
commit
48cff50a4c
@ -21,6 +21,7 @@ type trackerInfo struct {
|
||||
Start time.Time `json:"start"`
|
||||
Chain C.Chain `json:"chains"`
|
||||
Rule string `json:"rule"`
|
||||
RulePayload string `json:"rulePayload"`
|
||||
}
|
||||
|
||||
type tcpTracker struct {
|
||||
@ -56,10 +57,6 @@ func (tt *tcpTracker) Close() error {
|
||||
|
||||
func newTCPTracker(conn C.Conn, manager *Manager, metadata *C.Metadata, rule C.Rule) *tcpTracker {
|
||||
uuid, _ := uuid.NewV4()
|
||||
ruleType := ""
|
||||
if rule != nil {
|
||||
ruleType = rule.RuleType().String()
|
||||
}
|
||||
|
||||
t := &tcpTracker{
|
||||
Conn: conn,
|
||||
@ -69,10 +66,15 @@ func newTCPTracker(conn C.Conn, manager *Manager, metadata *C.Metadata, rule C.R
|
||||
Start: time.Now(),
|
||||
Metadata: metadata,
|
||||
Chain: conn.Chains(),
|
||||
Rule: ruleType,
|
||||
Rule: "",
|
||||
},
|
||||
}
|
||||
|
||||
if rule != nil {
|
||||
t.trackerInfo.Rule = rule.RuleType().String()
|
||||
t.trackerInfo.RulePayload = rule.Payload()
|
||||
}
|
||||
|
||||
manager.Join(t)
|
||||
return t
|
||||
}
|
||||
@ -118,10 +120,6 @@ func (ut *udpTracker) Close() error {
|
||||
|
||||
func newUDPTracker(conn C.PacketConn, manager *Manager, metadata *C.Metadata, rule C.Rule) *udpTracker {
|
||||
uuid, _ := uuid.NewV4()
|
||||
ruleType := ""
|
||||
if rule != nil {
|
||||
ruleType = rule.RuleType().String()
|
||||
}
|
||||
|
||||
ut := &udpTracker{
|
||||
PacketConn: conn,
|
||||
@ -131,10 +129,15 @@ func newUDPTracker(conn C.PacketConn, manager *Manager, metadata *C.Metadata, ru
|
||||
Start: time.Now(),
|
||||
Metadata: metadata,
|
||||
Chain: conn.Chains(),
|
||||
Rule: ruleType,
|
||||
Rule: "",
|
||||
},
|
||||
}
|
||||
|
||||
if rule != nil {
|
||||
ut.trackerInfo.Rule = rule.RuleType().String()
|
||||
ut.trackerInfo.RulePayload = rule.Payload()
|
||||
}
|
||||
|
||||
manager.Join(ut)
|
||||
return ut
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user