Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,19 @@ dev:
bun run concurrently --kill-others --names srv,bbb,web --prefix-colors auto \
"just relay" \
"sleep 1 && just pub bbb http://localhost:4443/anon" \
"sleep 2 && just web http://localhost:4443/anon"

"sleep 2 && just web auto"

# Run a localhost relay server without authentication.
relay *args:
# Run the relay server overriding the provided configuration file.
TOKIO_CONSOLE_BIND=127.0.0.1:6680 cargo run --bin moq-relay -- dev/relay.toml {{args}}
@if [ -n "${WSL_DISTRO_NAME:-}" ]; then \
ip="$(hostname -I | awk '{print $1}')"; \
TOKIO_CONSOLE_BIND=127.0.0.1:6680 cargo run --bin moq-relay -- dev/relay.toml \
--server-bind "0.0.0.0:4443" \
--tls-generate "localhost,$ip" \
{{args}}; \
Comment on lines +36 to +41
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add a guard for empty WSL IP detection.

If hostname -I returns nothing, TLS SAN becomes invalid and the relay may fail or generate a bad cert. Consider a fast-fail check.

🛠️ Suggested guard
-		ip="$(hostname -I | awk '{print $1}')"; \
+		ip="$(hostname -I | awk '{print $1}')"; \
+		if [ -z "$ip" ]; then \
+			echo "Error: unable to detect WSL IP" >&2; \
+			exit 1; \
+		fi; \
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@if [ -n "${WSL_DISTRO_NAME:-}" ]; then \
ip="$(hostname -I | awk '{print $1}')"; \
TOKIO_CONSOLE_BIND=127.0.0.1:6680 cargo run --bin moq-relay -- dev/relay.toml \
--server-bind "0.0.0.0:4443" \
--tls-generate "localhost,$ip" \
{{args}}; \
`@if` [ -n "${WSL_DISTRO_NAME:-}" ]; then \
ip="$(hostname -I | awk '{print $1}')"; \
if [ -z "$ip" ]; then \
echo "Error: unable to detect WSL IP" >&2; \
exit 1; \
fi; \
TOKIO_CONSOLE_BIND=127.0.0.1:6680 cargo run --bin moq-relay -- dev/relay.toml \
--server-bind "0.0.0.0:4443" \
--tls-generate "localhost,$ip" \
{{args}}; \
🤖 Prompt for AI Agents
In `@justfile` around lines 36 - 41, The WSL branch sets ip="$(hostname -I | awk
'{print $1}')" then passes it to --tls-generate which can produce an invalid SAN
when empty; add a guard that checks the ip variable before invoking cargo: if ip
is empty, print an error and exit (fast-fail) rather than continuing to run
TOKIO_CONSOLE_BIND=... cargo run --bin moq-relay -- dev/relay.toml ...
--tls-generate "localhost,$ip". Ensure the check lives in the same justfile WSL
block so the variables (ip, TOKIO_CONSOLE_BIND) and the invocation of moq-relay
are only executed when ip is non-empty.

else \
TOKIO_CONSOLE_BIND=127.0.0.1:6680 cargo run --bin moq-relay -- dev/relay.toml {{args}}; \
fi

# Run a cluster of relay servers
cluster:
Expand Down Expand Up @@ -260,8 +266,17 @@ serve name *args:
--name "{{name}}" fmp4

# Run the web server
web url='http://localhost:4443/anon':
cd js/hang-demo && VITE_RELAY_URL="{{url}}" bun run dev
web url="auto":
@url="{{url}}"; \
if [ "$url" = "auto" ]; then \
if [ -n "${WSL_DISTRO_NAME:-}" ]; then \
ip="$(hostname -I | awk '{print $1}')"; \
url="http://$ip:4443/anon"; \
else \
url="http://localhost:4443/anon"; \
fi; \
fi; \
cd js/hang-demo && VITE_RELAY_URL="$url" bun run dev -- --host 0.0.0.0
Comment on lines +269 to +279
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Avoid binding Vite to all interfaces outside WSL.

--host 0.0.0.0 on non-WSL exposes the dev server to the LAN by default. Consider limiting it to WSL only (or making it opt-in) to keep the previous security posture.

🔒 Suggested conditional host binding
 web url="auto":
 	`@url`="{{url}}"; \
+	host="127.0.0.1"; \
 	if [ "$url" = "auto" ]; then \
 		if [ -n "${WSL_DISTRO_NAME:-}" ]; then \
 			ip="$(hostname -I | awk '{print $1}')"; \
 			url="http://$ip:4443/anon"; \
+			host="0.0.0.0"; \
 		else \
 			url="http://localhost:4443/anon"; \
 		fi; \
 	fi; \
-	cd js/hang-demo && VITE_RELAY_URL="$url" bun run dev -- --host 0.0.0.0
+	cd js/hang-demo && VITE_RELAY_URL="$url" bun run dev -- --host "$host"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
web url="auto":
@url="{{url}}"; \
if [ "$url" = "auto" ]; then \
if [ -n "${WSL_DISTRO_NAME:-}" ]; then \
ip="$(hostname -I | awk '{print $1}')"; \
url="http://$ip:4443/anon"; \
else \
url="http://localhost:4443/anon"; \
fi; \
fi; \
cd js/hang-demo && VITE_RELAY_URL="$url" bun run dev -- --host 0.0.0.0
web url="auto":
`@url`="{{url}}"; \
host="127.0.0.1"; \
if [ "$url" = "auto" ]; then \
if [ -n "${WSL_DISTRO_NAME:-}" ]; then \
ip="$(hostname -I | awk '{print $1}')"; \
url="http://$ip:4443/anon"; \
host="0.0.0.0"; \
else \
url="http://localhost:4443/anon"; \
fi; \
fi; \
cd js/hang-demo && VITE_RELAY_URL="$url" bun run dev -- --host "$host"
🤖 Prompt for AI Agents
In `@justfile` around lines 269 - 279, The web recipe currently always appends
"--host 0.0.0.0" which exposes the Vite server to the LAN; change the invocation
in the web recipe (the line that runs: cd js/hang-demo && VITE_RELAY_URL="$url"
bun run dev -- --host 0.0.0.0) to only include "--host 0.0.0.0" when running
under WSL (WSL_DISTRO_NAME present) or when an explicit opt-in flag/env (e.g.,
DEV_HOST_ALL or similar) is set; otherwise omit the --host flag (or use --host
localhost) to keep the server bound to loopback. Ensure the conditional uses the
existing WSL_DISTRO_NAME check or a new opt-in env and updates the command
construction accordingly.


# Publish the clock broadcast
# `action` is either `publish` or `subscribe`
Expand Down
Loading