Metadata-Version: 2.4
Name: gofile-tool
Version: 0.1.0
Summary: Tải / upload Gofile.io tốc độ tối đa — tự động vượt chặn IP (Tor + chữ ký web X-Website-Token)
Author: gofile-tool contributors
License: MIT
Project-URL: Homepage, https://pypi.org/project/gofile-tool/
Project-URL: Source, https://pypi.org/project/gofile-tool/
Keywords: gofile,downloader,uploader,tor,cli,bypass,download
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.25.0
Requires-Dist: pysocks>=1.7.1
Provides-Extra: dev
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

# 🧰 gofile-tool

**Tải / upload Gofile.io ở tốc độ tối đa — tự động vượt chặn IP của datacenter/VPS.**

Gofile hay drop kết nối TLS với IP máy ảo (báo `error-rateLimit`, treo TLS handshake).
`gofile-tool` tự xử lý: thử đường thẳng → nếu bị chặn thì tự bật **Tor**, xoay IP, tạo tài
khoản guest và ký đúng header `X-Website-Token` mà Gofile đòi. Dữ liệu lớn vẫn tải/upload
**thẳng** qua `store*.gofile.io` / `upload.gofile.io` nên tốc độ nguyên bản.

```bash
pip install gofile-tool
gofile-tool download Uc4c9oyJ -o ./tai-ve
```

---

## ⚡ Cài đặt

```bash
pip install gofile-tool          # hoặc: pipx install gofile-tool

# chỉ cần khi IP của bạn bị Gofile chặn (tool tự bật Tor):
sudo apt install -y tor          # Debian/Ubuntu
brew install tor                 # macOS
```

Yêu cầu: Python ≥ 3.8.

## 🚀 Lệnh

```bash
gofile-tool info     <CODE>                  # xem metadata file/folder
gofile-tool download <CODE> -o ./tai-ve      # tải file hoặc cả folder
gofile-tool upload   ./file.zip              # up + tự set public + in link
gofile-tool public   <CODE>                  # mở public cho nội dung đã có
gofile-tool delete   <FILE_ID> --token <TK>  # xoá file
gofile-tool stop-tor                         # tắt Tor
```

| Cờ | Ý nghĩa |
|---|---|
| `--json` | Output JSON (cho AI agent / script). Luôn kèm `_token` để quản lý sau |
| `-o DIR` | Thư mục lưu file tải về (mặc định `.`) |
| `--workers N` | Số luồng khi tải folder (mặc định 4) |
| `--token TOKEN` | Dùng tài khoản Gofile của bạn (mặc định tự tạo guest) |
| `--proxy URL` | Dùng proxy/VPN riêng: `--proxy socks5h://127.0.0.1:1080` |
| `--no-tor` | Không dùng Tor |
| `--no-verify` | Bỏ qua kiểm tra MD5 |

**Ví dụ JSON (`gofile-tool upload ./file.zip --json`):**

```json
{
 "ok": true, "name": "file.zip", "size": 577188003, "md5": "912175…",
 "code": "UGqKJoFZ", "page": "https://gofile.io/d/nAF2ydFc",
 "file_id": "783e9f12-…", "speed_MBps": 83.0,
 "public": true, "link": "https://gofile.io/d/UGqKJoFZ",
 "_token": "Q23LICkojSBdNVgRjhbx7z72ZqVBldGw"
}
```

## 🤖 Dành cho AI agent

Không cần agent thông minh — chỉ cần bảo nó chạy:

```bash
pip install gofile-tool
gofile-tool download <CODE> -o <DIR> --json     # hoặc: gofile-tool upload <FILE> --json
```

Mọi lệnh đều có `--json`; output gồm `link`, `md5`, `size`, `ok`, `_token`.
Tool tự lo: tài khoản, chữ ký, đổi IP, resume, kiểm tra MD5.

## 🔍 Nguyên lý (3 mánh)

1. **Ký đúng chữ ký web.** Gofile đòi
   `X-Website-Token = sha256(UA :: ngôn ngữ :: accountToken :: floor(epoch/14400) :: secret)`.
   `secret` nằm trong `/js/wt.obf.js` và **bị xoay định kỳ** → tool tự tải, tự bóc
   (và đối chiếu chéo bằng `node` nếu có), cache 6 giờ.
2. **Đổi IP bằng Tor khi bị chặn.** Tự cài/khởi động Tor (SOCKS5 `9050`, control `9051`),
   gặp `error-rateLimit` thì gửi `SIGNAL NEWNYM` đổi exit node, thử lại tối đa 6 lần.
3. **Tách đường điều khiển / đường dữ liệu.** Chỉ vài KB metadata đi qua Tor/chậm;
   còn dữ liệu lớn đi **thẳng** `store*` / `upload` → tốc độ tối đa
   (đo thực tế: **tải 36 MB/s**, **upload 83 MB/s**).

Không vượt quyền truy cập: tool chỉ gửi đúng header mà trình duyệt vẫn gửi;
file private thì vẫn không mở được.

## 🩺 Sự cố thường gặp

| Thông báo | Cách sửa |
|---|---|
| `error-notPremium` | Secret đã xoay → tool tự nạp lại; nếu kẹt: xoá `~/.cache/gofile_secret.json` |
| `error-rateLimit` | Tool tự đổi mạch Tor; chờ vài giây |
| `API thất bại (direct: ConnectTimeout)` | Thiếu Tor → `sudo apt install -y tor`, hoặc `--proxy socks5h://…` |
| Folder tải chậm | Gofile chỉ cho ZIP folder ở gói Premium → tool tải từng file, đa luồng |
| `Permission denied …/control_auth_cookie` | `sudo rm -rf ~/.cache/gofile-tor` rồi chạy lại |
| Upload xong bị "Protected content" | Phải set public cho **cả thư mục cha** — tool đã làm sẵn |

## ⚠️ Giới hạn

- Mặc định dùng tài khoản **guest** (tự tạo). Muốn giữ file lâu: truyền `--token <token của bạn>` hoặc set `GOFILE_TOKEN`.
- Gofile miễn phí dọn file sau ~10 ngày không có lượt tải.
- Cần `tor` (hoặc proxy riêng) **chỉ khi** IP của bạn bị chặn; IP nhà thường không cần.

## Giấy phép

MIT
