diff --git a/client/go/outline/electron/outline_device.go b/client/go/outline/electron/outline_device.go index 360f2bd85e..6c18ae252d 100644 --- a/client/go/outline/electron/outline_device.go +++ b/client/go/outline/electron/outline_device.go @@ -58,17 +58,15 @@ func (d *outlineDevice) Connect() (perr *perrs.PlatformError) { } slog.Debug("[OutlineNetDev] lwIP network stack configured") - slog.Info("successfully connected Outline network device") + slog.Info("[VPN] successfully connected to Outline server") return nil } func (d *outlineDevice) Close() (err error) { if d.IPDevice != nil { - if err = d.IPDevice.Close(); err == nil { - d.IPDevice = nil - } + err = d.IPDevice.Close() } - slog.Info("successfully closed Outline network device") + slog.Info("[VPN] successfully disconnected from Outline server") return } diff --git a/client/go/outline/electron/vpn.go b/client/go/outline/electron/vpn.go index 69170b8538..6e5a70d100 100644 --- a/client/go/outline/electron/vpn.go +++ b/client/go/outline/electron/vpn.go @@ -79,12 +79,12 @@ func EstablishVPN(configStr string) (_ string, perr *perrs.PlatformError) { c.Close() return } - slog.Debug("Establishing VPN connection ...", "id", c.ID()) + slog.Debug("[VPN] Establishing VPN connection ...", "id", c.ID()) if perr = c.Establish(); perr != nil { // No need to call c.Close() cuz it's tracked in the global conn already return } - slog.Info("VPN connection established", "id", c.ID()) + slog.Info("[VPN] VPN connection established", "id", c.ID()) connJson, err := json.Marshal(vpnConnectionJSON{c.ID(), string(c.Status()), c.RouteUDP()}) if err != nil { @@ -106,12 +106,12 @@ func CloseVPN() *perrs.PlatformError { func atomicReplaceVPNConn(newConn VPNConnection) *perrs.PlatformError { mu.Lock() defer mu.Unlock() - slog.Debug("Adding VPN Connection ...", "id", newConn.ID()) + slog.Debug("[VPN] Creating VPN Connection ...", "id", newConn.ID()) if err := closeVPNNoLock(); err != nil { return err } conn = newConn - slog.Info("VPN Connection added", "id", newConn.ID()) + slog.Info("[VPN] VPN Connection created", "id", newConn.ID()) return nil } @@ -119,10 +119,10 @@ func closeVPNNoLock() (perr *perrs.PlatformError) { if conn == nil { return nil } - slog.Debug("Closing existing VPN Connection ...", "id", conn.ID()) + slog.Debug("[VPN] Closing existing VPN Connection ...", "id", conn.ID()) if perr = conn.Close(); perr == nil { + slog.Info("[VPN] VPN Connection closed", "id", conn.ID()) conn = nil - slog.Info("VPN Connection closed", "id", conn.ID()) } return } diff --git a/client/go/outline/electron/vpn_linux.go b/client/go/outline/electron/vpn_linux.go index fb5915b389..b1fd0a79c9 100644 --- a/client/go/outline/electron/vpn_linux.go +++ b/client/go/outline/electron/vpn_linux.go @@ -125,15 +125,15 @@ func (c *linuxVPNConn) Establish() (perr *perrs.PlatformError) { c.wgCopy.Add(2) go func() { defer c.wgCopy.Done() - slog.Debug("Copying traffic from TUN Device -> OutlineDevice...") + slog.Debug("[IO] Copying traffic from TUN Device -> OutlineDevice...") n, err := io.Copy(c.outline, c.tun.File) - slog.Debug("TUN Device -> OutlineDevice done", "n", n, "err", err) + slog.Debug("[IO] TUN Device -> OutlineDevice done", "n", n, "err", err) }() go func() { defer c.wgCopy.Done() - slog.Debug("Copying traffic from OutlineDevice -> TUN Device...") + slog.Debug("[IO] Copying traffic from OutlineDevice -> TUN Device...") n, err := io.Copy(c.tun.File, c.outline) - slog.Debug("OutlineDevice -> TUN Device done", "n", n, "err", err) + slog.Debug("[IO] OutlineDevice -> TUN Device done", "n", n, "err", err) }() return nil diff --git a/client/go/outline/electron/vpnlinux/nmconn_linux.go b/client/go/outline/electron/vpnlinux/nmconn_linux.go index 4cf2a9f355..a4659e3390 100644 --- a/client/go/outline/electron/vpnlinux/nmconn_linux.go +++ b/client/go/outline/electron/vpnlinux/nmconn_linux.go @@ -73,7 +73,7 @@ func NewNMConnection(tun *TUNDevice, dns net.IP) (_ *NMConnection, perr *perrs.P } slog.Debug(nmLogPfx+"saved all new setting values", "setting", c.c.GetPath()) - slog.Info("successfully configured NetworkManager connection", "conn", c.ac.GetPath()) + slog.Info(nmLogPfx+"successfully configured NetworkManager connection", "conn", c.ac.GetPath()) return c, nil } @@ -95,7 +95,7 @@ func (c *NMConnection) Close() *perrs.PlatformError { slog.Debug(nmLogPfx+"connection setting deleted", "setting", c.c.GetPath()) } - slog.Info("cleaned up NetworkManager connection", "conn", c.ac.GetPath(), "setting", c.c.GetPath()) + slog.Info(nmLogPfx+"cleaned up NetworkManager connection", "conn", c.ac.GetPath(), "setting", c.c.GetPath()) return nil } diff --git a/client/go/outline/electron/vpnlinux/routing_linux.go b/client/go/outline/electron/vpnlinux/routing_linux.go index 7bbfda0a3f..63e66bfe86 100644 --- a/client/go/outline/electron/vpnlinux/routing_linux.go +++ b/client/go/outline/electron/vpnlinux/routing_linux.go @@ -48,7 +48,7 @@ func NewRoutingRule(tun *TUNDevice, table, priority int, fwmark uint32) (_ *Rout if err := netlink.RouteAdd(rt); err != nil { return nil, errSetupVPN(nlLogPfx, "failed to add routing entry", err, "table", r.table, "route", rt) } - slog.Debug(nlLogPfx+"routing entry added", "table", r.table, "route", rt) + slog.Info(nlLogPfx+"routing entry added", "table", r.table, "route", rt) // ip rule add not fwmark "0x711E" table "113" priority "456" r.rule = netlink.NewRule() @@ -60,9 +60,8 @@ func NewRoutingRule(tun *TUNDevice, table, priority int, fwmark uint32) (_ *Rout if err := netlink.RuleAdd(r.rule); err != nil { return nil, errSetupVPN(nlLogPfx, "failed to add IP rule", err, "rule", r.rule) } - slog.Debug(nlLogPfx+"IP rule added", "rule", r.rule) + slog.Info(nlLogPfx+"IP rule added", "rule", r.rule) - slog.Info("successfully configured routing", "table", r.table, "rule", r.rule) return r, nil } @@ -75,7 +74,7 @@ func (r *RoutingRule) Close() *perrs.PlatformError { if err := netlink.RuleDel(r.rule); err != nil { return errCloseVPN(nlLogPfx, "failed to delete IP rule", err, "rule", r.rule) } - slog.Debug(nlLogPfx+"deleted IP rule", "rule", r.rule) + slog.Info(nlLogPfx+"deleted IP rule", "rule", r.rule) r.rule = nil } @@ -90,19 +89,20 @@ func (r *RoutingRule) Close() *perrs.PlatformError { var errs error for _, rt := range rts { if err := netlink.RouteDel(&rt); err == nil { - slog.Debug("successfully deleted routing entry", "table", r.table, "route", rt) + slog.Debug(nlLogPfx+"successfully deleted routing entry", "table", r.table, "route", rt) nDel++ } else { - slog.Warn("failed to delete routing entry", "table", r.table, "route", rt, "err", err) + slog.Warn(nlLogPfx+"failed to delete routing entry", "table", r.table, "route", rt, "err", err) errs = errors.Join(errs, err) } } if errs != nil { return errCloseVPN(nlLogPfx, "failed to delete all routig entries", errs, "table", r.table) } - slog.Debug(nlLogPfx+"deleted all routing entries", "table", r.table, "n", nDel) + if nDel > 0 { + slog.Info(nlLogPfx+"deleted all routing entries", "table", r.table, "n", nDel) + } } - slog.Info("successfully cleaned up routing", "table", r.table) return nil } diff --git a/client/go/outline/electron/vpnlinux/tun_linux.go b/client/go/outline/electron/vpnlinux/tun_linux.go index bc899d1905..585cc1d3c2 100644 --- a/client/go/outline/electron/vpnlinux/tun_linux.go +++ b/client/go/outline/electron/vpnlinux/tun_linux.go @@ -77,7 +77,7 @@ func NewTUNDevice(name string, ipCidr *net.IPNet) (_ *TUNDevice, perr *perrs.Pla } slog.Debug(nlLogPfx+"brought up TUN device", "name", tun.name) - slog.Info("successfully configured Outline TUN device", "name", tun.name) + slog.Info("[TUN] successfully configured TUN device", "name", tun.name) return tun, nil } @@ -93,20 +93,18 @@ func (tun *TUNDevice) Close() *perrs.PlatformError { if err := tun.File.Close(); err != nil { return errCloseVPN(ioLogPfx, "failed to close TUN file", err, "name", tun.name) } - slog.Debug(ioLogPfx+"closed TUN file", "name", tun.name) + slog.Info(ioLogPfx+"closed TUN device", "name", tun.name) tun.File = nil } if tun.link != nil { // Typically the previous Close call should delete the TUN device - if err := netlink.LinkDel(tun.link); err != nil && errors.Is(err, syscall.ENODEV) { + if err := netlink.LinkDel(tun.link); err != nil && !errors.Is(err, syscall.ENODEV) { return errCloseVPN(nlLogPfx, "failed to delete TUN device", err, "name", tun.name) } slog.Debug(nlLogPfx+"deleted TUN device", "name", tun.name) tun.link = nil } - slog.Info("cleaned up Outline TUN device", "name", tun.name) - tun.name = "" return nil }