mirror of
https://github.com/sigcn/pg.git
synced 2025-09-27 04:30:13 +08:00
vpn: gracefully handles err in func nicRead
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
"log/slog"
|
||||
"net"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/sigcn/pg/netlink"
|
||||
@@ -89,10 +88,7 @@ func (vpn *VPN) nicRead(wg *sync.WaitGroup, nic *nic.VirtualNIC) {
|
||||
for {
|
||||
packet, err := nic.Read()
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), os.ErrClosed.Error()) {
|
||||
return
|
||||
}
|
||||
if errors.Is(err, net.ErrClosed) {
|
||||
if errors.Is(err, os.ErrClosed) || errors.Is(err, net.ErrClosed) {
|
||||
return
|
||||
}
|
||||
panic(err)
|
||||
|
Reference in New Issue
Block a user