Skip to content

Commit

Permalink
wip: more mac tunnel problems
Browse files Browse the repository at this point in the history
  • Loading branch information
thdxr committed Oct 3, 2024
1 parent b523065 commit ec877e1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/sst/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func run() error {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
interruptChannel := make(chan os.Signal, 1)
signal.Notify(interruptChannel, syscall.SIGINT)
signal.Notify(interruptChannel, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-interruptChannel
slog.Info("interrupted")
Expand Down
2 changes: 1 addition & 1 deletion cmd/sst/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ var CmdTunnel = &cli.Command{
"--host", tun.IP,
"--user", tun.Username,
)
util.SetProcessGroupID(tunnelCmd)
tunnelCmd.Env = append(os.Environ(), "SSH_PRIVATE_KEY="+tun.PrivateKey)
tunnelCmd.Stdout = os.Stdout
tunnelCmd.Stderr = os.Stderr
util.SetProcessGroupID(tunnelCmd)
slog.Info("starting tunnel", "cmd", tunnelCmd.Args)
err = tunnelCmd.Start()
time.Sleep(time.Second * 1)
Expand Down
7 changes: 7 additions & 0 deletions pkg/tunnel/tunnel_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ import (
"os/exec"
"runtime"
"time"

"github.com/sst/ion/internal/util"
)

func Start(ctx context.Context, routes ...string) error {
name := "utun69"
slog.Info("creating interface", "name", name, "os", runtime.GOOS)
socksCmd := exec.CommandContext(ctx, "tun2socks", "-device", name, "-proxy", "socks5://127.0.0.1:1080")
util.SetProcessGroupID(socksCmd)
socksCmd.Cancel = func() error {
util.TerminateProcess(socksCmd.Process.Pid)
return nil
}
socksCmd.Start()
time.Sleep(time.Second * 1)
cmds := [][]string{
Expand Down

0 comments on commit ec877e1

Please sign in to comment.