pub struct Server { /* private fields */ }
Expand description

Represents RADIUS Generic Server instance

Implementations§

source§

impl Server

source

pub fn with_dictionary(dictionary: Dictionary) -> Server

Initialise Server instance with dictionary (other fields would be set to default values)

To be called first when creating RADIUS Server instance

source

pub fn set_server(self, server: String) -> Server

Required

Sets hostname to which server would bind

source

pub fn set_secret(self, secret: String) -> Server

Required

Sets secret which is used to encode/decode RADIUS packet

source

pub fn set_allowed_hosts(self, allowed_hosts: Vec<String>) -> Server

Required

Sets allowed hosts, from where Server would be allowed to accept RADIUS requests

source

pub fn set_port(self, msg_type: RadiusMsgType, port: u16) -> Server

Required/Optional

Sets remote port, that responsible for specific RADIUS Message Type

source

pub fn set_retries(self, retries: u16) -> Server

Optional

Sets socket retries, otherwise you would have a default value of 1

source

pub fn set_timeout(self, timeout: u16) -> Server

Optional

Sets socket timeout, otherwise you would have a default value of 2

source

pub fn port(&self, code: &TypeCode) -> Option<u16>

Returns port of RADIUS server, that receives given type of RADIUS message/packet

source

pub fn server(&self) -> &str

Returns hostname/FQDN of RADIUS Server

source

pub fn retries(&self) -> u16

Returns retries

source

pub fn timeout(&self) -> u16

Returns timeout

source

pub fn allowed_hosts(&self) -> &[String]

Returns allowed hosts list

source

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

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

For example, see Client

source

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

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

For example, see Client

source

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

Creates reply RADIUS packet

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

source

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

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

source

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

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

source

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

Initialises RadiusPacket from bytes

Unlike verify_request, on success this function would return RadiusPacket

source

pub fn host_allowed(&self, remote_host: &SocketAddr) -> bool

Checks if host from where Server received RADIUS request is allowed host, meaning RADIUS Server can process such request

Trait Implementations§

source§

impl Debug for Server

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Server

§

impl RefUnwindSafe for Server

§

impl Send for Server

§

impl Sync for Server

§

impl Unpin for Server

§

impl UnwindSafe for Server

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

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

source§

fn vzip(self) -> V