Skip to content

chore: support building Coder Desktop .dylib #15512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
add err enum
  • Loading branch information
ethanndickson committed Nov 19, 2024
commit 8dc0a06301d6fa063342f35bd8e2d760b5e89642
15 changes: 11 additions & 4 deletions vpn/dylib/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ import (
"github.com/coder/coder/v2/vpn"
)

const (
ErrDupReadFD = -2
ErrDupWriteFD = -3
ErrOpenPipe = -4
ErrNewTunnel = -5
)

// OpenTunnel creates a new VPN tunnel by `dup`ing the provided 'PIPE'
// file descriptors for reading, writing, and logging.
//
Expand All @@ -23,28 +30,28 @@ func OpenTunnel(cReadFD, cWriteFD int32) int32 {

readFD, err := unix.Dup(int(cReadFD))
if err != nil {
return -1
return ErrDupReadFD
}

writeFD, err := unix.Dup(int(cWriteFD))
if err != nil {
unix.Close(readFD)
return -1
return ErrDupWriteFD
}

conn, err := vpn.NewBidirectionalPipe(uintptr(cReadFD), uintptr(cWriteFD))
if err != nil {
unix.Close(readFD)
unix.Close(writeFD)
return -1
return ErrOpenPipe
}

// Logs will be sent over the protocol
_, err = vpn.NewTunnel(ctx, slog.Make(), conn)
if err != nil {
unix.Close(readFD)
unix.Close(writeFD)
return -1
return ErrNewTunnel
}

return 0
Expand Down
Loading