Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: use custom wireguard reverse proxy for dev tunnel#1975

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
coadler merged 5 commits intomainfromcolin/wg-dev-tunnel
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes fromall 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
33 changes: 28 additions & 5 deletionscli/server.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,6 +33,7 @@ import (
"golang.org/x/mod/semver"
"golang.org/x/oauth2"
xgithub "golang.org/x/oauth2/github"
"golang.org/x/sync/errgroup"
"golang.org/x/xerrors"
"google.golang.org/api/idtoken"
"google.golang.org/api/option"
Expand DownExpand Up@@ -169,8 +170,9 @@ func server() *cobra.Command {
}

var (
tunnelErrChan <-chan error
ctxTunnel, closeTunnel = context.WithCancel(cmd.Context())
devTunnel = (*devtunnel.Tunnel)(nil)
devTunnelErrChan = make(<-chan error, 1)
)
defer closeTunnel()

Expand All@@ -195,10 +197,11 @@ func server() *cobra.Command {
}
}
if err == nil {
accessURL, tunnelErrChan, err = devtunnel.New(ctxTunnel,localURL)
devTunnel, devTunnelErrChan, err = devtunnel.New(ctxTunnel,logger.Named("devtunnel"))
if err != nil {
return xerrors.Errorf("create tunnel: %w", err)
}
accessURL = devTunnel.URL
}
_, _ = fmt.Fprintln(cmd.ErrOrStderr())
}
Expand DownExpand Up@@ -327,7 +330,27 @@ func server() *cobra.Command {
return shutdownConnsCtx
},
}
errCh <- server.Serve(listener)

wg := errgroup.Group{}
wg.Go(func() error {
// Make sure to close the tunnel listener if we exit so the
// errgroup doesn't wait forever!
if dev && tunnel {
defer devTunnel.Listener.Close()
}

return server.Serve(listener)
})

if dev && tunnel {
wg.Go(func() error {
defer listener.Close()

return server.Serve(devTunnel.Listener)
})
}

errCh <- wg.Wait()
}()

config := createConfig(cmd)
Expand DownExpand Up@@ -393,7 +416,7 @@ func server() *cobra.Command {
case <-cmd.Context().Done():
coderAPI.Close()
return cmd.Context().Err()
case err := <-tunnelErrChan:
case err := <-devTunnelErrChan:
if err != nil {
return err
}
Expand DownExpand Up@@ -456,7 +479,7 @@ func server() *cobra.Command {
if dev && tunnel {
_, _ = fmt.Fprintf(cmd.OutOrStdout(), cliui.Styles.Prompt.String()+"Waiting for dev tunnel to close...\n")
closeTunnel()
<-tunnelErrChan
<-devTunnelErrChan
}

_, _ = fmt.Fprintf(cmd.OutOrStdout(), cliui.Styles.Prompt.String()+"Waiting for WebSocket connections to close...\n")
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp