github.com/HXSecurity/DongTai-agent-go@v0.4.2/core/kafkaGo/kafkaWriter/install.go (about) 1 package kafkaWriter 2 3 import ( 4 "fmt" 5 6 "github.com/HXSecurity/DongTai-agent-go/model" 7 "github.com/brahma-adshonor/gohook" 8 "github.com/segmentio/kafka-go" 9 ) 10 11 func init() { 12 model.HookMap["kafkaGoWriter"] = new(KafkaWriter) 13 } 14 15 type KafkaWriter struct { 16 } 17 18 func (h *KafkaWriter) Hook() { 19 w := &kafka.Writer{} 20 err := gohook.HookMethod(w, "WriteMessages", WriteMessages, WriteMessagesT) 21 if err != nil { 22 fmt.Println(err, "kafkaGoWriter") 23 } else { 24 fmt.Println("kafkaGoWriter") 25 } 26 } 27 28 func (h *KafkaWriter) UnHook() { 29 cl := &kafka.Writer{} 30 gohook.UnHookMethod(cl, "WriteMessages") 31 }