Commit Graph
37 Commits
Author SHA1 Message Date
maziggy 7d4dfd5a7d fix(vp): stop uvloop from silently truncating VP FTP uploads (#1896)
Native (non-Docker) installs launched uvicorn without --loop asyncio, so
uvicorn[standard] auto-selected uvloop. uvloop's SSL layer drops
already-received but still-buffered data when the client closes the data
connection without a TLS close_notify while the reader is flow-control
paused on slow storage. cmd_STOR writes each chunk to disk inside the read
loop, so a slow consumer falls behind, the tail is lost, read() returns a
clean EOF, and the loop exits with no exception -- the server acked 226 for
a file it truncated itself, then archived, queued, and forwarded the corrupt
3MF to the real printer.

Fix in two independent layers:

1. Remove the trigger: add --loop asyncio to every native launch path,
   matching the Dockerfile -- deploy/bambuddy.service, install/install.sh
   (systemd + launchd), spoolbuddy/install/install.sh, the Windows NSSM
   service, README, CONTRIBUTING dev command.

2. Defense in depth (loop-independent): cmd_STOR now validates that a
   received .3mf opens as a ZIP (reads the central directory, no
   decompression) before replying 226. A truncated/corrupt file is dropped
   and answered with 426, and on_file_received never runs -- so a broken
   upload surfaces as an immediate slicer-side send error instead of being
   archived and pushed to the printer. Scoped to .3mf; other filetypes pass
   through unchanged.
2026-07-05 10:32:13 +02:00
maziggy 1773cbd629 fix(install): docker installer tries mkdir without sudo, escalates on EACCES (#1774)
install/docker-install.sh::create_install_dir ran `mkdir -p
  "$INSTALL_PATH"` without sudo while DEFAULT_INSTALL_PATH was
  /opt/bambuddy, root-owned on every Linux distro. set -e then
  aborted the whole script before docker compose could pull the
  image — anyone running the documented `curl ... | bash` flow as
  a normal user hit this on first install.

  Fix: try the unprivileged `mkdir -p ... 2>/dev/null` first so
  --path ~/bambuddy, /srv/bambuddy and other writable targets don't
  trigger a needless password prompt, then fall back to
  `sudo mkdir -p` + `sudo chown -R "$USER:$USER"` only when the
  first attempt failed. The chown is load-bearing: without it the
  script would later try to write docker-compose.yml + .env into a
  root-owned dir as the invoking user and cascade further EACCES
  failures.

  Not changing the default path: install/update.sh and
  install/update_macos.sh both default INSTALL_DIR to /opt/bambuddy,
  and install/README.md's update flow documents the same — flipping
  the install default to ~/bambuddy without coordinating those
  would silently break self-service updates for anyone following
  the docs verbatim. The default stays /opt/bambuddy; only the
  escalation gap closes.

  set -e survives the redirected stderr because the `if !` form is
  the documented escape hatch for an expected-failure check.

  Smoke-tested writable-target, idempotent-rerun, and the
  failing-mkdir-then-sudo-fallback branches.
2026-06-19 08:14:49 +02:00
maziggy 6316ca929e install/windows-installer.ps1 2026-06-10 15:57:57 +02:00
maziggy fb1e9a917e fix(install): use ProtectHome=read-only for /home-rooted installs (#1685)
bambuddy.service shipped with ProtectHome=true, which makes /home/* invisible
  to the service namespace. Installing into /home/bambuddy/ (instead of the
  default /opt/bambuddy/) made ExecStart=/home/bambuddy/venv/bin/uvicorn fail
  with status=203/EXEC because systemd couldn't resolve the binary path.
  ReadWritePaths=$INSTALL_PATH does not reliably re-expose /home/* subpaths for
  exec resolution.

  install/install.sh now detects /home/* INSTALL_PATH and emits ProtectHome=read-only;
  default /opt/bambuddy installs keep ProtectHome=true. The manual deploy template
  defaults to read-only with a comment on when to tighten it.

  read-only keeps /home immutable to the service - no security regression, since
  ReadWritePaths still gates writes to the install/data/log dirs only.
2026-06-09 07:31:23 +02:00
maziggy bd19a8ccb4 docs(install): polish Windows section + Service/Update/Troubleshooting
entries

  PR #1529 added the Windows installer but the rendered README sections
  had a stray blank line inside the install one-liner's code fence and
  the cross-platform Service Management / Updating / Troubleshooting
  sections still only covered Linux + macOS + Docker. Fold in Windows
  entries (Start-Service, Get-NetTCPConnection, NSSM runtime log path)
  and link the README description to the Windows Installer wiki page so
  users know where the parameter reference and unattended examples live.
2026-06-02 15:25:31 +02:00
Marko@VMHOMELAB 873c78a6ff Feature/windows installer (#1529)
Add feature: Added a powershells script to easily install bambuddy on windows
2026-06-02 15:17:25 +02:00
maziggy 597762685c fix(virtual-printer): #1558 Send pre-flight + slicer-surface audit bundle
#1558: cached-as-base push_status only forced gcode_state=IDLE while letting
  the real printer's live-progress fields (mc_percent, stg_cur, layer_num, ...)
  leak through. Bambu Studio's Send pre-flight read them as busy and refused.
  The cached branch now overrides the activity-field set the same way it
  already overrode storage indicators (#1228) and protocol fields.

  Same bundle ships a multi-round VP audit that found adjacent bugs in the
  same family:

  - #1558: cached branch zeroes mc_print_stage / mc_percent / mc_remaining_time / stg / stg_cur / layer_num / total_layer_num / print_error
  - MQTT auth: per-IP rate-limit (5/60s lockout), hmac.compare_digest, access_code redacted in DEBUG log
  - FTP cmd_STOR streams chunks to disk + 4 GiB cap (was buffering whole upload)
  - Sticky-keys allowlist extended with upgrade_state / xcam / hw_switch_state / nozzle_diameter / nozzle_type / online / ams_status
  - _pending_files cleanup in finally for archive / queue / dispatch handlers
  - _add_to_print_queue position uses MAX+1 (was hardcoded 1)
  - DELETE VP removes orphan PendingUpload rows + upload_dir from disk
  - Per-VP cert regenerates on shared-CA rotation (real signature verification, not DN match)
  - DHCP target-IP refresh + queue_force_color_match toggle now restart proxy VPs
  - Per-slicer bridge-response routing (multi-slicer cross-leak fix via sequence_id map)
  - Child-service readiness barrier (FTP / MQTT / Bind / SSDP) — no false is_running before sockets bind
  - H2D Pro O1E / O2D model codes added (experimental, needs field confirmation)
  - FTP passive port range widened 50000-51000; docker-compose + wiki updated
  - VP refresh_loop crash now unbinds raw_message_handler; tailscale catches asyncio.TimeoutError; SlicerProxyManager lifecycle hardening
2026-05-30 13:34:10 +02:00
maziggy fed8f1f74f Added install_docker for Windows 11 2026-05-10 15:22:10 +02:00
maziggy 6a426c74d5 Updated install/install.sh 2026-04-24 10:37:38 +02:00
maziggy 37231d9991 Updated install/install.sh 2026-04-24 10:34:23 +02:00
maziggy 71afe35a49 Added new update.sh and update docs 2026-04-19 09:08:30 +02:00
maziggy 46e183cb9f Removed --bind flag from docker_install.sh 2026-04-08 12:53:04 +02:00
maziggy 8816c2334e Added install/update_macos.sh 2026-03-31 10:25:57 +02:00
maziggy a36a0e09eb Fix daily beta release contributors list and add VP ports 2024-2026 to docker-compose
Strip @mentions from changelog text in docker-publish-daily-beta.sh
  so GitHub doesn't auto-generate a "Contributors" section in release
  notes. Add --generate-notes=false for extra safety. Also add ports
  2024-2026 (A1/P1S proprietary) to the docker-compose.yml bridge-mode
  port mapping and update the install script comment.
2026-03-25 16:47:27 +01:00
maziggy 332a7c6ac8 [Fix] Virtual Printer proxy: transparent TCP for X1C/X1 compatibility (#757)
The closed-source bambu_networking DLL validates TLS connection parameters
  and rejects connections where the certificate doesn't match the printer's
  real BBL CA certificate. The TLS-terminating proxy presented Bambuddy's
  own certificate, causing X1C/X1 prints to silently fail after verify_job.

  Switch to transparent TCP proxying for FTP, FileTransfer, Camera, and FTP
  data — only MQTT remains TLS-terminated (required for IP rewriting). The
  slicer now gets end-to-end TLS directly with the printer's real certificate.

  Changes:
  - SlicerProxyManager uses TCPProxy for FTP (990), FileTransfer (6000),
    Camera (322), and pre-listens on FTP data ports (50000-50100)
  - Only MQTT (8883) uses TLSProxy for IP rewriting
  - Remove debug logging from MQTT and FTP proxy code
  - Fix install.sh missing AmbientCapabilities=CAP_NET_BIND_SERVICE
  - Update module docstring, migration docs, README proxy description
  - Add tests verifying transparent proxy architecture
2026-03-19 15:43:11 +01:00
maziggy 82d329d85c [Fix] Virtual Printer FTP routed to wrong VP with different access codes (#735)
When running multiple virtual printers with different access codes on
  separate bind IPs, FTP connections were always routed to the wrong VP.

  Root cause: the iptables REDIRECT rule (990→9990) rewrites the
  destination IP to the incoming interface's primary address. With Linux's
  weak host model (arp_filter=0), packets for secondary IPs arrive on the
  primary interface, and REDIRECT sends them all to the first VP's FTP
  server. MQTT was unaffected because port 8883 had no redirect.

  Fix: FTP server now binds directly to port 990 (standard implicit FTPS),
  eliminating the iptables redirect entirely. Requires CAP_NET_BIND_SERVICE
  (already set in the systemd service file and Docker image).

  Also removed a global asyncio set_exception_handler() in the MQTT server
  that was overwritten by each VP instance, causing spurious "Unhandled
  exception in client_connected_cb" errors on startup.

  Changes:
  - FTP_PORT: 9990 → 990 (ftp_server.py)
  - Removed set_exception_handler() from MQTT server
  - Updated Dockerfile, docker-compose.yml port mappings
  - Deprecated --redirect-990 in install script
  - Updated wiki: removed iptables instructions for all platforms
  - Added migration guide (docs/migration-vp-ftp-port.md)
  - Added unit tests for port constant and no-global-state invariant
2026-03-18 09:04:31 +01:00
maziggy a388ab791f Deleted broken install/start_bambuddy.bat 2026-03-15 16:50:49 +01:00
maziggy b16b12bf8d Fixed install/start_bambuddy.bat 2026-03-06 11:20:36 +01:00
maziggy 4981c60389 Add --branch support to install script with validation
The install script hardcoded origin/main, so beta testers told to
  install from a dev branch silently got the stable release instead.
  Add a --branch CLI option and interactive prompt (defaults to main).
  Invalid branch names are validated via git ls-remote before any work
  is done, showing available branches on failure.
2026-03-05 11:01:06 +01:00
maziggy 3a0b3f8035 Add --branch support to install script
The install script hardcoded origin/main, so beta testers told to
  install from a dev branch silently got the stable release instead.
  Add a --branch CLI option and interactive prompt (defaults to main).
  Fresh installs use git clone --branch, existing installs checkout
  and reset to the selected branch.
2026-03-05 10:58:29 +01:00
maziggy 0faf03ecb3 Fix Python 3.10 compatibility (StrEnum requires 3.11)
enum.StrEnum was added in Python 3.11, but the documented minimum is
  3.10. Add a compatibility shim in backend/app/core/compat.py that falls
  back to (str, Enum) on older versions. Updated all 5 import sites and
  lowered pyproject.toml target-version to py310.
2026-03-05 10:44:24 +01:00
maziggy f488c9f3f4 Fix Windows install syntax error from multi-line for /f command (#544)
The Python hash verification in start_bambuddy.bat used a multi-line
  `for /f "usebackq"` with a backtick-delimited command split across
  lines. Windows CMD cannot parse line breaks inside backtick-delimited
  for /f commands, causing "The syntax of the command is incorrect" at
  step 1/6. Removed the entire redundant verification block — the
  verify_sha256 subroutine already checks the archive against the
  pinned hash. The removed block also had a secondary bug: it always
  downloaded the amd64 checksum from python.org even on arm64 systems.
2026-03-01 08:08:41 +01:00
MartinNYHC 1ba681d7b7 Merge branch '0.2.1b' into codex/add-systemd-updater-script 2026-02-19 08:24:46 +01:00
MartinNYHC 324c716692 Fix indentation in iptables check 2026-02-19 08:02:11 +01:00
uefigs139 3b02d3eedd Updated prompt flow of update 2026-02-18 13:36:45 -05:00
Wesley Reuel Marques Silva c879a787f6 Complying with PR 2026-02-18 18:00:23 +00:00
uefigs139 78f17614e7 fix: use robust systemd service detection in updater 2026-02-18 08:48:07 -05:00
uefigs139 d12aaa222e feat: add native updater script with backup and safety checks 2026-02-18 08:32:04 -05:00
Wesley Reuel Marques Silva 0d7cf0f227 Complying with PR 2026-02-16 19:47:34 +00:00
MartinNYHC ee1a0125ee Merge branch '0.2.0b' into feature/addIpTablesOnDockerInstal 2026-02-16 07:28:44 +01:00
Wesley Silva ac597e5ff6 Adding the option to include the ip tables route when installing via docker-install.sh 2026-02-15 17:22:19 +00:00
Mori Naoyuki bb88527915 Changed to use %~dp (for improved security) 2026-02-15 10:04:23 +09:00
Mori Naoyuki 3ce98899fb The script stopped launching after moving the folder, so I fixed it. 2026-02-15 09:35:14 +09:00
maziggy f094c16012 Updated install scripts and related docs 2026-02-08 18:24:51 +01:00
maziggy 75c049b05c Updated install scripts and related docs 2026-02-08 18:21:19 +01:00
maziggy 8b3ea0602c Moved start_bambuddy.bat to install/ 2026-02-05 14:54:07 +01:00
maziggy 196b7a93e9 Added one-shot install scripts 2026-01-31 14:31:10 +01:00