utp-engine 2.6.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Arpit Nayak & Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,7 @@
1
+ include LICENSE
2
+ include PRIVACY.md
3
+ include SECURITY.md
4
+ include README.md
5
+ recursive-include utp_engine *.py
6
+ prune tests
7
+ global-exclude __pycache__ *.py[cod]
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.4
2
+ Name: utp-engine
3
+ Version: 2.6.3
4
+ Summary: Zero-disk cloud-to-cloud transfer, direct web ingestion, media streaming & sync engine — Google Drive, OneDrive, S3, R2, Dropbox, WebDAV — TLS 1.3 RAM pipeline
5
+ Author: Arpit Nayak
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Arpit Nayak & Contributors
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://ctp.arpitnayak.tech
29
+ Project-URL: Repository, https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol
30
+ Project-URL: Issues, https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol/issues
31
+ Project-URL: Documentation, https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol#readme
32
+ Keywords: cloud,transfer,streaming,zero-disk,direct-download,ingest,migration,sync,google-drive,onedrive,dropbox,icloud,s3,r2,b2,webdav,cli,media-server
33
+ Classifier: Development Status :: 5 - Production/Stable
34
+ Classifier: Environment :: Console
35
+ Classifier: Intended Audience :: Developers
36
+ Classifier: Intended Audience :: System Administrators
37
+ Classifier: License :: OSI Approved :: MIT License
38
+ Classifier: Operating System :: MacOS
39
+ Classifier: Operating System :: Microsoft :: Windows
40
+ Classifier: Operating System :: POSIX :: Linux
41
+ Classifier: Programming Language :: C++
42
+ Classifier: Programming Language :: Python :: 3
43
+ Classifier: Programming Language :: Python :: 3 :: Only
44
+ Classifier: Topic :: Internet
45
+ Classifier: Topic :: System :: Archiving :: Backup
46
+ Classifier: Topic :: Utilities
47
+ Requires-Python: >=3.8
48
+ Description-Content-Type: text/markdown
49
+ License-File: LICENSE
50
+ Dynamic: license-file
51
+
52
+ # Universal Cloud Transfer Protocol (UTP)
53
+
54
+ **Zero-Disk Cloud-to-Cloud Transfer, Direct Web Ingestion, Media Streaming & Sync Engine**
55
+
56
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol/blob/PROJECTS/LICENSE)
57
+ [![Official Portal](https://img.shields.io/badge/Official%20Site-ctp.arpitnayak.tech-FF5B1F.svg)](https://ctp.arpitnayak.tech)
58
+ [![Release](https://img.shields.io/badge/Release-v2.6.3--pro-cyan.svg)](https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol/releases)
59
+
60
+ UTP (`utp-engine`) streams files directly across cloud storage drives and HTTP/HTTPS URLs through bounded **volatile RAM ring buffers** over TLS 1.3 — writing **0 bytes** to local disk.
61
+
62
+ ## Installation
63
+
64
+ ```bash
65
+ pip install utp-engine
66
+ ```
67
+
68
+ Or install cleanly in an isolated environment:
69
+
70
+ ```bash
71
+ pipx install utp-engine
72
+ # or
73
+ uv tool install utp-engine
74
+ ```
75
+
76
+ Installing `utp-engine` provides `utp`, `ctp`, `utp-engine`, `utpd`, and `utp-server` directly in your terminal. On first launch, it fetches the official native C++ release binary for your OS over HTTPS and verifies its SHA-256 digest against `SHA256SUMS.txt` before execution.
77
+
78
+ ## Quick Usage
79
+
80
+ ```bash
81
+ # Interactive terminal explorer & operations hub
82
+ utp
83
+
84
+ # Direct HTTPS URL ingestion into cloud storage (zero disk)
85
+ utp ingest https://example.com/archive.tar.gz gdrive://Backups/
86
+
87
+ # Direct cloud-to-cloud streaming transfer
88
+ utp transfer gdrive://1BxiMVs0XRA5nF... onedrive://Backups/data.zip
89
+
90
+ # On-demand zero-disk media streaming (HTTP 206 Range -> VLC / MPV / browser)
91
+ utp stream gdrive://movies/clip.mp4 --open
92
+
93
+ # Start the local utpd REST daemon (bound to 127.0.0.1:8080 by default)
94
+ utp daemon start
95
+ ```
96
+
97
+ ## Security & Privacy
98
+
99
+ - **Verified Binary Fetch:** Downloads only over HTTPS (with redirect caps), checks SHA-256 in constant time against GitHub Release `SHA256SUMS.txt`, and rejects ZipSlip/TarSlip paths or symlinks.
100
+ - **Zero Telemetry & Local Credentials:** OAuth tokens and daemon credentials remain solely in owner-restricted files on your machine.
101
+ - **Full Documentation:** [GitHub Repository](https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol) · [Privacy Policy](https://ctp.arpitnayak.tech/privacy)
@@ -0,0 +1,85 @@
1
+ # Privacy Policy for Cloud Transfer Protocol
2
+
3
+ **Effective Date:** November 20, 2026
4
+ **Last Updated:** November 23, 2026
5
+ **Application Name:** Cloud Transfer Protocol (CTP)
6
+ **Developer:** Arpit Nayak
7
+ **Contact Email:** [arpitpupu@gmail.com](mailto:arpitpupu@gmail.com)
8
+ **Official Homepage:** [https://ctp.arpitnayak.tech](https://ctp.arpitnayak.tech)
9
+ **Hosted Privacy Policy:** [https://ctp.arpitnayak.tech/privacy](https://ctp.arpitnayak.tech/privacy)
10
+ **Hosted Terms of Service:** [https://ctp.arpitnayak.tech/terms](https://ctp.arpitnayak.tech/terms)
11
+
12
+ ---
13
+
14
+ ## 1. Application Overview & Purpose
15
+ **Cloud Transfer Protocol** ("Cloud Transfer Protocol", "CTP", "the Application", "we", or "us") is an open-source, client-side, zero-disk cloud migration engine and command-line utility.
16
+
17
+ The sole and exclusive purpose of Cloud Transfer Protocol is to enable users to migrate, back up, and synchronize their own files between supported cloud storage providers (such as Google Drive, Microsoft OneDrive, and local storage) directly through in-memory streaming, without caching or writing transient file data to local storage disks.
18
+
19
+ ---
20
+
21
+ ## 2. Google User Data: What We Access & How It Is Used
22
+
23
+ Cloud Transfer Protocol requests OAuth 2.0 authorization from Google for the following specific scopes:
24
+
25
+ * **`https://www.googleapis.com/auth/drive.readonly`**: Used exclusively to list folders and files in your Google Drive and read file metadata (file names, sizes, MIME types, and file IDs) and content streams so that you can view and select files to transfer to your designated destination storage.
26
+ * **`https://www.googleapis.com/auth/drive.file`**: Used exclusively to upload and create files in your Google Drive that you specifically and explicitly direct the application to transfer from another storage source.
27
+
28
+ ### Data Accessed:
29
+ 1. **File Metadata:** File identifiers, names, byte sizes, and MIME types strictly to display file listings to you in your terminal.
30
+ 2. **File Content:** In-memory byte chunks streamed in transient RAM solely to deliver the payload to your chosen destination cloud provider.
31
+
32
+ ### Data NOT Collected or Stored:
33
+ * Cloud Transfer Protocol operates with **Zero Intermediary Servers**. There is no backend server, database, or proxy operated by the developer. All network requests are made directly from your client machine to Google API endpoints (`https://www.googleapis.com/...`).
34
+ * Cloud Transfer Protocol **never** collects, logs, transmits, or shares your file names, folder hierarchies, or file contents to any third party or developer server.
35
+
36
+ ---
37
+
38
+ ## 3. Google API Limited Use Disclosure
39
+
40
+ > **Cloud Transfer Protocol's use and transfer to any other app of information received from Google APIs will adhere to the [Google API Services User Data Policy](https://developers.google.com/terms/api-services-user-data-policy), including the Limited Use requirements.**
41
+
42
+ * **No Advertising or Commercial Profiling:** Google user data is never used, shared, or sold for targeted advertising, retargeting, interest-based advertising, credit scoring, or user profiling.
43
+ * **No AI/ML Model Training:** Data accessed via Google APIs is **never** used to develop, train, fine-tune, or improve generalized machine learning (ML) or artificial intelligence (AI) models.
44
+ * **Strict Human Oversight Restrictions:** No human beings ever inspect or view your file contents, except in the normal course of you viewing your own files in your local terminal.
45
+ * **Prohibition of AI NCII:** Cloud Transfer Protocol complies fully with the Google APIs Terms of Service and strictly prohibits the generation, facilitation, processing, or distribution of AI-generated Non-Consensual Intimate Imagery (AI NCII) or any non-consensual sexual content.
46
+
47
+ ---
48
+
49
+ ## 4. Local Credential Storage & Security
50
+
51
+ * **Local Token Storage:** When you authenticate with Google Drive, the resulting OAuth 2.0 access and refresh tokens are stored locally on your device in a user-restricted JSON file (e.g., `.utp_gdrive_token.json`).
52
+ * **Transport Encryption:** All API communications are secured with strict Transport Layer Security (TLS 1.3 / TLS 1.2) with mutual certificate authority validation (`ca-bundle.crt`).
53
+ * **Token Protection:** Authorization tokens and secret values are never printed in plaintext console logs or stored in persistent unencrypted transaction ledgers.
54
+
55
+ ---
56
+
57
+ ## 5. User Control: Data Deletion & Revoking Access
58
+
59
+ Because Cloud Transfer Protocol does not operate external databases or servers, no Google user data or personal data is ever stored on any remote system.
60
+
61
+ You retain complete and total control over your Google credentials:
62
+ 1. **Revoke Google API Permissions:** You may revoke Cloud Transfer Protocol's access to your Google account at any time by visiting [Google Third-party apps & services](https://myaccount.google.com/permissions).
63
+ 2. **Local Token Deletion:** You can delete your locally stored authorization tokens at any time by running:
64
+ ```bash
65
+ utp account remove gdrive
66
+ ```
67
+ or by manually deleting the local `.utp_gdrive_token.json` file on your machine.
68
+ 3. **Cache & Ledger Deletion:** You can delete the local SQLite transaction ledger by deleting `utp.db` from your machine.
69
+
70
+ ---
71
+
72
+ ## 6. Open Source Transparency & Source Code
73
+
74
+ Cloud Transfer Protocol is published as open-source software under the MIT License. The entire source code is publicly auditable at:
75
+ [https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol](https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol)
76
+
77
+ ---
78
+
79
+ ## 7. Contact Information
80
+
81
+ For any inquiries, questions, or concerns regarding this Privacy Policy or our security practices:
82
+ * **Developer:** Arpit Nayak
83
+ * **Email:** [arpitpupu@gmail.com](mailto:arpitpupu@gmail.com)
84
+ * **GitHub Issues:** [https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol/issues](https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol/issues)
85
+
@@ -0,0 +1,50 @@
1
+ # Universal Cloud Transfer Protocol (UTP)
2
+
3
+ **Zero-Disk Cloud-to-Cloud Transfer, Direct Web Ingestion, Media Streaming & Sync Engine**
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol/blob/PROJECTS/LICENSE)
6
+ [![Official Portal](https://img.shields.io/badge/Official%20Site-ctp.arpitnayak.tech-FF5B1F.svg)](https://ctp.arpitnayak.tech)
7
+ [![Release](https://img.shields.io/badge/Release-v2.6.3--pro-cyan.svg)](https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol/releases)
8
+
9
+ UTP (`utp-engine`) streams files directly across cloud storage drives and HTTP/HTTPS URLs through bounded **volatile RAM ring buffers** over TLS 1.3 — writing **0 bytes** to local disk.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ pip install utp-engine
15
+ ```
16
+
17
+ Or install cleanly in an isolated environment:
18
+
19
+ ```bash
20
+ pipx install utp-engine
21
+ # or
22
+ uv tool install utp-engine
23
+ ```
24
+
25
+ Installing `utp-engine` provides `utp`, `ctp`, `utp-engine`, `utpd`, and `utp-server` directly in your terminal. On first launch, it fetches the official native C++ release binary for your OS over HTTPS and verifies its SHA-256 digest against `SHA256SUMS.txt` before execution.
26
+
27
+ ## Quick Usage
28
+
29
+ ```bash
30
+ # Interactive terminal explorer & operations hub
31
+ utp
32
+
33
+ # Direct HTTPS URL ingestion into cloud storage (zero disk)
34
+ utp ingest https://example.com/archive.tar.gz gdrive://Backups/
35
+
36
+ # Direct cloud-to-cloud streaming transfer
37
+ utp transfer gdrive://1BxiMVs0XRA5nF... onedrive://Backups/data.zip
38
+
39
+ # On-demand zero-disk media streaming (HTTP 206 Range -> VLC / MPV / browser)
40
+ utp stream gdrive://movies/clip.mp4 --open
41
+
42
+ # Start the local utpd REST daemon (bound to 127.0.0.1:8080 by default)
43
+ utp daemon start
44
+ ```
45
+
46
+ ## Security & Privacy
47
+
48
+ - **Verified Binary Fetch:** Downloads only over HTTPS (with redirect caps), checks SHA-256 in constant time against GitHub Release `SHA256SUMS.txt`, and rejects ZipSlip/TarSlip paths or symlinks.
49
+ - **Zero Telemetry & Local Credentials:** OAuth tokens and daemon credentials remain solely in owner-restricted files on your machine.
50
+ - **Full Documentation:** [GitHub Repository](https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol) · [Privacy Policy](https://ctp.arpitnayak.tech/privacy)
@@ -0,0 +1,39 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ The following versions of Universal Cloud Transfer Protocol (UTP) are currently supported with security updates:
6
+
7
+ | Version | Supported |
8
+ | ------- | ------------------ |
9
+ | >= 2.6.2 | :white_check_mark: |
10
+ | < 2.6.2 | :x: |
11
+
12
+ ---
13
+
14
+ ## Reporting a Vulnerability
15
+
16
+ We take the security of UTP and user data seriously. If you discover a potential security vulnerability, please report it responsibly rather than opening a public issue.
17
+
18
+ ### How to Report
19
+
20
+ 1. **GitHub Security Advisory**: Use the private security advisory feature on GitHub:
21
+ [https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol/security/advisories/new](https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol/security/advisories/new)
22
+ 2. **Details to Include**:
23
+ * A description of the vulnerability and its potential impact.
24
+ * Clear, reproducible proof-of-concept steps or scripts.
25
+ * The operating system, UTP version, and cloud provider involved.
26
+
27
+ ### What to Expect
28
+
29
+ * **Initial Response**: We will acknowledge receipt of your vulnerability report within 48 hours.
30
+ * **Assessment & Fix**: We will triage and develop a security patch in private before public release.
31
+ * **Credit**: Vulnerability reporters will be credited in the release notes upon patch disclosure.
32
+
33
+ ---
34
+
35
+ ## Security Guarantees & Architecture
36
+
37
+ * **TLS 1.3 In-Transit**: All remote socket connections enforce TLS 1.3 / TLS 1.2 with Certificate Authority verification (`CURLOPT_SSL_VERIFYPEER = 1`, `CURLOPT_SSL_VERIFYHOST = 2`).
38
+ * **Zero-Disk Streaming**: File payloads are streamed strictly in bounded RAM buffers and are deallocated immediately upon commit.
39
+ * **Secret Hygiene**: Client secrets, tokens, and authorization codes are never committed to revision control, tracked in SQLite logs, or displayed in terminal output.
@@ -0,0 +1,66 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "utp-engine"
7
+ version = "2.6.3"
8
+ description = "Zero-disk cloud-to-cloud transfer, direct web ingestion, media streaming & sync engine — Google Drive, OneDrive, S3, R2, Dropbox, WebDAV — TLS 1.3 RAM pipeline"
9
+ readme = "README.md"
10
+ license = { file = "LICENSE" }
11
+ authors = [{ name = "Arpit Nayak" }]
12
+ requires-python = ">=3.8"
13
+ dependencies = []
14
+ keywords = [
15
+ "cloud",
16
+ "transfer",
17
+ "streaming",
18
+ "zero-disk",
19
+ "direct-download",
20
+ "ingest",
21
+ "migration",
22
+ "sync",
23
+ "google-drive",
24
+ "onedrive",
25
+ "dropbox",
26
+ "icloud",
27
+ "s3",
28
+ "r2",
29
+ "b2",
30
+ "webdav",
31
+ "cli",
32
+ "media-server",
33
+ ]
34
+ classifiers = [
35
+ "Development Status :: 5 - Production/Stable",
36
+ "Environment :: Console",
37
+ "Intended Audience :: Developers",
38
+ "Intended Audience :: System Administrators",
39
+ "License :: OSI Approved :: MIT License",
40
+ "Operating System :: MacOS",
41
+ "Operating System :: Microsoft :: Windows",
42
+ "Operating System :: POSIX :: Linux",
43
+ "Programming Language :: C++",
44
+ "Programming Language :: Python :: 3",
45
+ "Programming Language :: Python :: 3 :: Only",
46
+ "Topic :: Internet",
47
+ "Topic :: System :: Archiving :: Backup",
48
+ "Topic :: Utilities",
49
+ ]
50
+
51
+ [project.scripts]
52
+ utp = "utp_engine.cli:main_utp"
53
+ utp-engine = "utp_engine.cli:main_utp"
54
+ ctp = "utp_engine.cli:main_utp"
55
+ utpd = "utp_engine.cli:main_utpd"
56
+ utp-server = "utp_engine.cli:main_utpd"
57
+
58
+ [project.urls]
59
+ Homepage = "https://ctp.arpitnayak.tech"
60
+ Repository = "https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol"
61
+ Issues = "https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol/issues"
62
+ Documentation = "https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol#readme"
63
+
64
+ [tool.setuptools.packages.find]
65
+ include = ["utp_engine*"]
66
+ exclude = ["tests*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,4 @@
1
+ """Universal Cloud Transfer Protocol (UTP) PyPI launcher package."""
2
+
3
+ __version__ = "2.6.3"
4
+ __all__ = ["__version__"]
@@ -0,0 +1,48 @@
1
+ """Console-script wrappers forwarding commands to native UTP / UTPD binaries."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import subprocess
7
+ import sys
8
+ from typing import Optional
9
+
10
+ from .installer import BinaryVerificationError, UnsupportedPlatformError, ensure_binary
11
+
12
+
13
+ def _run_binary(base_names: list[str], label: str, argv: Optional[list[str]] = None) -> int:
14
+ args = sys.argv[1:] if argv is None else argv
15
+ exe_names = [f"{n}.exe" for n in base_names] if os.name == "nt" else base_names
16
+
17
+ try:
18
+ binary_path = ensure_binary(exe_names)
19
+ except (UnsupportedPlatformError, BinaryVerificationError, OSError) as exc:
20
+ print(f"[{label} Error] {exc}", file=sys.stderr)
21
+ return 1
22
+
23
+ if os.name == "nt":
24
+ try:
25
+ proc = subprocess.run([str(binary_path), *args], shell=False)
26
+ if proc.returncode in (-1073741515, 0xC0000135):
27
+ print(
28
+ f"[{label} Error] Native executable {binary_path} failed to load a Windows DLL "
29
+ f"(0xC0000135). Clear %LOCALAPPDATA%\\utp\\bin or reinstall the full release bundle.",
30
+ file=sys.stderr,
31
+ )
32
+ return proc.returncode
33
+ except KeyboardInterrupt:
34
+ return 130
35
+ except OSError as exc:
36
+ print(f"[{label} Error] Failed to execute {binary_path}: {exc}", file=sys.stderr)
37
+ return 1
38
+
39
+ os.execv(str(binary_path), [str(binary_path), *args])
40
+ return 0
41
+
42
+
43
+ def main_utp() -> None:
44
+ raise SystemExit(_run_binary(["utp"], "UTP"))
45
+
46
+
47
+ def main_utpd() -> None:
48
+ raise SystemExit(_run_binary(["utpd", "utp-server"], "UTPD"))
@@ -0,0 +1,653 @@
1
+ """Verified native binary discovery and SHA-256 download installer for UTP."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import hashlib
6
+ import hmac
7
+ import os
8
+ import platform
9
+ import re
10
+ import shutil
11
+ import ssl
12
+ import stat
13
+ import struct
14
+ import sys
15
+ import sysconfig
16
+ import tarfile
17
+ import tempfile
18
+ import urllib.parse
19
+ import urllib.request
20
+ import zipfile
21
+ from pathlib import Path, PurePosixPath
22
+ from typing import Iterable, Optional
23
+
24
+ VERSION = "v2.6.3"
25
+ REPO = "ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol"
26
+ MAX_REDIRECTS = 5
27
+ REQUEST_TIMEOUT_SEC = 30
28
+ MAX_ARCHIVE_BYTES = 100 * 1024 * 1024 # 100 MiB ceiling
29
+
30
+ ALLOWED_UNIX_BINARIES = frozenset({"utp", "utpd", "utp-server"})
31
+ ALLOWED_WINDOWS_BINARIES = frozenset({"utp.exe", "utpd.exe", "utp-server.exe"})
32
+ _WINDOWS_DLL_RE = re.compile(r"^[A-Za-z0-9_.+-]+\.dll$", re.IGNORECASE)
33
+ _APISET_PREFIXES = ("api-ms-win-", "ext-ms-win-")
34
+
35
+ _MACHO_MAGICS = (
36
+ b"\xfe\xed\xfa\xce",
37
+ b"\xfe\xed\xfa\xcf",
38
+ b"\xce\xfa\xed\xfe",
39
+ b"\xcf\xfa\xed\xfe",
40
+ b"\xca\xfe\xba\xbe",
41
+ )
42
+
43
+
44
+ class UnsupportedPlatformError(RuntimeError):
45
+ """Raised when prebuilt binaries are unavailable for the host OS/architecture."""
46
+
47
+
48
+ class BinaryVerificationError(RuntimeError):
49
+ """Raised when binary download, TLS, redirect, or SHA-256 verification fails."""
50
+
51
+
52
+ class _HttpsOnlyRedirectHandler(urllib.request.HTTPRedirectHandler):
53
+ """Enforces HTTPS-only redirect targets and caps redirect hops."""
54
+
55
+ def __init__(self, max_redirects: int = MAX_REDIRECTS) -> None:
56
+ super().__init__()
57
+ self.max_redirects = max_redirects
58
+
59
+ def redirect_request(self, req, fp, code, msg, headers, newurl):
60
+ count = getattr(req, "_utp_redirect_count", 0) + 1
61
+ if count > self.max_redirects:
62
+ raise BinaryVerificationError(f"Exceeded maximum redirects ({self.max_redirects})")
63
+
64
+ resolved = urllib.parse.urljoin(req.full_url, newurl)
65
+ parsed = urllib.parse.urlsplit(resolved)
66
+ if parsed.scheme.lower() != "https" or not parsed.netloc:
67
+ raise BinaryVerificationError(f"Refusing insecure non-HTTPS redirect target: {parsed.scheme!r}")
68
+
69
+ next_req = super().redirect_request(req, fp, code, msg, headers, resolved)
70
+ if next_req is not None:
71
+ next_req._utp_redirect_count = count
72
+ return next_req
73
+
74
+
75
+ def get_asset_name(system_name: Optional[str] = None, machine: Optional[str] = None) -> str:
76
+ sys_name = (system_name or platform.system()).lower()
77
+ arch = (machine or platform.machine()).lower()
78
+
79
+ if sys_name == "windows":
80
+ if arch in ("amd64", "x86_64", "x64"):
81
+ return "utp-windows-x64.zip"
82
+ raise UnsupportedPlatformError(
83
+ f"Unsupported Windows architecture '{arch}' for prebuilt binaries. Build from source with CMake."
84
+ )
85
+ if sys_name == "linux":
86
+ if arch in ("x86_64", "amd64"):
87
+ return "utp-linux-x64.tar.gz"
88
+ raise UnsupportedPlatformError(
89
+ f"Architecture '{arch}' does not have prebuilt Linux binaries yet. Clone and run ./build.sh."
90
+ )
91
+ if sys_name == "darwin":
92
+ return "utp-macos.tar.gz"
93
+
94
+ raise UnsupportedPlatformError(
95
+ f"Unsupported OS '{sys_name}'. Please build from source: https://github.com/{REPO}"
96
+ )
97
+
98
+
99
+ def get_cache_dir(version: str = VERSION) -> Path:
100
+ if os.name == "nt":
101
+ base = Path(os.environ.get("LOCALAPPDATA") or (Path.home() / "AppData" / "Local"))
102
+ else:
103
+ base = Path(os.environ.get("XDG_CACHE_HOME") or (Path.home() / ".cache"))
104
+ return base / "utp" / "bin" / version
105
+
106
+
107
+ def download_https_file(
108
+ url: str,
109
+ dest: Path,
110
+ *,
111
+ timeout: int = REQUEST_TIMEOUT_SEC,
112
+ max_bytes: int = MAX_ARCHIVE_BYTES,
113
+ max_redirects: int = MAX_REDIRECTS,
114
+ ) -> None:
115
+ parsed = urllib.parse.urlsplit(url)
116
+ if parsed.scheme.lower() != "https" or not parsed.netloc:
117
+ raise BinaryVerificationError(f"Refusing non-HTTPS URL: {url}")
118
+
119
+ ssl_ctx = ssl.create_default_context()
120
+ opener = urllib.request.build_opener(
121
+ urllib.request.HTTPSHandler(context=ssl_ctx),
122
+ _HttpsOnlyRedirectHandler(max_redirects=max_redirects),
123
+ )
124
+ req = urllib.request.Request(url, headers={"User-Agent": f"utp-engine-pypi/{VERSION}"})
125
+
126
+ total = 0
127
+ tmp_dest = dest.with_suffix(dest.suffix + ".part")
128
+ try:
129
+ with opener.open(req, timeout=timeout) as resp:
130
+ status = getattr(resp, "status", 200)
131
+ if status != 200:
132
+ raise BinaryVerificationError(f"HTTP {status} while fetching {url}")
133
+
134
+ final_scheme = urllib.parse.urlsplit(resp.geturl()).scheme.lower()
135
+ if final_scheme != "https":
136
+ raise BinaryVerificationError(f"Refusing insecure final scheme: {final_scheme}")
137
+
138
+ with open(tmp_dest, "wb") as out_f:
139
+ while True:
140
+ chunk = resp.read(65536)
141
+ if not chunk:
142
+ break
143
+ total += len(chunk)
144
+ if total > max_bytes:
145
+ raise BinaryVerificationError(f"Download exceeded {max_bytes} byte limit")
146
+ out_f.write(chunk)
147
+ os.replace(tmp_dest, dest)
148
+ except Exception:
149
+ try:
150
+ tmp_dest.unlink(missing_ok=True)
151
+ except OSError:
152
+ pass
153
+ raise
154
+
155
+
156
+ def parse_sha256sums(sums_text: str, asset_name: str) -> Optional[str]:
157
+ for raw_line in sums_text.splitlines():
158
+ line = raw_line.strip()
159
+ if not line:
160
+ continue
161
+ match = re.match(r"^([a-fA-F0-9]{64})\s+\*?(.+)$", line)
162
+ if not match:
163
+ continue
164
+ candidate_name = PurePosixPath(match.group(2).strip().replace("\\", "/")).name
165
+ if candidate_name == asset_name:
166
+ return match.group(1).lower()
167
+ return None
168
+
169
+
170
+ def verify_sha256(file_path: Path, expected_hex: str) -> bool:
171
+ if not file_path.is_file() or file_path.stat().st_size == 0:
172
+ return False
173
+ if not re.fullmatch(r"[a-fA-F0-9]{64}", expected_hex or ""):
174
+ return False
175
+
176
+ digest = hashlib.sha256()
177
+ with open(file_path, "rb") as f:
178
+ while True:
179
+ chunk = f.read(65536)
180
+ if not chunk:
181
+ break
182
+ digest.update(chunk)
183
+ actual_hex = digest.hexdigest().lower()
184
+ return hmac.compare_digest(actual_hex, expected_hex.lower())
185
+
186
+
187
+ def _safe_member_basename(
188
+ raw_name: str,
189
+ expected_names: Iterable[str],
190
+ *,
191
+ allow_windows_dlls: bool = False,
192
+ ) -> Optional[str]:
193
+ norm = raw_name.replace("\\", "/")
194
+ if not norm or norm.startswith("/"):
195
+ return None
196
+ if len(norm) >= 2 and norm[1] == ":" and norm[0].isalpha():
197
+ return None
198
+ parts = PurePosixPath(norm).parts
199
+ if any(part in ("..", "") for part in parts):
200
+ return None
201
+ base = parts[-1]
202
+ if base in expected_names:
203
+ return base
204
+ if allow_windows_dlls and _WINDOWS_DLL_RE.fullmatch(base):
205
+ return base
206
+ return None
207
+
208
+
209
+ def _write_archive_stream(src, out_path: Path, base_name: str) -> Path:
210
+ tmp_out = out_path.with_suffix(out_path.suffix + ".tmp")
211
+ try:
212
+ with open(tmp_out, "wb") as dst:
213
+ while True:
214
+ buf = src.read(65536)
215
+ if not buf:
216
+ break
217
+ dst.write(buf)
218
+ if tmp_out.stat().st_size == 0:
219
+ raise BinaryVerificationError(f"Refusing empty extracted file: {base_name}")
220
+ os.replace(tmp_out, out_path)
221
+ except Exception:
222
+ tmp_out.unlink(missing_ok=True)
223
+ raise
224
+ if os.name != "nt" and not base_name.lower().endswith(".dll"):
225
+ os.chmod(out_path, 0o755)
226
+ return out_path
227
+
228
+
229
+ def safe_extract_binaries(
230
+ archive_path: Path,
231
+ dest_dir: Path,
232
+ expected_names: set[str],
233
+ *,
234
+ allow_windows_dlls: Optional[bool] = None,
235
+ ) -> list[Path]:
236
+ """Extracts allowlisted executables (and Windows runtime DLLs) without ZipSlip, TarSlip, or symlinks."""
237
+ if allow_windows_dlls is None:
238
+ allow_windows_dlls = any(name.lower().endswith(".exe") for name in expected_names)
239
+
240
+ dest_dir.mkdir(parents=True, exist_ok=True)
241
+ if os.name != "nt":
242
+ try:
243
+ os.chmod(dest_dir, 0o700)
244
+ except OSError:
245
+ pass
246
+
247
+ extracted: list[Path] = []
248
+ dest_resolved = dest_dir.resolve()
249
+
250
+ if archive_path.suffix == ".zip":
251
+ with zipfile.ZipFile(archive_path, "r") as zf:
252
+ for info in zf.infolist():
253
+ if info.is_dir():
254
+ continue
255
+ unix_mode = info.external_attr >> 16
256
+ if stat.S_ISLNK(unix_mode):
257
+ raise BinaryVerificationError(f"Refusing symlink archive entry: {info.filename}")
258
+ base = _safe_member_basename(
259
+ info.filename, expected_names, allow_windows_dlls=allow_windows_dlls
260
+ )
261
+ if not base:
262
+ continue
263
+ out_path = (dest_dir / base).resolve()
264
+ if not out_path.is_relative_to(dest_resolved):
265
+ raise BinaryVerificationError(f"Archive path escape detected: {info.filename}")
266
+ with zf.open(info, "r") as src:
267
+ extracted.append(_write_archive_stream(src, out_path, base))
268
+ else:
269
+ with tarfile.open(archive_path, "r:gz") as tf:
270
+ for member in tf.getmembers():
271
+ if member.isdir():
272
+ continue
273
+ if member.issym() or member.islnk() or not member.isreg():
274
+ if _safe_member_basename(
275
+ member.name, expected_names, allow_windows_dlls=allow_windows_dlls
276
+ ):
277
+ raise BinaryVerificationError(f"Refusing non-regular archive entry: {member.name}")
278
+ continue
279
+ base = _safe_member_basename(
280
+ member.name, expected_names, allow_windows_dlls=allow_windows_dlls
281
+ )
282
+ if not base:
283
+ continue
284
+ out_path = (dest_dir / base).resolve()
285
+ if not out_path.is_relative_to(dest_resolved):
286
+ raise BinaryVerificationError(f"Archive path escape detected: {member.name}")
287
+ src = tf.extractfile(member)
288
+ if src is None:
289
+ continue
290
+ with src:
291
+ extracted.append(_write_archive_stream(src, out_path, base))
292
+
293
+ return extracted
294
+
295
+
296
+ def read_pe_imports(pe_path: Path) -> list[str]:
297
+ """Reads direct and delay-load PE DLL imports; returns [] for stubs or non-PE files."""
298
+ try:
299
+ data = pe_path.read_bytes()
300
+ except OSError:
301
+ return []
302
+ if len(data) < 0x40 or data[:2] != b"MZ":
303
+ return []
304
+ pe = struct.unpack_from("<I", data, 0x3C)[0]
305
+ if pe + 24 > len(data) or data[pe : pe + 4] != b"PE\x00\x00":
306
+ return []
307
+
308
+ n_sec = struct.unpack_from("<H", data, pe + 6)[0]
309
+ opt_sz = struct.unpack_from("<H", data, pe + 20)[0]
310
+ opt = pe + 24
311
+ if opt + 2 > len(data) or opt + opt_sz > len(data):
312
+ return []
313
+ magic = struct.unpack_from("<H", data, opt)[0]
314
+ if magic not in (0x10B, 0x20B):
315
+ return []
316
+
317
+ is_pe32_plus = magic == 0x20B
318
+ num_dirs_off = opt + (108 if is_pe32_plus else 92)
319
+ dir_base = opt + (112 if is_pe32_plus else 96)
320
+ sec_off = opt + opt_sz
321
+ if num_dirs_off + 4 > len(data) or sec_off + n_sec * 40 > len(data):
322
+ return []
323
+
324
+ num_dirs = struct.unpack_from("<I", data, num_dirs_off)[0]
325
+ secs = []
326
+ for i in range(n_sec):
327
+ _, vsz, va, rsz, ra = struct.unpack_from("<8sIIII", data, sec_off + i * 40)
328
+ secs.append((va, max(vsz, rsz), ra))
329
+
330
+ def rva2off(rva: int) -> Optional[int]:
331
+ for va, sz, ra in secs:
332
+ if va <= rva < va + sz:
333
+ return ra + (rva - va)
334
+ return None
335
+
336
+ def read_cstr(off: int) -> str:
337
+ end = data.find(b"\x00", off)
338
+ return "" if end == -1 else data[off:end].decode("ascii", "replace")
339
+
340
+ dlls: list[str] = []
341
+ if num_dirs > 1 and dir_base + 16 <= sec_off:
342
+ imp_rva, imp_sz = struct.unpack_from("<II", data, dir_base + 8)
343
+ off = rva2off(imp_rva) if imp_rva and imp_sz else None
344
+ while off is not None and off + 20 <= len(data):
345
+ _, _, _, name_rva, _ = struct.unpack_from("<IIIII", data, off)
346
+ if not name_rva:
347
+ break
348
+ no = rva2off(name_rva)
349
+ if no is not None:
350
+ name = read_cstr(no)
351
+ if name:
352
+ dlls.append(name)
353
+ off += 20
354
+
355
+ if num_dirs > 13 and dir_base + 112 <= sec_off:
356
+ d_rva, d_sz = struct.unpack_from("<II", data, dir_base + 13 * 8)
357
+ off = rva2off(d_rva) if d_rva and d_sz else None
358
+ while off is not None and off + 32 <= len(data):
359
+ attrs, dll_name, _, _, _, _, _, _ = struct.unpack_from("<IIIIIIII", data, off)
360
+ if not dll_name:
361
+ break
362
+ if attrs & 1:
363
+ no = rva2off(dll_name)
364
+ if no is not None:
365
+ name = read_cstr(no)
366
+ if name:
367
+ dlls.append(name)
368
+ off += 32
369
+
370
+ return dlls
371
+
372
+
373
+ def _default_windows_dll_dirs() -> list[Path]:
374
+ win_root = Path(os.environ.get("SystemRoot") or os.environ.get("WINDIR") or r"C:\Windows")
375
+ dirs = [win_root / "System32", win_root / "SysWOW64", win_root]
376
+ for raw_dir in os.environ.get("PATH", "").split(os.pathsep):
377
+ if raw_dir:
378
+ dirs.append(Path(raw_dir))
379
+ return dirs
380
+
381
+
382
+ def find_missing_windows_dlls(
383
+ exe_path: Path,
384
+ *,
385
+ search_dirs: Optional[list[Path]] = None,
386
+ ) -> list[str]:
387
+ """Finds non-API-set Windows DLL imports of exe_path that cannot be resolved locally."""
388
+ probe_dirs = [exe_path.parent]
389
+ if search_dirs is None:
390
+ probe_dirs.extend(_default_windows_dll_dirs())
391
+ else:
392
+ probe_dirs.extend(search_dirs)
393
+
394
+ dir_indexes: list[dict[str, Path]] = []
395
+ for d in probe_dirs:
396
+ try:
397
+ if d.is_dir():
398
+ dir_indexes.append({p.name.lower(): p for p in d.iterdir() if p.is_file()})
399
+ except OSError:
400
+ continue
401
+
402
+ queue = [exe_path]
403
+ seen: set[str] = set()
404
+ missing: list[str] = []
405
+
406
+ while queue:
407
+ cur = queue.pop(0)
408
+ for dll in read_pe_imports(cur):
409
+ key = dll.lower()
410
+ if key in seen or key.startswith(_APISET_PREFIXES):
411
+ continue
412
+ seen.add(key)
413
+ found_dll: Optional[Path] = None
414
+ for idx in dir_indexes:
415
+ if key in idx:
416
+ found_dll = idx[key]
417
+ break
418
+ if found_dll is None:
419
+ missing.append(dll)
420
+ elif found_dll.parent == exe_path.parent:
421
+ queue.append(found_dll)
422
+
423
+ return sorted(missing)
424
+
425
+
426
+ def bundle_windows_runtime_dlls(
427
+ executables: list[Path],
428
+ toolchain_bin_dir: Path,
429
+ dest_dir: Path,
430
+ *,
431
+ system_dirs: Optional[list[Path]] = None,
432
+ require_non_empty: bool = True,
433
+ ) -> list[str]:
434
+ """Recursively copies non-system Windows PE DLL dependencies into dest_dir."""
435
+ dest_dir.mkdir(parents=True, exist_ok=True)
436
+ toolchain_map = {p.name.lower(): p for p in toolchain_bin_dir.glob("*.dll") if p.is_file()}
437
+
438
+ if system_dirs is None:
439
+ win_root = Path(os.environ.get("SystemRoot") or os.environ.get("WINDIR") or r"C:\Windows")
440
+ sys_dirs = [win_root / "System32", win_root / "SysWOW64", win_root]
441
+ else:
442
+ sys_dirs = list(system_dirs)
443
+
444
+ sys_names: set[str] = set()
445
+ for d in sys_dirs:
446
+ try:
447
+ if d.is_dir():
448
+ sys_names.update(p.name.lower() for p in d.iterdir() if p.is_file())
449
+ except OSError:
450
+ continue
451
+
452
+ queue = list(executables)
453
+ seen: set[str] = set()
454
+ copied: list[str] = []
455
+
456
+ while queue:
457
+ cur = queue.pop(0)
458
+ for dll in read_pe_imports(cur):
459
+ key = dll.lower()
460
+ if key in seen or key.startswith(_APISET_PREFIXES):
461
+ continue
462
+ seen.add(key)
463
+ src = toolchain_map.get(key)
464
+ if src is not None:
465
+ dst = dest_dir / src.name
466
+ shutil.copy2(src, dst)
467
+ copied.append(src.name)
468
+ queue.append(dst)
469
+ elif key not in sys_names:
470
+ raise BinaryVerificationError(f"Unresolved non-system DLL required by {cur.name}: {dll}")
471
+
472
+ if require_non_empty and not copied:
473
+ raise BinaryVerificationError(f"Expected runtime DLL dependencies in {toolchain_bin_dir}, found 0")
474
+
475
+ return sorted(copied)
476
+
477
+
478
+ def is_native_executable(path: Path, is_windows: Optional[bool] = None) -> bool:
479
+ if is_windows is None:
480
+ is_windows = os.name == "nt"
481
+ try:
482
+ st = path.lstat()
483
+ if stat.S_ISLNK(st.st_mode) or not stat.S_ISREG(st.st_mode) or st.st_size < 4:
484
+ return False
485
+ with open(path, "rb") as f:
486
+ magic = f.read(4)
487
+ except OSError:
488
+ return False
489
+
490
+ if is_windows:
491
+ return magic[:2] == b"MZ"
492
+
493
+ # Reject script shims (#! ...) to prevent recursive wrapper self-invocation
494
+ if magic[:2] == b"#!":
495
+ return False
496
+ return magic == b"\x7fELF" or magic in _MACHO_MAGICS
497
+
498
+
499
+ def _excluded_script_dirs() -> set[Path]:
500
+ dirs: set[Path] = set()
501
+ scripts_path = sysconfig.get_path("scripts")
502
+ if scripts_path:
503
+ try:
504
+ dirs.add(Path(scripts_path).resolve())
505
+ except OSError:
506
+ pass
507
+ if sys.argv and sys.argv[0]:
508
+ try:
509
+ dirs.add(Path(sys.argv[0]).resolve().parent)
510
+ except OSError:
511
+ pass
512
+ return dirs
513
+
514
+
515
+ def resolve_binary(
516
+ names: list[str],
517
+ *,
518
+ cache_dir: Optional[Path] = None,
519
+ package_dir: Optional[Path] = None,
520
+ search_path: bool = True,
521
+ is_windows: Optional[bool] = None,
522
+ ) -> Optional[Path]:
523
+ if is_windows is None:
524
+ is_windows = os.name == "nt"
525
+
526
+ pkg_root = (package_dir or Path(__file__).resolve().parent).parent
527
+ pkg_bin = (package_dir or Path(__file__).resolve().parent) / "bin"
528
+ candidate_dirs: list[Path] = [pkg_bin, pkg_root]
529
+
530
+ # Monorepo checkout detection (pypi/utp_engine -> repo root is 2 levels up)
531
+ monorepo_root = pkg_root.parent
532
+ if (monorepo_root / "CMakeLists.txt").is_file():
533
+ candidate_dirs.append(monorepo_root)
534
+
535
+ candidate_dirs.append(cache_dir or get_cache_dir())
536
+
537
+ for directory in candidate_dirs:
538
+ for name in names:
539
+ candidate = directory / name
540
+ if is_native_executable(candidate, is_windows=is_windows):
541
+ return candidate
542
+
543
+ if not search_path:
544
+ return None
545
+
546
+ excluded_dirs = _excluded_script_dirs()
547
+ for raw_dir in os.environ.get("PATH", "").split(os.pathsep):
548
+ if not raw_dir:
549
+ continue
550
+ try:
551
+ dir_path = Path(raw_dir).resolve()
552
+ except OSError:
553
+ continue
554
+ if dir_path in excluded_dirs:
555
+ continue
556
+ for name in names:
557
+ candidate = dir_path / name
558
+ if is_native_executable(candidate, is_windows=is_windows):
559
+ return candidate
560
+
561
+ return None
562
+
563
+
564
+ def install_release_binaries(
565
+ *,
566
+ version: str = VERSION,
567
+ repo: str = REPO,
568
+ cache_dir: Optional[Path] = None,
569
+ system_name: Optional[str] = None,
570
+ machine: Optional[str] = None,
571
+ ) -> list[Path]:
572
+ asset_name = get_asset_name(system_name=system_name, machine=machine)
573
+ target_cache = cache_dir or get_cache_dir(version=version)
574
+ is_win = (system_name or platform.system()).lower() == "windows"
575
+ expected_names = set(ALLOWED_WINDOWS_BINARIES if is_win else ALLOWED_UNIX_BINARIES)
576
+
577
+ base_url = f"https://github.com/{repo}/releases/download/{version}"
578
+ archive_url = f"{base_url}/{asset_name}"
579
+ checksum_url = f"{base_url}/SHA256SUMS.txt"
580
+
581
+ with tempfile.TemporaryDirectory(prefix="utp-install-") as tmp_dir_str:
582
+ tmp_dir = Path(tmp_dir_str)
583
+ archive_file = tmp_dir / asset_name
584
+ sums_file = tmp_dir / "SHA256SUMS.txt"
585
+
586
+ download_https_file(archive_url, archive_file)
587
+ download_https_file(checksum_url, sums_file)
588
+
589
+ expected_sha = parse_sha256sums(sums_file.read_text(encoding="utf-8", errors="replace"), asset_name)
590
+ if not expected_sha:
591
+ raise BinaryVerificationError(f"Checksum for {asset_name} not found in SHA256SUMS.txt")
592
+
593
+ if not verify_sha256(archive_file, expected_sha):
594
+ raise BinaryVerificationError(f"SHA-256 checksum verification failed for {asset_name}")
595
+
596
+ extracted = safe_extract_binaries(
597
+ archive_file, target_cache, expected_names, allow_windows_dlls=is_win
598
+ )
599
+ if not any(p.name in expected_names for p in extracted):
600
+ raise BinaryVerificationError(f"No valid binaries found inside {asset_name}")
601
+ return extracted
602
+
603
+
604
+ def _is_within_dir(path: Path, parent: Path) -> bool:
605
+ try:
606
+ return path.resolve().is_relative_to(parent.resolve())
607
+ except OSError:
608
+ return False
609
+
610
+
611
+ def ensure_binary(
612
+ names: list[str],
613
+ *,
614
+ cache_dir: Optional[Path] = None,
615
+ package_dir: Optional[Path] = None,
616
+ version: str = VERSION,
617
+ repo: str = REPO,
618
+ ) -> Path:
619
+ target_cache = cache_dir or get_cache_dir(version=version)
620
+ found = resolve_binary(names, cache_dir=target_cache, package_dir=package_dir)
621
+ if found is not None:
622
+ if os.name == "nt":
623
+ missing = find_missing_windows_dlls(found)
624
+ if not missing:
625
+ return found
626
+ if not _is_within_dir(found, target_cache):
627
+ raise BinaryVerificationError(
628
+ f"Resolved binary {found} is missing Windows runtime DLLs: {', '.join(missing)}"
629
+ )
630
+ print(
631
+ f"[utp-engine] Cached binary {found.name} is missing runtime DLLs ({', '.join(missing)}); refreshing...",
632
+ file=sys.stderr,
633
+ flush=True,
634
+ )
635
+ else:
636
+ return found
637
+
638
+ print(
639
+ f"[utp-engine] Downloading verified UTP {version} native engine from GitHub Releases...",
640
+ file=sys.stderr,
641
+ flush=True,
642
+ )
643
+ install_release_binaries(version=version, repo=repo, cache_dir=target_cache)
644
+ found = resolve_binary(names, cache_dir=target_cache, package_dir=package_dir)
645
+ if found is None:
646
+ raise BinaryVerificationError(f"Native binary {names[0]} unavailable after installation")
647
+ if os.name == "nt":
648
+ missing = find_missing_windows_dlls(found)
649
+ if missing:
650
+ raise BinaryVerificationError(
651
+ f"Missing Windows runtime DLLs for {found.name}: {', '.join(missing)}"
652
+ )
653
+ return found
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.4
2
+ Name: utp-engine
3
+ Version: 2.6.3
4
+ Summary: Zero-disk cloud-to-cloud transfer, direct web ingestion, media streaming & sync engine — Google Drive, OneDrive, S3, R2, Dropbox, WebDAV — TLS 1.3 RAM pipeline
5
+ Author: Arpit Nayak
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Arpit Nayak & Contributors
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://ctp.arpitnayak.tech
29
+ Project-URL: Repository, https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol
30
+ Project-URL: Issues, https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol/issues
31
+ Project-URL: Documentation, https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol#readme
32
+ Keywords: cloud,transfer,streaming,zero-disk,direct-download,ingest,migration,sync,google-drive,onedrive,dropbox,icloud,s3,r2,b2,webdav,cli,media-server
33
+ Classifier: Development Status :: 5 - Production/Stable
34
+ Classifier: Environment :: Console
35
+ Classifier: Intended Audience :: Developers
36
+ Classifier: Intended Audience :: System Administrators
37
+ Classifier: License :: OSI Approved :: MIT License
38
+ Classifier: Operating System :: MacOS
39
+ Classifier: Operating System :: Microsoft :: Windows
40
+ Classifier: Operating System :: POSIX :: Linux
41
+ Classifier: Programming Language :: C++
42
+ Classifier: Programming Language :: Python :: 3
43
+ Classifier: Programming Language :: Python :: 3 :: Only
44
+ Classifier: Topic :: Internet
45
+ Classifier: Topic :: System :: Archiving :: Backup
46
+ Classifier: Topic :: Utilities
47
+ Requires-Python: >=3.8
48
+ Description-Content-Type: text/markdown
49
+ License-File: LICENSE
50
+ Dynamic: license-file
51
+
52
+ # Universal Cloud Transfer Protocol (UTP)
53
+
54
+ **Zero-Disk Cloud-to-Cloud Transfer, Direct Web Ingestion, Media Streaming & Sync Engine**
55
+
56
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol/blob/PROJECTS/LICENSE)
57
+ [![Official Portal](https://img.shields.io/badge/Official%20Site-ctp.arpitnayak.tech-FF5B1F.svg)](https://ctp.arpitnayak.tech)
58
+ [![Release](https://img.shields.io/badge/Release-v2.6.3--pro-cyan.svg)](https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol/releases)
59
+
60
+ UTP (`utp-engine`) streams files directly across cloud storage drives and HTTP/HTTPS URLs through bounded **volatile RAM ring buffers** over TLS 1.3 — writing **0 bytes** to local disk.
61
+
62
+ ## Installation
63
+
64
+ ```bash
65
+ pip install utp-engine
66
+ ```
67
+
68
+ Or install cleanly in an isolated environment:
69
+
70
+ ```bash
71
+ pipx install utp-engine
72
+ # or
73
+ uv tool install utp-engine
74
+ ```
75
+
76
+ Installing `utp-engine` provides `utp`, `ctp`, `utp-engine`, `utpd`, and `utp-server` directly in your terminal. On first launch, it fetches the official native C++ release binary for your OS over HTTPS and verifies its SHA-256 digest against `SHA256SUMS.txt` before execution.
77
+
78
+ ## Quick Usage
79
+
80
+ ```bash
81
+ # Interactive terminal explorer & operations hub
82
+ utp
83
+
84
+ # Direct HTTPS URL ingestion into cloud storage (zero disk)
85
+ utp ingest https://example.com/archive.tar.gz gdrive://Backups/
86
+
87
+ # Direct cloud-to-cloud streaming transfer
88
+ utp transfer gdrive://1BxiMVs0XRA5nF... onedrive://Backups/data.zip
89
+
90
+ # On-demand zero-disk media streaming (HTTP 206 Range -> VLC / MPV / browser)
91
+ utp stream gdrive://movies/clip.mp4 --open
92
+
93
+ # Start the local utpd REST daemon (bound to 127.0.0.1:8080 by default)
94
+ utp daemon start
95
+ ```
96
+
97
+ ## Security & Privacy
98
+
99
+ - **Verified Binary Fetch:** Downloads only over HTTPS (with redirect caps), checks SHA-256 in constant time against GitHub Release `SHA256SUMS.txt`, and rejects ZipSlip/TarSlip paths or symlinks.
100
+ - **Zero Telemetry & Local Credentials:** OAuth tokens and daemon credentials remain solely in owner-restricted files on your machine.
101
+ - **Full Documentation:** [GitHub Repository](https://github.com/ARPIT-NAYAK-LEGEND/Cloud-Transfer-Protocol) · [Privacy Policy](https://ctp.arpitnayak.tech/privacy)
@@ -0,0 +1,14 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ PRIVACY.md
4
+ README.md
5
+ SECURITY.md
6
+ pyproject.toml
7
+ utp_engine/__init__.py
8
+ utp_engine/cli.py
9
+ utp_engine/installer.py
10
+ utp_engine.egg-info/PKG-INFO
11
+ utp_engine.egg-info/SOURCES.txt
12
+ utp_engine.egg-info/dependency_links.txt
13
+ utp_engine.egg-info/entry_points.txt
14
+ utp_engine.egg-info/top_level.txt
@@ -0,0 +1,6 @@
1
+ [console_scripts]
2
+ ctp = utp_engine.cli:main_utp
3
+ utp = utp_engine.cli:main_utp
4
+ utp-engine = utp_engine.cli:main_utp
5
+ utp-server = utp_engine.cli:main_utpd
6
+ utpd = utp_engine.cli:main_utpd
@@ -0,0 +1 @@
1
+ utp_engine