Fix VP bind server rejecting TLS connections on port 3002 (#559)

BambuStudio uses TLS on port 3002 for certain printer models (e.g. A1
  Mini / N1). The bind server only spoke plain TCP on both ports, so the
  TLS ClientHello was rejected as "invalid frame" and the slicer could
  never discover or connect to the virtual printer.

  Port 3002 now uses TLS (reusing the VP's existing certificate), port
  3000 remains plain TCP. Also updated proxy-mode to use TLSProxy for
  the port 3002 bind proxy instead of raw TCPProxy.
This commit is contained in:
maziggy
2026-03-01 12:43:13 +01:00
parent bf66f7a536
commit e5b2cee2f1
5 changed files with 71 additions and 20 deletions
@@ -346,7 +346,7 @@ class TLSProxy:
class TCPProxy:
"""Raw TCP proxy that forwards data without TLS termination.
Used for protocols where the printer doesn't use TLS (e.g., port 3002
Used for protocols where the printer doesn't use TLS (e.g., port 3000
binding/authentication protocol).
"""
@@ -1123,18 +1123,30 @@ class SlicerProxyManager:
bind_address=self.bind_address,
)
# Bind/auth proxy (ports 3000 + 3002) - raw TCP, no TLS
# Different BambuStudio versions use different ports
# Bind/auth proxy — port 3000 plain TCP, port 3002 TLS
for bind_port in self.PRINTER_BIND_PORTS:
proxy = TCPProxy(
name="Bind",
listen_port=bind_port,
target_host=self.target_host,
target_port=bind_port,
on_connect=lambda cid: self._log_activity("Bind", f"connected: {cid}"),
on_disconnect=lambda cid: self._log_activity("Bind", f"disconnected: {cid}"),
bind_address=self.bind_address,
)
if bind_port == 3002:
proxy = TLSProxy(
name="Bind-TLS",
listen_port=bind_port,
target_host=self.target_host,
target_port=bind_port,
server_cert_path=self.cert_path,
server_key_path=self.key_path,
on_connect=lambda cid: self._log_activity("Bind", f"connected: {cid}"),
on_disconnect=lambda cid: self._log_activity("Bind", f"disconnected: {cid}"),
bind_address=self.bind_address,
)
else:
proxy = TCPProxy(
name="Bind",
listen_port=bind_port,
target_host=self.target_host,
target_port=bind_port,
on_connect=lambda cid: self._log_activity("Bind", f"connected: {cid}"),
on_disconnect=lambda cid: self._log_activity("Bind", f"disconnected: {cid}"),
bind_address=self.bind_address,
)
self._bind_proxies.append(proxy)
# Start as background tasks