Skip to content

Commit e517242

Browse files
committed
TUN-6995: Disable quick-tunnels spin up by default
Before this change when running cloudflare tunnel command without any subcommand and without any additional flag, we would spin up a QuickTunnel. This is really a strange behaviour because we can easily create unwanted tunnels and results in bad user experience. This also has the side effect on putting more burden in our services that are probably just mistakes. This commit fixes that by requiring user to specify the url command flag. Running cloudflared tunnel alone will result in an error message instead.
1 parent 7dee179 commit e517242

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

cmd/cloudflared/tunnel/cmd.go

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ const (
8282
LogFieldPIDPathname = "pidPathname"
8383
LogFieldTmpTraceFilename = "tmpTraceFilename"
8484
LogFieldTraceOutputFilepath = "traceOutputFilepath"
85+
86+
tunnelCmdErrorMessage = `You did not specify any valid additional argument to the cloudflared tunnel command.
87+
88+
If you are trying to run a Quick Tunnel then you need to explicitly pass the --url flag.
89+
Eg. cloudflared tunnel --url localhost:8080/.
90+
91+
Please note that Quick Tunnels are meant to be ephemeral and should only be used for testing purposes.
92+
For production usage, we recommend creating Named Tunnels. (https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/tunnel-guide/)
93+
`
8594
)
8695

8796
var (
@@ -166,21 +175,27 @@ func TunnelCommand(c *cli.Context) error {
166175
if err != nil {
167176
return err
168177
}
178+
169179
if name := c.String("name"); name != "" { // Start a named tunnel
170180
return runAdhocNamedTunnel(sc, name, c.String(CredFileFlag))
171181
}
182+
183+
// Unauthenticated named tunnel on <random>.<quick-tunnels-service>.com
184+
shouldRunQuickTunnel := c.IsSet("url") || c.IsSet("hello-world")
185+
if !dnsProxyStandAlone(c, nil) && c.String("hostname") == "" && c.String("quick-service") != "" && shouldRunQuickTunnel {
186+
return RunQuickTunnel(sc)
187+
}
188+
172189
if ref := config.GetConfiguration().TunnelID; ref != "" {
173190
return fmt.Errorf("Use `cloudflared tunnel run` to start tunnel %s", ref)
174191
}
175192

176-
// Unauthenticated named tunnel on <random>.<quick-tunnels-service>.com
177-
// For now, default to legacy setup unless quick-service is specified
178-
if !dnsProxyStandAlone(c, nil) && c.String("hostname") == "" && c.String("quick-service") != "" {
179-
return RunQuickTunnel(sc)
193+
// Start a classic tunnel if hostname is specified.
194+
if c.String("hostname") != "" {
195+
return runClassicTunnel(sc)
180196
}
181197

182-
// Start a classic tunnel
183-
return runClassicTunnel(sc)
198+
return errors.New(tunnelCmdErrorMessage)
184199
}
185200

186201
func Init(info *cliutil.BuildInfo, gracefulShutdown chan struct{}) {

0 commit comments

Comments
 (0)