Add import directory functionality for Wireguard tunnels#20
Merged
Conversation
Owner
|
Hi, thank you for your interest in my project. I like the PR. I’ll adjust it to work with a ZIP archive as you suggested. I’ll also personally look into performance issues when handling a large number of tunnels. As for the “delete all tunnels” functionality, I considered adding it a while back but decided against it because it feels potentially dangerous. I assumed that anyone who truly wants to wipe all tunnels would go through the trouble of running Thank you. |
… handle conflicts
Structured error handling:
- Replace catch-all Error::WgTui(String) with 7 typed variants:
InvalidInterfaceName, TunnelAlreadyExists, Config, CommandFailed,
Validation, Import, NoTunnelsToExport
- Migrate all 27 call sites in wireguard.rs to appropriate variants
DRY config parsing:
- Extract WgConfig parser struct with parse(), interface_value(),
all_values(), interface_has_any_key() to replace 4 functions that
duplicated INI-section parsing boilerplate
- Optimize add_server_peer() to parse config once instead of 5 times
Stronger path types:
- Change import_tunnel, import_zip_conflict_count, import_tunnels,
export_tunnels_to_zip from &str to &Path parameters
- Move expand_path() calls to call sites in app layer
- Extract open_conf_archive() helper to deduplicate zip validation
Split monolithic app.rs (1412 lines) into focused modules:
- app.rs: App struct, AppFlags bitfield, core state management
- app/input.rs: event handling, all consume_* handlers
- app/render.rs: draw() and all render_* methods
- app/wizard.rs: wizard types and supporting structs
Consolidate duplicated patterns:
- Extract InputAction enum + handle_text_input() helper to eliminate
7x duplicated Backspace/Char/Esc match arms across input handlers
- Define WizardSteps trait implemented by both Client and Server
wizards, replacing manual 5-method delegation
- Add NewTunnelWizard::create() to collapse duplicated completion
branches from 24 lines to 8
- Unify interface name validation into single shared helper
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.
Hey- feel free to reject this as out-of-scope, but I just found this tool and it's minimal and neat, and I'd love the ability to import a whole directory of configurations (as you might get from a VPN service with a configurator).
I've not really used Rust before, so this is an experiment and a learning exercise.
I did consider implementing an "import from ZIP", and that might actually be a neater idea as it would perfectly mirror the "export to ZIP" functionality. Perhaps also a "delete all routes" function, although with some form of protection (require a key combo, or to enter a randomly generated string)?
Additionally, the program seems to start to run a little chunky with ~50 or so endpoints, as you might get from a commercial VPN service.