Skip to content

Commit 09d40e7

Browse files
committed
Termux support
1 parent 90caf84 commit 09d40e7

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

flaredantic/logging_config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
from .__version__ import __version__
23

34
# ANSI colors for console output
45
GREEN = "\033[92m"
@@ -35,6 +36,6 @@ def setup_logger(verbose: bool = False) -> logging.Logger:
3536
_logger.addHandler(console_handler)
3637

3738
# Log GitHub URL and version
38-
_logger.info("https://github.com/linuztx/flaredantic")
39+
_logger.info(f"https://github.com/linuztx/flaredantic (v{__version__})")
3940

4041
return _logger

flaredantic/tunnel/cloudflare/downloader.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from ...base.downloader import BaseDownloader
88
from ...exceptions import CloudflaredError, DownloadError
99
from ...logging_config import setup_logger
10+
from ...utils.termux import is_termux, install_cloudflared
1011

1112
class FlareDownloader(BaseDownloader):
1213
def __init__(self, bin_dir: Path, verbose: bool = False):
@@ -50,6 +51,11 @@ def download(self) -> Path:
5051
Returns:
5152
Path to installed cloudflared binary
5253
"""
54+
# Check if Termux environment first
55+
if is_termux():
56+
self.logger.debug("Termux environment detected")
57+
return install_cloudflared()
58+
5359
system, _ = self._platform_info
5460
executable_name = "cloudflared.exe" if system == "windows" else "cloudflared"
5561
install_path = self.bin_dir / executable_name

flaredantic/tunnel/cloudflare/tunnel.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import subprocess
22
import threading
3+
import os
34
from typing import Union, Optional
45
from ...base.tunnel import BaseTunnel
56
from ...exceptions import TunnelError
@@ -66,6 +67,8 @@ def start(self) -> str:
6667
[
6768
str(self.binary_path),
6869
"tunnel",
70+
"--protocol",
71+
"http2" if "TERMUX_VERSION" in os.environ else "quic",
6972
"--url",
7073
f"http://localhost:{self.config.port}"
7174
],

flaredantic/utils/termux.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import os
2+
import shutil
3+
from pathlib import Path
4+
5+
def is_termux() -> bool:
6+
"""Check if running in Termux"""
7+
return "TERMUX_VERSION" in os.environ
8+
9+
def install_cloudflared() -> Path:
10+
"""
11+
Install termux official cloudflared package if not already installed
12+
"""
13+
if shutil.which("cloudflared") is None:
14+
os.system("pkg install cloudflared -y")
15+
return Path(shutil.which("cloudflared"))

0 commit comments

Comments
 (0)