Add server

This commit is contained in:
moznion
2020-11-23 01:37:05 +09:00
parent 3ffb8b75be
commit 6164f7b597
10 changed files with 457 additions and 5 deletions
+5 -2
View File
@@ -1,5 +1,4 @@
use std::convert::TryInto;
use std::io::Write;
use rand::Rng;
@@ -30,6 +29,10 @@ impl Packet {
}
}
pub(crate) fn get_identifier(&self) -> u8 {
self.identifier
}
pub fn parse(bs: &Vec<u8>, secret: &Vec<u8>) -> Result<Self, String> {
if bs.len() < 20 {
return Err("radius packet doesn't have enough length of bytes; that has to be at least 20 bytes".to_owned());
@@ -129,7 +132,7 @@ impl Packet {
].concat()).to_vec().eq(&response[4..20].to_vec())
}
pub fn is_authentic_request(request: Vec<u8>, secret: Vec<u8>) -> bool {
pub fn is_authentic_request(request: &Vec<u8>, secret: &Vec<u8>) -> bool {
if request.len() < 20 || secret.len() == 0 {
return false;
}