pi-reply-reader 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,32 +1,43 @@
1
- # Carries pi-reply-reader's audio from the machine that runs Pi (here the HS) to the PipeWire of
2
- # the machine you sit at (here called "desktop"), over SSH.
1
+ # Carries pi-reply-reader's audio from the agent host (the machine that runs Pi; in this example a
2
+ # home server) to the PipeWire of the listener (the machine you sit at; here called "desktop"), over
3
+ # SSH. Use it when the agent host can reach the listener (same LAN, Tailscale); for a cloud VPS that
4
+ # cannot reach it, use reply-reader-vps-audio.service on the listener instead. It also serves as the
5
+ # "fallback" of a listener output that synthesizes on the listener (README, "Synthesize on the listener").
3
6
  #
4
7
  # Why a tunnel and not a TCP PulseAudio port on the desktop: pipewire-pulse has no IP allow-list,
5
8
  # so a LAN port would let anyone on the network play sound on the desktop or record its microphone
6
- # unless a firewall closes it. The tunnel opens nothing on the desktop: it forwards a loopback port
7
- # on this machine to the desktop's own Pulse socket, with SSH doing authentication and encryption.
9
+ # unless a firewall closes it. The tunnel opens nothing on the desktop: it forwards a socket on this
10
+ # machine to the desktop's own Pulse socket, with SSH doing authentication and encryption.
11
+ #
12
+ # Why a Unix socket and not a loopback port such as 127.0.0.1:4714: the forwarded Pulse socket gives
13
+ # the desktop's whole audio, microphone included. A loopback port is open to every process here,
14
+ # other users and containers with host networking. The socket is created mode 0600
15
+ # (StreamLocalBindMask=0177) inside your 0700 runtime dir (%t), so only your user can open it.
8
16
  #
9
17
  # Install (on the machine that runs Pi):
10
18
  # cp examples/reply-reader-desktop-audio.service ~/.config/systemd/user/
11
19
  # systemctl --user daemon-reload && systemctl --user enable --now reply-reader-desktop-audio.service
12
- # Then name the output in ~/.config/pi-reply-reader/outputs.json:
13
- # { "desktop": "tcp:127.0.0.1:4714" }
20
+ # Then name the output in ~/.config/pi-reply-reader/outputs.json (your user ID on this machine,
21
+ # `id -u`, in place of 1000):
22
+ # { "desktop": "unix:/run/user/1000/reply-reader-pulse.sock" }
14
23
  # Verify (prints the desktop's host name; plays nothing):
15
- # PULSE_SERVER=tcp:127.0.0.1:4714 pactl info | grep 'Host Name'
24
+ # PULSE_SERVER=unix:$XDG_RUNTIME_DIR/reply-reader-pulse.sock pactl info | grep 'Host Name'
16
25
  #
17
26
  # It is down while the desktop is off; the restart policy retries, and a reading on "desktop"
18
27
  # fails with "Playback on "desktop" failed: ..." in the meantime.
19
28
 
20
29
  [Unit]
21
- Description=SSH tunnel for pi-reply-reader audio to the desktop's PipeWire (loopback port 4714)
30
+ Description=SSH tunnel for pi-reply-reader audio to the desktop's PipeWire (socket in the runtime dir)
22
31
  After=network-online.target
23
32
  Wants=network-online.target
24
33
 
25
34
  [Service]
26
35
  Type=simple
27
- # The desktop's address and its user's runtime dir, in one place.
36
+ # The desktop's address and its user's ID there, in one place.
28
37
  Environment=AUDIO_HOST=192.168.1.50
29
38
  Environment=AUDIO_UID=1000
39
+ # StreamLocalBindUnlink replaces a socket left by a dropped connection; without it the next start
40
+ # fails with "Could not request local forwarding".
30
41
  ExecStart=/usr/bin/ssh -N \
31
42
  -o BatchMode=yes \
32
43
  -o ExitOnForwardFailure=yes \
@@ -35,7 +46,9 @@ ExecStart=/usr/bin/ssh -N \
35
46
  -o ServerAliveCountMax=3 \
36
47
  -o ControlMaster=no \
37
48
  -o ControlPath=none \
38
- -L 127.0.0.1:4714:/run/user/${AUDIO_UID}/pulse/native \
49
+ -o StreamLocalBindMask=0177 \
50
+ -o StreamLocalBindUnlink=yes \
51
+ -L %t/reply-reader-pulse.sock:/run/user/${AUDIO_UID}/pulse/native \
39
52
  you@${AUDIO_HOST}
40
53
  Restart=always
41
54
  RestartSec=15
@@ -0,0 +1,57 @@
1
+ # Carries pi-reply-reader's audio from a cloud VPS that runs Pi to the PipeWire of the machine you
2
+ # sit at (here called "desktop"), over SSH. Install it ON THE DESKTOP: a VPS usually cannot reach a
3
+ # desktop behind NAT, so the desktop connects out and asks the VPS to forward a socket back
4
+ # (ssh -R). Nothing is opened on the desktop or on the VPS's network.
5
+ #
6
+ # On the VPS the socket is /run/user/<your VPS uid>/reply-reader-pulse.sock, mode 0600 (sshd's
7
+ # default StreamLocalBindMask), so only your user there can open it. It still gives the desktop's
8
+ # whole audio, microphone included, to whoever can act as that user on the VPS: root and your cloud
9
+ # provider among them. Keep the unit stopped when you do not need readings there.
10
+ #
11
+ # On the VPS, once:
12
+ # loginctl enable-linger # /run/user/<uid> exists without a login session
13
+ # On the desktop:
14
+ # cp examples/reply-reader-vps-audio.service ~/.config/systemd/user/
15
+ # (edit VPS_HOST, VPS_UID and the user in you@${VPS_HOST})
16
+ # systemctl --user daemon-reload && systemctl --user enable --now reply-reader-vps-audio.service
17
+ # Then on the VPS, in ~/.config/pi-reply-reader/outputs.json (VPS_UID in place of 1000):
18
+ # { "desktop": "unix:/run/user/1000/reply-reader-pulse.sock" }
19
+ # Verify on the VPS (prints the desktop's host name; plays nothing):
20
+ # PULSE_SERVER=unix:$XDG_RUNTIME_DIR/reply-reader-pulse.sock pactl info | grep 'Host Name'
21
+ #
22
+ # The VPS's sshd keeps the socket after a dropped connection and then refuses the next forward
23
+ # ("remote port forwarding failed for listen path"), so ExecStartPre removes it first. With
24
+ # "StreamLocalBindUnlink yes" in the VPS's sshd_config that step is not needed.
25
+
26
+ [Unit]
27
+ Description=SSH reverse tunnel for pi-reply-reader audio from a VPS to this machine's PipeWire
28
+ After=network-online.target
29
+ Wants=network-online.target
30
+
31
+ [Service]
32
+ Type=simple
33
+ # The VPS's address and your user's ID there, in one place.
34
+ Environment=VPS_HOST=vps.example.com
35
+ Environment=VPS_UID=1000
36
+ # "-" lets the tunnel start (and fail and retry) even when this step cannot reach the VPS.
37
+ ExecStartPre=-/usr/bin/ssh \
38
+ -o BatchMode=yes \
39
+ -o ConnectTimeout=10 \
40
+ -o ControlMaster=no \
41
+ -o ControlPath=none \
42
+ you@${VPS_HOST} rm -f /run/user/${VPS_UID}/reply-reader-pulse.sock
43
+ ExecStart=/usr/bin/ssh -N \
44
+ -o BatchMode=yes \
45
+ -o ExitOnForwardFailure=yes \
46
+ -o ConnectTimeout=10 \
47
+ -o ServerAliveInterval=30 \
48
+ -o ServerAliveCountMax=3 \
49
+ -o ControlMaster=no \
50
+ -o ControlPath=none \
51
+ -R /run/user/${VPS_UID}/reply-reader-pulse.sock:%t/pulse/native \
52
+ you@${VPS_HOST}
53
+ Restart=always
54
+ RestartSec=15
55
+
56
+ [Install]
57
+ WantedBy=default.target