Skip to main content

bofile — Python CLI for BoFileX

Control a running local BoFileX using its existing HTTP API. The PyPI distribution, Python module and console command are all named bofile. Python 3.10+; no runtime dependencies. This package does not include the BoFileX daemon or implement libp2p, start services, or create machine state.

Install and run

After publication:

python -m pip install bofile
bofile --help
python -m bofile --version

From this directory during development:

python -m pip install -e .
python -m bofile --help

The default API origin is http://127.0.0.1:34120, set by client/bofilex_main.go. BoFileX can choose another free port if that port is busy: use the actual HTTP UI origin explicitly. A native-only Wails window may not expose this HTTP API. The old dialer API on port 34115 is a different API and is not supported here.

bofile --base-url http://127.0.0.1:34120 info
bofile peers --json
bofile message send PEER_ID "你好,文件已经准备好了"
bofile files list PEER_ID . --json
bofile transfer upload PEER_ID ./report.pdf /shared
bofile transfer download PEER_ID /shared/report.pdf ./downloads --size 12345 --mtime 1700000000
bofile transfer list --json
bofile transfer cancel 42
bofile transfer resume 42
bofile channels list PEER_ID
bofile channels select nat --direction up
bofile channels select auto
bofile channels mode direct
bofile channels mode auto

Replace PEER_ID with a full peer ID from peers. Global flags (--base-url, --token-file, --timeout, --json) work before or after subcommands. Each command supports --help. This CLI defaults to a 30-second HTTP timeout. There is no automatic retry, since resubmitting a mutation could duplicate work.

Authentication and connection safety

core/modules/admin/guard.go allows non-browser scripts that omit Origin, Referer and Sec-Fetch-Site. The CLI uses that contract by default and does not read any token, configuration, identity or state file automatically. It never fetches the UI page to harvest a session cookie.

When a persisted UI token is needed, explicitly select the existing file:

bofile --token-file /path/to/ui-session.token info

The file must contain the 32-character hex UI token. It is sent as the cookie bofile_ui_<API-port>, not as a Bearer token or query parameter. No token option accepts the raw secret on the command line. The file is read only and is never created or refreshed. Invalid/missing explicit files fail rather than falling back silently. A 401/403 is an error; remote management password login is not implemented.

BoFileX resolves its own state using BOFILE_STATE_DIR, or on Windows usually %ProgramData%\bofilex, otherwise the platform user config directory with the bofilex namespace (and native fallback rules). Choose the file used by your instance explicitly; this CLI does not reproduce the daemon's state migration or executable-directory fallback logic.

Only numeric loopback origins are accepted (127.0.0.1, [::1]); DNS names, including localhost, non-loopback IPs, URL credentials, base paths, queries and fragments are rejected before reading a token. Environment HTTP proxies are disabled. All redirects are refused, even to another loopback port. This keeps cookies and local data from being forwarded to a different endpoint or through a proxy. HTTPS uses Python's normal certificate verification. For another machine use a trusted SSH tunnel to a local numeric loopback port; remote file paths and metadata then belong to that daemon, so upload/download local path checks assume the CLI and BoFileX share the same filesystem.

Transfer and channel semantics

  • Upload/download queue a server-side single-file job. File bytes do not pass through Python. A successful command returns a job ID, not a completed transfer. Inspect transfer list for queued/active/done/error/canceled states. Exiting or interrupting the CLI does not cancel submitted work.
  • Upload source paths are resolved to absolute paths and must be regular local files. Size comes from the file stat. The destination is a remote directory; --name changes the destination basename. Directory recursion is not included.
  • Download targets are existing local directories, resolved to absolute paths. Use files list to obtain the remote path, size and mtime (Unix seconds). --size is required, including --size 0 for an empty file. No metadata lookup happens implicitly. --mtime defaults to zero (unknown). --overwrite opts into replacing a local destination; otherwise BoFileX chooses a free name. Remote upload conflict handling remains the daemon's behavior.
  • Cancel is the daemon's idempotent operation: it may return status: ok even for an unknown ID. Resume acts on the same existing job and its .part data; the daemon rejects jobs it cannot continue. Queue durability across a daemon restart is not promised by this CLI.
  • A message response sent: true means accepted for asynchronous delivery. The daemon may subsequently queue/retry delivery or record a refusal.
  • channels list PEER_ID can focus the engine on that peer when no UI socket holds focus. An open UI socket may retain focus instead; check the response's peer. channels select and channels mode change the shared currently focused engine, not a per-command or per-peer isolated session. Selecting auto sends an empty pin; selecting all directions clears directional pins. A pin may fall back to another ready path. direct/relay modes clear pins.
  • files list can update the daemon's remembered remote pane directory. peers may refresh discovery. These are existing API side effects.

Output, errors and API mapping

--json prints the API response as one JSON value on stdout. Human output is pretty JSON except for explicit message submission/transfer queue acknowledgments. Operational errors use stderr (a JSON {"error": "..."} object with --json), with no traceback or HTTP response body dump. API error fields fail even when HTTP status is 200. HTTP responses are limited to 8 MiB.

Exit codes: 0 success, 1 operational/API error, 2 argparse usage error, 130 interrupted. Argparse usage errors remain standard text, including with --json. A timeout or lost connection does not prove that a mutation failed; check daemon state before submitting it again.

Command Local route Method / query
info /api/info GET
peers /api/peers GET
message send /api/peers/chat/send POST; peer, text
files list /api/remote/listdir GET; peer, path
transfer list /api/transfers GET
transfer upload/download /api/transfer/add POST; peer, peername, dir=up/down, src, target, name, size; download: mtime, overwrite
transfer cancel/resume /api/transfer/cancel, /api/transfer/resume POST; id
channels list /api/peers/channels GET; peer
channels select /api/peers/channels/select POST; name, dir=empty/up/down
channels mode /api/peers/channels/mode POST; mode=auto/direct/relay

Mutations use POST with URL query parameters and an empty body, matching the Go handlers' r.URL.Query() implementation. Do not log full request URLs if message content or filesystem paths are sensitive. Peer IDs and paths are encoded query values and can never change the HTTP destination.

Test, build and release handoff

From this directory (PowerShell):

$env:PYTHONPATH = "$PWD/src"
python -m unittest discover -s tests -v
python -m build

Tests use only ephemeral loopback mock HTTP servers and temporary files. No test contacts a running BoFileX, reads real tokens, starts/stops services, or publishes anything. Coverage includes route/query contracts, file metadata, Unicode escaping, cookie auth, redirects, proxy isolation, URL restrictions, JSON/API errors, and validation before any mutation.

python -m build creates dist/bofile-0.1.0-py3-none-any.whl and dist/bofile-0.1.0.tar.gz. Setuptools is a build dependency only. The sdist includes the tests. Review package metadata, ownership/licensing and release version before publication; PyPI name availability does not reserve a name. The release owner handles PyPI credentials, final validation and publishing. This implementation deliberately does not upload to PyPI or TestPyPI.

Metadata

Release files for bofile 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bofile 0.1.0
File Size Uploaded Provenance Actions
bofile-0.1.0.tar.gz 18.3 kB Without provenance Details for bofile-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bofile 0.1.0
File Interpreter ABI Platform Actions
bofile-0.1.0-py3-none-any.whl Python 3 none any Details for bofile-0.1.0-py3-none-any.whl

Total release size: 30.1 kB

Release files / bofile-0.1.0.tar.gz

Download URL bofile-0.1.0.tar.gz
Size 18.3 kB
Tags Source
SHA-256 checksum
How to use checksums
93cc81974f7646970d829e047b4d07b0c8cbf4c209aed5d582f3a83abd27ee50
BLAKE2b-256 checksum
How to use checksums
2f0ff59a7e945a08285909a5749bc24f9de9a471718de3f5dffc2bb3f80dbcc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / bofile-0.1.0-py3-none-any.whl

Download URL bofile-0.1.0-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
77e5191674e1323f7829c26caf1dad41c67b2efd38f317fffcfc2d19d3db405e
BLAKE2b-256 checksum
How to use checksums
3539fa9c6af62164f1fd503c8223f03553d9379d24fdcd9b8f00963028ad9693
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Security for bofile 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page