diff --git a/.idea/palm.iml b/.idea/palm.iml index c254557..ef83226 100644 --- a/.idea/palm.iml +++ b/.idea/palm.iml @@ -2,7 +2,7 @@ - + diff --git a/Cargo.lock b/Cargo.lock index 934734b..c4170d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -149,6 +149,15 @@ version = "0.2.140" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" +[[package]] +name = "libpalm" +version = "0.1.0" +dependencies = [ + "prost", + "prost-build", + "prost-types", +] + [[package]] name = "linux-raw-sys" version = "0.1.4" @@ -176,15 +185,6 @@ version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" -[[package]] -name = "palm" -version = "0.1.0" -dependencies = [ - "prost", - "prost-build", - "prost-types", -] - [[package]] name = "petgraph" version = "0.6.3" diff --git a/Cargo.toml b/Cargo.toml index 23ffcd1..59cc85b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,14 +1,4 @@ -[package] -name = "palm" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -prost = "0.11.8" -# Only necessary if using Protobuf well-known types: -prost-types = "0.11.8" - -[build-dependencies] -prost-build = { version = "0.11.8" } \ No newline at end of file +[workspace] +members = [ + "libpalm" +] \ No newline at end of file diff --git a/build.rs b/build.rs deleted file mode 100644 index c2715ad..0000000 --- a/build.rs +++ /dev/null @@ -1,5 +0,0 @@ -fn main() { - prost_build::compile_protos(&[ - "palmdef/palm.proto" - ], &["palmdef/"]).unwrap(); -} \ No newline at end of file diff --git a/libpalm/Cargo.toml b/libpalm/Cargo.toml new file mode 100644 index 0000000..6b84d93 --- /dev/null +++ b/libpalm/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "libpalm" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +prost = "0.11.8" +# Only necessary if using Protobuf well-known types: +prost-types = "0.11.8" + +[build-dependencies] +prost-build = { version = "0.11.8" } \ No newline at end of file diff --git a/libpalm/build.rs b/libpalm/build.rs new file mode 100644 index 0000000..fa52f5c --- /dev/null +++ b/libpalm/build.rs @@ -0,0 +1,5 @@ +fn main() { + prost_build::compile_protos(&[ + format!("{}/../palmdef/palm.proto", env!("CARGO_MANIFEST_DIR")) + ], &[format!("{}/../palmdef/", env!("CARGO_MANIFEST_DIR"))]).unwrap(); +} \ No newline at end of file diff --git a/libpalm/src/lib.rs b/libpalm/src/lib.rs new file mode 100644 index 0000000..2b31f11 --- /dev/null +++ b/libpalm/src/lib.rs @@ -0,0 +1,67 @@ +//! # libpalm +//! A Rust crate to simplify the parsing operations for the Palm general-purpose relaying protocol. +//! Palm is used to build **srt** (Simple Relayed Traffic) - a set of utilities written around `libpalm` that simplify the process +//! of communicating through Palm. +//! +//! Palm is pure-rust with 100% safe code. It is left up to the user to provide the `Writer` that `libpalm` writes packets to, as that is +//! outside the scope of `libpalm`. `libpalm` is just a serialization library for creating the required incantation of bytes to send arbitrary data +//! over a Palm bytestream. +//! +//! Want to learn more about the Palm protocol? Check out `palmdef`! Inside `libpalm`'s repository, you can find a set of +//! Protocol Buffers schemas, which contain the documentation for the entire Palm protocol. +//! +//! Want to use Palm, but don't feel like writing any code? Check out **srt**! Inside `libpalm`'s repository, you can find **srt** +//! which is a general-purpose libpalm wrapper to create or connect to relays. + +#![forbid(unsafe_code)] +#![warn(clippy::pedantic)] +#![warn(clippy::nursery)] +#![deny(clippy::unwrap_used)] +#![deny(clippy::expect_used)] +#![deny(missing_docs)] +#![deny(clippy::missing_errors_doc)] +#![deny(clippy::missing_panics_doc)] +#![deny(clippy::missing_safety_doc)] +#![allow(clippy::must_use_candidate)] +#![allow(clippy::too_many_lines)] +#![allow(clippy::module_name_repetitions)] + +/// Contains the Rust code generated from the protobuf definitions. This code is mostly undocumented, as it is regenerated constantly. +/// Proceed with caution. +pub mod palmdef { + include!(concat!(env!("OUT_DIR"), "/palmdef.rs")); + + #[allow(missing_docs)] + #[allow(clippy::doc_markdown)] + #[allow(clippy::missing_const_for_fn)] + #[allow(clippy::use_self)] + pub mod encrypted_reflection { + include!(concat!(env!("OUT_DIR"), "/palmdef.encrypted_reflection.rs")); + } + + #[allow(missing_docs)] + #[allow(clippy::doc_markdown)] + #[allow(clippy::missing_const_for_fn)] + #[allow(clippy::use_self)] + pub mod encrypted_tunnel { + include!(concat!(env!("OUT_DIR"), "/palmdef.encrypted_tunnel.rs")); + } + + #[allow(missing_docs)] + #[allow(clippy::doc_markdown)] + #[allow(clippy::missing_const_for_fn)] + #[allow(clippy::use_self)] + pub mod unencrypted_reflection { + include!(concat!(env!("OUT_DIR"), "/palmdef.unencrypted_reflection.rs")); + } + + #[allow(missing_docs)] + #[allow(clippy::doc_markdown)] + #[allow(clippy::missing_const_for_fn)] + #[allow(clippy::use_self)] + pub mod unencrypted_tunnel { + include!(concat!(env!("OUT_DIR"), "/palmdef.unencrypted_tunnel.rs")); + } +} + +pub mod uri; \ No newline at end of file diff --git a/libpalm/src/uri.rs b/libpalm/src/uri.rs new file mode 100644 index 0000000..f280aad --- /dev/null +++ b/libpalm/src/uri.rs @@ -0,0 +1,9 @@ +//! A module for parsing Palm relay URIs. +//! +//! They use the following format: +//! `palm[+]://:/` +//! +//! - `transport` is optional. If not provided, it will be set to `tcp`. It represents which method will be used to encapsulate traffic. Please note that ensuring both the relay and the client support this is outside the scope of libpalm - it only loads the transport libs. +//! - `ip/domain` is required, and is the IP or DNS domain the relay is reachable at. +//! - `port` is required, and is the TCP port the relay is listening on. +//! - `hex-encoded public key` is required, and is the hex-encoded static public key of the relay. \ No newline at end of file diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index 1e92e33..0000000 --- a/src/main.rs +++ /dev/null @@ -1,23 +0,0 @@ -pub mod palmdef { - include!(concat!(env!("OUT_DIR"), "/palmdef.rs")); - - pub mod encrypted_reflection { - include!(concat!(env!("OUT_DIR"), "/palmdef.encrypted_reflection.rs")); - } - - pub mod encrypted_tunnel { - include!(concat!(env!("OUT_DIR"), "/palmdef.encrypted_tunnel.rs")); - } - - pub mod unencrypted_reflection { - include!(concat!(env!("OUT_DIR"), "/palmdef.unencrypted_reflection.rs")); - } - - pub mod unencrypted_tunnel { - include!(concat!(env!("OUT_DIR"), "/palmdef.unencrypted_tunnel.rs")); - } -} - -fn main() { - println!("Hello, world!"); -}