Repository navigation
Port the network page to the rewritten NetworkMgr API - #13
Conversation
NetworkMgr renamed its net_api functions and moved scan results out of
network_dictionary() into scan_networks(), which returns dicts instead
of index-based lists, so setup-station failed to import at startup.
Networks are now saved through wpa_supplicant's control socket rather
than appended to wpa_supplicant.conf. The config is written only after
a connection succeeds, with the other saved networks re-enabled first
so they are not stored as disabled. A failed attempt reopens the dialog
titled "Could not connect to {ssid}", and a failed save of the config
is reported on the status line.
The page scans once in the background when it opens, and connecting
to a saved or open network no longer blocks the GTK thread.
Extract the two new network page strings into the template and merge them into every language file.
Reviewer's GuideUpdates the network setup page for the rewritten NetworkMgr API, adds asynchronous scanning and connection attempts, and delegates network persistence to wpa_supplicant while improving failure feedback and translations. Sequence diagram for asynchronous Wi-Fi scan refreshsequenceDiagram
participant Page as NetworkSetup
participant Worker as Scan worker
participant API as NetworkMgr
participant GTK as GTK main loop
Page->>API: scan_networks(wifi_card)
Page->>Worker: scan_and_refresh(wifi_card)
Worker->>API: wait_for_daemon(wifi_card)
Worker->>API: request_scan(wifi_card)
Worker->>Worker: sleep(SCAN_WAIT)
Worker->>API: scan_networks(wifi_card)
Worker->>GTK: GLib.idle_add(refresh_networks, networks)
GTK->>Page: refresh_networks(networks)
Sequence diagram for background Wi-Fi connection and persistencesequenceDiagram
participant User
participant Page as NetworkSetup
participant Worker as Connection worker
participant API as NetworkMgr
participant GTK as GTK main loop
User->>Page: Select network
Page->>API: save_psk_network(ssid, security, password, card)
Page->>Worker: connect_in_background(network, card)
Worker->>API: connect_to_ssid(ssid, card)
Worker->>API: wait_for_connection(card, ssid)
Worker->>API: enable_all_networks(card)
alt Connected
Worker->>API: wpa_save_config(card)
Worker->>GTK: GLib.idle_add(connection_finished, ...)
GTK->>Page: connection_finished(network_info, ssid, saved)
else Failed
Worker->>API: wpa_reconfigure(card)
Worker->>GTK: GLib.idle_add(restart_authentication, network, card)
GTK->>Page: restart_authentication(network, card)
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 6 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="setup_station/network_setup.py" line_range="330" />
<code_context>
+ network: Access point record from scan_networks()
+ card: Name of the wireless network interface
+ """
+ threading.Thread(
target=cls.try_to_connect_to_ssid,
- args=(ssid_info[0], ssid_info, card),
</code_context>
<issue_to_address>
**Connection attempts interfere**
When the user selects another network before a connection worker finishes, `connect_in_background` starts another worker, and both workers change, reconfigure, or save the same supplicant state; an earlier attempt can disrupt the later one or publish or save a stale result, so the connection and saved configuration can disagree.
Serialize connection attempts or prevent further selections until the active worker finishes.
Also at `setup_station/network_setup.py:349-368`.
</issue_to_address>
### Comment 2
<location path="setup_station/network_setup.py" line_range="349" />
<code_context>
+ connected = connect_to_ssid(ssid, card) and wait_for_connection(card, ssid)
+ # select_network disabled every other saved network. Re-enable them
+ # before saving, or the file keeps them disabled for good.
+ enable_all_networks(card)
+ if connected:
+ saved = wpa_save_config(card)
</code_context>
<issue_to_address>
**Disabled networks become enabled**
When the wpa_supplicant configuration contains a network intentionally marked disabled and this connection succeeds, `enable_all_networks(card)` also enables profiles that were already disabled before this attempt, and the subsequent `wpa_save_config(card)` persists that change. Those networks can then auto-connect despite having been intentionally disabled.
Preserve each profile’s prior disabled state and re-enable only profiles disabled by this connection attempt before saving.
</issue_to_address>
### Comment 3
<location path="setup_station/network_setup.py" line_range="349-351" />
<code_context>
+ connected = connect_to_ssid(ssid, card) and wait_for_connection(card, ssid)
+ # select_network disabled every other saved network. Re-enable them
+ # before saving, or the file keeps them disabled for good.
+ enable_all_networks(card)
+ if connected:
+ saved = wpa_save_config(card)
+ GLib.idle_add(cls.connection_finished, network_dictionary(), ssid, saved)
else:
</code_context>
<issue_to_address>
**Disabled profiles remain saved**
When re-enabling networks fails while the selected connection succeeds, `try_to_connect_to_ssid` ignores the result of `enable_all_networks` and still calls `wpa_save_config`, saving other networks as disabled and preventing them from reconnecting automatically after a restart.
Check whether `enable_all_networks` succeeded and avoid saving the configuration as successful when it did not.
</issue_to_address>
### Comment 4
<location path="setup_station/network_setup.py" line_range="315" />
<code_context>
+ if ssid_is_saved(ssid, card):
+ stored = update_psk_network(ssid, pwd, card)
+ else:
+ stored = save_psk_network(ssid, network['security'], pwd, card) is not None
+ if stored:
+ cls.connect_in_background(network, card)
</code_context>
<issue_to_address>
**WEP networks cannot connect**
When the selected access point uses WEP security, `wifi_setup` sends every non-open network through `save_psk_network`, which is the PSK credential path. WEP access points therefore cannot be saved or connected through this flow, even though the removed `setup_wpa_supplicant` code wrote WEP keys for networks that were neither RSN nor WPA.
Handle WEP with a supported WEP credential API, or clearly reject it rather than routing it through the PSK path.
</issue_to_address>
### Comment 5
<location path="setup_station/network_setup.py" line_range="255-257" />
<code_context>
+ Args:
+ wifi_card: Name of the wireless network interface
+ """
+ if wait_for_daemon(wifi_card) and request_scan(wifi_card):
+ sleep(SCAN_WAIT)
+ GLib.idle_add(cls.refresh_networks, scan_networks(wifi_card))
+
+ @classmethod
</code_context>
<issue_to_address>
**Access point list stays stale**
When the daemon is unavailable or scan results take longer than four seconds, `scan_and_refresh` can skip `request_scan` or read the table before it is updated, then publish that result without retrying; access points remain stale or absent until another page initialization.
Wait for the daemon and scan completion, or retry until fresh results are available before refreshing the list.
</issue_to_address>
### Comment 6
<location path="setup_station/network_setup.py" line_range="355" />
<code_context>
- GLib.idle_add(cls.restart_authentication, ssid_info, card)
- return
+ wpa_reconfigure(card)
+ GLib.idle_add(cls.restart_authentication, network, card)
+
+ @classmethod
</code_context>
<issue_to_address>
**Open-network failures go unnoticed**
When an open-network connection attempt fails, `try_to_connect_to_ssid` schedules `restart_authentication`, but that handler skips OPEN networks and no other failure handler updates the status; the user sees no failure indication and the page retains stale connection status.
Handle failed OPEN attempts by refreshing the status and showing a failure indication instead of relying on `restart_authentication`.
Also at `setup_station/network_setup.py:384-385`.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 6 findings to address first, and before saving a successful connection, the code enables every saved network and persists the supplicant configuration, including profiles a user may have deliberately disabled. Those networks could reconnect and expose traffic; reverting the code will not restore the prior saved settings or undo any exposure.
Blocking findings: setup_station/network_setup.py:330, setup_station/network_setup.py:349, setup_station/network_setup.py:351, setup_station/network_setup.py:315, setup_station/network_setup.py:257, and 1 more
Both pages had the same connect code with diverging fixes. Copy install-station's page, adjusted for setup-station's package and CSS path, so setup-station gains the Rescan button, the WPA-Enterprise dialog, the connection spinner and the locked list during an attempt. This also addresses the review findings on overlapping connection attempts, a stale access point list with no way to refresh it, and a failed open network giving no feedback.
Add the strings from the new network page, fill every untranslated string in all language files and replace the fuzzy guesses msgmerge made, which are ignored at runtime and were often wrong. Existing translations are kept. The files are now UTF-8, since their headers declared ASCII.
NetworkMgr renamed its
net_apifunctions and moved the scan results out ofnetwork_dictionary()intoscan_networks(), which returns dicts instead of index-based lists. setup-station failed to import at startup with the new NetworkMgr.Changes
scan_networks()./etc/wpa_supplicant.conf. The config is written only after a connection succeeds, so a wrong password never reaches disk.select_networkdisables them, and saving first stored them asdisabled=1.Same changes as ghostbsd/install-station#21.
Summary by Sourcery
Modernize the network setup page for the rewritten NetworkMgr API and improve Wi-Fi scanning, authentication, persistence, and responsiveness.
New Features:
Bug Fixes:
Enhancements:
Build:
Chores: