Feature: connections add rule payload

This commit is contained in:
Dreamacro 2020-06-07 17:28:56 +08:00
parent fb628e9c62
commit 48cff50a4c
1 changed files with 13 additions and 10 deletions

View File

@ -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
}