Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/vpn panic #887

Merged
merged 3 commits into from
Sep 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions pkg/router/route_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,16 +619,18 @@ func (rg *RouteGroup) handleNetworkProbePacket(packet routing.Packet) error {
}

func (rg *RouteGroup) handleDataPacket(packet routing.Packet) error {

// in this case remote is already closed, and `readCh` is closed too,
// but some packets may still reach the rg causing panic on writing
// to `readCh`, so we simple omit such packets
if rg.isRemoteClosed() {
return nil
}
rg.networkStats.AddBandwidthReceived(uint64(packet.Size()))

select {
case <-rg.closed:
return io.ErrClosedPipe
case <-rg.remoteClosed:
// in this case remote is already closed, and `readCh` is closed too,
// but some packets may still reach the rg causing panic on writing
// to `readCh`, so we simple omit such packets
return nil
case rg.readCh <- packet.Payload():
}

Expand Down