Initial Checkin

This commit is contained in:
Dominik Heidler 2023-11-03 23:07:32 +01:00
parent e34bc73dd2
commit 4151f72c58
3 changed files with 46 additions and 1 deletions

5
Dockerfile Normal file
View file

@ -0,0 +1,5 @@
FROM python:3.11-alpine
RUN apk --no-cache add wireguard-tools-wg
ADD announce.py /
CMD ["python", "./announce.py"]

View file

@ -1,4 +1,8 @@
# bambulab-wireguard-proxy # bambulab-wireguard-proxy
```
docker run --rm -it --network container:firezone-firezone-1 --cap-add NET_ADMIN python:3.11-alpine /bin/sh
```
Send SSDP announcements that imitate the Bambulab printer to each wireguard peer. Send SSDP announcements that imitate the Bambulab printer to each wireguard peer.
This allows using OrcaSlicer via VPN This allows using OrcaSlicer via VPN

36
announce.py Executable file
View file

@ -0,0 +1,36 @@
#!/usr/bin/python3
import socket
import time
import subprocess
UDP_PORT = 2021
MESSAGE = b"""NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
Server: Buildroot/2018.02-rc3 UPnP/1.0 ssdpd/1.8
Location: 10.73.37.29
NT: urn:bambulab-com:device:3dprinter:1
USN: 01S00C321501449
Cache-Control: max-age=1800
DevModel.bambu.com: C11
DevName.bambu.com: Nerdberg Bambu P1P
DevSignal.bambu.com: -41
DevConnect.bambu.com: lan
DevBind.bambu.com: free
Devseclink.bambu.com: secure
""".replace(b"\n", b"\r\n")
while True:
for pl in subprocess.check_output(["wg", "show", "wg-firezone", "dump"]).decode().strip().split("\n")[1:]:
ips = pl.split("\t")[3]
for ip in ips.split(","):
if ip.endswith("/32"):
print(ip[:-3])
print(f"{ip}:{UDP_PORT} {MESSAGE=}" % MESSAGE)
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.bind(('0.0.0.0', 1900)) # 1900 is SSDP src port
sock.sendto(MESSAGE, (ip, UDP_PORT))
sock.close()
time.sleep(10)