mirror of
https://github.com/cubixle/radius-rs.git
synced 2026-04-24 22:34:42 +01:00
Restructure the project tree
This commit is contained in:
26
Cargo.toml
26
Cargo.toml
@@ -1,19 +1,11 @@
|
||||
[package]
|
||||
name = "radius-rs"
|
||||
version = "0.1.0"
|
||||
authors = ["moznion <moznion@gmail.com>"]
|
||||
edition = "2018"
|
||||
license-file = "LICENSE"
|
||||
[workspace]
|
||||
|
||||
[dependencies]
|
||||
md5 = "0.7.0"
|
||||
chrono = "0.4"
|
||||
rand = "0.7.3"
|
||||
num_enum = "0.5.1"
|
||||
tokio = { version = "0.3.4", features = ["full"] }
|
||||
log = "0.4.11"
|
||||
thiserror = "1.0"
|
||||
async-trait = "0.1.42"
|
||||
members = [
|
||||
"radius",
|
||||
"radius-server",
|
||||
"radius-client",
|
||||
|
||||
[dev-dependencies]
|
||||
env_logger = "0.8.2"
|
||||
# Internal
|
||||
"code-generator",
|
||||
"examples",
|
||||
]
|
||||
|
||||
2
Makefile
2
Makefile
@@ -8,4 +8,4 @@ lint:
|
||||
cargo clippy
|
||||
|
||||
gen:
|
||||
bash ./scripts/generate_code.sh
|
||||
bash ./scripts/generate-code.sh
|
||||
|
||||
11
code-generator/Cargo.toml
Normal file
11
code-generator/Cargo.toml
Normal file
@@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "code-generator"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
license-file = "../LICENSE"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
regex = "1"
|
||||
getopts = "0.2"
|
||||
Inflector = "0.11"
|
||||
2
code_generator/.gitignore
vendored
2
code_generator/.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
/target
|
||||
|
||||
83
code_generator/Cargo.lock
generated
83
code_generator/Cargo.lock
generated
@@ -1,83 +0,0 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "Inflector"
|
||||
version = "0.11.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "code_generator"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"Inflector",
|
||||
"getopts",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getopts"
|
||||
version = "0.2.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5"
|
||||
dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
"thread_local",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189"
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
|
||||
@@ -1,13 +0,0 @@
|
||||
[package]
|
||||
name = "code_generator"
|
||||
version = "0.1.0"
|
||||
authors = ["moznion <moznion@gmail.com>"]
|
||||
edition = "2018"
|
||||
license-file = "LICENSE"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
regex = "1"
|
||||
getopts = "0.2"
|
||||
Inflector = "0.11"
|
||||
@@ -1,9 +0,0 @@
|
||||
test:
|
||||
cargo test
|
||||
|
||||
build:
|
||||
cargo build
|
||||
|
||||
lint:
|
||||
cargo clippy
|
||||
|
||||
25
examples/Cargo.toml
Normal file
25
examples/Cargo.toml
Normal file
@@ -0,0 +1,25 @@
|
||||
[package]
|
||||
name = "examples"
|
||||
version = "0.1.0"
|
||||
publish = false
|
||||
edition = "2018"
|
||||
license-file = "../LICENSE"
|
||||
repository = "https://github.com/moznion/radius-rs"
|
||||
|
||||
[dev-dependencies]
|
||||
radius = { version = "0.1.0", path = "../radius" }
|
||||
radius-client = { version = "0.1.0", path = "../radius-client" }
|
||||
radius-server = { version = "0.1.0", path = "../radius-server" }
|
||||
log = "0.4.11"
|
||||
env_logger = "0.8.2"
|
||||
tokio = { version = "0.3.4", features = ["signal", "net"] }
|
||||
async-trait = "0.1.42"
|
||||
|
||||
[[example]]
|
||||
name = "server"
|
||||
path = "server.rs"
|
||||
|
||||
[[example]]
|
||||
name = "client"
|
||||
path = "client.rs"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#[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 radius::code::Code;
|
||||
use radius::packet::Packet;
|
||||
use radius::rfc2865;
|
||||
use radius_client::client::Client;
|
||||
use std::net::SocketAddr;
|
||||
|
||||
#[tokio::main]
|
||||
|
||||
@@ -8,12 +8,12 @@ use async_trait::async_trait;
|
||||
use tokio::net::UdpSocket;
|
||||
use tokio::signal;
|
||||
|
||||
use radius_rs::code::Code;
|
||||
use radius_rs::request::Request;
|
||||
use radius_rs::request_handler::RequestHandler;
|
||||
use radius_rs::rfc2865;
|
||||
use radius_rs::secret_provider::{SecretProvider, SecretProviderError};
|
||||
use radius_rs::server::Server;
|
||||
use radius::code::Code;
|
||||
use radius::request::Request;
|
||||
use radius::rfc2865;
|
||||
use radius_server::request_handler::RequestHandler;
|
||||
use radius_server::secret_provider::{SecretProvider, SecretProviderError};
|
||||
use radius_server::server::Server;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
|
||||
13
radius-client/Cargo.toml
Normal file
13
radius-client/Cargo.toml
Normal file
@@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "radius-client"
|
||||
version = "0.1.0"
|
||||
authors = ["moznion <moznion@gmail.com>"]
|
||||
edition = "2018"
|
||||
license-file = "../LICENSE"
|
||||
repository = "https://github.com/moznion/radius-rs"
|
||||
keywords = ["radius", "client"]
|
||||
|
||||
[dependencies]
|
||||
radius = { path = "../radius" }
|
||||
tokio = { version = "0.3.4", features = ["net"] }
|
||||
thiserror = "1.0"
|
||||
@@ -7,7 +7,7 @@ use crate::client::ClientError::{
|
||||
FailedConnection, FailedParsingUDPResponse, FailedRadiusPacketEncoding,
|
||||
FailedReceivingResponse, FailedSendingPacket, FailedUdpSocketBinding,
|
||||
};
|
||||
use crate::packet::Packet;
|
||||
use radius::packet::Packet;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum ClientError {
|
||||
1
radius-client/src/lib.rs
Normal file
1
radius-client/src/lib.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod client;
|
||||
15
radius-server/Cargo.toml
Normal file
15
radius-server/Cargo.toml
Normal file
@@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "radius-server"
|
||||
version = "0.1.0"
|
||||
authors = ["moznion <moznion@gmail.com>"]
|
||||
edition = "2018"
|
||||
license-file = "../LICENSE"
|
||||
repository = "https://github.com/moznion/radius-rs"
|
||||
keywords = ["radius", "client"]
|
||||
|
||||
[dependencies]
|
||||
radius = { path = "../radius" }
|
||||
tokio = { version = "0.3.4", features = ["full"] }
|
||||
log = "0.4.11"
|
||||
thiserror = "1.0"
|
||||
async-trait = "0.1.42"
|
||||
6
radius-server/src/lib.rs
Normal file
6
radius-server/src/lib.rs
Normal file
@@ -0,0 +1,6 @@
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
pub mod request_handler;
|
||||
pub mod secret_provider;
|
||||
pub mod server;
|
||||
@@ -1,7 +1,7 @@
|
||||
use async_trait::async_trait;
|
||||
use tokio::net::UdpSocket;
|
||||
|
||||
use crate::request::Request;
|
||||
use radius::request::Request;
|
||||
|
||||
#[async_trait]
|
||||
pub trait RequestHandler<T, E>: 'static + Sync + Send {
|
||||
@@ -7,10 +7,10 @@ use std::sync::{Arc, RwLock};
|
||||
|
||||
use tokio::net::UdpSocket;
|
||||
|
||||
use crate::packet::Packet;
|
||||
use crate::request::Request;
|
||||
use crate::request_handler::RequestHandler;
|
||||
use crate::secret_provider::SecretProvider;
|
||||
use radius::packet::Packet;
|
||||
use radius::request::Request;
|
||||
use std::fmt::Debug;
|
||||
|
||||
pub struct Server {}
|
||||
15
radius/Cargo.toml
Normal file
15
radius/Cargo.toml
Normal file
@@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "radius"
|
||||
version = "0.1.0"
|
||||
authors = ["moznion <moznion@gmail.com>"]
|
||||
edition = "2018"
|
||||
license-file = "../LICENSE"
|
||||
repository = "https://github.com/moznion/radius-rs"
|
||||
keywords = ["radius"]
|
||||
|
||||
[dependencies]
|
||||
md5 = "0.7.0"
|
||||
chrono = "0.4"
|
||||
rand = "0.7.3"
|
||||
num_enum = "0.5.1"
|
||||
thiserror = "1.0"
|
||||
@@ -1,15 +1,8 @@
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
pub(crate) mod attributes;
|
||||
pub mod avp;
|
||||
pub mod client;
|
||||
pub mod code;
|
||||
pub mod packet;
|
||||
pub mod request;
|
||||
pub mod request_handler;
|
||||
pub mod rfc2865;
|
||||
pub mod rfc2866;
|
||||
pub mod rfc2867;
|
||||
pub mod secret_provider;
|
||||
pub mod server;
|
||||
@@ -9,7 +9,7 @@ pub struct Request {
|
||||
}
|
||||
|
||||
impl Request {
|
||||
pub(crate) fn new(local_addr: SocketAddr, remote_addr: SocketAddr, packet: Packet) -> Self {
|
||||
pub fn new(local_addr: SocketAddr, remote_addr: SocketAddr, packet: Packet) -> Self {
|
||||
Self {
|
||||
local_addr,
|
||||
remote_addr,
|
||||
0
radius/src/rfc2868.rs
Normal file
0
radius/src/rfc2868.rs
Normal file
@@ -4,7 +4,7 @@ set -eu
|
||||
|
||||
REPO_ROOT="$(cd ./"$(git rev-parse --show-cdup)" || exit; pwd)"
|
||||
DICTS_DIR="${REPO_ROOT}/dicts"
|
||||
SRC_DIR="${REPO_ROOT}/src"
|
||||
SRC_DIR="${REPO_ROOT}/radius/src"
|
||||
|
||||
DICTS=$(ls "$DICTS_DIR")
|
||||
|
||||
@@ -17,7 +17,7 @@ done
|
||||
# shellcheck disable=SC2068
|
||||
for DICT in ${DICTS[@]}; do
|
||||
DICT_NAME="${DICT##*.}"
|
||||
(cd "${REPO_ROOT}/code_generator"; cargo run "${DICTS_DIR}/dictionary.${DICT_NAME}" "${SRC_DIR}/${DICT_NAME}.rs")
|
||||
cargo run --bin code-generator "${DICTS_DIR}/dictionary.${DICT_NAME}" "${SRC_DIR}/${DICT_NAME}.rs"
|
||||
done
|
||||
|
||||
cargo fix --allow-dirty --allow-staged
|
||||
Reference in New Issue
Block a user