add option for serving jwt info

This commit is contained in:
Robin Appelman 2026-11-04 00:57:16 +01:00
commit c04a04ea29
Signed by: robin
SSH key fingerprint: SHA256:kifqgrqnut7q1YUIrI0AdMNC23qiKAS/T9uGFmIYvbE
8 changed files with 256 additions and 22 deletions

View file

@ -6,19 +6,19 @@ mod jwt;
use crate::config::{Config, FeedConfig, HeaderVal};
use crate::error::{FetchError, FetchFeedError, HubError, ParseFeedError, TriggerError};
use crate::fetcher::{next_fetch, CacheHeaders, FetchPlan, FetchResponse};
use crate::jwt::generate_token;
use crate::fetcher::{CacheHeaders, FetchPlan, FetchResponse, next_fetch};
use crate::jwt::{generate_token, serve_well_known};
use main_error::MainResult;
use std::collections::hash_map::DefaultHasher;
use std::collections::HashMap;
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
use std::str::FromStr;
use std::sync::atomic::{AtomicBool, Ordering};
use std::thread::sleep;
use std::thread::{sleep, spawn};
use std::time::{Duration, Instant};
use tracing::{debug, error, info, instrument, warn};
use ureq::http::header::{HeaderValue, USER_AGENT};
use ureq::http::Response;
use ureq::http::header::{HeaderValue, USER_AGENT};
use ureq::{Agent, Body};
const FETCHER_USER_AGENT: &str = concat!(
@ -47,6 +47,20 @@ fn main() -> MainResult {
let config = Config::from_file(&file)?;
if let Some(jwt_config) = config.jwt.clone() {
if let Some(listen) = jwt_config.listen.clone() {
spawn(|| {
let rt = tokio::runtime::Builder::new_current_thread()
.enable_io()
.build()
.expect("Setup tokio");
if let Err(e) = rt.block_on(serve_well_known(jwt_config, listen)) {
eprintln!("{e:#}");
}
});
}
}
info!("Running rss trigger for {} feeds", config.feed.len());
ctrlc::set_handler(|| RUNNING.store(false, Ordering::SeqCst))?;