From 605986c402a163aae11265bd4f898ab6e1bc23ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Tue, 19 Jul 2022 19:40:43 +0200 Subject: [PATCH 01/23] WIP: start work on a aquatic_ws.Dockerfile --- .dockerignore | 2 ++ docker/aquatic_ws.Dockerfile | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 .dockerignore create mode 100644 docker/aquatic_ws.Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e0ad30c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +target +docker diff --git a/docker/aquatic_ws.Dockerfile b/docker/aquatic_ws.Dockerfile new file mode 100644 index 0000000..5d122c1 --- /dev/null +++ b/docker/aquatic_ws.Dockerfile @@ -0,0 +1,32 @@ +# aquatic_ws +# +# If no changes are made to settings, aquatic_ws is run without +# TLS, on port 3000 and with http health checks enabled. +# +# $ docker build -t aquatic-ws -f docker/aquatic_ws.Dockerfile . +# $ docker run -it --rm --ulimit memlock=65536:65536 -p 3000:3000 --name aquatic-ws aquatic-ws + +FROM rust:latest AS builder + +WORKDIR /usr/src/aquatic + +COPY . . + +RUN . ./scripts/env-native-cpu-without-avx-512 && cargo build --release -p aquatic_ws + +FROM debian:stable-slim + +ENV CONFIG_FILE_CONTENTS "log_level = 'trace'\n\n[network]\nenable_http_health_checks = true" +ENV ACCESS_LIST_CONTENTS "" + +WORKDIR /root/ + +COPY --from=builder /usr/src/aquatic/target/release/aquatic_ws ./ + +RUN echo "$CONFIG_FILE_CONTENTS" > ./config.toml +RUN echo "$ACCESS_LIST_CONTENTS" > ./access-list.txt + +# Enable setting config and access list file contents at runtime +RUN echo "#!/bin/sh\necho \"\$CONFIG_FILE_CONTENTS\" > ./config.toml\necho \"\$ACCESS_LIST_CONTENTS\" > ./access-list.txt\n./aquatic_ws -P -c ./config.toml" > entrypoint.sh && chmod +x entrypoint.sh + +ENTRYPOINT ["sh", "./entrypoint.sh"] From 375dc1c8e6d5d53a675f06dcd30b211a64b74d43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Tue, 19 Jul 2022 22:37:28 +0200 Subject: [PATCH 02/23] add aquatic_udp.Dockerfile --- docker/aquatic_udp.Dockerfile | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 docker/aquatic_udp.Dockerfile diff --git a/docker/aquatic_udp.Dockerfile b/docker/aquatic_udp.Dockerfile new file mode 100644 index 0000000..72c9228 --- /dev/null +++ b/docker/aquatic_udp.Dockerfile @@ -0,0 +1,29 @@ +# aquatic_udp +# +# Customize by setting CONFIG_FILE_CONTENTS and +# ACCESS_LIST_CONTENTS environment variables. +# +# $ docker build -t aquatic-udp -f docker/aquatic_udp.Dockerfile . +# $ docker run -it -p 0.0.0.0:3000:3000/udp --name aquatic-udp aquatic-udp + +FROM rust:latest AS builder + +WORKDIR /usr/src/aquatic + +COPY . . + +RUN . ./scripts/env-native-cpu-without-avx-512 && cargo build --release -p aquatic_udp + +FROM debian:stable-slim + +ENV CONFIG_FILE_CONTENTS "log_level = 'warn'" +ENV ACCESS_LIST_CONTENTS "" + +WORKDIR /root/ + +COPY --from=builder /usr/src/aquatic/target/release/aquatic_udp ./ + +# Setting config and access list file contents at runtime +RUN echo "#!/bin/sh\necho \"\$CONFIG_FILE_CONTENTS\" > ./config.toml\necho \"\$ACCESS_LIST_CONTENTS\" > ./access-list.txt\n./aquatic_udp -c ./config.toml" > entrypoint.sh && chmod +x entrypoint.sh + +ENTRYPOINT ["./entrypoint.sh"] From d4f9c0b74f8b935481457ae2b7bf2e8b03a33872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Tue, 19 Jul 2022 22:43:47 +0200 Subject: [PATCH 03/23] Update aquatic_ws.Dockerfile --- docker/aquatic_ws.Dockerfile | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/docker/aquatic_ws.Dockerfile b/docker/aquatic_ws.Dockerfile index 5d122c1..2e23462 100644 --- a/docker/aquatic_ws.Dockerfile +++ b/docker/aquatic_ws.Dockerfile @@ -1,10 +1,19 @@ # aquatic_ws # -# If no changes are made to settings, aquatic_ws is run without -# TLS, on port 3000 and with http health checks enabled. +# WORK IN PROGRESS # +# Customize by setting CONFIG_FILE_CONTENTS and +# ACCESS_LIST_CONTENTS environment variables. +# +# If no changes are made to configuration, aquatic_ws is run: +# - on port 3000 +# - without TLS +# - with no info hash access control +# - with http health checks enabled +# +# Run from root directory of repository with: # $ docker build -t aquatic-ws -f docker/aquatic_ws.Dockerfile . -# $ docker run -it --rm --ulimit memlock=65536:65536 -p 3000:3000 --name aquatic-ws aquatic-ws +# $ docker run -it --ulimit memlock=65536:65536 -p 0.0.0.0:3000:3000 --name aquatic-ws aquatic-ws FROM rust:latest AS builder @@ -16,17 +25,14 @@ RUN . ./scripts/env-native-cpu-without-avx-512 && cargo build --release -p aquat FROM debian:stable-slim -ENV CONFIG_FILE_CONTENTS "log_level = 'trace'\n\n[network]\nenable_http_health_checks = true" +ENV CONFIG_FILE_CONTENTS "log_level = 'warn'\n\n[network]\nenable_http_health_checks = true" ENV ACCESS_LIST_CONTENTS "" WORKDIR /root/ COPY --from=builder /usr/src/aquatic/target/release/aquatic_ws ./ -RUN echo "$CONFIG_FILE_CONTENTS" > ./config.toml -RUN echo "$ACCESS_LIST_CONTENTS" > ./access-list.txt - # Enable setting config and access list file contents at runtime RUN echo "#!/bin/sh\necho \"\$CONFIG_FILE_CONTENTS\" > ./config.toml\necho \"\$ACCESS_LIST_CONTENTS\" > ./access-list.txt\n./aquatic_ws -P -c ./config.toml" > entrypoint.sh && chmod +x entrypoint.sh -ENTRYPOINT ["sh", "./entrypoint.sh"] +ENTRYPOINT ["./entrypoint.sh"] From 809aa4def956262ce37e1be7c1d6734e33eec102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Tue, 19 Jul 2022 22:44:26 +0200 Subject: [PATCH 04/23] Update .dockerignore --- .dockerignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.dockerignore b/.dockerignore index e0ad30c..96042e7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,4 @@ target docker +.git +tmp From b79636730c944d6a789bac687370f82c8cf40767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Tue, 19 Jul 2022 23:45:15 +0200 Subject: [PATCH 05/23] ws: add some info level logging --- aquatic_ws/src/lib.rs | 4 ++++ aquatic_ws/src/workers/socket.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/aquatic_ws/src/lib.rs b/aquatic_ws/src/lib.rs index 7d48a08..d7e961d 100644 --- a/aquatic_ws/src/lib.rs +++ b/aquatic_ws/src/lib.rs @@ -96,6 +96,8 @@ pub fn run(config: Config) -> ::anyhow::Result<()> { executors.push(executor); } + ::log::info!("spawned socket workers"); + for i in 0..(config.swarm_workers) { let sentinel = sentinel.clone(); let config = config.clone(); @@ -129,6 +131,8 @@ pub fn run(config: Config) -> ::anyhow::Result<()> { executors.push(executor); } + ::log::info!("spawned swarm workers"); + if config.cpu_pinning.active { set_affinity_for_util_worker( &config.cpu_pinning, diff --git a/aquatic_ws/src/workers/socket.rs b/aquatic_ws/src/workers/socket.rs index fdfd5a9..6626832 100644 --- a/aquatic_ws/src/workers/socket.rs +++ b/aquatic_ws/src/workers/socket.rs @@ -65,6 +65,8 @@ pub async fn run_socket_worker( let listener = create_tcp_listener(&config, priv_dropper).expect("create tcp listener"); + ::log::info!("created tcp listener"); + let (control_message_senders, _) = control_message_mesh_builder .join(Role::Producer) .await @@ -86,6 +88,8 @@ pub async fn run_socket_worker( out_message_mesh_builder.join(Role::Consumer).await.unwrap(); let out_message_consumer_id = ConsumerId(out_message_receivers.consumer_id().unwrap()); + ::log::info!("joined channels"); + let connection_slab = Rc::new(RefCell::new(Slab::new())); // Periodically clean connections From 38e74bfc206e9d9f77965797203661cbe4e71d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sat, 23 Jul 2022 17:34:38 +0200 Subject: [PATCH 06/23] aquatic_ws.Dockerfile: use multiline ENV instruction --- docker/aquatic_ws.Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docker/aquatic_ws.Dockerfile b/docker/aquatic_ws.Dockerfile index 2e23462..6e556f0 100644 --- a/docker/aquatic_ws.Dockerfile +++ b/docker/aquatic_ws.Dockerfile @@ -25,7 +25,11 @@ RUN . ./scripts/env-native-cpu-without-avx-512 && cargo build --release -p aquat FROM debian:stable-slim -ENV CONFIG_FILE_CONTENTS "log_level = 'warn'\n\n[network]\nenable_http_health_checks = true" +ENV CONFIG_FILE_CONTENTS "\ + log_level = 'info'\n\ + [network]\n\ + enable_http_health_checks = true\n\ + " ENV ACCESS_LIST_CONTENTS "" WORKDIR /root/ From 9b2c5b97df63ec532d785ea19456fcccb65b6822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sat, 23 Jul 2022 17:35:11 +0200 Subject: [PATCH 07/23] ws: add logging in create_tcp_listener --- aquatic_ws/src/workers/socket.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/aquatic_ws/src/workers/socket.rs b/aquatic_ws/src/workers/socket.rs index 6626832..61870c7 100644 --- a/aquatic_ws/src/workers/socket.rs +++ b/aquatic_ws/src/workers/socket.rs @@ -722,28 +722,42 @@ fn create_tcp_listener( socket2::Domain::IPV6 }; + ::log::info!("creating socket.."); + let socket = socket2::Socket::new(domain, socket2::Type::STREAM, Some(socket2::Protocol::TCP)) .with_context(|| "create socket")?; if config.network.only_ipv6 { + ::log::info!("setting socket to ipv6 only.."); + socket .set_only_v6(true) .with_context(|| "socket: set only ipv6")?; } + ::log::info!("setting SO_REUSEPORT on socket.."); + socket .set_reuse_port(true) .with_context(|| "socket: set reuse port")?; + ::log::info!("binding socket.."); + socket .bind(&config.network.address.into()) .with_context(|| format!("socket: bind to {}", config.network.address))?; + ::log::info!("listening on socket.."); + socket .listen(config.network.tcp_backlog) .with_context(|| format!("socket: listen {}", config.network.address))?; + ::log::info!("running PrivilegeDropper::after_socket_creation.."); + priv_dropper.after_socket_creation()?; + ::log::info!("casting socket to glommio TcpListener.."); + Ok(unsafe { TcpListener::from_raw_fd(socket.into_raw_fd()) }) } From 66e005f37a690e03e8f1a7bcb7f5f1c95991e8a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sat, 23 Jul 2022 17:46:54 +0200 Subject: [PATCH 08/23] aquatic_ws.Dockerfile: enable access control in "allow" mode --- docker/aquatic_ws.Dockerfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docker/aquatic_ws.Dockerfile b/docker/aquatic_ws.Dockerfile index 6e556f0..0b3ed8a 100644 --- a/docker/aquatic_ws.Dockerfile +++ b/docker/aquatic_ws.Dockerfile @@ -8,10 +8,11 @@ # If no changes are made to configuration, aquatic_ws is run: # - on port 3000 # - without TLS -# - with no info hash access control # - with http health checks enabled +# - only allowing announces for hashes in access list, e.g., contained +# in ACCESS_LIST_CONTENTS env var. By default, this file is empty. # -# Run from root directory of repository with: +# Run from root directory of aquatic repository with: # $ docker build -t aquatic-ws -f docker/aquatic_ws.Dockerfile . # $ docker run -it --ulimit memlock=65536:65536 -p 0.0.0.0:3000:3000 --name aquatic-ws aquatic-ws @@ -29,6 +30,9 @@ ENV CONFIG_FILE_CONTENTS "\ log_level = 'info'\n\ [network]\n\ enable_http_health_checks = true\n\ + [access_list]\n\ + mode = 'allow'\n\ + path = './access-list.txt'\n\ " ENV ACCESS_LIST_CONTENTS "" From 1e9b421c7e860b4be4fcdf3b8013558532916804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sat, 23 Jul 2022 17:50:54 +0200 Subject: [PATCH 09/23] Add "documents" to .dockerignore --- .dockerignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.dockerignore b/.dockerignore index 96042e7..4636ce6 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,3 +2,4 @@ target docker .git tmp +documents From bb44f3558aebd4e307532b7857c54f80337aa43e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sat, 23 Jul 2022 17:51:13 +0200 Subject: [PATCH 10/23] Update TODO --- TODO.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/TODO.md b/TODO.md index 1cc19ae..5396993 100644 --- a/TODO.md +++ b/TODO.md @@ -2,9 +2,6 @@ ## High priority -* ws - * add integration test for non-TLS configuration, maybe behind reverse proxy - ## Medium priority * quit whole program if any thread panics From ea046dd5fe1bf32eaf8fd2b6214de3fda75d7315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sat, 23 Jul 2022 17:51:21 +0200 Subject: [PATCH 11/23] AccessListConfig: add serde(default, deny_unknown_fields) --- aquatic_common/src/access_list.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aquatic_common/src/access_list.rs b/aquatic_common/src/access_list.rs index d002d2f..ec69db1 100644 --- a/aquatic_common/src/access_list.rs +++ b/aquatic_common/src/access_list.rs @@ -28,6 +28,7 @@ impl AccessListMode { } #[derive(Clone, Debug, PartialEq, TomlConfig, Deserialize)] +#[serde(default, deny_unknown_fields)] pub struct AccessListConfig { pub mode: AccessListMode, /// Path to access list file consisting of newline-separated hex-encoded info hashes. @@ -39,7 +40,7 @@ pub struct AccessListConfig { impl Default for AccessListConfig { fn default() -> Self { Self { - path: "".into(), + path: "./access-list.txt".into(), mode: AccessListMode::Off, } } From 22e3a77863b6819ce840f440ea1a41c0bbf7bbab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sun, 24 Jul 2022 11:25:26 +0200 Subject: [PATCH 12/23] aquatic_ws.Dockerfile: rely on default access list path,add example hash --- docker/aquatic_ws.Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docker/aquatic_ws.Dockerfile b/docker/aquatic_ws.Dockerfile index 0b3ed8a..bbe15f8 100644 --- a/docker/aquatic_ws.Dockerfile +++ b/docker/aquatic_ws.Dockerfile @@ -10,7 +10,7 @@ # - without TLS # - with http health checks enabled # - only allowing announces for hashes in access list, e.g., contained -# in ACCESS_LIST_CONTENTS env var. By default, this file is empty. +# in ACCESS_LIST_CONTENTS env var # # Run from root directory of aquatic repository with: # $ docker build -t aquatic-ws -f docker/aquatic_ws.Dockerfile . @@ -32,9 +32,8 @@ ENV CONFIG_FILE_CONTENTS "\ enable_http_health_checks = true\n\ [access_list]\n\ mode = 'allow'\n\ - path = './access-list.txt'\n\ " -ENV ACCESS_LIST_CONTENTS "" +ENV ACCESS_LIST_CONTENTS "0f0f0f0f0f1f1f1f1f1f2f2f2f2f2f3f3f3f3f3f" WORKDIR /root/ From 2a3919869287f832685cfb21c1cf1cbd81a10318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sun, 24 Jul 2022 11:41:46 +0200 Subject: [PATCH 13/23] ws Dockerfile: use here-doc for entrypoint creation, use exec --- docker/aquatic_ws.Dockerfile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/docker/aquatic_ws.Dockerfile b/docker/aquatic_ws.Dockerfile index bbe15f8..3d508fc 100644 --- a/docker/aquatic_ws.Dockerfile +++ b/docker/aquatic_ws.Dockerfile @@ -1,3 +1,5 @@ +# syntax=docker/dockerfile:1 + # aquatic_ws # # WORK IN PROGRESS @@ -39,7 +41,15 @@ WORKDIR /root/ COPY --from=builder /usr/src/aquatic/target/release/aquatic_ws ./ -# Enable setting config and access list file contents at runtime -RUN echo "#!/bin/sh\necho \"\$CONFIG_FILE_CONTENTS\" > ./config.toml\necho \"\$ACCESS_LIST_CONTENTS\" > ./access-list.txt\n./aquatic_ws -P -c ./config.toml" > entrypoint.sh && chmod +x entrypoint.sh +# Create entry point script for setting config and access +# list file contents at runtime +COPY <<-"EOT" ./entrypoint.sh +#!/bin/sh +echo "$CONFIG_FILE_CONTENTS" > ./config.toml +echo "$ACCESS_LIST_CONTENTS" > ./access-list.txt +exec ./aquatic_ws -P -c ./config.toml +EOT + +RUN chmod +x ./entrypoint.sh ENTRYPOINT ["./entrypoint.sh"] From bd70474d7310bd02a0e33ae23f839c44a7162871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sun, 24 Jul 2022 11:47:31 +0200 Subject: [PATCH 14/23] udp Dockerfile: use here-doc for entrypoint creation --- docker/aquatic_udp.Dockerfile | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/docker/aquatic_udp.Dockerfile b/docker/aquatic_udp.Dockerfile index 72c9228..876a91a 100644 --- a/docker/aquatic_udp.Dockerfile +++ b/docker/aquatic_udp.Dockerfile @@ -1,8 +1,13 @@ +# syntax=docker/dockerfile:1 + # aquatic_udp # # Customize by setting CONFIG_FILE_CONTENTS and # ACCESS_LIST_CONTENTS environment variables. # +# By default runs tracker on port 3000 without info hash access control. +# +# Run from repository root directory with: # $ docker build -t aquatic-udp -f docker/aquatic_udp.Dockerfile . # $ docker run -it -p 0.0.0.0:3000:3000/udp --name aquatic-udp aquatic-udp @@ -23,7 +28,15 @@ WORKDIR /root/ COPY --from=builder /usr/src/aquatic/target/release/aquatic_udp ./ -# Setting config and access list file contents at runtime -RUN echo "#!/bin/sh\necho \"\$CONFIG_FILE_CONTENTS\" > ./config.toml\necho \"\$ACCESS_LIST_CONTENTS\" > ./access-list.txt\n./aquatic_udp -c ./config.toml" > entrypoint.sh && chmod +x entrypoint.sh +# Create entry point script for setting config and access +# list file contents at runtime +COPY <<-"EOT" ./entrypoint.sh +#!/bin/sh +echo "$CONFIG_FILE_CONTENTS" > ./config.toml +echo "$ACCESS_LIST_CONTENTS" > ./access-list.txt +exec ./aquatic_udp -P -c ./config.toml +EOT + +RUN chmod +x ./entrypoint.sh ENTRYPOINT ["./entrypoint.sh"] From 414af5a26ffd608d58d84a35cbaa6bdc80921ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sun, 24 Jul 2022 12:01:18 +0200 Subject: [PATCH 15/23] aquatic_common: ignore some whitespace in cli arg parser --- aquatic_common/src/cli.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/aquatic_common/src/cli.rs b/aquatic_common/src/cli.rs index 6c9a2e0..db18f09 100644 --- a/aquatic_common/src/cli.rs +++ b/aquatic_common/src/cli.rs @@ -69,6 +69,7 @@ impl Options { "-h" | "--help" => { return Err(None); } + "" => (), _ => { return Err(Some("Unrecognized argument".to_string())); } From 55646d33b9f4a9c3f6954eae0556dd12732300af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sun, 24 Jul 2022 12:01:46 +0200 Subject: [PATCH 16/23] udp Dockerfile: pass on docker cli arguments to tracker --- docker/aquatic_udp.Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/aquatic_udp.Dockerfile b/docker/aquatic_udp.Dockerfile index 876a91a..db57b98 100644 --- a/docker/aquatic_udp.Dockerfile +++ b/docker/aquatic_udp.Dockerfile @@ -31,10 +31,10 @@ COPY --from=builder /usr/src/aquatic/target/release/aquatic_udp ./ # Create entry point script for setting config and access # list file contents at runtime COPY <<-"EOT" ./entrypoint.sh -#!/bin/sh +#!/bin/bash echo "$CONFIG_FILE_CONTENTS" > ./config.toml echo "$ACCESS_LIST_CONTENTS" > ./access-list.txt -exec ./aquatic_udp -P -c ./config.toml +exec ./aquatic_udp -c ./config.toml "$@" EOT RUN chmod +x ./entrypoint.sh From cdd9569fd9cb4cf0ed31c94d6fe87ac10b554693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sun, 24 Jul 2022 12:12:44 +0200 Subject: [PATCH 17/23] ws dockerfile: pass docker arguments to tracker --- docker/aquatic_ws.Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/aquatic_ws.Dockerfile b/docker/aquatic_ws.Dockerfile index 3d508fc..711511f 100644 --- a/docker/aquatic_ws.Dockerfile +++ b/docker/aquatic_ws.Dockerfile @@ -44,10 +44,10 @@ COPY --from=builder /usr/src/aquatic/target/release/aquatic_ws ./ # Create entry point script for setting config and access # list file contents at runtime COPY <<-"EOT" ./entrypoint.sh -#!/bin/sh -echo "$CONFIG_FILE_CONTENTS" > ./config.toml -echo "$ACCESS_LIST_CONTENTS" > ./access-list.txt -exec ./aquatic_ws -P -c ./config.toml +#!/bin/bash +echo -e "$CONFIG_FILE_CONTENTS" > ./config.toml +echo -e "$ACCESS_LIST_CONTENTS" > ./access-list.txt +exec ./aquatic_ws -c ./config.toml "$@" EOT RUN chmod +x ./entrypoint.sh From 24b86107ca78209f5d81685d653e2866fcf8d9ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sun, 24 Jul 2022 12:15:28 +0200 Subject: [PATCH 18/23] udp dockerfile: fix newline env arg issues --- docker/aquatic_udp.Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/aquatic_udp.Dockerfile b/docker/aquatic_udp.Dockerfile index db57b98..d88d098 100644 --- a/docker/aquatic_udp.Dockerfile +++ b/docker/aquatic_udp.Dockerfile @@ -32,8 +32,8 @@ COPY --from=builder /usr/src/aquatic/target/release/aquatic_udp ./ # list file contents at runtime COPY <<-"EOT" ./entrypoint.sh #!/bin/bash -echo "$CONFIG_FILE_CONTENTS" > ./config.toml -echo "$ACCESS_LIST_CONTENTS" > ./access-list.txt +echo -e "$CONFIG_FILE_CONTENTS" > ./config.toml +echo -e "$ACCESS_LIST_CONTENTS" > ./access-list.txt exec ./aquatic_udp -c ./config.toml "$@" EOT From c4b07b072cfbcfa5236479c1693d23a998b7de6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sun, 24 Jul 2022 12:17:43 +0200 Subject: [PATCH 19/23] dockerfiles: recommend using --network="host" --- docker/aquatic_udp.Dockerfile | 2 ++ docker/aquatic_ws.Dockerfile | 2 ++ 2 files changed, 4 insertions(+) diff --git a/docker/aquatic_udp.Dockerfile b/docker/aquatic_udp.Dockerfile index d88d098..0e0bb00 100644 --- a/docker/aquatic_udp.Dockerfile +++ b/docker/aquatic_udp.Dockerfile @@ -10,6 +10,8 @@ # Run from repository root directory with: # $ docker build -t aquatic-udp -f docker/aquatic_udp.Dockerfile . # $ docker run -it -p 0.0.0.0:3000:3000/udp --name aquatic-udp aquatic-udp +# +# Pass --network="host" to run command for much better performance. FROM rust:latest AS builder diff --git a/docker/aquatic_ws.Dockerfile b/docker/aquatic_ws.Dockerfile index 711511f..6ab8b85 100644 --- a/docker/aquatic_ws.Dockerfile +++ b/docker/aquatic_ws.Dockerfile @@ -17,6 +17,8 @@ # Run from root directory of aquatic repository with: # $ docker build -t aquatic-ws -f docker/aquatic_ws.Dockerfile . # $ docker run -it --ulimit memlock=65536:65536 -p 0.0.0.0:3000:3000 --name aquatic-ws aquatic-ws +# +# Pass --network="host" to run command for much better performance. FROM rust:latest AS builder From fce3bb1d9ced60128fad1d5a33dea4ddf15455f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sun, 24 Jul 2022 12:46:39 +0200 Subject: [PATCH 20/23] docker files: add DOCKER_BUILDKIT=1 --- docker/aquatic_udp.Dockerfile | 2 +- docker/aquatic_ws.Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/aquatic_udp.Dockerfile b/docker/aquatic_udp.Dockerfile index 0e0bb00..1d9f4b6 100644 --- a/docker/aquatic_udp.Dockerfile +++ b/docker/aquatic_udp.Dockerfile @@ -8,7 +8,7 @@ # By default runs tracker on port 3000 without info hash access control. # # Run from repository root directory with: -# $ docker build -t aquatic-udp -f docker/aquatic_udp.Dockerfile . +# $ DOCKER_BUILDKIT=1 docker build -t aquatic-udp -f docker/aquatic_udp.Dockerfile . # $ docker run -it -p 0.0.0.0:3000:3000/udp --name aquatic-udp aquatic-udp # # Pass --network="host" to run command for much better performance. diff --git a/docker/aquatic_ws.Dockerfile b/docker/aquatic_ws.Dockerfile index 6ab8b85..448d752 100644 --- a/docker/aquatic_ws.Dockerfile +++ b/docker/aquatic_ws.Dockerfile @@ -15,7 +15,7 @@ # in ACCESS_LIST_CONTENTS env var # # Run from root directory of aquatic repository with: -# $ docker build -t aquatic-ws -f docker/aquatic_ws.Dockerfile . +# $ DOCKER_BUILDKIT=1 docker build -t aquatic-ws -f docker/aquatic_ws.Dockerfile . # $ docker run -it --ulimit memlock=65536:65536 -p 0.0.0.0:3000:3000 --name aquatic-ws aquatic-ws # # Pass --network="host" to run command for much better performance. From f909febf170ac8977c1e44d20ef4d7596c7580e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sun, 24 Jul 2022 13:02:31 +0200 Subject: [PATCH 21/23] ws Dockerfile: add note about file not working --- docker/aquatic_ws.Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/aquatic_ws.Dockerfile b/docker/aquatic_ws.Dockerfile index 448d752..fdc7648 100644 --- a/docker/aquatic_ws.Dockerfile +++ b/docker/aquatic_ws.Dockerfile @@ -2,7 +2,8 @@ # aquatic_ws # -# WORK IN PROGRESS +# WORK IN PROGRESS: currently has issues spawning worker threads, possibly +# related to https://github.com/DataDog/glommio/issues/547 # # Customize by setting CONFIG_FILE_CONTENTS and # ACCESS_LIST_CONTENTS environment variables. From 6bdb50df8ab1525e4829a974b70f75efd35af1e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Tue, 26 Jul 2022 23:17:30 +0200 Subject: [PATCH 22/23] access control: strip whitespace in hashes, ignore empty lines --- aquatic_common/src/access_list.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/aquatic_common/src/access_list.rs b/aquatic_common/src/access_list.rs index ec69db1..04e7532 100644 --- a/aquatic_common/src/access_list.rs +++ b/aquatic_common/src/access_list.rs @@ -64,6 +64,11 @@ impl AccessList { for line in reader.lines() { let line = line?; + let line = line.trim(); + + if line.is_empty() { + continue; + } new_list .insert_from_line(&line) From 46fee0e085203bcc34ef175d6ff6c0853f16484d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Mon, 1 Aug 2022 14:19:28 +0200 Subject: [PATCH 23/23] Update warning in aquatic_ws.Dockerfile --- docker/aquatic_ws.Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/aquatic_ws.Dockerfile b/docker/aquatic_ws.Dockerfile index fdc7648..104e80c 100644 --- a/docker/aquatic_ws.Dockerfile +++ b/docker/aquatic_ws.Dockerfile @@ -2,8 +2,8 @@ # aquatic_ws # -# WORK IN PROGRESS: currently has issues spawning worker threads, possibly -# related to https://github.com/DataDog/glommio/issues/547 +# WORK IN PROGRESS: currently doesn't work due to issues with spawning worker +# threads, possibly related to https://github.com/DataDog/glommio/issues/547 # # Customize by setting CONFIG_FILE_CONTENTS and # ACCESS_LIST_CONTENTS environment variables.