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_embedded() -> Result<Self, String>
pub fn load_embedded() -> Result<Self, String>
Examples found in repository?
examples/server.rs (line 11)
9async fn main() -> Result<(), Box<dyn std::error::Error>> {
10 // Load the RADIUS dictionary
11 let dict = Arc::new(Dictionary::load_embedded()?);
12 let secret = "test123";
13
14 // Start the RADIUS server using an async handler
15 serve_async("0.0.0.0:1812", dict, secret, move |packet| async move {
16 println!("🔍 Incoming ID {} from {:?}", packet.identifier, packet.username());
17
18 if let Some(username) = packet.username() {
19 if username.trim() == "ec:30:b3:6d:24:6a" {
20 Ok(packet.reply_accept(vec![
21 RadiusAttribute::session_timeout(3600),
22 RadiusAttribute::reply_message("Welcome, admin."),
23 ]))
24 } else {
25 Ok(packet.reply_reject("User not allowed"))
26 }
27 } else {
28 Ok(packet.reply_reject("Missing username"))
29 }
30 })
31 .await
32}pub fn parse_from_str(content: &str) -> Result<Self, String>
pub fn load_from_file<P: AsRef<Path>>(path: P) -> Result<Self, String>
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