Added psk support for configs and a test script#1
Open
jordanwiseman wants to merge 15 commits into
Open
Conversation
export config
may be missing
that the modified wgctl.sh functions as needed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add pre-shared key (PSK) support
Adds an optional
use-pskflag toadd peerthat enables WireGuard's PresharedKey feature for an added layer of post-quantum protection on individual peer connections.What changed
wgctl.shadd peeraccepts a newuse-psk [psk]option. If no key is supplied, one is generated automatically viaopenssl rand --base64 32. An explicitly supplied PSK is validated against the standard WireGuard base64 format ([A-Za-z0-9+/]{43}=).usePSK.show_interfacerenders aPresharedKeyline in the INI output for peers that have one.apply_interfacewritesPresharedKey = ...into the generated.conffile for PSK-enabled peers.export_peerincludesPresharedKeyin the client-side config output when the peer has a PSK.ERR_MISSING_VALUE(28) for keyed options called without a value, andERR_INVALID_PSK(29) for a malformed key.openssladded to the required-tools check at startup.return #ERR_INVALID_PORTwas a no-op comment instead ofreturn $ERR_INVALID_PORT.test_wgctl.sh(new)A self-contained unit test suite covering the full command surface. Requires no root and no real WireGuard installation;
wg,wg-quick, andopensslare replaced by mock binaries, and the script sourceswgctl.shfunctions directly after stripping the privilege guards withawk. Coverage includes happy-path and error-path cases forcreate_interface,show_interface,list_interfaces,add_peer(including PSK generation, explicit PSK, invalid PSK formats, subnet exhaustion, and duplicate detection),enable_peer/disable_peer,remove_peer,export_peer, andapply_interface.README.mduse-psk [psk]to theadd peeroptions reference.use-pskin action.