Skip to content

network applet: fix WireGuard connection state handling - #13986

Open
wocisjr wants to merge 1 commit into
linuxmint:masterfrom
wocisjr:fix-wireguard-applet-state
Open

network applet: fix WireGuard connection state handling#13986
wocisjr wants to merge 1 commit into
linuxmint:masterfrom
wocisjr:fix-wireguard-applet-state

Conversation

@wocisjr

@wocisjr wocisjr commented Sep 9, 2026

Copy link
Copy Markdown

Three separate issues in the WireGuard part of the network applet:

  • NMDeviceWIREGUARD kept a single _activeConnection, so when more than one tunnel was up, _syncActiveConnections() overwrote it once per active connection and only the last one seen was shown as connected. It now keeps a list of active connections, mirroring what NMDeviceVPN already does, so every tunnel that is up gets its dot, and clicking a row toggles that specific tunnel instead of only ever activating it.

  • _connectionRemoved() called this._connections.splice(pos) without a delete count, which drops every element from pos to the end of the array rather than the single removed connection. Removing one profile could therefore silently discard unrelated ones from the applet's bookkeeping, leaving menu rows without their label or toggle state until Cinnamon was restarted.

  • _updateIcon() runs entirely inside a try/catch, so anything thrown in it leaves the icon and tooltip frozen at their previous values. Two throws lived there: reading _switch.state off this._devices.wireguard.item without checking that the switch exists, and dereferencing mc._section in the VPN loop when there is no main connection at all. Both are now guarded, and the VPN and WireGuard cases share one code path.

The tooltip now also names every active tunnel rather than just the first.

Tested against NetworkManager 1.46.0 on Cinnamon 6.6.9 with three concurrent WireGuard tunnels, including removing both a running and a stopped profile.

Three separate issues in the WireGuard part of the network applet:

* NMDeviceWIREGUARD kept a single _activeConnection, so when more than one
  tunnel was up, _syncActiveConnections() overwrote it once per active
  connection and only the last one seen was shown as connected. It now keeps
  a list of active connections, mirroring what NMDeviceVPN already does, so
  every tunnel that is up gets its dot, and clicking a row toggles that
  specific tunnel instead of only ever activating it.

* _connectionRemoved() called this._connections.splice(pos) without a delete
  count, which drops every element from pos to the end of the array rather
  than the single removed connection. Removing one profile could therefore
  silently discard unrelated ones from the applet's bookkeeping, leaving menu
  rows without their label or toggle state until Cinnamon was restarted.

* _updateIcon() runs entirely inside a try/catch, so anything thrown in it
  leaves the icon and tooltip frozen at their previous values. Two throws
  lived there: reading _switch.state off this._devices.wireguard.item without
  checking that the switch exists, and dereferencing mc._section in the VPN
  loop when there is no main connection at all. Both are now guarded, and the
  VPN and WireGuard cases share one code path.

The tooltip now also names every active tunnel rather than just the first.

Tested against NetworkManager 1.46.0 on Cinnamon 6.6.9 with three concurrent
WireGuard tunnels, including removing both a running and a stopped profile.
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

Best-practices scanner

This is a regex-based check for API usage that can pose security, performance or
maintainability issues, or that may already be provided by Cinnamon. Most findings
are advisory and do not automatically disqualify a pull request.

This check is not perfect and will not replace a normal review.


Found 2 potential issue(s):

⚠️ WARNING

⚠️ lang_bind

files/usr/share/cinnamon/applets/network@cinnamon.org/applet.js:1157

obj.item.connect('activate', Lang.bind(this, function() {

Lang.bind() is deprecated. Use arrow functions (() => {}) or Function.prototype.bind() instead.

files/usr/share/cinnamon/applets/network@cinnamon.org/applet.js:1965

this._devices.wireguard.device.connect('active-connections-changed', Lang.bind(this, function() {

Lang.bind() is deprecated. Use arrow functions (() => {}) or Function.prototype.bind() instead.


Automated pattern check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant