4 Commits

Author SHA1 Message Date
UNITRONIX b65a16c7b5 fix(signal,updater,ratelimit): address #121, #122, #123
Three independent bug fixes bundled together; none of the issues are
auto-closed by this commit so the reporters can confirm on a tagged build.

#121 — NAT hairpin: same-public-IP detection forces relay path

The signal handler now distinguishes 'same /24 private subnet' (genuine
LAN, keep direct path) from 'same public IP' (NAT hairpin scenario).
When both peers register from the same public IP, both the UDP and
TCP/WS punch-hole handlers skip the LAN-address exchange and steer the
client straight to the relay — matching upstream RustDesk behavior.
Most consumer routers and cellular gateways drop hairpinned UDP, which
was causing same-Wi-Fi connections to silently time out.

  - new helper isSamePublicIP() in signal/handler.go
  - new config flag SameNATRelay (default: enabled)
  - env: SAME_NAT_RELAY=N to opt out
  - cli: --same-nat-relay=false to opt out

Reported-by: @eternalliving (#121)

#122 — Rate limit configurable, 0 disables

The 20 registrations/min/IP cap was unworkable for any deployment with
real NAT/CGNAT in front of it. Made it tunable without recompiling and
hardened the limiter to short-circuit when disabled.

  - new config field SignalRateLimitPerIP (default: 20, unchanged)
  - env: SIGNAL_RATE_LIMIT_PER_IP=<n> (0 = unlimited)
  - cli: --signal-rate-limit-per-ip=<n>
  - ratelimit.IPLimiter.Allow() now returns true early when limit<=0

Reported-by: @Henry-739 (#122)

#123 — Updater corrupting live SQLite WAL files

A previous gitleaks-fix commit accidentally tracked live SQLite sidecar
files (auth.db-shm/wal, betterdesk.db-shm/wal, .session_secret,
.update_sha). The in-app updater's diff-against-GitHub logic then
'restored' those tracked-by-mistake files on user installs, which is
exactly how SQLite database corruption gets manufactured.

Layered defense:
  - .gitignore now covers *.db-shm, *.db-wal, *.sqlite3-{shm,wal,journal},
    web-nodejs/data/, .session_secret, .update_sha, .api_key,
    .admin_credentials, .force_password_update, .env*
  - removed the offending files from the index (data/.gitkeep retained)
  - updateService.js EXCLUDE_PATTERNS extended to match the new gitignore
  - new write-time guard isProtectedRuntimePath() wired into all four
    write sites in updateService.js so even a stale GitHub diff cannot
    overwrite a runtime state file on disk

Reported-by: @SterlynKong (#123)
2026-05-01 16:22:50 +02:00
UNITRONIX 7ffd109243 Gitleaks fix 2026-04-29 01:54:04 +02:00
UNITRONIX ca33cf3919 fix: #93 EJS template error, #90 modal z-index, #95 org select, #75 kebab menu overflow
- remote.ejs + remote-viewer.ejs: Replace EJS tag inside JS template literal
  with JS interpolation to fix 'Could not find matching close tag' error (#93)
- variables.css: Increase z-index layers (modal:1000, toast:1100, tooltip:1200)
  so modals always appear above device detail panel (#90)
- policies.js: Fix API endpoint /api/panel/organizations -> /api/panel/org
  to correctly load organizations in policy dropdown (#95)
- devices.js: Fix kebab menu positioning - force reflow before measuring
  offsetHeight, add dynamic max-height constraint for viewport bounds (#75)
2026-04-08 23:55:03 +02:00
UNITRONIX 8d952e4ba1 Add password auth helpers; remove legacy dev scripts
Add a new auth package implementing password hashing/verification (PBKDF2-HMAC-SHA256), a random-string generator, and unit tests. Update .gitignore to catch additional sensitive filenames and to ignore legacy dev scripts, migrations, templates and build artifacts. Remove many legacy/dev helper scripts (dev_modules/, scripts/legacy/, build_windows.sh, migrations/, templates/) and add web-nodejs reset-password scripts and a session secret placeholder. Changes consolidate authentication utilities and clean up old/unused development tooling and noise in the repo.
2026-03-02 07:59:24 +01:00