-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
networking: Add wireguard keepalive and preshared-key option in the gui #19521
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,19 +104,29 @@ class TestWireGuard(packagelib.PackageCase, netlib.NetworkCase): | |
# peer | ||
b.click("button:contains('Add peer')") | ||
b.wait_visible("#network-wireguard-settings-peer-0") | ||
b.set_input_text("#network-wireguard-settings-publickey-peer-0", m2_pubkey) | ||
b.click("button:contains('Add peer')") | ||
b.wait_visible("#network-wireguard-settings-peer-1") | ||
b.set_input_text("#network-wireguard-settings-publickey-peer-1", m2_pubkey) | ||
b.set_input_text("#network-wireguard-settings-endpoint-peer-1", f"192.168.100.12:{m2_port}") | ||
b.set_input_text("#network-wireguard-settings-allowedips-peer-1", m2_ip4) | ||
|
||
test_pubkey = m1.execute("head -c 32 /dev/random | base64").strip() | ||
b.set_input_text("#network-wireguard-settings-publickey-peer-0", test_pubkey) | ||
b.set_input_text("#network-wireguard-settings-endpoint-peer-0", " 192.168.100.12 ") # test that the extra spaces are trimmed | ||
b.set_input_text("#network-wireguard-settings-allowedips-peer-0", f" {m2_ip4} ") # test that the extra spaces are trimmed | ||
b.click("#network-wireguard-settings-save") | ||
b.wait_visible(".pf-v5-c-alert:contains('Peer #1 has invalid endpoint. It must be specified as host:port, e.g. 1.2.3.4:51820 or example.com:51820')") | ||
b.set_input_text("#network-wireguard-settings-endpoint-peer-0", "192.168.100.12:somestring") | ||
b.click("#network-wireguard-settings-save") | ||
b.wait_visible(".pf-v5-c-alert:contains('Peer #1 has invalid endpoint port. Port must be a number.')") | ||
b.click("button:contains('Add peer')") | ||
b.wait_visible("#network-wireguard-settings-peer-1") | ||
b.set_input_text("#network-wireguard-settings-publickey-peer-1", m2_pubkey) | ||
b.set_input_text("#network-wireguard-settings-endpoint-peer-1", f"192.168.100.12:{m2_port}") | ||
b.set_input_text("#network-wireguard-settings-allowedips-peer-1", m2_ip4) | ||
b.set_input_text("#network-wireguard-settings-endpoint-peer-0", "192.168.100.12:51820") | ||
b.set_input_text("#network-wireguard-settings-keepalive-peer-0", "asdf") | ||
b.click("#network-wireguard-settings-save") | ||
b.wait_visible(".pf-v5-c-alert:contains('Peer #1 has invalid persistent keepalive. It must be a number.')") | ||
b.set_input_text("#network-wireguard-settings-keepalive-peer-0", "60") | ||
b.set_input_text("#network-wireguard-settings-presharedkey-peer-0", "invalidpsk") | ||
b.click("#network-wireguard-settings-save") | ||
b.wait_visible(".pf-v5-c-alert:contains('invalid preshared-key for peer')") | ||
b.click("button#network-wireguard-settings-btn-close-peer-0") | ||
b.wait_not_present("#network-wireguard-settings-peer-1") | ||
b.assert_pixels("#network-wireguard-settings-dialog", "networking-wireguard-add-generated", | ||
|
@@ -127,10 +137,23 @@ class TestWireGuard(packagelib.PackageCase, netlib.NetworkCase): | |
b.wait_not_present("#network-wireguard-settings-dialog") | ||
b.wait_in_text(f"#networking-interfaces th:contains('{iface_name}') + td", f"1.2.3.4/32, {m1_ip4}/24") | ||
|
||
b.click(f"#networking-interfaces button:contains('{iface_name}')") | ||
b.wait_visible("#network-interface") | ||
b.click("#networking-edit-wg") | ||
b.wait_visible("#network-wireguard-settings-dialog") | ||
b.set_input_text("#network-wireguard-settings-keepalive-peer-0", "120") | ||
psk = m1.execute("head -c 32 /dev/random | base64").strip() | ||
b.set_input_text("#network-wireguard-settings-presharedkey-peer-0", psk) | ||
Comment on lines
+144
to
+146
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please also validate these settings in the API or with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, good idea! Done, thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did it with |
||
b.click("#network-wireguard-settings-save") | ||
b.wait_not_present("#network-wireguard-settings-dialog") | ||
m1.execute(f"until wg showconf wg0 | grep -q 'PresharedKey.*{psk}'; do sleep 1; done") | ||
m1.execute("until wg showconf wg0 | grep -q 'PersistentKeepalive.*120'; do sleep 1; done") | ||
|
||
# if some wg properties are not valid, for example, if it was changed by some external tool, don't crash | ||
m1.execute("sed -i '/allowed-ips/d' /etc/NetworkManager/system-connections/con-wg0.nmconnection") | ||
m1.execute("systemctl restart NetworkManager") | ||
b.reload() | ||
b.go("/network") | ||
b.enter_page("/network") | ||
b.wait_visible("#networking") | ||
b.click(f"#networking-interfaces button:contains('{iface_name}')") | ||
|
@@ -149,6 +172,7 @@ class TestWireGuard(packagelib.PackageCase, netlib.NetworkCase): | |
b2.click("button:contains('Add peer')") | ||
b2.set_input_text("#network-wireguard-settings-publickey-peer-0", m1_pubkey) | ||
b2.set_input_text("#network-wireguard-settings-allowedips-peer-0", f"{m1_ip4}/32") | ||
b2.set_input_text("#network-wireguard-settings-presharedkey-peer-0", psk) | ||
b2.click("#network-wireguard-settings-save") | ||
b2.wait_not_present("#network-wireguard-settings-dialog") | ||
b2.wait_in_text(f"#networking-interfaces th:contains('{m2_iface_name}') + td", f"{m2_ip4}/24") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably it should also check for ≥ 1 and possibly some maximum? Also, can this be a float?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dbus type for Keepalive is 'u', so it has to be >=0. Passing negative or float shows an error in the UI. Like below:
I opened an issue for a better error message at #19645.
0 (zero) means "not set" as usual.
I couldn't find a documented maximum value, but little experiment shows it can be in the range 0 to 65535 (i.e. 2^16 possible values).. after that it overflows without any error.