Skip to content

Add import directory functionality for Wireguard tunnels#20

Merged
excoffierleonard merged 3 commits into
excoffierleonard:mainfrom
1ynxy:main
Feb 10, 2026
Merged

Add import directory functionality for Wireguard tunnels#20
excoffierleonard merged 3 commits into
excoffierleonard:mainfrom
1ynxy:main

Conversation

@1ynxy

@1ynxy 1ynxy commented Feb 10, 2026

Copy link
Copy Markdown

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.

@excoffierleonard excoffierleonard self-assigned this Feb 10, 2026
@excoffierleonard

Copy link
Copy Markdown
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 rm -rf themselves. That said, it may be something I add in the future. Feel free to submit a feature request in the Issues tab so I can keep it in mind.

Thank you.

  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
@excoffierleonard excoffierleonard enabled auto-merge (rebase) February 10, 2026 19:34
@excoffierleonard excoffierleonard merged commit 2ea7f70 into excoffierleonard:main Feb 10, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants