From 719b719d30e3ef03c2cd6621c7109ea44263e3f8 Mon Sep 17 00:00:00 2001 From: Owen Date: Tue, 20 Oct 2026 16:48:45 -0400 Subject: [PATCH] Fall back to other socket path so commands work on service --- internal/olm/client.go | 2 +- internal/olm/client_unix.go | 6 ++++++ internal/olm/client_windows.go | 20 ++++++++++++++++++++ internal/svcmgr/olmclient_windows.go | 5 ++++- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/internal/olm/client.go b/internal/olm/client.go index c0330f7..d7d6ce1 100644 --- a/internal/olm/client.go +++ b/internal/olm/client.go @@ -106,7 +106,7 @@ type GatewayResponse struct { // NewClient creates a new OLM socket client func NewClient(socketPath string) *Client { if socketPath == "" { - socketPath = getDefaultSocketPath() + socketPath = resolveClientSocketPath() } return &Client{ diff --git a/internal/olm/client_unix.go b/internal/olm/client_unix.go index 24b6403..6a2f711 100644 --- a/internal/olm/client_unix.go +++ b/internal/olm/client_unix.go @@ -20,6 +20,12 @@ func GetDefaultSocketPath() string { return getDefaultSocketPath() } +// resolveClientSocketPath picks which socket a client should talk to when none +// was given explicitly. +func resolveClientSocketPath() string { + return defaultSocketPath +} + func newHTTPTransport(socketPath string) *http.Transport { return &http.Transport{ DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { diff --git a/internal/olm/client_windows.go b/internal/olm/client_windows.go index 892a04b..8da0554 100644 --- a/internal/olm/client_windows.go +++ b/internal/olm/client_windows.go @@ -13,6 +13,12 @@ import ( const defaultSocketPath = `\\.\pipe\pangolin-olm` +// ServiceSocketPath is the named pipe the CLI's own Windows client service +// (`pangolin service install client` / `pangolin up client`) listens on. It is +// distinct from defaultSocketPath so the service can't collide with the +// desktop app's olm instance on the same machine. +const ServiceSocketPath = `\\.\pipe\pangolin-client` + // CompanionAgentName is the OLM agent identifier used by the Pangolin Windows Client. // Must match the Agent value in the Windows app's OLM tunnel config. const CompanionAgentName = "Pangolin Windows" @@ -26,6 +32,20 @@ func GetDefaultSocketPath() string { return getDefaultSocketPath() } +// resolveClientSocketPath picks which pipe a client should talk to when none +// was given explicitly: the desktop app's pipe if something is listening on +// it, otherwise the CLI service's pipe if that is up, otherwise the default +// (so error messages still name the expected pipe). +func resolveClientSocketPath() string { + if socketExists(defaultSocketPath) { + return defaultSocketPath + } + if socketExists(ServiceSocketPath) { + return ServiceSocketPath + } + return defaultSocketPath +} + func newHTTPTransport(socketPath string) *http.Transport { return &http.Transport{ DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { diff --git a/internal/svcmgr/olmclient_windows.go b/internal/svcmgr/olmclient_windows.go index 7c81a1e..668938c 100644 --- a/internal/svcmgr/olmclient_windows.go +++ b/internal/svcmgr/olmclient_windows.go @@ -9,6 +9,7 @@ import ( "sync" "time" + "github.com/fosrl/cli/internal/olm" versionpkg "github.com/fosrl/cli/internal/version" newtLogger "github.com/fosrl/newt/logger" olmpkg "github.com/fosrl/olm/olm" @@ -132,7 +133,9 @@ func runOlmClient(ctx context.Context, serviceName string, creds ClientCreds) er // Named pipe on Windows. A name distinct from olm's own "olm" // default, so this machine-client service can't collide with a // separate interactive olm/desktop-app instance on the same box. - SocketPath: "pangolin-client", + // internal/olm.NewClient("") falls back to this pipe, so `status`, + // `down`, etc. still find the service. + SocketPath: olm.ServiceSocketPath, Version: versionpkg.Version, Agent: "Pangolin Service", // No WatchdogSubcommand: `pangolin up client` sets one (see