mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-05-09 08:25:54 +02:00
[GH-ISSUE #623] FTP proxy: OrcaSlicer data channel TLS fixes for X1C #405
Labels
No labels
A1
automated
automated
bug
bug
Closed due to inactivity
contrib
dependencies
dependencies
duplicate
enhancement
feedback
hold
invalid
Notes
P1S
pull-request
security
ThumbsUp
user-report
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/bambuddy-maziggy-1#405
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @begna112 on GitHub (Mar 5, 2026).
Original GitHub issue: https://github.com/maziggy/bambuddy/issues/623
Originally assigned to: @maziggy on GitHub.
Following up on #620 (cipher fix, now merged). After applying the cipher fix, I ran into several more issues getting the virtual printer proxy to work with OrcaSlicer and my X1C. I'm not sure if my setup is unusual or if others are hitting the same things — my network may be different, or OrcaSlicer might behave differently than Bambu Studio in ways that don't come up for everyone. But in case it's helpful, here's what I had to do to get FTP uploads working end-to-end through the proxy.
All changes are in
backend/app/services/virtual_printer/tcp_proxy.py. Tested with BambuDdy 0.2.2b2, OrcaSlicer 2.3.1 (as well as 2.3.2-rc and nightly)m Bambu X1C, proxy mode.1. FTP data channel needs TLS on the slicer side when PROT P is active
The code currently starts the slicer-side data listener as cleartext even after
PROT P, with a comment that Bambu Studio doesn't do TLS on data connections. OrcaSlicer does expect TLS on the data channel afterPROT P, so the upload fails with an SSL handshake error.Fix: Pass the server SSL context to
asyncio.start_serverwhenuse_tlsis True:This alone wasn't enough though — see fix 2 below.
2. FTP data channel TLS needs session reuse + eager connect
Even with slicer-side TLS, the printer-side data TLS handshake still fails. Two issues:
Session reuse: The printer's vsFTPd requires TLS session reuse on data connections — the data channel must present the same TLS session as the control channel. A fresh handshake is rejected.
Deadlock: The proxy had a deadlock where the slicer waits for
150 Openingbefore connecting to the data port, but the printer waits for a data connection before sending150.Fix: Three parts:
Capture the TLS session from the control connection:
Eagerly connect TCP to the printer data port before the slicer connects, breaking the deadlock:
Defer the TLS upgrade until after the slicer connects (STOR/150 have been exchanged by then). Inject the control session via a one-shot
wrap_biomonkey-patch:The monkey-patch is ugly but necessary — Python's
asyncio.StreamWriter.start_tls()doesn't expose a way to set the session before the handshake, andwrap_biois the internal hook where the SSL object is created.3. PROT P/C needs to be forwarded to the printer
The proxy was consuming
PROT P/PROT Ccommands without forwarding them. My printer requiresPROT Pto be sent or it returns522 Data connections must be encrypted.Fix: Forward
PROT P/PROT Cto the printer while still tracking the state locally for the proxy's own TLS decisions.4. EPSV→PASV rewrite should be removed
The code rewrites
EPSVtoPASV, but the printer supportsEPSVnatively and_maybe_rewrite_pasvalready handles both227(PASV) and229(EPSV) responses. The rewrite was unnecessary and removing it simplified things.Happy to provide the full diff if that's useful. With all four changes applied, the complete flow works: MQTT, Bind-TLS, FTP control, and FTP data uploads all go through the proxy successfully. Printer control and print sending both work with OrcaSlicer.
@maziggy commented on GitHub (Mar 5, 2026):
Do you have the chance to also test with BambuStudio? That would help a lot!
@begna112 commented on GitHub (Mar 6, 2026):
I can test later tonight
@begna112 commented on GitHub (Mar 6, 2026):
Unfortunately, I'm running into two firmware-related issues that are preventing me from testing:
https://github.com/OrcaSlicer/OrcaSlicer/issues/12537
https://github.com/OrcaSlicer/OrcaSlicer/issues/11898
I don't think either is caused by Bambuddy but It's possible that you may need to account for them at some point, not sure. Haven't looked terribly deep into the code, just troubleshooting exactly what I needed to.
I may need to roll back the firmware to resolve these. Until then, I won't be able to test printing with Bambu Studio.
@maziggy commented on GitHub (Mar 6, 2026):
Anyway, thanks!
@begna112 commented on GitHub (Mar 6, 2026):
Were any changes made to address the original issue?
I still think the core issue is there, but I can't confirm if on bambu studio.
@maziggy commented on GitHub (Mar 6, 2026):
Yes, added your fix from https://github.com/maziggy/bambuddy/issues/620
@begna112 commented on GitHub (Mar 6, 2026):
Just to be clear, this is a totally different issue than #620.
The first was to be able to auth to the printer, this is to be able to send print jobs to it.
@maziggy commented on GitHub (Mar 6, 2026):
Yes, but i first need to check that in detail.