Add example implementation for server and client

This commit is contained in:
moznion
2020-11-28 04:08:26 +09:00
parent bf412991b0
commit 89f36717e5
2 changed files with 101 additions and 0 deletions

21
examples/client.rs Normal file
View File

@@ -0,0 +1,21 @@
#[macro_use]
extern crate log;
use radius_rs::client::Client;
use radius_rs::code::Code;
use radius_rs::packet::Packet;
use radius_rs::rfc2865;
use std::net::SocketAddr;
#[tokio::main]
async fn main() {
env_logger::init();
let remote_addr: SocketAddr = "127.0.0.1:1812".parse().unwrap();
let mut req_packet = Packet::new(Code::AccessRequest, &b"secret".to_vec());
rfc2865::add_user_name(&mut req_packet, "admin");
rfc2865::add_user_password(&mut req_packet, b"p@ssw0rd").unwrap(); // TODO
let res = Client::send_packet(&remote_addr, &req_packet).await;
info!("response: {:?}", res);
}