mirror of
https://github.com/nxtrace/NTrace-core.git
synced 2025-08-12 06:26:39 +00:00
43 lines
762 B
Go
43 lines
762 B
Go
package plgn
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
|
|
"github.com/sjlleo/nexttrace-core/core"
|
|
)
|
|
|
|
type DebugPlugin struct {
|
|
DefaultPlugin
|
|
DebugLevel int
|
|
}
|
|
|
|
func NewDebugPlugin(params interface{}) core.Plugin {
|
|
debugLevel, ok := params.(int)
|
|
if !ok {
|
|
return nil
|
|
}
|
|
return &DebugPlugin{DebugLevel: debugLevel}
|
|
}
|
|
|
|
func (d *DebugPlugin) OnTTLChange(ttl int) error {
|
|
if d.DebugLevel <= 2 {
|
|
fmt.Println("Debug Level 2: TTL changed to", ttl)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (d *DebugPlugin) OnNewIPFound(ip net.Addr) error {
|
|
if d.DebugLevel <= 2 {
|
|
fmt.Println("Debug Level 2: New IP Found: ", ip)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (d *DebugPlugin) OnTTLCompleted(ttl int, hop []core.Hop) error {
|
|
if d.DebugLevel <= 2 {
|
|
fmt.Println("Debug Level 2: ttl=", ttl, "Hop:", hop)
|
|
}
|
|
return nil
|
|
}
|