Skip to content
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

Fix: Can't use Unix Sockets in Quick Tunnel mode #1367

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rhyswilliamsza
Copy link

From #1294:

When you try to use a unix socket (--unix-socket) without a domain configured, cloudflared still asks for the --url parameter.

This PR aims to address the above by adding unix-socket as an accepted flag for spawning quick tunnels. I unfortunately couldn't find an elegant way to mock out the RunQuickTunnel command, so I had to add a small work around. Please let me know if there is a better standard for this.

Thanks!

Comment on lines +317 to +319
shouldRunQuickTunnel := c.IsSet("url") || c.IsSet("unix-socket") || c.IsSet(ingress.HelloWorldFlag)
if !c.IsSet("proxy-dns") && c.String("quick-service") != "" && shouldRunQuickTunnel {
return RunQuickTunnel(sc)
return runQuickTunnel(sc)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hoping to avoid changes here as far as possible, but I'm happy to refactor this into a separate function if this is too hacky.

@@ -15,3 +18,76 @@ func TestHostnameFromURI(t *testing.T) {
assert.Equal(t, "", hostnameFromURI("trash"))
assert.Equal(t, "", hostnameFromURI("https://awesomesauce.com"))
}

func TestShouldRunQuickTunnel(t *testing.T) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've scoped this specifically to quick tunnels, so it won't test falling through to other tunnel types.

@@ -313,9 +314,9 @@ func TunnelCommand(c *cli.Context) error {
// Run a quick tunnel
// A unauthenticated named tunnel hosted on <random>.<quick-tunnels-service>.com
// We don't support running proxy-dns and a quick tunnel at the same time as the same process
shouldRunQuickTunnel := c.IsSet("url") || c.IsSet(ingress.HelloWorldFlag)
shouldRunQuickTunnel := c.IsSet("url") || c.IsSet("unix-socket") || c.IsSet(ingress.HelloWorldFlag)
Copy link
Author

@rhyswilliamsza rhyswilliamsza Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't done any side-effect analysis to check whether anyone could be relying on --unix-socket forcing a trapdoor to proxy-dns, but that seems unlikely so it should be okay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant