Skip to content

Commit 49543f6

Browse files
authored
Merge pull request #20 from fosrl/dev
Dev
2 parents 2cf33a7 + c212d15 commit 49543f6

26 files changed

Lines changed: 99 additions & 32 deletions

cmd/up/client/client.go

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"log"
8+
"net"
89
"os"
910
"os/exec"
1011
"os/signal"
@@ -55,6 +56,27 @@ type ClientUpCmdOpts struct {
5556
UpstreamDNS []string
5657
}
5758

59+
// validateDNSIP ensures the given DNS server string is a valid IP address.
60+
// The input may be "ip" or "ip:port"; only the host part is validated.
61+
func validateDNSIP(s, field string) error {
62+
s = strings.TrimSpace(s)
63+
if s == "" {
64+
return fmt.Errorf("%s: DNS server cannot be empty", field)
65+
}
66+
host := s
67+
if strings.Contains(s, ":") {
68+
var err error
69+
host, _, err = net.SplitHostPort(s)
70+
if err != nil {
71+
return fmt.Errorf("%s: invalid address %q: %w", field, s, err)
72+
}
73+
}
74+
if net.ParseIP(host) == nil {
75+
return fmt.Errorf("%s: must be a valid IP address, got %q", field, host)
76+
}
77+
return nil
78+
}
79+
5880
func ClientUpCmd() *cobra.Command {
5981
opts := ClientUpCmdOpts{}
6082

@@ -72,6 +94,15 @@ func ClientUpCmd() *cobra.Command {
7294
return errors.New("--silent and --attached options conflict")
7395
}
7496

97+
if err := validateDNSIP(opts.DNS, "netstack-dns"); err != nil {
98+
return err
99+
}
100+
for i, server := range opts.UpstreamDNS {
101+
if err := validateDNSIP(server, fmt.Sprintf("upstream-dns[%d]", i)); err != nil {
102+
return err
103+
}
104+
}
105+
75106
return nil
76107
},
77108
Run: func(cmd *cobra.Command, args []string) {
@@ -97,8 +128,8 @@ func ClientUpCmd() *cobra.Command {
97128
cmd.Flags().DurationVar(&opts.PingTimeout, "ping-timeout", 5*time.Second, "Ping `timeout`")
98129
cmd.Flags().BoolVar(&opts.Holepunch, "holepunch", true, "Enable holepunching")
99130
cmd.Flags().StringVar(&opts.TlsClientCert, "tls-client-cert", "", "TLS client certificate `path`")
100-
cmd.Flags().BoolVar(&opts.OverrideDNS, "override-dns", true, "Override system DNS for resolving internal resource alias")
101-
cmd.Flags().BoolVar(&opts.TunnelDNS, "tunnel-dns", false, "Use tunnel DNS for internal resource alias resolution")
131+
cmd.Flags().BoolVar(&opts.OverrideDNS, "override-dns", true, "When enabled, the client uses custom DNS servers to resolve internal resources and aliases. This overrides your system's default DNS settings. Queries that cannot be resolved as a Pangolin resource will be forwarded to your configured Upstream DNS Server.")
132+
cmd.Flags().BoolVar(&opts.TunnelDNS, "tunnel-dns", false, "When enabled, DNS queries are routed through the tunnel for remote resolution. To ensure queries are tunneled correctly, you must define the DNS server as a Pangolin resource and enter its address as an Upstream DNS Server.")
102133
cmd.Flags().StringSliceVar(&opts.UpstreamDNS, "upstream-dns", []string{defaultDNSServer}, "List of DNS servers to use for external DNS resolution if overriding system DNS")
103134
cmd.Flags().BoolVar(&opts.Attached, "attach", false, "Run in attached (foreground) mode, (default: detached (background) mode)")
104135
cmd.Flags().BoolVar(&opts.Silent, "silent", false, "Disable TUI and run silently when detached")
@@ -196,7 +227,7 @@ func clientUpMain(cmd *cobra.Command, opts *ClientUpCmdOpts, extraArgs []string)
196227
}
197228

198229
if newCredsGenerated {
199-
fmt.Println("New creds generated saving them")
230+
// fmt.Println("New creds generated saving them")
200231
// Update the account in the store since ActiveAccount() returns a copy
201232
if err := accountStore.UpdateActiveAccount(activeAccount); err != nil {
202233
logger.Error("Failed to update account in store: %v", err)

docs/pangolin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ Pangolin CLI
2222
* [pangolin update](pangolin_update.md) - Update Pangolin CLI to the latest version
2323
* [pangolin version](pangolin_version.md) - Print the version number
2424

25-
###### Auto generated by spf13/cobra on 23-Jan-2026
25+
###### Auto generated by spf13/cobra on 27-Jan-2026

docs/pangolin_apply.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ Apply resources to the Pangolin server
1717
* [pangolin](pangolin.md) - Pangolin CLI
1818
* [pangolin apply blueprint](pangolin_apply_blueprint.md) - Apply a blueprint
1919

20-
###### Auto generated by spf13/cobra on 23-Jan-2026
20+
###### Auto generated by spf13/cobra on 27-Jan-2026

docs/pangolin_apply_blueprint.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ pangolin apply blueprint [flags]
2222

2323
* [pangolin apply](pangolin_apply.md) - Apply commands
2424

25-
###### Auto generated by spf13/cobra on 23-Jan-2026
25+
###### Auto generated by spf13/cobra on 27-Jan-2026

docs/pangolin_auth.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ Manage authentication and sessions
1919
* [pangolin auth logout](pangolin_auth_logout.md) - Logout from Pangolin
2020
* [pangolin auth status](pangolin_auth_status.md) - Check authentication status
2121

22-
###### Auto generated by spf13/cobra on 23-Jan-2026
22+
###### Auto generated by spf13/cobra on 27-Jan-2026

docs/pangolin_auth_login.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ pangolin auth login [hostname] [flags]
2020

2121
* [pangolin auth](pangolin_auth.md) - Authentication commands
2222

23-
###### Auto generated by spf13/cobra on 23-Jan-2026
23+
###### Auto generated by spf13/cobra on 27-Jan-2026

docs/pangolin_auth_logout.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ pangolin auth logout [flags]
2020

2121
* [pangolin auth](pangolin_auth.md) - Authentication commands
2222

23-
###### Auto generated by spf13/cobra on 23-Jan-2026
23+
###### Auto generated by spf13/cobra on 27-Jan-2026

docs/pangolin_auth_status.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ pangolin auth status [flags]
2020

2121
* [pangolin auth](pangolin_auth.md) - Authentication commands
2222

23-
###### Auto generated by spf13/cobra on 23-Jan-2026
23+
###### Auto generated by spf13/cobra on 27-Jan-2026

docs/pangolin_down.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ pangolin down [flags]
2424
* [pangolin](pangolin.md) - Pangolin CLI
2525
* [pangolin down client](pangolin_down_client.md) - Stop the client connection
2626

27-
###### Auto generated by spf13/cobra on 23-Jan-2026
27+
###### Auto generated by spf13/cobra on 27-Jan-2026

docs/pangolin_down_client.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ pangolin down client [flags]
2020

2121
* [pangolin down](pangolin_down.md) - Stop a connection
2222

23-
###### Auto generated by spf13/cobra on 23-Jan-2026
23+
###### Auto generated by spf13/cobra on 27-Jan-2026

0 commit comments

Comments
 (0)