Fix launcher verification session check and socket IP resolution

This commit is contained in:
SCOPEDD committed 2026-09-29 02:03:08 -04:00
1 parent 522e3a5717
commit c7aa563dac
6 files changed
+185 -29

No files matched your search

+26 -9
View File
@@ -9,23 +9,40 @@ use std::time::Duration;
pub struct Recorder {
http: reqwest::Client,
panel: String,
token: String,
token: Option<String>,
username: Option<String>,
}
pub fn capture(state: &AppState) -> Option<Recorder> {
Some(Recorder { http: state.http.clone(), panel: state.panel_url()?, token: accounts::panel_token(state)? })
let panel = state.panel_url()?;
let accounts = state.accounts.read().unwrap();
let active = accounts.active()?;
let token = accounts::panel_token(state);
Some(Recorder {
http: state.http.clone(),
panel,
token,
username: Some(active.username.clone()),
})
}
impl Recorder {
pub async fn send(&self, kind: &str, instance: &str) -> anyhow::Result<()> {
self.http
let mut req = self
.http
.post(format!("{}/api/v1/launcher/events", self.panel))
.bearer_auth(&self.token)
.timeout(Duration::from_secs(5))
.json(&LaunchEvent { kind: kind.into(), instance_id: instance.into(), username: None })
.send()
.await?
.error_for_status()?;
.timeout(Duration::from_secs(5));
if let Some(token) = &self.token {
req = req.bearer_auth(token);
}
req.json(&LaunchEvent {
kind: kind.into(),
instance_id: instance.into(),
username: self.username.clone(),
})
.send()
.await?
.error_for_status()?;
Ok(())
}