Parse URL query better
This commit is contained in:
parent
8b812da751
commit
c9f0243956
2 changed files with 16 additions and 14 deletions
16
src/main.rs
16
src/main.rs
|
|
@ -1,4 +1,4 @@
|
|||
use std::{env::args, thread, time::Duration};
|
||||
use std::{collections::HashMap, env::args, thread, time::Duration};
|
||||
|
||||
use der::{Any, Decode, asn1::SetOfVec, oid::ObjectIdentifier};
|
||||
use openssl::{bn::BigNumContext, ec::PointConversionForm, pkey::PKey};
|
||||
|
|
@ -94,6 +94,7 @@ pub trait Card {
|
|||
}
|
||||
|
||||
async fn run_auth(
|
||||
host: String,
|
||||
session_id: String,
|
||||
ctg_pipe: async_channel::Sender<crate::pipe::CardToGUI>,
|
||||
gtc_pipe: async_channel::Receiver<crate::pipe::GUIToCard>,
|
||||
|
|
@ -105,7 +106,7 @@ async fn run_auth(
|
|||
service: String::from("UI Test"),
|
||||
}
|
||||
} else {
|
||||
let Some(ctx) = digid_api::wid_init(&session_id).await else {
|
||||
let Some(ctx) = digid_api::wid_init(&host, &session_id).await else {
|
||||
ctg_pipe.send(pipe::CardToGUI::ProcessingMessage { message: "Failed to initialize DigiD session.".to_owned() }).await;
|
||||
return Ok(());
|
||||
};
|
||||
|
|
@ -497,17 +498,10 @@ fn main() {
|
|||
let (gtc_pipe_s, gtc_pipe_r) = async_channel::unbounded();
|
||||
|
||||
let s = args().nth(1).unwrap();
|
||||
let session_id = s
|
||||
.split('&')
|
||||
.next()
|
||||
.unwrap()
|
||||
.split('=')
|
||||
.last()
|
||||
.unwrap()
|
||||
.to_owned();
|
||||
let mut parsed_url = url::form_urlencoded::parse(s.split(':').last().unwrap().as_bytes()).into_owned().collect::<HashMap<String, String>>();
|
||||
|
||||
let rt = Runtime::new().unwrap();
|
||||
rt.spawn(async { run_auth(session_id, ctg_pipe_s, gtc_pipe_r).await.unwrap() });
|
||||
rt.spawn(async move { run_auth(parsed_url.remove("host").unwrap_or_else(|| String::from("test")), parsed_url.remove("app_session_id").unwrap_or_else(|| String::from("test")), ctg_pipe_s, gtc_pipe_r).await.unwrap() });
|
||||
|
||||
gui::run_gui(ctg_pipe_r, gtc_pipe_s);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue