tap program output much more readable

This commit is contained in:
soypat
2025-06-04 01:13:26 -03:00
parent 589c9d3013
commit bc14ed395d
4 changed files with 113 additions and 23 deletions
+9
View File
@@ -12,6 +12,7 @@ import (
"time"
"github.com/soypat/lneto/internal/ltesto"
"github.com/soypat/lneto/internet/pcap"
)
func main() {
@@ -39,6 +40,14 @@ func run() error {
return err
}
defer sv.Close()
var cap pcap.PacketBreakdown
sv.OnTransfer(func(channel int, pkt []byte) {
captime := time.Now()
frames, err := cap.CaptureEthernet(nil, pkt, 0)
if err == nil {
fmt.Println(channel, captime.Format("15:04:05.000"), frames)
}
})
hwaddr, err := sv.HardwareAddress6()
if err != nil {
return err