Skip to content

Commit

Permalink
ipn/wg: avoid closing the events channel twice
Browse files Browse the repository at this point in the history
  • Loading branch information
ignoramous committed Aug 9, 2023
1 parent 60c76a1 commit fa5af8c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions intra/ipn/wgproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,19 @@ func (tun *wgtun) WriteNotify() {
}

func (tun *wgtun) Close() error {
// TODO: move this to wgproxy.Close()?
// should work: go.dev/play/p/HeU5EvzAjnv
if tun.status == END {
log.W("proxy: wg: tun: already closed?")
return errProxyStopped
}

tun.status = END
tun.stack.RemoveNIC(wgnic)

if tun.events != nil {
close(tun.events)
}
// if tun.events != nil {
// panics; is it closed by device.Device.Close()?
// close(tun.events) }

tun.stack.Close()
tun.ep.Close()
Expand Down

1 comment on commit fa5af8c

@ignoramous
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.