mirror of
https://github.com/ZeusWPI/ZNS.git
synced 2024-11-22 05:41:11 +01:00
Fix bugs
This commit is contained in:
parent
5d59f1bd97
commit
e99ba5c97e
3 changed files with 18 additions and 12 deletions
|
@ -1,4 +1,5 @@
|
||||||
use diesel::PgConnection;
|
use diesel::PgConnection;
|
||||||
|
use reqwest::header::ACCEPT;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::Config,
|
config::Config,
|
||||||
|
@ -34,16 +35,20 @@ pub async fn authenticate(
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn validate_ssh(username: &String, sig: &Sig) -> Result<bool, reqwest::Error> {
|
async fn validate_ssh(username: &String, sig: &Sig) -> Result<bool, reqwest::Error> {
|
||||||
Ok(reqwest::get(format!(
|
let client = reqwest::Client::new();
|
||||||
"{}/users/keys/{}",
|
Ok(client
|
||||||
Config::get().zauth_url,
|
.get(format!(
|
||||||
username
|
"{}/users/{}/keys",
|
||||||
))
|
Config::get().zauth_url,
|
||||||
.await?
|
username
|
||||||
.json::<Vec<String>>()
|
))
|
||||||
.await?
|
.header(ACCEPT, "application/json")
|
||||||
.iter()
|
.send()
|
||||||
.any(|key| sig.verify_ssh(&key).is_ok_and(|b| b)))
|
.await?
|
||||||
|
.json::<Vec<String>>()
|
||||||
|
.await?
|
||||||
|
.iter()
|
||||||
|
.any(|key| sig.verify_ssh(&key).is_ok_and(|b| b)))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn validate_dnskey(
|
async fn validate_dnskey(
|
||||||
|
|
|
@ -71,7 +71,9 @@ impl<'a> Reader<'a> {
|
||||||
message: String::from("Seeking into the future is not allowed!!"),
|
message: String::from("Seeking into the future is not allowed!!"),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Ok(Reader::new(&self.buffer[position..self.position]))
|
let mut reader = Reader::new(&self.buffer[0..self.position]);
|
||||||
|
reader.position = position;
|
||||||
|
Ok(reader)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,6 @@ async fn get_response(bytes: &[u8]) -> Message {
|
||||||
response
|
response
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("{:#?}", message);
|
|
||||||
eprintln!("{}", e.to_string());
|
eprintln!("{}", e.to_string());
|
||||||
message.set_response(e.rcode());
|
message.set_response(e.rcode());
|
||||||
message
|
message
|
||||||
|
|
Loading…
Reference in a new issue