mirror of
https://github.com/ZeusWPI/ZNS.git
synced 2024-11-24 14:11:10 +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 reqwest::header::ACCEPT;
|
||||
|
||||
use crate::{
|
||||
config::Config,
|
||||
|
@ -34,16 +35,20 @@ pub async fn authenticate(
|
|||
}
|
||||
|
||||
async fn validate_ssh(username: &String, sig: &Sig) -> Result<bool, reqwest::Error> {
|
||||
Ok(reqwest::get(format!(
|
||||
"{}/users/keys/{}",
|
||||
Config::get().zauth_url,
|
||||
username
|
||||
))
|
||||
.await?
|
||||
.json::<Vec<String>>()
|
||||
.await?
|
||||
.iter()
|
||||
.any(|key| sig.verify_ssh(&key).is_ok_and(|b| b)))
|
||||
let client = reqwest::Client::new();
|
||||
Ok(client
|
||||
.get(format!(
|
||||
"{}/users/{}/keys",
|
||||
Config::get().zauth_url,
|
||||
username
|
||||
))
|
||||
.header(ACCEPT, "application/json")
|
||||
.send()
|
||||
.await?
|
||||
.json::<Vec<String>>()
|
||||
.await?
|
||||
.iter()
|
||||
.any(|key| sig.verify_ssh(&key).is_ok_and(|b| b)))
|
||||
}
|
||||
|
||||
async fn validate_dnskey(
|
||||
|
|
|
@ -71,7 +71,9 @@ impl<'a> Reader<'a> {
|
|||
message: String::from("Seeking into the future is not allowed!!"),
|
||||
})
|
||||
} 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
|
||||
}
|
||||
Err(e) => {
|
||||
println!("{:#?}", message);
|
||||
eprintln!("{}", e.to_string());
|
||||
message.set_response(e.rcode());
|
||||
message
|
||||
|
|
Loading…
Reference in a new issue