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 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