pub struct Dictionary {
pub attributes: HashMap<u32, RadiusAttributeDef>,
pub vendors: HashMap<String, u32>,
}Fields§
§attributes: HashMap<u32, RadiusAttributeDef>§vendors: HashMap<String, u32>Implementations§
Source§impl Dictionary
impl Dictionary
Sourcepub fn load_from_file<P: AsRef<Path>>(path: P) -> Result<Self, String>
pub fn load_from_file<P: AsRef<Path>>(path: P) -> Result<Self, String>
Examples found in repository?
examples/server.rs (line 8)
7async fn main() -> Result<(), Box<dyn std::error::Error>> {
8 let dict = Arc::new(Dictionary::load_from_file("dictionaries/dictionary")?);
9 let secret = "test123";
10
11 serve("0.0.0.0:1812", dict, secret, |packet| {
12 println!("🔍 Incoming ID {} from {:?}", packet.identifier, packet.username());
13
14 if let Some(username) = packet.username() {
15 if username.trim() == "ec:30:b3:6d:24:6a" {
16 Ok(packet.reply_accept(vec![
17 RadiusAttribute::session_timeout(3600),
18 RadiusAttribute::reply_message("Welcome, admin."),
19 ]))
20 } else {
21 Ok(packet.reply_reject("User not allowed"))
22 }
23 } else {
24 Ok(packet.reply_reject("Missing username"))
25 }
26 }).await
27}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Dictionary
impl RefUnwindSafe for Dictionary
impl Send for Dictionary
impl Sync for Dictionary
impl Unpin for Dictionary
impl UnwindSafe for Dictionary
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more