From 48cff50a4ce4c2f9d799f7e08a400663e0dcdea6 Mon Sep 17 00:00:00 2001 From: Dreamacro <305009791@qq.com> Date: Sun, 7 Jun 2020 17:28:56 +0800 Subject: [PATCH] Feature: connections add rule payload --- tunnel/tracker.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tunnel/tracker.go b/tunnel/tracker.go index 2be5220..c887169 100644 --- a/tunnel/tracker.go +++ b/tunnel/tracker.go @@ -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 }