Content-Length: 451421 | pFad | http://github.com/coder/coder/commit/6147da58ddc40bcdffbd1e84ec052bda056578af

9E chore: add `vpn-daemon run` command for macos (#19080) · coder/coder@6147da5 · GitHub
Skip to content

Commit 6147da5

Browse files
chore: add vpn-daemon run command for macos (#19080)
Continues to address coder/coder-desktop-macos#201 Identical to the windows command, except we don't write to stdio. We're retaining the system we have for logging on macOS, where we push logs over the tunnel and use the OS logger. I've tested that a build with this command works end-to-end with my new version of Coder Desktop macOS. Also brings in the soft net isolation changes from `main` of coder/tailscale.
1 parent 4e7331a commit 6147da5

File tree

4 files changed

+77
-4
lines changed

4 files changed

+77
-4
lines changed

cli/vpndaemon_darwin.go

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
//go:build darwin
2+
3+
package cli
4+
5+
import (
6+
"golang.org/x/xerrors"
7+
8+
"cdr.dev/slog"
9+
"github.com/coder/coder/v2/vpn"
10+
"github.com/coder/serpent"
11+
)
12+
13+
func (r *RootCmd) vpnDaemonRun() *serpent.Command {
14+
var (
15+
rpcReadFD int64
16+
rpcWriteFD int64
17+
)
18+
19+
cmd := &serpent.Command{
20+
Use: "run",
21+
Short: "Run the VPN daemon on macOS.",
22+
Middleware: serpent.Chain(
23+
serpent.RequireNArgs(0),
24+
),
25+
Options: serpent.OptionSet{
26+
{
27+
Flag: "rpc-read-fd",
28+
Env: "CODER_VPN_DAEMON_RPC_READ_FD",
29+
Description: "The file descriptor for the pipe to read from the RPC connection.",
30+
Value: serpent.Int64Of(&rpcReadFD),
31+
Required: true,
32+
},
33+
{
34+
Flag: "rpc-write-fd",
35+
Env: "CODER_VPN_DAEMON_RPC_WRITE_FD",
36+
Description: "The file descriptor for the pipe to write to the RPC connection.",
37+
Value: serpent.Int64Of(&rpcWriteFD),
38+
Required: true,
39+
},
40+
},
41+
Handler: func(inv *serpent.Invocation) error {
42+
ctx := inv.Context()
43+
44+
if rpcReadFD < 0 || rpcWriteFD < 0 {
45+
return xerrors.Errorf("rpc-read-fd (%v) and rpc-write-fd (%v) must be positive", rpcReadFD, rpcWriteFD)
46+
}
47+
if rpcReadFD == rpcWriteFD {
48+
return xerrors.Errorf("rpc-read-fd (%v) and rpc-write-fd (%v) must be different", rpcReadFD, rpcWriteFD)
49+
}
50+
51+
pipe, err := vpn.NewBidirectionalPipe(uintptr(rpcReadFD), uintptr(rpcWriteFD))
52+
if err != nil {
53+
return xerrors.Errorf("create bidirectional RPC pipe: %w", err)
54+
}
55+
defer pipe.Close()
56+
57+
tunnel, err := vpn.NewTunnel(ctx, slog.Make().Leveled(slog.LevelDebug), pipe,
58+
vpn.NewClient(),
59+
vpn.UseOSNetworkingStack(),
60+
vpn.UseAsLogger(),
61+
)
62+
if err != nil {
63+
return xerrors.Errorf("create new tunnel for client: %w", err)
64+
}
65+
defer tunnel.Close()
66+
67+
<-ctx.Done()
68+
return nil
69+
},
70+
}
71+
72+
return cmd
73+
}

cli/vpndaemon_other.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build !windows
1+
//go:build !windows && !darwin
22

33
package cli
44

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ replace github.com/tcnksm/go-httpstat => github.com/coder/go-httpstat v0.0.0-202
3636

3737
// There are a few minor changes we make to Tailscale that we're slowly upstreaming. Compare here:
3838
// https://github.com/tailscale/tailscale/compare/main...coder:tailscale:main
39-
replace tailscale.com => github.com/coder/tailscale v1.1.1-0.20250724015444-494197765996
39+
replace tailscale.com => github.com/coder/tailscale v1.1.1-0.20250729141742-067f1e5d9716
4040

4141
// This is replaced to include
4242
// 1. a fix for a data race: c.f. https://github.com/tailscale/wireguard-go/pull/25

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -926,8 +926,8 @@ github.com/coder/serpent v0.10.0 h1:ofVk9FJXSek+SmL3yVE3GoArP83M+1tX+H7S4t8BSuM=
926926
github.com/coder/serpent v0.10.0/go.mod h1:cZFW6/fP+kE9nd/oRkEHJpG6sXCtQ+AX7WMMEHv0Y3Q=
927927
github.com/coder/ssh v0.0.0-20231128192721-70855dedb788 h1:YoUSJ19E8AtuUFVYBpXuOD6a/zVP3rcxezNsoDseTUw=
928928
github.com/coder/ssh v0.0.0-20231128192721-70855dedb788/go.mod h1:aGQbuCLyhRLMzZF067xc84Lh7JDs1FKwCmF1Crl9dxQ=
929-
github.com/coder/tailscale v1.1.1-0.20250724015444-494197765996 h1:9x+ouDw9BKW1tdGzuQOWGMT2XkWLs+QQjeCrxYuU1lo=
930-
github.com/coder/tailscale v1.1.1-0.20250724015444-494197765996/go.mod h1:l7ml5uu7lFh5hY28lGYM4b/oFSmuPHYX6uk4RAu23Lc=
929+
github.com/coder/tailscale v1.1.1-0.20250729141742-067f1e5d9716 h1:hi7o0sA+RPBq8Rvvz+hNrC/OTL2897OKREMIRIuQeTs=
930+
github.com/coder/tailscale v1.1.1-0.20250729141742-067f1e5d9716/go.mod h1:l7ml5uu7lFh5hY28lGYM4b/oFSmuPHYX6uk4RAu23Lc=
931931
github.com/coder/terraform-config-inspect v0.0.0-20250107175719-6d06d90c630e h1:JNLPDi2P73laR1oAclY6jWzAbucf70ASAvf5mh2cME0=
932932
github.com/coder/terraform-config-inspect v0.0.0-20250107175719-6d06d90c630e/go.mod h1:Gz/z9Hbn+4KSp8A2FBtNszfLSdT2Tn/uAKGuVqqWmDI=
933933
github.com/coder/terraform-provider-coder/v2 v2.9.0 h1:nd9d1/qHTdx5foBLZoy0SWCc0W13GQUbPTzeGsuLlU0=

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/coder/coder/commit/6147da58ddc40bcdffbd1e84ec052bda056578af

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy