diff options
Diffstat (limited to 'internal/cli/cli.go')
| -rw-r--r-- | internal/cli/cli.go | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/internal/cli/cli.go b/internal/cli/cli.go index 0876d08..11914b1 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -178,7 +178,15 @@ func (a *App) ExecuteCommand(cfg *config.Config) error { } // Start the WireGuard userspace device & routing table setup - tunnel, err := wireguard.StartTunnel(wgCfg) + dnsServer := cfg.DNSServer + if dnsServer == "" { + dnsServer = wgCfg.DNS + } + if dnsServer == "" { + dnsServer = "1.1.1.1" // Fallback to safe public DNS to prevent leaks + } + + tunnel, err := wireguard.StartTunnel(wgCfg, dnsServer) if err != nil { return fmt.Errorf("failed to start WireGuard tunnel: %w", err) } @@ -256,15 +264,23 @@ func (a *App) handleProfileConfigure(name string) error { return fmt.Errorf("profile '%s' not found", name) } - cfg, err := wgconf.Parse(profilePath) - if err != nil { - return fmt.Errorf("failed to parse profile %s: %w", name, err) + editor := os.Getenv("EDITOR") + if editor == "" { + editor = "vi" // Sensible fallback } - fmt.Printf("Editing profile %s...\n", name) - fmt.Println("DNS server (current: '" + cfg.DNS + "'):") + fmt.Printf("Opening profile %s in default editor (%s)...\n", name, editor) + + cmd := exec.Command(editor, profilePath) + cmd.Stdin = os.Stdin + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + if err := cmd.Run(); err != nil { + return fmt.Errorf("editor failed: %w", err) + } - return fmt.Errorf("interactive configuration not supported in this environment, use a config file") + return nil } func (a *App) handleProfileList() error { @@ -354,6 +370,7 @@ func (a *App) showConfig() error { fmt.Printf("Configuration:\n") fmt.Printf(" Profile: %s\n", cfg.Profile) fmt.Printf(" DNS Server: %s\n", cfg.DNSServer) + fmt.Printf(" Config Dir: %s\n", pm.ConfigDir()) fmt.Printf(" Runtime Base: %s\n", pm.RuntimeBaseDir()) fmt.Printf(" Profile Path: %s\n", profilePath) fmt.Printf(" PIDs Path: %s\n", pidsPath) |
