2023-09-15 19:06:28 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
# Change directory to the root of the project
|
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
|
2023-10-20 03:04:55 +00:00
|
|
|
# Use debug logging by default
|
|
|
|
export RUST_LOG="${RUST_LOG:-debug}"
|
2023-10-12 04:09:32 +00:00
|
|
|
|
2023-09-15 19:06:28 +00:00
|
|
|
# Default to a self-signed certificate
|
|
|
|
# TODO automatically generate if it doesn't exist.
|
|
|
|
CERT="${CERT:-dev/localhost.crt}"
|
|
|
|
KEY="${KEY:-dev/localhost.key}"
|
|
|
|
|
2023-10-12 04:09:32 +00:00
|
|
|
# Default to listening on localhost:4443
|
|
|
|
HOST="${HOST:-[::]}"
|
|
|
|
PORT="${PORT:-4443}"
|
|
|
|
LISTEN="${LISTEN:-$HOST:$PORT}"
|
|
|
|
|
|
|
|
# A list of optional args
|
|
|
|
ARGS=""
|
|
|
|
|
|
|
|
# Connect to the given URL to get origins.
|
|
|
|
# TODO default to a public instance?
|
2023-10-12 04:24:28 +00:00
|
|
|
if [ -n "${API-}" ]; then
|
2023-10-12 04:09:32 +00:00
|
|
|
ARGS="$ARGS --api $API"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Provide our node URL when registering origins.
|
2023-10-12 04:24:28 +00:00
|
|
|
if [ -n "${NODE-}" ]; then
|
2023-10-17 05:50:17 +00:00
|
|
|
ARGS="$ARGS --api-node $NODE"
|
2023-10-12 04:09:32 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Publish URL: https://quic.video/publish/?server=localhost:${PORT}"
|
|
|
|
|
2023-09-15 19:06:28 +00:00
|
|
|
# Run the relay and forward any arguments
|
2023-10-17 05:50:17 +00:00
|
|
|
cargo run --bin moq-relay -- --listen "$LISTEN" --tls-cert "$CERT" --tls-key "$KEY" --dev $ARGS -- "$@"
|