Skip to content
Merged

Dev #20

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions cmd/up/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"errors"
"fmt"
"log"
"net"
"os"
"os/exec"
"os/signal"
Expand All @@ -23,7 +24,7 @@
"github.com/fosrl/cli/internal/utils"
versionpkg "github.com/fosrl/cli/internal/version"
newtLogger "github.com/fosrl/newt/logger"
olmpkg "github.com/fosrl/olm/olm"

Check failure on line 27 in cmd/up/client/client.go

View workflow job for this annotation

GitHub Actions / build (go-build-release-linux-arm32-v6)

github.com/fosrl/olm@v1.4.0: replacement directory ../olm does not exist

Check failure on line 27 in cmd/up/client/client.go

View workflow job for this annotation

GitHub Actions / build (go-build-release-darwin-arm64)

github.com/fosrl/olm@v1.4.0: replacement directory ../olm does not exist

Check failure on line 27 in cmd/up/client/client.go

View workflow job for this annotation

GitHub Actions / build (go-build-release-darwin-amd64)

github.com/fosrl/olm@v1.4.0: replacement directory ../olm does not exist

Check failure on line 27 in cmd/up/client/client.go

View workflow job for this annotation

GitHub Actions / build (go-build-release-linux-amd64)

github.com/fosrl/olm@v1.4.0: replacement directory ../olm does not exist

Check failure on line 27 in cmd/up/client/client.go

View workflow job for this annotation

GitHub Actions / build (go-build-release-linux-riscv64)

github.com/fosrl/olm@v1.4.0: replacement directory ../olm does not exist

Check failure on line 27 in cmd/up/client/client.go

View workflow job for this annotation

GitHub Actions / build (go-build-release-linux-arm32-v7)

github.com/fosrl/olm@v1.4.0: replacement directory ../olm does not exist

Check failure on line 27 in cmd/up/client/client.go

View workflow job for this annotation

GitHub Actions / build (go-build-release-linux-arm64)

github.com/fosrl/olm@v1.4.0: replacement directory ../olm does not exist
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -55,6 +56,27 @@
UpstreamDNS []string
}

// validateDNSIP ensures the given DNS server string is a valid IP address.
// The input may be "ip" or "ip:port"; only the host part is validated.
func validateDNSIP(s, field string) error {
s = strings.TrimSpace(s)
if s == "" {
return fmt.Errorf("%s: DNS server cannot be empty", field)
}
host := s
if strings.Contains(s, ":") {
var err error
host, _, err = net.SplitHostPort(s)
if err != nil {
return fmt.Errorf("%s: invalid address %q: %w", field, s, err)
}
}
if net.ParseIP(host) == nil {
return fmt.Errorf("%s: must be a valid IP address, got %q", field, host)
}
return nil
}

func ClientUpCmd() *cobra.Command {
opts := ClientUpCmdOpts{}

Expand All @@ -72,6 +94,15 @@
return errors.New("--silent and --attached options conflict")
}

if err := validateDNSIP(opts.DNS, "netstack-dns"); err != nil {
return err
}
for i, server := range opts.UpstreamDNS {
if err := validateDNSIP(server, fmt.Sprintf("upstream-dns[%d]", i)); err != nil {
return err
}
}

return nil
},
Run: func(cmd *cobra.Command, args []string) {
Expand All @@ -97,8 +128,8 @@
cmd.Flags().DurationVar(&opts.PingTimeout, "ping-timeout", 5*time.Second, "Ping `timeout`")
cmd.Flags().BoolVar(&opts.Holepunch, "holepunch", true, "Enable holepunching")
cmd.Flags().StringVar(&opts.TlsClientCert, "tls-client-cert", "", "TLS client certificate `path`")
cmd.Flags().BoolVar(&opts.OverrideDNS, "override-dns", true, "Override system DNS for resolving internal resource alias")
cmd.Flags().BoolVar(&opts.TunnelDNS, "tunnel-dns", false, "Use tunnel DNS for internal resource alias resolution")
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.")
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.")
cmd.Flags().StringSliceVar(&opts.UpstreamDNS, "upstream-dns", []string{defaultDNSServer}, "List of DNS servers to use for external DNS resolution if overriding system DNS")
cmd.Flags().BoolVar(&opts.Attached, "attach", false, "Run in attached (foreground) mode, (default: detached (background) mode)")
cmd.Flags().BoolVar(&opts.Silent, "silent", false, "Disable TUI and run silently when detached")
Expand Down Expand Up @@ -196,7 +227,7 @@
}

if newCredsGenerated {
fmt.Println("New creds generated saving them")
// fmt.Println("New creds generated saving them")
// Update the account in the store since ActiveAccount() returns a copy
if err := accountStore.UpdateActiveAccount(activeAccount); err != nil {
logger.Error("Failed to update account in store: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion docs/pangolin.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ Pangolin CLI
* [pangolin update](pangolin_update.md) - Update Pangolin CLI to the latest version
* [pangolin version](pangolin_version.md) - Print the version number

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
2 changes: 1 addition & 1 deletion docs/pangolin_apply.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ Apply resources to the Pangolin server
* [pangolin](pangolin.md) - Pangolin CLI
* [pangolin apply blueprint](pangolin_apply_blueprint.md) - Apply a blueprint

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
2 changes: 1 addition & 1 deletion docs/pangolin_apply_blueprint.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ pangolin apply blueprint [flags]

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

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
2 changes: 1 addition & 1 deletion docs/pangolin_auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ Manage authentication and sessions
* [pangolin auth logout](pangolin_auth_logout.md) - Logout from Pangolin
* [pangolin auth status](pangolin_auth_status.md) - Check authentication status

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
2 changes: 1 addition & 1 deletion docs/pangolin_auth_login.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ pangolin auth login [hostname] [flags]

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

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
2 changes: 1 addition & 1 deletion docs/pangolin_auth_logout.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ pangolin auth logout [flags]

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

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
2 changes: 1 addition & 1 deletion docs/pangolin_auth_status.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ pangolin auth status [flags]

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

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
2 changes: 1 addition & 1 deletion docs/pangolin_down.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ pangolin down [flags]
* [pangolin](pangolin.md) - Pangolin CLI
* [pangolin down client](pangolin_down_client.md) - Stop the client connection

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
2 changes: 1 addition & 1 deletion docs/pangolin_down_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ pangolin down client [flags]

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

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
2 changes: 1 addition & 1 deletion docs/pangolin_login.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ pangolin login [hostname] [flags]

* [pangolin](pangolin.md) - Pangolin CLI

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
2 changes: 1 addition & 1 deletion docs/pangolin_logout.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ pangolin logout [flags]

* [pangolin](pangolin.md) - Pangolin CLI

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
2 changes: 1 addition & 1 deletion docs/pangolin_logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ View and follow client logs
* [pangolin](pangolin.md) - Pangolin CLI
* [pangolin logs client](pangolin_logs_client.md) - View client logs

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
2 changes: 1 addition & 1 deletion docs/pangolin_logs_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ pangolin logs client [flags]

* [pangolin logs](pangolin_logs.md) - View client logs

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
2 changes: 1 addition & 1 deletion docs/pangolin_select.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ Select account information to use
* [pangolin select account](pangolin_select_account.md) - Select an account
* [pangolin select org](pangolin_select_org.md) - Select an organization

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
2 changes: 1 addition & 1 deletion docs/pangolin_select_account.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ pangolin select account [flags]

* [pangolin select](pangolin_select.md) - Select account information to use

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
2 changes: 1 addition & 1 deletion docs/pangolin_select_org.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ pangolin select org [flags]

* [pangolin select](pangolin_select.md) - Select account information to use

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
2 changes: 1 addition & 1 deletion docs/pangolin_status.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ pangolin status [flags]
* [pangolin](pangolin.md) - Pangolin CLI
* [pangolin status client](pangolin_status_client.md) - Show client status

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
2 changes: 1 addition & 1 deletion docs/pangolin_status_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ pangolin status client [flags]

* [pangolin status](pangolin_status.md) - Status commands

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
6 changes: 3 additions & 3 deletions docs/pangolin_up.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ pangolin up [flags]
--mtu int Maximum transmission unit (default 1280)
--netstack-dns server DNS server to use for Netstack (default "1.1.1.1")
--org string Organization ID (default: selected organization if logged in)
--override-dns Override system DNS for resolving internal resource alias (default true)
--override-dns 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. (default true)
--ping-interval interval Ping interval (default 5s)
--ping-timeout timeout Ping timeout (default 5s)
--secret string Client secret (optional, will use user info if not provided)
--silent Disable TUI and run silently when detached
--tls-client-cert path TLS client certificate path
--tunnel-dns Use tunnel DNS for internal resource alias resolution
--tunnel-dns 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.
--upstream-dns strings List of DNS servers to use for external DNS resolution if overriding system DNS (default [1.1.1.1])
```

Expand All @@ -42,4 +42,4 @@ pangolin up [flags]
* [pangolin](pangolin.md) - Pangolin CLI
* [pangolin up client](pangolin_up_client.md) - Start a client connection

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
6 changes: 3 additions & 3 deletions docs/pangolin_up_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ pangolin up client [flags]
--mtu int Maximum transmission unit (default 1280)
--netstack-dns server DNS server to use for Netstack (default "1.1.1.1")
--org string Organization ID (default: selected organization if logged in)
--override-dns Override system DNS for resolving internal resource alias (default true)
--override-dns 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. (default true)
--ping-interval interval Ping interval (default 5s)
--ping-timeout timeout Ping timeout (default 5s)
--secret string Client secret (optional, will use user info if not provided)
--silent Disable TUI and run silently when detached
--tls-client-cert path TLS client certificate path
--tunnel-dns Use tunnel DNS for internal resource alias resolution
--tunnel-dns 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.
--upstream-dns strings List of DNS servers to use for external DNS resolution if overriding system DNS (default [1.1.1.1])
```

### SEE ALSO

* [pangolin up](pangolin_up.md) - Start a connection

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
2 changes: 1 addition & 1 deletion docs/pangolin_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ pangolin update [flags]

* [pangolin](pangolin.md) - Pangolin CLI

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
2 changes: 1 addition & 1 deletion docs/pangolin_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ pangolin version [flags]

* [pangolin](pangolin.md) - Pangolin CLI

###### Auto generated by spf13/cobra on 23-Jan-2026
###### Auto generated by spf13/cobra on 27-Jan-2026
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ require (
// If changes to Olm or Newt are required, use these
// replace directives during development.
//
// replace github.com/fosrl/olm => ../olm
// replace github.com/fosrl/newt => ../newt
replace github.com/fosrl/olm => ../olm
replace github.com/fosrl/newt => ../newt
2 changes: 1 addition & 1 deletion internal/version/consts.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package version

// Version is the current version of the Pangolin CLI
const Version = "0.3.0"
const Version = "0.3.1"
36 changes: 36 additions & 0 deletions scripts/set-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
# Bump the CLI version by replacing the version in internal/version/consts.go

set -e

VERSION_FILE="internal/version/consts.go"

if [ -z "$1" ]; then
echo "Usage: $0 <version>"
echo "Example: $0 0.4.0"
exit 1
fi

NEW_VERSION="$1"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"

cd "$REPO_ROOT"

if [ ! -f "$VERSION_FILE" ]; then
echo "Error: $VERSION_FILE not found"
exit 1
fi

# Replace the version in consts.go (matches: const Version = "X.Y.Z")
case $(uname) in
Darwin) sed -i '' "s/const Version = \"[^\"]*\"/const Version = \"$NEW_VERSION\"/" "$VERSION_FILE" ;;
*) sed -i "s/const Version = \"[^\"]*\"/const Version = \"$NEW_VERSION\"/" "$VERSION_FILE" ;;
esac

if grep -q "const Version = \"$NEW_VERSION\"" "$VERSION_FILE"; then
echo "Version bumped to $NEW_VERSION in $VERSION_FILE"
else
echo "Error: failed to update version"
exit 1
fi
Loading