Commit Graph
9 Commits
Author SHA1 Message Date
eberkheev a0c996b19d refactor(server): extract helpers and simplify auth dispatch
- Move `sha256_hex` and cookie constants to module level; drop `token_is_hash` param in favour of regex auto-detection
- Make `_respond()` accept `status`/`headers`; add `_redirect()` helper to eliminate boilerplate in auth routes
- Simplify `_dispatch()` with a `PUBLIC_ROUTES` set and positive-logic early-return
- Restrict CORS header to file API; auth responses no longer send `Access-Control-Allow-Origin: *`
- Extract `clearPager()` in frontend and deduplicate `copyText` fallback path
2026-07-29 18:08:36 +04:00
eberkheev 7af9aec0b3 feat(deploy): add install script and untrack share.config
Package the service for setup on a new machine:

- install.sh generates a token, writes share.config (mode 600, token
  stored as a SHA-256 hash) and installs the systemd user unit from
  share.service.template
- share.config is now gitignored, with share.config.example as the
  tracked template — the config holds the secret and must not be in
  the repo
- warn at startup when token is empty, since that means open access
- SETUP.md documents install, verification and security posture
2026-07-27 02:07:21 +04:00
eberkheev 6f6b7552fc feat(auth): add token authentication with SHA-256 hashed storage 2026-03-29 15:54:41 +04:00
eberkheevandClaude Opus 4.6 6a540eaf81 Split share.py into modules by responsibility
config.py  — share.config loading, constants, load_config(), client_cfg()
cert.py    — get_local_ip(), ensure_cert()
cleanup.py — cleanup_loop()
server.py  — ShareServer, Handler, file_type()
share.py   — main() entry point only

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 20:56:58 +04:00
eberkheevandClaude Opus 4.6 9cc4693f39 Extract all magic numbers into share.config
Unified config file with [server] (user-facing: port, dir, ttl, lang,
etc.) and [internal] (constants: timeouts, buffer sizes, cert params,
UI timings). Replaces both DEFAULTS dict and hardcoded constants.
JS constants (toast_ms, progress_hide_ms) passed through CFG injection.
Old share.conf no longer used.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 20:52:57 +04:00
eberkheevandClaude Opus 4.6 082a80a6c5 Harden server and fix client-side edge cases
Python: per-file error handling in cleanup, single stat() in download,
S_ISREG check, Content-Disposition escaping, Content-Length on all
responses, route prefix passed to handlers (no magic numbers), validate
empty upload, ensure_cert handles partial cert pair, narrower exception
catches.

JS: visibility-aware polling, concurrent upload guard, fetch r.ok checks,
missing .catch() on delete/loadFiles, REFRESH_SEC→REFRESH_MS rename,
explicit parseInt radix, transition: all→specific properties.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 20:47:47 +04:00
eberkheevandClaude Opus 4.6 ebe5c6ec90 Refactor: fix socket leak, deduplicate stat/path logic, simplify config
- get_local_ip: use context manager to prevent socket leak
- _route_files: single stat() per file instead of two
- _safe_path helper: DRY path resolution for download/delete
- load_config: loop over vars(args) instead of 6 repetitive blocks
- Remove stale comment from index.html

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 20:38:53 +04:00
eberkheevandClaude Opus 4.6 266308a2eb Detect text files via MIME + binary heuristic instead of hardcoded extension list
Server-side _file_type() now uses mimetypes for images/known text,
and falls back to null-byte check on first 8KB for everything else.
Client uses the "type" field from /files API instead of local extension sets.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 20:35:16 +04:00
eberkheevandClaude Opus 4.6 eba5ece147 Initial commit
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 20:23:55 +04:00