Struct radius_rust::server::Server[][src]

pub struct Server { /* fields omitted */ }

Represents RADIUS server instance

Implementations

impl Server[src]

pub fn initialise_server(
    auth_port: u16,
    acct_port: u16,
    coa_port: u16,
    dictionary: Dictionary,
    server: String,
    secret: String,
    retries: u16,
    timeout: u16
) -> Result<Server, RadiusError>
[src]

Initialises RADIUS server instance

pub fn add_allowed_hosts(&mut self, host_addr: String)[src]

Adds client host address to allowed hosts list

pub fn get_allowed_hosts(&self) -> &[String][src]

Returns allowed hosts list

pub fn add_request_handler(
    &mut self,
    handler_type: RadiusMsgType,
    handler_function: fn(server: &Server, request: &mut [u8]) -> Result<Vec<u8>, RadiusError>
) -> Result<(), RadiusError>
[src]

Adds packet handller function to server instance

Note: server can only have 3 handlers, 1 for each Radius message/packet type

For example refer to examples/simple_radius_server.rs

pub fn get_request_handlers(
    &self
) -> &HashMap<RadiusMsgType, fn(server: &Server, request: &mut [u8]) -> Result<Vec<u8>, RadiusError>>
[src]

Returns HashMap with packet handler functions

pub fn create_attribute_by_name(
    &self,
    attribute_name: &str,
    value: Vec<u8>
) -> Result<RadiusAttribute, RadiusError>
[src]

Creates RADIUS packet attribute by name, that is defined in dictionary file

For example, see Client (these function are same)

pub fn create_attribute_by_id(
    &self,
    attribute_id: u8,
    value: Vec<u8>
) -> Result<RadiusAttribute, RadiusError>
[src]

Creates RADIUS packet attribute by id, that is defined in dictionary file

For example, see Client (these function are same)

pub fn create_reply_packet(
    &self,
    reply_code: TypeCode,
    attributes: Vec<RadiusAttribute>,
    request: &mut [u8]
) -> RadiusPacket
[src]

Creates reply RADIUS packet

Similar to Client create_packet(), however also sets correct packet ID and authenticator

pub fn run_server(&mut self) -> Result<(), RadiusError>[src]

Main function, that starts and keeps server running

For example see examples/simple_radius_server.rs

pub fn verify_request(&self, request: &[u8]) -> Result<(), RadiusError>[src]

Verifies incoming RADIUS packet:

Server would try to build RadiusPacket from raw bytes, and if it succeeds then packet is valid, otherwise would return RadiusError

pub fn verify_request_attributes(
    &self,
    request: &[u8]
) -> Result<(), RadiusError>
[src]

Verifies RadiusAttributes's values of incoming RADIUS packet:

Server would try to build RadiusPacket from raw bytes, and then it would try to restore RadiusAttribute original value from bytes, based on the attribute data type (see SupportedAttributeTypes)

pub fn initialise_packet_from_bytes(
    &self,
    request: &[u8]
) -> Result<RadiusPacket, RadiusError>
[src]

Initialises RadiusPacket from bytes

Unlike validate_request() returns new RadiusPacket (if valid), so user can get data out of it

Trait Implementations

impl Debug for Server[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,