From b1b68a4aa441d9ce39d05f85338e371a704dd601 Mon Sep 17 00:00:00 2001 From: James O'Doherty Date: Fri, 29 May 2026 19:30:26 -0400 Subject: feat(cli,parser): support custom profile names and overhaul WireGuard .conf parser for robustness - CLI: - Add optional `[name]` argument to `wg-wrap profile import [name]` to allow overriding the imported profile name. If not provided, it falls back to the derived filename. - Update `README.md` command documentation to reflect custom profile names and list the `wg-wrap profile stop ` subcommand. - Expand `internal/cli/profile_test.go` to cover derived vs custom-named profile imports. - WG Configuration Parser: - Overhaul `pkg/wgconf/wgconf.go` to support case-insensitivity on section headers (e.g. `[peer]`, `[interface]`) and key names (e.g. `privatekey`, `allowedips`). - Implement robust trailing comment stripping (both `#` and `;`) while preserving inline comment-like characters in cryptographic keys (e.g. `key-with-hash-inside#123`) using whitespace-padded match logic. - Clean up and normalize leading/trailing spaces/tabs on parsed keys, values, and list elements (e.g. `AllowedIPs` and `DNS` fields). - Gracefully ignore unrecognized keys (e.g. `MTU`, `ListenPort`, `PresharedKey`) without returning errors. - Add comprehensive tests in `pkg/wgconf/wgconf_test.go` covering inline/block comments, formatting variations, unrecognized keys, and case-insensitivity. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'README.md') diff --git a/README.md b/README.md index c6d572f..6de14d1 100644 --- a/README.md +++ b/README.md @@ -43,9 +43,10 @@ To simplify usage, `wg-wrap` implements a profile system for managing WireGuard ### Profile Management Commands Beyond wrapping commands, `wg-wrap` provides management sub-commands to handle profiles: - `wg-wrap profile list`: Lists all available profiles in the config directory. -- `wg-wrap profile import `: Imports a `.conf` file into the profiles directory, prompting for a profile name. +- `wg-wrap profile import [name]`: Imports a `.conf` file into the profiles directory. If `[name]` is not provided, the profile name is derived from the `.conf` filename. Otherwise, the specified custom name is used. - `wg-wrap profile configure `: Opens the selected profile in the system's default editor. - `wg-wrap profile delete `: Removes the specified profile. +- `wg-wrap profile stop `: Stops the tunnel/namespace associated with the specified profile and unpins it. ### Diagnostics For debugging and environment verification, `wg-wrap` provides diagnostic tools: -- cgit v1.2.3