cloudflare / cloudflared

Cloudflare Tunnel client (formerly Argo Tunnel)
https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/tunnel-guide
Apache License 2.0
9.07k stars 799 forks source link

💡--pidfile support for "cloudflared access" #723

Open ambis opened 2 years ago

ambis commented 2 years ago

Describe the feature you'd like Hello! Here to suggest adding --pidfile to cloudflared access.

Currently working version:

version: '3'
tasks:
  env:
    cmds:
      - cloudflared access tcp --hostname https://api.example.com --url 127.0.0.1:12345 &
      - defer: kill -15 $(pgrep -fl cloudflared | grep '127.0.0.1:12345' | cut -d' ' -f1)
      - HTTPS_PROXY=socks5://127.0.0.1:12345 "${SHELL}" # kubectl now works with the API

Oh boy if this would be possible:

version: '3'
tasks:
  env:
    cmds:
      - cloudflared access tcp --pidfile .cloudflared.pid --hostname https://api.example.com --url 127.0.0.1:12345 &
      - defer: pkill -F .cloudflared.pid
      - HTTPS_PROXY=socks5://127.0.0.1:12345 "${SHELL}" # kubectl now works with the API

I have found myself using the socks tunnels for quite many things now (Hashicorp Vault access for CI, kube API etc). This would make supporting scripts so much cleaner.

Thanks.

abelinkinbio commented 2 years ago

Hi @ambis - Thank you for submitting this feature request with a detailed example. It makes sense and helps us understand what you're aiming to accomplish. We don't develop too many new features for cloudflared access since we've begun investing more and more into our private network model. We do accept a number of community driven pull requests though if you're able to take a stab at implementing this. If not, we'll track this internally and provide updates on this thread if and when we're able to pick it up from the backlog.

varshneydevansh commented 1 year ago

If this is still active, I would love to look at this. Or maybe if there is some other issue which is good as a starting point?