aboutsummaryrefslogtreecommitdiffstats
path: root/src/cache
diff options
context:
space:
mode:
Diffstat (limited to 'src/cache')
-rw-r--r--src/cache/user.rs36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/cache/user.rs b/src/cache/user.rs
index f12d852..253773c 100644
--- a/src/cache/user.rs
+++ b/src/cache/user.rs
@@ -15,9 +15,9 @@ type UserGetter = CacheGetter<Arc<(User, Track, TrackStub)>>;
type UserCache = Cache<Arc<(User, Track, TrackStub)>>;
#[derive(Debug)]
-enum Whitelist {
+enum Allowlist {
Exclusive{cache: UserCache},
- Open{default_cache: UserCache, whitelist_cache: UserCache}
+ Open{default_cache: UserCache, allowlist_cache: UserCache}
}
fn user_getter(username: &String) -> UserFuture {
@@ -63,40 +63,40 @@ fn user_getter(username: &String) -> UserFuture {
static HTTP: LazyLock<Client> = crate::http::lazy();
-static WHITELIST: LazyLock<Whitelist> = LazyLock::new(|| {
+static ALLOWLIST: LazyLock<Allowlist> = LazyLock::new(|| {
let default_cache = Arc::new(RwLock::new(AsyncCache::new(CONFIG.default_refresh, user_getter as UserGetter)));
- let whitelist_cache = Arc::new(RwLock::new(AsyncCache::new(CONFIG.whitelist_refresh, user_getter as UserGetter)));
- match CONFIG.whitelist_mode.as_str() {
+ let allowlist_cache = Arc::new(RwLock::new(AsyncCache::new(CONFIG.allowlist_refresh, user_getter as UserGetter)));
+ match CONFIG.allowlist_mode.as_str() {
"open" => {
- Whitelist::Open{default_cache, whitelist_cache}
+ Allowlist::Open{default_cache, allowlist_cache}
},
"exclusive" => {
- if CONFIG.whitelist.is_empty() {
- panic!("Exclusive mode set with empty whitelist, cannot serve any requests!");
+ if CONFIG.allowlist.is_empty() {
+ panic!("Exclusive mode set with empty allowlist, cannot serve any requests!");
}
- Whitelist::Exclusive{cache: whitelist_cache}
+ Allowlist::Exclusive{cache: allowlist_cache}
},
m => {
- panic!("Bad whitelist mode: `{m}`");
+ panic!("Bad allowlist mode: `{m}`");
}
}
});
pub async fn get_userinfo(user: &String) -> (Result<Arc<(User, Track, TrackStub)>, (StatusCode, &'static str)>, Duration) {
- match LazyLock::force(&WHITELIST) {
- Whitelist::Open{default_cache, whitelist_cache} => {
- if CONFIG.whitelist.contains(user) {
- (whitelist_cache.write().await.get_owned(user).await, CONFIG.whitelist_refresh)
+ match LazyLock::force(&ALLOWLIST) {
+ Allowlist::Open{default_cache, allowlist_cache} => {
+ if CONFIG.allowlist.contains(user) {
+ (allowlist_cache.write().await.get_owned(user).await, CONFIG.allowlist_refresh)
}
else {
(default_cache.write().await.get_owned(user).await, CONFIG.default_refresh)
}
},
- Whitelist::Exclusive{cache} => {
- if CONFIG.whitelist.contains(user) {
- (cache.write().await.get_owned(user).await, CONFIG.whitelist_refresh)
+ Allowlist::Exclusive{cache} => {
+ if CONFIG.allowlist.contains(user) {
+ (cache.write().await.get_owned(user).await, CONFIG.allowlist_refresh)
}
- else { (Err((StatusCode::FORBIDDEN, "User not in whitelist!")), CONFIG.default_refresh) }
+ else { (Err((StatusCode::FORBIDDEN, "User not in allowlist!")), CONFIG.default_refresh) }
}
}
}