Investigate ^C behaviour

This commit is contained in:
Josh Deprez 2024-04-07 13:08:15 +10:00
parent 2c4eb80595
commit a59d7f7584
Signed by: josh
SSH key fingerprint: SHA256:zZji7w1Ilh2RuUpbQcqkLPrqmRwpiCSycbF2EfKm6Kw

View file

@ -31,6 +31,7 @@ import (
"gitea.drjosh.dev/josh/jrouter/atalk" "gitea.drjosh.dev/josh/jrouter/atalk"
"gitea.drjosh.dev/josh/jrouter/aurp" "gitea.drjosh.dev/josh/jrouter/aurp"
"github.com/google/gopacket/pcap"
"github.com/sfiera/multitalk/pkg/ddp" "github.com/sfiera/multitalk/pkg/ddp"
"github.com/sfiera/multitalk/pkg/ethernet" "github.com/sfiera/multitalk/pkg/ethernet"
"github.com/sfiera/multitalk/pkg/ethertalk" "github.com/sfiera/multitalk/pkg/ethertalk"
@ -157,7 +158,15 @@ func main() {
go func() { go func() {
for { for {
if ctx.Err() != nil {
return
}
rawPkt, _, err := pcapHandle.ReadPacketData() rawPkt, _, err := pcapHandle.ReadPacketData()
if errors.Is(err, pcap.NextErrorTimeoutExpired) {
continue
}
if err != nil { if err != nil {
log.Fatalf("Couldn't read AppleTalk / AARP packet data: %v", err) log.Fatalf("Couldn't read AppleTalk / AARP packet data: %v", err)
} }