fix: wireguard reconnect failed

This commit is contained in:
wwqgtxx
2023-04-13 17:01:01 +08:00
parent 38a85272c2
commit 394889258c
3 changed files with 12 additions and 4 deletions

View File

@ -174,7 +174,7 @@ func NewWireGuard(option WireGuardOption) (*WireGuard, error) {
connectAddr = option.Addr()
}
}
outbound.bind = wireguard.NewClientBind(context.Background(), outbound.dialer, isConnect, connectAddr, reserved)
outbound.bind = wireguard.NewClientBind(context.Background(), outbound, outbound.dialer, isConnect, connectAddr, reserved)
var localPrefixes []netip.Prefix
@ -329,6 +329,14 @@ func NewWireGuard(option WireGuardOption) (*WireGuard, error) {
return outbound, nil
}
func (w *WireGuard) NewError(ctx context.Context, err error) {
if E.IsClosedOrCanceled(err) {
log.SingLogger.Debug(fmt.Sprintf("[WG](%s) connection closed: %s", w.Name(), err))
return
}
log.SingLogger.Error(fmt.Sprintf("[WG](%s) %s", w.Name(), err))
}
func closeWireGuard(w *WireGuard) {
if w.device != nil {
w.device.Close()