Skip to content

Commit

Permalink
macOS sandboxed app support
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Noha <[email protected]>
  • Loading branch information
nohajc committed Sep 10, 2023
1 parent 925a1e7 commit 45addca
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
11 changes: 9 additions & 2 deletions internal/wguser/conn_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,18 @@ func dial(device string) (net.Conn, error) {

// find is the default implementation of Client.find.
func find() ([]string, error) {
return findUNIXSockets([]string{
paths := []string{
// It seems that /var/run is a common location between Linux and the
// BSDs, even though it's a symlink on Linux.
"/var/run/wireguard",
})
}
altPaths, err := altSockPaths()
if err != nil {
return nil, err
}
paths = append(paths, altPaths...)

return findUNIXSockets(paths)
}

// findUNIXSockets looks for UNIX socket files in the specified directories.
Expand Down
19 changes: 19 additions & 0 deletions internal/wguser/sockpath_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//go:build darwin

package wguser

import (
"os"
"path/filepath"
)

const NET_EXT_APP_ID = "com.wireguard.macos.network-extension"

func altSockPaths() ([]string, error) {
homeDir, err := os.UserHomeDir()
if err != nil {
return nil, err
}
path := filepath.Join(homeDir, "Library", "Containers", NET_EXT_APP_ID, "Data")
return []string{path}, nil
}
7 changes: 7 additions & 0 deletions internal/wguser/sockpath_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build !darwin && !windows

package wguser

func altSockPaths() ([]string, error) {
return nil, nil
}

0 comments on commit 45addca

Please sign in to comment.