mirror of
https://github.com/cubixle/radius-rs.git
synced 2026-07-30 13:33:12 +01:00
📝 doc
This commit is contained in:
@@ -3,7 +3,15 @@ use tokio::net::UdpSocket;
|
||||
|
||||
use radius::request::Request;
|
||||
|
||||
/// RequestHandler is a handler for the received RADIUS request.
|
||||
#[async_trait]
|
||||
pub trait RequestHandler<T, E>: 'static + Sync + Send {
|
||||
/// This method has to implement the core feature of the server application what you need.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * conn - This connection is associated with the remote requester. In the most situations,
|
||||
/// you have to send a response through this connection object.
|
||||
/// * request - This is a request object that comes from the remote requester.
|
||||
async fn handle_radius_request(&self, conn: &UdpSocket, request: &Request) -> Result<T, E>;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@ pub enum SecretProviderError {
|
||||
FailedFetching(String),
|
||||
}
|
||||
|
||||
/// SecretProvider is a provider for secret value.
|
||||
pub trait SecretProvider: 'static + Sync + Send {
|
||||
/// This method has to implement the generator of the secret value to verify the request of
|
||||
/// `Accounting-Response`, `Accounting-Response` and `CoA-Request`.
|
||||
fn fetch_secret(&self, remote_addr: SocketAddr) -> Result<Vec<u8>, SecretProviderError>;
|
||||
}
|
||||
|
||||
@@ -13,9 +13,11 @@ use radius::packet::Packet;
|
||||
use radius::request::Request;
|
||||
use std::fmt::Debug;
|
||||
|
||||
/// A basic implementation of the RADIUS server.
|
||||
pub struct Server {}
|
||||
|
||||
impl Server {
|
||||
/// Start listening a UDP socket to process the RAIDUS requests.
|
||||
pub async fn run<X, E: Debug, T: RequestHandler<X, E>, U: SecretProvider>(
|
||||
host: &str,
|
||||
port: u16,
|
||||
|
||||
Reference in New Issue
Block a user