Best-effort Android/Termux downloads directory. - Termux: ~/storage/downloads (requires termux-setup-storage) - Android common: /storage/emulated/0/Download - Fallback: Homework/ButSystem/ (or internal if storage permission missing)
()
| 3676 | |
| 3677 | # --------------------------- |
| 3678 | # Admin helpers / kick support |
| 3679 | # --------------------------- |
| 3680 | |
| 3681 | |
| 3682 | def _client_ip() -> str: |
| 3683 | """Real client IP with anti-spoofing. |
| 3684 | |
| 3685 | We only trust forwarded headers when the request comes from loopback |
| 3686 | (i.e., a local reverse-proxy like cloudflared/tor on the SAME device). |
| 3687 | """ |
| 3688 | ra = (request.remote_addr or "?").strip() |
| 3689 | try: |
| 3690 | if not _is_loopback(ra): |
| 3691 | return ra |
| 3692 | |
| 3693 | # If loopback, allow reverse-proxy headers (cloudflared commonly sets one of these) |
| 3694 | for h in ("CF-Connecting-IP", "X-Real-IP"): |
no outgoing calls
no test coverage detected