mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-22 03:49:18 +02:00
[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
This commit is contained in:
@@ -232,7 +232,13 @@ class VirtualPrinterSSDPServer:
|
||||
try:
|
||||
msg = self._build_notify_message()
|
||||
self._socket.sendto(msg, (SSDP_BROADCAST_ADDR, SSDP_PORT))
|
||||
logger.debug("Sent SSDP NOTIFY for %s", self.name)
|
||||
logger.debug(
|
||||
"Sent SSDP NOTIFY for %s (Location=%s, USN=%s, bind=%s)",
|
||||
self.name,
|
||||
self._get_local_ip(),
|
||||
self.serial,
|
||||
self._bind_ip,
|
||||
)
|
||||
except OSError as e:
|
||||
logger.debug("Failed to send NOTIFY for %s: %s", self.name, e)
|
||||
|
||||
@@ -278,7 +284,13 @@ class VirtualPrinterSSDPServer:
|
||||
try:
|
||||
response = self._build_response_message()
|
||||
self._socket.sendto(response, addr)
|
||||
logger.info("Sent SSDP response to %s for virtual printer '%s'", addr[0], self.name)
|
||||
logger.info(
|
||||
"Sent SSDP response to %s for '%s' (Location=%s, USN=%s)",
|
||||
addr[0],
|
||||
self.name,
|
||||
self._get_local_ip(),
|
||||
self.serial,
|
||||
)
|
||||
except OSError as e:
|
||||
logger.debug("Failed to send SSDP response for %s: %s", self.name, e)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user