From c4d2f411e6cd830e10992039190d0208eb225b4f Mon Sep 17 00:00:00 2001 From: Raghu Saxena Date: Wed, 26 Apr 2023 19:13:30 +0800 Subject: [PATCH 1/2] Add the ZADDS --- src/main.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index f8246fe..6940062 100644 --- a/src/main.rs +++ b/src/main.rs @@ -101,10 +101,11 @@ async fn announce(req: HttpRequest, data: web::Data) -> HttpResponse { post_announce_pipeline.cmd("ZREM").arg(&leechers_key).arg(&parsed.ip_port).ignore(); // We dont care about the return value } } else if parsed.is_seeding { + // ZADD it regardless to update timestamp for the guy (in redis) + post_announce_pipeline.cmd("ZADD").arg(&seeders_key).arg(time_now_ms).arg(&parsed.ip_port).ignore(); // New seeder if let Exists::No = is_seeder_v2 { - post_announce_pipeline.cmd("ZADD").arg(&seeders_key).arg(time_now_ms).arg(&parsed.ip_port).ignore(); seed_count_mod += 1; } @@ -119,10 +120,14 @@ async fn announce(req: HttpRequest, data: web::Data) -> HttpResponse { // Increment the downloaded count for the infohash stats post_announce_pipeline.cmd("HINCRBY").arg(&parsed.info_hash).arg("downloaded").arg(1u32).ignore(); } - } else if let Exists::No = is_leecher_v2 { - post_announce_pipeline.cmd("ZADD").arg(&leechers_key).arg(time_now_ms).arg(&parsed.ip_port).ignore(); + } else { + // ZADD it regardless to update timestamp for the guy (in redis) + post_announce_pipeline.cmd("ZADD").arg(&leechers_key).arg(time_now_ms).arg(&parsed.ip_port).ignore(); + + if let Exists::No = is_leecher_v2 { leech_count_mod += 1; - }; + }; + } // Cache miss = query redis // no change = update cache From 3bc5b6cf01869736c95dd9d21e2753cc616a1d91 Mon Sep 17 00:00:00 2001 From: Raghu Saxena Date: Wed, 17 May 2023 15:14:53 +0800 Subject: [PATCH 2/2] Pass expected announce IP to gauge --- .github/workflows/integration_test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index 7ab81de..af07d29 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -144,4 +144,5 @@ jobs: uses: docker://ghcr.io/ckcr4lyf/kiryuu-gauge:master env: KIRYUU_HOST: http://172.17.0.1:6969 - REDIS_HOST: redis://172.17.0.1:6379 \ No newline at end of file + REDIS_HOST: redis://172.17.0.1:6379 + ANNOUNCE_IP_PORT: AC120003115C #172.18.0.3:4444 <- This is the IP kiryuu will see the announce come from, so what we need to hardcode in redis via Gauge \ No newline at end of file