aboutsummaryrefslogtreecommitdiffstats
path: root/src/cache
diff options
context:
space:
mode:
authoralyx <alyx@aleteoryx.me>2024-04-03 11:57:23 -0400
committeralyx <alyx@aleteoryx.me>2024-04-03 11:57:23 -0400
commit5a97731c6996847e335daf1fe9a5d265540de3d1 (patch)
tree04b5221411c76e637dd75ee22723b3deb7cd066f /src/cache
parentd69f7fc08c491817358d944ab8177152d3afea19 (diff)
downloadlfm_embed-5a97731c6996847e335daf1fe9a5d265540de3d1.tar.gz
lfm_embed-5a97731c6996847e335daf1fe9a5d265540de3d1.tar.bz2
lfm_embed-5a97731c6996847e335daf1fe9a5d265540de3d1.zip
whitelist -> allowlist
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) }
}
}
}