mirror of
https://github.com/coder/coder.git
synced 2025-07-09 11:45:56 +00:00
fix: add CODER_AGENT_TAILNET_LISTEN_PORT
for specifying a static tailnet port (#6980)
Fixes #5175.
This commit is contained in:
25
cli/agent.go
25
cli/agent.go
@ -30,11 +30,12 @@ import (
|
||||
|
||||
func (r *RootCmd) workspaceAgent() *clibase.Cmd {
|
||||
var (
|
||||
auth string
|
||||
logDir string
|
||||
pprofAddress string
|
||||
noReap bool
|
||||
sshMaxTimeout time.Duration
|
||||
auth string
|
||||
logDir string
|
||||
pprofAddress string
|
||||
noReap bool
|
||||
sshMaxTimeout time.Duration
|
||||
tailnetListenPort int64
|
||||
)
|
||||
cmd := &clibase.Cmd{
|
||||
Use: "agent",
|
||||
@ -187,9 +188,10 @@ func (r *RootCmd) workspaceAgent() *clibase.Cmd {
|
||||
}
|
||||
|
||||
closer := agent.New(agent.Options{
|
||||
Client: client,
|
||||
Logger: logger,
|
||||
LogDir: logDir,
|
||||
Client: client,
|
||||
Logger: logger,
|
||||
LogDir: logDir,
|
||||
TailnetListenPort: uint16(tailnetListenPort),
|
||||
ExchangeToken: func(ctx context.Context) (string, error) {
|
||||
if exchangeToken == nil {
|
||||
return client.SDK.SessionToken(), nil
|
||||
@ -248,6 +250,13 @@ func (r *RootCmd) workspaceAgent() *clibase.Cmd {
|
||||
Description: "Specify the max timeout for a SSH connection.",
|
||||
Value: clibase.DurationOf(&sshMaxTimeout),
|
||||
},
|
||||
{
|
||||
Flag: "tailnet-listen-port",
|
||||
Default: "0",
|
||||
Env: "CODER_AGENT_TAILNET_LISTEN_PORT",
|
||||
Description: "Specify a static port for Tailscale to use for listening.",
|
||||
Value: clibase.Int64Of(&tailnetListenPort),
|
||||
},
|
||||
}
|
||||
|
||||
return cmd
|
||||
|
3
cli/testdata/coder_agent_--help.golden
vendored
3
cli/testdata/coder_agent_--help.golden
vendored
@ -18,5 +18,8 @@ Starts the Coder workspace agent.
|
||||
--ssh-max-timeout duration, $CODER_AGENT_SSH_MAX_TIMEOUT (default: 0)
|
||||
Specify the max timeout for a SSH connection.
|
||||
|
||||
--tailnet-listen-port int, $CODER_AGENT_TAILNET_LISTEN_PORT (default: 0)
|
||||
Specify a static port for Tailscale to use for listening.
|
||||
|
||||
---
|
||||
Run `coder --help` for a list of global options.
|
||||
|
Reference in New Issue
Block a user