Skip to content

Commit 4af893d

Browse files
committed
Use enabled regions to filter regions for servers.
1 parent 2f7839c commit 4af893d

File tree

1 file changed

+11
-1
lines changed
  • nts-pool-management/src/routes

1 file changed

+11
-1
lines changed

nts-pool-management/src/routes/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::collections::HashSet;
2+
13
use askama::Template;
24
use axum::{
35
Json, Router,
@@ -148,6 +150,10 @@ pub async fn poolke_servers(
148150
_authentication: AuthenticatedInternal,
149151
) -> Result<impl IntoResponse, AppError> {
150152
let timesources = models::time_source::list(&state.db).await?;
153+
let regions: HashSet<_> = models::regions::list_enabled_regions(&state.db)
154+
.await?
155+
.into_iter()
156+
.collect();
151157
Ok(Json(
152158
timesources
153159
.into_iter()
@@ -158,7 +164,11 @@ pub async fn poolke_servers(
158164
base_key_index: 0,
159165
randomizer: ts.auth_token_randomizer,
160166
weight: Some(ts.weight.try_into().unwrap_or(1)),
161-
regions: vec![],
167+
regions: ts
168+
.countries
169+
.into_iter()
170+
.filter(|v| regions.contains(v))
171+
.collect(),
162172
ipv4_capable: Some(ts.ipv4_score > 10.0),
163173
ipv6_capable: Some(ts.ipv6_score > 10.0),
164174
})

0 commit comments

Comments
 (0)