cloudflared icon indicating copy to clipboard operation
cloudflared copied to clipboard

cloudflared doesn't provide useful diagnostics for proxy loops

Open csnook opened this issue 5 years ago • 0 comments

A common pattern for scripts that use tunnels is to start the tunnel in the background, export an environment variable configuring the use of that tunnel, running the wrapped command, and then killing the backgrounded tunnel when it's done.

This works pretty well, but if for whatever reason that environment variable gets set first, and it's one that cloudflared itself honors, such as HTTPS_PROXY, it will form a proxy loop and recursively open proxy sessions to itself until it runs out of file descriptors, leaving the user extremely baffled that a program that should only be opening 2 sockets is running out of those. While this is a case of the user asking cloudflared to do something ridiculous, it's a somewhat easy mistake to make, and there's no hint of what it's doing in any place one normally looks to troubleshoot resource exhaustion.

While there are certainly difficult edge cases, it would be easy to detect the more obvious proxy loops (like this one) and emit a warning when it appears that the user has asked cloudflared to do something that is expected to cause cloudflared to exit abnormally.

csnook avatar Oct 22 '21 05:10 csnook