Skip to content

Commit

Permalink
trying to fix
Browse files Browse the repository at this point in the history
  • Loading branch information
1majom committed Jul 8, 2024
1 parent 6f4e7df commit d7a9183
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 81 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:bookworm as builder
FROM rust:bookworm AS builder

# Create a build directory and copy over all of the files
WORKDIR /build
Expand All @@ -14,7 +14,7 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \
cargo build --release && cp /build/target/release/moq-* /usr/local/cargo/bin

# Create a pub image that also contains ffmpeg and a helper script
FROM debian:bookworm-slim as moq-pub
FROM debian:bookworm-slim AS moq-pub

# Install required utilities and ffmpeg
RUN apt-get update && \
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export CAROOT ?= $(shell cd dev ; go run filippo.io/mkcert -CAROOT)

.PHONY: run
run: dev/localhost.crt
@./gen_compose.sh
@./gen_compose.sh old
@docker-compose up --build --remove-orphans

dev/localhost.crt:
Expand Down
2 changes: 1 addition & 1 deletion dev/cert
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ go run filippo.io/mkcert -ecdsa -install
# Generate a new certificate for localhost
# This fork of mkcert supports the -days flag.
# TODO remove the -days flag when Chrome accepts self-signed certs.
go run filippo.io/mkcert -ecdsa -days 10 -cert-file "$CRT" -key-file "$KEY" localhost 127.0.0.1 ::1 relay1 relay2 relay4443 relay4441 relay4444
go run filippo.io/mkcert -ecdsa -days 10 -cert-file "$CRT" -key-file "$KEY" localhost 127.0.0.1 ::1 relay1 relay2 relay4443 relay4441 relay4442
7 changes: 7 additions & 0 deletions dev/topos/topo_old.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
nodes:
- localhost4441
- localhost4442

edges:
- - localhost4441
- localhost4442
71 changes: 36 additions & 35 deletions docker-compose-old.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
version: "3.8"

x-relay: &x-relay
x-moq: &x-moq
build: .
entrypoint: ["moq-relay"]
environment:
RUST_LOG: ${RUST_LOG:-debug}
volumes:
- ./dev/localhost.crt:/etc/tls/cert:ro
- ./dev/localhost.key:/etc/tls/key:ro
- certs:/etc/ssl/certs
- ./dev/localhost.crt:/etc/tls/cert:ro
- ./dev/localhost.key:/etc/tls/key:ro
- certs:/etc/ssl/certs
depends_on:
install-certs:
condition: service_completed_successfully
Expand All @@ -17,43 +16,45 @@ services:
redis:
image: redis:7
ports:
- "6400:6379"
- "6379"

api:
build: .
<<: *x-moq
entrypoint: moq-api
volumes:
- ./topo.yaml:/topo.yaml:ro
entrypoint: moq-api
command: --listen [::]:4440 --redis redis://redis:6379 --topo-path topo.yaml
command: --redis redis://redis:6379 --topo-path topo.yaml
ports:
- "80"

relay4441:
<<: *x-relay
command: --listen [::]:4441 --tls-cert /etc/tls/cert --tls-key /etc/tls/key --api http://api:4440 --api-node https://localhost:4441 --dev
<<: *x-moq
entrypoint: moq-relay
command: --tls-cert /etc/tls/cert --tls-key /etc/tls/key --tls-disable-verify --api http://api --node https://localhost:4441 --dev --announce https://dir
depends_on:
- api
- dir
ports:
- "4441:4441"
- "4441:4441/udp"
- "4441:4441"
- "4441:4441/udp"

relay4443:
<<: *x-relay
command: --listen [::]:4443 --tls-cert /etc/tls/cert --tls-key /etc/tls/key --api http://api:4440 --api-node https://localhost:4443 --dev
relay4442:
<<: *x-moq
entrypoint: moq-relay
command: --tls-cert /etc/tls/cert --tls-key /etc/tls/key --tls-disable-verify --api http://api --node https://localhost:4442 --dev --announce https://dir
depends_on:
- api
- dir
ports:
- "4443:4443"
- "4443:4443/udp"
- "4442:4442"
- "4442:4442/udp"

relay4444:
<<: *x-relay
command: --listen [::]:4444 --tls-cert /etc/tls/cert --tls-key /etc/tls/key --api http://api:4440 --api-node https://localhost:4444 --dev
dir:
<<: *x-moq
entrypoint: moq-dir
command: --tls-cert /etc/tls/cert --tls-key /etc/tls/key
ports:
- "4444:4444"
- "4444:4444/udp"
relay4445:
<<: *x-relay
command: --listen [::]:4445 --tls-cert /etc/tls/cert --tls-key /etc/tls/key --api http://api:4440 --api-node https://localhost:4445 --dev
ports:
- "4445:4445"
- "4445:4445/udp"


- "443/udp"

install-certs:
image: golang:latest
Expand All @@ -62,10 +63,10 @@ services:
environment:
CAROOT: /work/caroot
volumes:
- ${CAROOT:-.}:/work/caroot
- certs:/etc/ssl/certs
- ./dev/go.mod:/work/go.mod:ro
- ./dev/go.sum:/work/go.sum:ro
- ${CAROOT:-.}:/work/caroot
- certs:/etc/ssl/certs
- ./dev/go.mod:/work/go.mod:ro
- ./dev/go.sum:/work/go.sum:ro

volumes:
certs:
37 changes: 2 additions & 35 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,41 +46,8 @@ services:
- api
- dir
ports:
- "4444:443"
- "4444:443/udp"


relay4443:
<<: *x-moq
entrypoint: moq-relay
command: --tls-cert /etc/tls/cert --tls-key /etc/tls/key --tls-disable-verify --api http://api --node https://localhost:4443 --dev --announce https://dir
depends_on:
- api
- dir
ports:
- "4444:443"
- "4444:443/udp"
relay4444:
<<: *x-moq
entrypoint: moq-relay
command: --tls-cert /etc/tls/cert --tls-key /etc/tls/key --tls-disable-verify --api http://api --node https://localhost:4444 --dev --announce https://dir
depends_on:
- api
- dir
ports:
- "4444:443"
- "4444:443/udp"

relay4445:
<<: *x-moq
entrypoint: moq-relay
command: --tls-cert /etc/tls/cert --tls-key /etc/tls/key --tls-disable-verify --api http://api --node https://localhost:4445 --dev --announce https://dir
depends_on:
- api
- dir
ports:
- "4444:443"
- "4444:443/udp"
- "4442:4442"
- "4442:4442/udp"

dir:
<<: *x-moq
Expand Down
7 changes: 7 additions & 0 deletions gen_compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ if [ -z "$topology_file" ]; then
fi
fi

if [ "$topology_file" == "old" ]; then
cp dev/topos/topo_old.yaml topo.yaml
cp docker-compose-old.yml docker-compose.yml
echo "Using old docker-compose configuration."
exit 0
fi


relays=($(awk '/nodes:/,/edges:/{if (!/edges:/)print}' $topology_file | grep -v 'nodes:' | tr -d ' -'))

Expand Down
4 changes: 2 additions & 2 deletions moq-api/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ pub struct Client {

client: reqwest::Client,

the_type: u16,
the_type: String,
}

impl Client {
pub fn new(url: Url, the_type: &u16) -> Self {
pub fn new(url: Url, the_type: &str) -> Self {
let client = reqwest::Client::new();
Self { url, client, the_type: the_type.to_owned() }
}
Expand Down
1 change: 0 additions & 1 deletion moq-api/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ async fn get_origin(
) -> Result<Json<Origin>, AppError> {
let key = origin_key(&namespace, &relayid);

let key = origin_key(&id, &relayid);
let payload: Option<String> = state.redis.get(&key).await?;
let payload = payload.ok_or(AppError::NotFound)?;
let origin: Origin = serde_json::from_str(&payload)?;
Expand Down
4 changes: 2 additions & 2 deletions moq-relay/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ pub struct Api {

impl Api {
pub fn new(url: Url, node: Url) -> Self {
let origin = moq_api::Origin { url: node };
let client = moq_api::Client::new(url);
let origin = moq_api::Origin { url: node.clone() };
let client: moq_api::Client = moq_api::Client::new(url, &(node).as_str().replace(":", "").replace("/", ""));

Self { client, origin }
}
Expand Down
3 changes: 1 addition & 2 deletions moq-relay/src/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ impl Relay {

let api = if let (Some(url), Some(node)) = (config.api, config.node) {
log::info!("using moq-api: url={} node={}", url, node);
let port=config.api_node.as_ref().unwrap().port().unwrap();

Some(Api::new(url, node, &port))
Some(Api::new(url, node))
} else {
None
};
Expand Down

0 comments on commit d7a9183

Please sign in to comment.