ping: Fix not handling reject

This commit is contained in:
世界 2025-08-27 00:12:17 +08:00
parent 055fe13ec0
commit 4c43f4af12
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
3 changed files with 21 additions and 5 deletions

View file

@ -4,6 +4,7 @@ package tun
import (
"context"
"errors"
"net/netip"
"sync"
"time"
@ -73,7 +74,10 @@ func (f *ICMPForwarder) HandlePacket(id stack.TransportEndpointID, pkt *stack.Pa
timeout,
)
})
if err != nil {
if errors.Is(err, ErrReset) {
gWriteUnreachable(f.stack, pkt)
return true
} else if errors.Is(err, ErrDrop) {
return true
}
if action != nil {
@ -132,7 +136,10 @@ func (f *ICMPForwarder) HandlePacket(id stack.TransportEndpointID, pkt *stack.Pa
timeout,
)
})
if err != nil {
if errors.Is(err, ErrReset) {
gWriteUnreachable(f.stack, pkt)
return true
} else if errors.Is(err, ErrDrop) {
return true
}
if action != nil {