Skip to content

Added cloudflared features - #4

Open
TejasPersonal wants to merge 1 commit into
Bing-su:mainfrom
TejasPersonal:feature/system-cloudflared-access
Open

TejasPersonal wants to merge 1 commit into
Bing-su:mainfrom
TejasPersonal:feature/system-cloudflared-access

Conversation

@TejasPersonal

Copy link
Copy Markdown

What's New

System cloudflared Binary Detection

If cloudflared is already installed on the system (found via PATH), it will be used directly instead of downloading a bundled copy.

Why:

  • Avoids redundant downloads when a binary is already available.
  • Enables support on environments previously considered "unsupported" (e.g. Termux on Android), where a system-provided binary may work even if this package's bundled binaries do not.

Note: If no system binary is found, the package falls back to downloading one as before.


host and scheme Arguments (tunnel function)

The tunnel-launching function — previously exposed as __call__ — has been renamed to tunnel() and now accepts two new arguments: host and scheme.

Why:

  • host allows forwarding a custom local IP address instead of assuming 127.0.0.1.
  • scheme (protocol) allows forwarding non-HTTP traffic — most notably tcp, which makes it possible to tunnel arbitrary TCP services such as SSH.

access Function

A new access() function uses cloudflared to proxy a remote tunnel URL back down to a local address.

Why: this complements tunnel() to enable full round-trip forwarding. For example, tunnel() can expose a local SSH port as a public HTTPS tunnel URL; access() can then be used on another device to consume that URL and proxy it back into a local TCP connection.
ssh/tcp (host) → https (forwarded tunnel URL) → ssh/tcp (proxied local access)

This effectively lets you SSH into a machine through a Cloudflare tunnel, without exposing the SSH port directly to the internet.

@Bing-su

Bing-su commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Thank you for your contribution.
However, pycloudflared is currently downloaded over 1000 times a day, so breaking api changes cannot be adopted casually. Please avoid making changes to the api.

Comment thread pycloudflared/util.py
Comment on lines +28 to +32
cloudflared_path = shutil.which("cloudflared")

if cloudflared_path is not None:
self.executable = cloudflared_path
return

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Other programs I've seen that use already installed applications usually receive them via environment variables. That approach seems like the way to go here as well.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

well ...
after evaluating pycloudflared, I found it doesn't meet my requirements. The library is missing features and lacks robustness
therefore: https://github.com/TejasPersonal/flared [I didn't write much readme yet]
this doesn't work like a auto download wrapper, its more of a interface or client

I learnt about atexit from your code, thanks!

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.

2 participants