fix: wireguard reconnect failed
This commit is contained in:
parent
316522de53
commit
3267da1292
3 changed files with 12 additions and 4 deletions
|
@ -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()
|
||||
|
|
2
go.mod
2
go.mod
|
@ -22,7 +22,7 @@ require (
|
|||
github.com/metacubex/quic-go v0.33.3-0.20230322045857-901b636b4594
|
||||
github.com/metacubex/sing-shadowsocks v0.2.2-0.20230409073201-1ce3505114ae
|
||||
github.com/metacubex/sing-tun v0.1.3
|
||||
github.com/metacubex/sing-wireguard v0.0.0-20230402083957-d134f603ac98
|
||||
github.com/metacubex/sing-wireguard v0.0.0-20230413082948-e51777dcf025
|
||||
github.com/miekg/dns v1.1.52
|
||||
github.com/mroth/weightedrand/v2 v2.0.0
|
||||
github.com/openacid/low v0.1.21
|
||||
|
|
4
go.sum
4
go.sum
|
@ -100,8 +100,8 @@ github.com/metacubex/sing-shadowsocks v0.2.2-0.20230409073201-1ce3505114ae h1:SN
|
|||
github.com/metacubex/sing-shadowsocks v0.2.2-0.20230409073201-1ce3505114ae/go.mod h1:JefDbbkQHCn8w+IcjFqMOMV2VmN9wvbYX4RaeBUkPwM=
|
||||
github.com/metacubex/sing-tun v0.1.3 h1:LCz8TlAZUWwnBYZxs1PEE04PyfLA9xdsye6CjHZlZGQ=
|
||||
github.com/metacubex/sing-tun v0.1.3/go.mod h1:kHkYHoRlYA4I12QPTt/ADyRGqy5YweLUfye1E1hC/q4=
|
||||
github.com/metacubex/sing-wireguard v0.0.0-20230402083957-d134f603ac98 h1:Dr6A4drhVkjPaJ5lIf3DwhH2HSo+Qmf8fCQmJoDG5YU=
|
||||
github.com/metacubex/sing-wireguard v0.0.0-20230402083957-d134f603ac98/go.mod h1:7mPG9qYln+CLKBcDt7Dk4c7b3S53VzEfexMVPe6T6FM=
|
||||
github.com/metacubex/sing-wireguard v0.0.0-20230413082948-e51777dcf025 h1:itjCqEeem+BKZFiBEhQmWHDHKK4FgTGvnYCFS0JOb3A=
|
||||
github.com/metacubex/sing-wireguard v0.0.0-20230413082948-e51777dcf025/go.mod h1:7mPG9qYln+CLKBcDt7Dk4c7b3S53VzEfexMVPe6T6FM=
|
||||
github.com/metacubex/uber-atomic v0.0.0-20230202125923-feb10b770370 h1:UkViS4DCESAUEYgbIEQdD02hyMacFt6Dny+1MOJtNIo=
|
||||
github.com/metacubex/uber-atomic v0.0.0-20230202125923-feb10b770370/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
github.com/miekg/dns v1.1.52 h1:Bmlc/qsNNULOe6bpXcUTsuOajd0DzRHwup6D9k1An0c=
|
||||
|
|
Loading…
Reference in a new issue