mirror of
https://github.com/cubixle/radius-rs.git
synced 2026-07-29 14:43:11 +01:00
Add server
This commit is contained in:
+5
-2
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user