Struct radius_rust::server::server::Server
source · pub struct Server { /* private fields */ }
Expand description
Represents RADIUS Generic Server instance
Implementations§
source§impl Server
impl Server
sourcepub fn with_dictionary(dictionary: Dictionary) -> Server
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
sourcepub fn set_server(self, server: String) -> Server
pub fn set_server(self, server: String) -> Server
Required
Sets hostname to which server would bind
sourcepub fn set_secret(self, secret: String) -> Server
pub fn set_secret(self, secret: String) -> Server
Required
Sets secret which is used to encode/decode RADIUS packet
sourcepub fn set_allowed_hosts(self, allowed_hosts: Vec<String>) -> Server
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
sourcepub fn set_port(self, msg_type: RadiusMsgType, port: u16) -> Server
pub fn set_port(self, msg_type: RadiusMsgType, port: u16) -> Server
Required/Optional
Sets remote port, that responsible for specific RADIUS Message Type
sourcepub fn set_retries(self, retries: u16) -> Server
pub fn set_retries(self, retries: u16) -> Server
Optional
Sets socket retries, otherwise you would have a default value of 1
sourcepub fn set_timeout(self, timeout: u16) -> Server
pub fn set_timeout(self, timeout: u16) -> Server
Optional
Sets socket timeout, otherwise you would have a default value of 2
sourcepub fn port(&self, code: &TypeCode) -> Option<u16>
pub fn port(&self, code: &TypeCode) -> Option<u16>
Returns port of RADIUS server, that receives given type of RADIUS message/packet
sourcepub fn allowed_hosts(&self) -> &[String]
pub fn allowed_hosts(&self) -> &[String]
Returns allowed hosts list
sourcepub fn create_attribute_by_name(
&self,
attribute_name: &str,
value: Vec<u8>
) -> Result<RadiusAttribute, RadiusError>
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
sourcepub fn create_attribute_by_id(
&self,
attribute_id: u8,
value: Vec<u8>
) -> Result<RadiusAttribute, RadiusError>
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
sourcepub fn create_reply_packet(
&self,
reply_code: TypeCode,
attributes: Vec<RadiusAttribute>,
request: &mut [u8]
) -> RadiusPacket
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
sourcepub fn verify_request(&self, request: &[u8]) -> Result<(), RadiusError>
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
sourcepub fn verify_request_attributes(
&self,
request: &[u8]
) -> Result<(), RadiusError>
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
sourcepub fn initialise_packet_from_bytes(
&self,
request: &[u8]
) -> Result<RadiusPacket, RadiusError>
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
sourcepub fn host_allowed(&self, remote_host: &SocketAddr) -> bool
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