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

Represents RADIUS Generic Client instance

Implementations§

source§

impl Client

source

pub fn with_dictionary(dictionary: Dictionary) -> Client

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

To be called first when creating RADIUS Client instance

source

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

Required

Sets hostname to which client would attempt to send RADIUS packets

source

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

Required

Sets secret which is used to encode/decode RADIUS packet

source

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

Required/Optional

Sets remote port, that responsible for specific RADIUS Message Type

source

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

Optional

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

source

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

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 secret(&self) -> &str

Returns secret

source

pub fn retries(&self) -> u16

Returns retries

source

pub fn timeout(&self) -> u16

Returns timeout

source

pub fn create_packet(&self, code: TypeCode) -> RadiusPacket

Creates RADIUS packet with any TypeCode without attributes

You would need to set attributes manually via set_attributes() function

source

pub fn create_auth_packet(&self) -> RadiusPacket

Creates RADIUS Access Request packet

You would need to set attributes manually via set_attributes() function

source

pub fn create_acct_packet(&self) -> RadiusPacket

Creates RADIUS Accounting Request packet without attributes

You would need to set attributes manually via set_attributes() function

source

pub fn create_coa_packet(&self) -> RadiusPacket

Creates RADIUS CoA Request packet without attributes

You would need to set attributes manually via set_attributes() function

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

§Examples
use radius_rust::client::client::Client;
use radius_rust::protocol::dictionary::Dictionary;
use radius_rust::protocol::radius_packet::TypeCode;

fn main() {
    let dictionary = Dictionary::from_file("./dict_examples/integration_dict").unwrap();
    let client     = Client::with_dictionary(dictionary)
       .set_server(String::from("127.0.0.1"))
       .set_secret(String::from("secret"))
       .set_retries(1)
       .set_timeout(2);

    client.create_attribute_by_name("User-Name", String::from("testing").into_bytes());
}
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

§Examples
use radius_rust::client::client::Client;
use radius_rust::protocol::dictionary::Dictionary;
use radius_rust::protocol::radius_packet::TypeCode;

fn main() {
    let dictionary = Dictionary::from_file("./dict_examples/integration_dict").unwrap();
    let client     = Client::with_dictionary(dictionary)
       .set_server(String::from("127.0.0.1"))
       .set_secret(String::from("secret"))
       .set_retries(1)
       .set_timeout(2);

    client.create_attribute_by_id(1, String::from("testing").into_bytes());
}
source

pub fn generate_message_hash(&self, packet: &mut RadiusPacket) -> Vec<u8>

👎Deprecated since 0.4.1: This function may work incorrectly, please use radius_packet’s generate_message_authenticator instead

Generates HMAC-MD5 hash for Message-Authenticator attribute

Note 1: this function assumes that RadiusAttribute Message-Authenticator already exists in RadiusPacket Note 2: this function only works correctly when Message-Authenticator is set to exactly [0;16] Note 3: this function would be removed in 0.5.0

source

pub fn radius_attr_original_string_value( &self, attribute: &RadiusAttribute ) -> Result<String, RadiusError>

Gets the original value as a String

If the RadiusAttribute respresents dictionary attribute of type: string, ipaddr, ipv6addr or ipv6prefix

source

pub fn radius_attr_original_integer_value( &self, attribute: &RadiusAttribute ) -> Result<u32, RadiusError>

Gets the original value as an Integer

If the RadiusAttribute respresents dictionary attribute of type: integer or date

source

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

Initialises RadiusPacket from bytes

source

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

Verifies that reply packet’s ID and authenticator are a match

source

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

Verifies that reply packet’s Message-Authenticator attribute is valid

source

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

Verifies that reply packet’s attributes have valid values

Trait Implementations§

source§

impl Debug for Client

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Client

§

impl RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl UnwindSafe for Client

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