Skip to content

introduce VpnConfig trait, refactor connect_vpn signature #289

@cachebag

Description

@cachebag

part of #288

current VpnCredentials has wireguard-specific fields baked in. introduce a trait-based abstraction so openvpn (and future protocols) don't bloat the same struct.

changes

add VpnConfig trait in api/models/vpn.rs:

pub trait VpnConfig: Send + Sync + std::fmt::Debug {
    fn vpn_type(&self) -> VpnType;
    fn name(&self) -> &str;
    fn gateway(&self) -> &str;
    fn dns(&self) -> Option<&[String]>;
    fn mtu(&self) -> Option<u32>;
    fn uuid(&self) -> Option<uuid::Uuid>;
}

add WireGuardConfig struct as the new preferred wireguard config type, implementing VpnConfig.

impl VpnConfig for VpnCredentials for backward compat — deprecate VpnCredentials with a note pointing to WireGuardConfig.

change connect_vpn(&self, config: impl VpnConfig) in network_manager.rs. non-breaking since VpnCredentials implements the trait and callers use type inference.

files

  • api/models/vpn.rs — trait, WireGuardConfig, deprecation
  • api/network_manager.rs — signature change
  • lib.rs — re-exports

Metadata

Metadata

Assignees

Labels

nmrsChanges to nmrsrefactorChange or improve codevpnChanges to VPN surface

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions