From ce9b1a23c9a2402e903ff8f716a7ac84f5b6472f Mon Sep 17 00:00:00 2001 From: hiddify Date: Thu, 22 Feb 2024 19:08:32 +0100 Subject: [PATCH] make network up after it is availble --- outbound/wireguard.go | 49 +++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/outbound/wireguard.go b/outbound/wireguard.go index c009b56264..442af93787 100644 --- a/outbound/wireguard.go +++ b/outbound/wireguard.go @@ -210,27 +210,27 @@ func (w *WireGuard) Close() error { } func (w *WireGuard) InterfaceUpdated() { - w.logger.Warn("Hiddify! Wirguard! Interface updated!1") - err := w.device.BindUpdate() - // err := fmt.Errorf("Hiddify! downing wireguard interface failed") + // w.logger.Warn("Hiddify! Wirguard! Interface updated!1") + // err := w.device.BindUpdate() + // // err := fmt.Errorf("Hiddify! downing wireguard interface failed") - if err != nil { - w.logger.Error("Hiddify! bind update failed", err) - e1 := w.device.Down() - if e1 != nil { - w.logger.Error("Hiddify! downing wireguard interface failed", e1) - } - w.logger.Warn("Hiddify! uping.... wireguard interface") - e2 := w.device.Up() - if e2 != nil { - w.logger.Error("Hiddify! Uping wireguard interface failed", e2) - } else { - w.logger.Warn("Hiddify! OK!Updating wireguard interface") + // if err != nil { + // w.logger.Error("Hiddify! bind update failed", err) + // e1 := w.device.Down() + // if e1 != nil { + // w.logger.Error("Hiddify! downing wireguard interface failed", e1) + // } + // w.logger.Warn("Hiddify! uping.... wireguard interface") + // e2 := w.device.Up() + // if e2 != nil { + // w.logger.Error("Hiddify! Uping wireguard interface failed", e2) + // } else { + // w.logger.Warn("Hiddify! OK!Updating wireguard interface") - } - } else { - w.logger.Warn("Hiddify! OK2!Updating wireguard interface") - } + // } + // } else { + // w.logger.Warn("Hiddify! OK2!Updating wireguard interface") + // } return } @@ -240,12 +240,15 @@ func (w *WireGuard) onPauseUpdated(event int) { case pause.EventDevicePaused: w.device.Down() - // case EventNetworkPause://hiddify already handled in Interface Updated - // w.device.Down() + case pause.EventNetworkPause: //hiddify already handled in Interface Updated + err := w.device.Down() + w.logger.Warn("Hiddify! Wirguard! downing net! err=", err) + case pause.EventDeviceWake: w.device.Up() - // case pause.EventNetworkWake://hiddify already handled in Interface Updated - // w.device.Up() + case pause.EventNetworkWake: //hiddify already handled in Interface Updated + err := w.device.Up() + w.logger.Warn("Hiddify! Wirguard! Uping net! err=", err) } }