Skip to content
Merged
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
2 changes: 1 addition & 1 deletion internal/olm/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
6 changes: 6 additions & 0 deletions internal/olm/client_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
20 changes: 20 additions & 0 deletions internal/olm/client_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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) {
Expand Down
5 changes: 4 additions & 1 deletion internal/svcmgr/olmclient_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
Loading