🌉 bridged from @lemmyvore@feddit.nl by Tidepool
lemmyvore
@lemmyvore.feddit.nl.ap.tdpl.io
Play movies on your framebuffer
I was getting tired of connecting a laptop to the TV with a long-ass HDMI cable so I could play movies on there, or running the movies through an arcane combo of apps so the Chromecast would deign to play from Jellyfin... ,,,when I thought, hey, the server is near the TV, can't that fucker somehow play to the TV directly? The server is a barebones Debian with just the basic packages installed and everything running in Docker containers, no graphics stack. But it has an Intel CPU+iGPU and it does have a HDMI out. That's when I remember the framebuffer. Long story short, here's the Dockerfile for a container that installs
mpvand all that's needed to play on the framebuffer:FROM debian:trixie-slim ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update RUN apt-get -y install ca-certificates openssl COPY <<"EOT" /etc/apt/sources.list.d/debian.sources Types: deb URIs: https://deb.debian.org/debian Suites: trixie trixie-updates trixie-backports Components: main non-free non-free-firmware Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg Types: deb URIs: https://security.debian.org/debian-security Suites: trixie-security Components: main non-free non-free-firmware Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg EOT RUN apt-get update RUN apt-get -y dist-upgrade RUN apt-get -y install \ mpv vainfo libdrm-tests \ mesa-va-drivers libva-drm2 libdrm2 alsa-utils \ nnn RUN rm -rf /var/lib/apt/lists/*
Can probably simplify it further. And here's a compose.yaml for it:
services: fbplayer: image: local/fbplayer:1 container_name: fbplayer hostname: fbplayer volumes: - "./playmovie:/usr/local/bin/playmovie:ro" - "./nnn:/usr/local/bin/nnn:ro" - "/mnt/nas/multimedia:/media:ro" devices: - "/dev/dri:/dev/dri" - "/dev/snd:/dev/snd" group_add: - 44 # getent group video - 105 # getent group render - 29 # getent group audio environment: - TZ=Continent/Capital - NNN_OPENER=/usr/local/bin/playmovie entrypoint: ["tail", "-f", "/dev/null"] restart: 'always'The playmovie and nnn scripts are helper scripts so I don't have to re-type all the mpv parameters or refer the file by hand. Here's playmovie. Find out your audio card name and device number with
aplay -l). The DejaVu fonts are installed by default on Trixie.#!/bin/sh case "$1" in *.[Mm][Kk][Vv]|*.[Mm][Pp]4|*.[Aa][Vv][Ii]) exec mpv --vo=drm --drm-device=/dev/dri/card0 --hwdec=vaapi \ --ao=alsa --audio-device=alsa/hw:CARD=PCH,DEV=3 --volume=50 \ --sub-font="DejaVu Sans Mono" --sub-font-size=40 --sub-bold=yes --sub-ass-override=force \ --sub-color="#FFFF00" --sub-border-size=5 --sub-border-color="#000000" \ "$1" ;; *) exit 1 ;; esacAnd here's the nnn script (make sure to place it in a dir that's before /usr/bin in PATH):
#!/bin/sh exec /usr/bin/nnn -coQ /media
It's still pretty arcane and I have to grab a shell in that container from the PC or a laptop, and remember mpv keyboard shortcuts... but at least I don't have to run cables or fuck around with phone apps. If anybody knows some sort of media/DLNA browser that can run in framebuffer please leave a comment. It would be nice to have some sort of UI that runs standalone on the TV all the time, and I can probably figure out how to add a bluetooth airmouse/remote or something to control it. I've seen some cute BT gadgets that even have a mini keyboard so you can do a quick search. Edit: I also got jellyfin-mpv-shim to work, at the recommendation of people in comments, here's how. Here's what I added to Dockerfile to install the shim:
RUN apt-get -y install python3-venv libmpv-dev RUN mkdir -p /opt/venv RUN python3 -m venv /opt/venv ENV PATH="/opt/venv/bin:$PATH" RUN python3 -m pip install --upgrade pip RUN python3 -m pip install --upgrade jellyfin-mpv-shim
The compose is the same but the entrypoint can be the shim. The command needs to be:
jellyfin-mpv-shim --server address --username user --password pass add
In order to securely give the password to the entrypoint there are several methods. You can set env vars in a chmod 600 .env file, bring them in with
env_file:and usesh -cto expand the variables. Another approach that doesn't leak into the environment is to put the command (with hardcoded credentials) in a docker secrets file and make the entrypoint execute the /run/secrets/name. I also needed to modify~/.config/jellyfin-mpv-shim/conf.jsonand set "headless" to true, "enable_gui" to false, and "audio_device" to the mpv audio device (""alsa/plughw:CARD=PCH,DEV=3" in my case). Once the shim is running and connected it will appear in the casting menu on jellyfin clients and you can control it from there. One more tip, the shim may not connect if started too soon after the jellyfin container. To fix this I've set a healthcheck command on jellyfin (curl -q http://localhost:8096/health) and made the shim containerdepends_onthe jellyfin container withcondition: service_healthy. Edit 2: and here's a compact version based on alpine:FROM alpine RUN apk update RUN apk add python3 mpv-libs fontconfig font-dejavu RUN fc-cache -f RUN mkdir -p /opt/venv RUN python -m venv /opt/venv ENV PATH="/opt/venv/bin:$PATH" RUN python -m pip install --upgrade pip RUN python -m pip install --upgrade jellyfin-mpv-shim
Issue #64 that was blocking DNS-PERSIST-01 has been resolved
Good news, a security issue that was blocking the draft for the new DNS-PERSIST-01 challenge mode for TLS certificates has been resolved, meaning the challenge can resume moving forward. Some background for those who aren't up to date: • TLS challenges are how self-hosters and many other TLS certificate users prove who they are in order to automate cert renewals. • The most popular challenge methods are HTTP-01 (which involves having a live web server answering on port 80 somewhere) and DNS-01 (which involves putting a key given by the TLS authority in your DNS zone in a TXT record temporarily). • All the current challenges are conducted "live" and require active online participation on the part of the domain owner each time a cert is approaching expiration. • The new DNS-PERSIST-01 challenge would let owners keep a proof in their DNS zone indefinitely (or with self-imposed expirations), eliminating the need for those online sessions. • DNS-PERSIST-01 was slated to come out in Q2 this year at the latest and all the popular tools (ACME bots, reverse proxies etc.) have been chomping at the bit to implement it. • Unfortunately there's been a security snag. Trying to do things the way DNS-01 did (record only the server-provided proof in DNS) would open DNS-PERSIST-01 to middleman attacks, because unlike DNS-01 where the proof is only there temporarily for a few seconds or a few minutes at the most, in this case the proof would be long-term. • Hence issue #64, which has been trying to come up with a way to keep only a partial proof in DNS, and combine it with something issued by the server and something issued by the domain owner to make the whole proof, thus rendering the stuff stored in DNS impossible to use for malicious purposes, yet still sufficient for verifying ownership periodically. Hopefully now that this hurdle has been passed things will proceed faster and we'll get to use this in the near future.
Setting up a deny/allow feature
I'm working on a personal project and I'd like to add a feature where you can deny/allow access based on IP.
I'm not sure that the way I'm thinking about it is good enough.
The user would be able to specify multiple deny and allow ranges as IP[/CIDR] and then I would:
• Go through all the "deny" ranges and if any of them matches reject access. • Go through all the "allow" ranges and if any of them matches permit access. • If nothing matches the final decision is taken by a default fallback policy that can be set to allow or deny.
Would this be good enough or are there scenarios that can't be expressed this way?
PS: fwiw I did have a look at how other projects achieve this. Some let you define ranges and combine them with boolean logic in any manner, pseudo-programatically; that's a bit too complex for mine. Some let you draw up a list where order matters and the first matching range "wins"; I'm not sure if that's more capable than my way, and having order matter would complicate things for my code.
Appreciate any help. If you can link me to something that talks about this, that's good too.
How to physically isolate a camera with OpenWRT, tagged VLANs and Docker
Having fought for several days with this, I'd thought it would be worth sharing while it's still fresh in what's left of my mind: Problem: • OpenWRT router running latest available version (25.12) and Luci UI. • IP cam that I want hardwired-only (Ethernet). • Cam must have no access to internet or rest of LAN. • Cam must only be accessed directly by the NVR software. • Software (NVR and reverse proxy) run as docker containers on server PC. • Any other LAN device (laptop, phone) must be able to access the NVR only via the reverse proxy. Network topology: • Cam is plugged physically in lan1 port on router. • Server is plugged physically in lan3 port on router. • The problem above basically means we need two tagged VLANs, one for regular LAN devices, and one just for NVR and camera. Configuring the VLANs in OpenWRT: Before anything else: try doing the next batch of configs from wireless if possible not Ethernet, in case you mess up and lose wired connectivity to the router. • Go to Network > Interfaces > Devices and press "Configure" for the bridge that holds your router ports. This will typically be called "br-lan". • Go to the "Bridge VLAN filtering" tab and check "enable Vlan filtering". • Press the "Add" button twice to get two VLANs. • First VLAN: set id=1, check "local", mark lan1=off (not member), lan2=untagged, lan3=tagged (also primary), lan4=untagged. You can use any ID but "1" is traditional for the base LAN network. • Second VLAN: set id=100, check "local", mark lan1=untagged, lan2=off, lan3=tagged, lan4=off. Again, you can use any ID, but it's traditional to avoid numbers under 10 because they're typically used for core VLANs. • Case in point, please note that my router has two physical NICs, one for LAN ports 1-4 and one for WAN, so I have a separate br-wan device just for wan. But some routers only have one physical NIC so they only have one bridge that covers both lan1-4 and wan ports. On these routers when you get to the filtering tab you will find two VLANs (1 and 2, typically) already set up. If this is the case add the VLAN 100 and modify VLAN 1 as above and mark wan as off in 100. • After you press "save" you will notice two new virtual devices called "br-lan.1" and "br-lan.100" type VLAN 802.1q have appeared in the device list. • Do not apply modifications yet. First go to Network > Interfaces, edit the "lan" interface and switch it from device "br-lan" to device "br-lan.1", otherwise you may lose connectivity to router if you're on Ethernet. • If you've applied changes early and lose connectivity, don't panic, just wait. In recent OpenWRT versions after 90s without confirmation from the UI the router will automatically rollback the last changes. If all went well and you're on wireless or one of the untagged Ethernet ports (lan2 or lan4) you should have retained connectivity to the router and wireless devices. Configuring the NVR network in OpenWRT: • Go to Network > Interfaces, click "Add new interface". • Call it "NVR", protocol "static address", device "br-lan.100". • Next, edit it and set up your desired IPv4 address and netmask. • You MUST go to "firewall settings" and use the "custom" field to add a new "NVR" zone. alternatively you can go to Network > Fireall, create the NVR zone there, and choose it here. • Enable DHCP if you want. • If you do, please note that some routers bind dnsmasq only explicitly to select interfaces. Please check under Network > DHCP > dnsmasq > Devices & Ports and if "non-wildcard" is checked you will have to add "NVR" to the "Listen interfaces" to actually get DHCP services on that network. • Under Network > Firewall you should have a zone called "NVR". Set input/output/forward to accept/accept/reject. • Under Network > Firewall > Traffic rules you have to add a new rule, calld it "NVR DHCP", that says that protocol UDP, source zone "NVR", destination "device (input)", destination port 67, action "accept", and under advanced restrict address family to IPv4. Traffic rules have priority over zone configuration so DHCP will work no matter how you fuck up your zone access. • We will be skipping DNS because we don't want the NVR network to benefit from any. But if we did we'd be doing the same we did for DHCP (got to Network > DNS to enable explicitly on NVR interface, and add a traffic rule for it). Configuring the camera: • Plug the camera into port lan1, it should pick up a DHCP address on the network you've defined for interface "NVR". • In order to be able to access that IP from your regular LAN to configure the camera with your phone you'll have to temporarily add the "NVR" zone to the list of forward zonez of the "lan" zone. • Would probably be a good idea to either configure the camera to a static IP or give it a static DHCP assignment based on the Ethernet MAC, so you know where to reach it from the NVR software. • Remember to remove the "NVR" zone from the lan's zone forwards when you're done. Configuring the server for tagged VLAN connectivity: • Your server (port lan3) was marked for tagged VLAN connectivity in OpenWRT but it doesn't (yet) actually use tagged connections. We have to fix that or it won't be reachable. • Feel free to mark lan3 as "untagged" on VLAN 1 to connect to it while you change the settings, but keep in mind that direct console access may be needed if you fuck up. • My server runs Debian so configuration basically runs down to loading module 8021q (and adding it to /etc/modules just in case, although this should be largely automated), and editing /etc/network/interfaces. Feel free to adjust the example below to your needs:
# this will bring up eth0 but leave it unconfigured, merely as a support carrier for the VLANs auto eth0 iface eth0 inet manual # this will set up VLAN ID 1 and tell it to use DHCP auto eth0.1 iface eth0.1 inet dhcp # this will set up VLAN ID 100 with a static address auto eth0.100 iface eth0.100 inet static address 10.234.100.2/24
Configuring docker networks and containers: • Remember I said the proxy and the NVR are running in docker containers. If you haven't done anything fancy with them before, you were probably using
ports:to expose a port for the proxy and one for the NVR on the host's LAN IP, and pointing the proxy to the NVR. • First, we will want to make an ipvlan or macvlan docker network that will use the eth0.100 interface. Containers that use this network will be placed in the NVR network/zone, and have their communications tagged with VLAN ID 100. Feel free to customize the network range. You can use either ipvlan or macvlan, the latter is not very useful since docker can't do DHCP. Note the use ofaux-addressto reserve the IP you've assigned the camera, in case there's potential overlap with the range you choose for automatic allocation. It's essential that you use theeth0.100interface as parent.docker network create --driver ipvlan \ --ip-range=10.234.100.97/27 --subnet=10.234.100.0/24 --gateway=10.234.100.1 \ --aux-address 'cam1=10.234.100.10' \ -o parent=eth0.100 nvr-vlan
• We also need a bridge network that will allow the proxy to see the NVR container, because once the NVR container is placed on the NVR network on the VLAN ID 100 it won't be reachable directly by the proxy.
docker network create --driver bridge \ --opt com.docker.network.bridge.name=br-docker-proxy \ --ipv4 --subnet=172.23.1.0/24 --gateway=172.23.1.1 \ proxy-bridge
• Next, in the NVR container compose, join both proxy-bridge and nvr-lan:
services: nvr: networks: nvr-vlan: proxy-bridge: hostname: nvr networks: nvr-vlan: external: true proxy-bridge: external: true• Also in the proxy container compose you will want to join the proxy-bridge network. • Remove the
ports:directive from the NVR container, it doesn't serve any purpose now. Containers on ipvlan/macvlan are reachable by their native port assignments on the networks they've joined. • Please note thehostname: nvrin the NVR compose, that's the name you will have to use in the proxy configuration to reach the NVR. Docker will supply a DNS resolve for this automatically. • The proxy doesn't need to be onnvr-vlan. I mean you can, but you need to keep the proxy accessible from the main network so it will keep usingports:as usual. Bibliography: • https://docs.docker.com/engine/network/drivers/ipvlan/#manually-create-8021q-links • https://openwrt.org/docs/guide-user/network/vlan/switch_configuration • https://openwrt.org/docs/guide-user/network/dsa/converting-to-dsa • https://openwrt.org/docs/guide-user/network/dsa/dsa-mini-tutorial • https://forum.openwrt.org/t/openwrt-vlan-tagging/208098 • https://computingforgeeks.com/how-to-configure-vlan-interface-on-debian/ • https://wiki.debian.org/NetworkConfiguration#Howto_use_vlan • https://manpages.debian.org/trixie/ifupdown-ng-compat/interfaces.5.en.html • https://deepwiki.com/openwrt/firewall4/6.1-zone-configuration • https://deepwiki.com/openwrt/firewall4/7-rules-and-nat