commit 23d8c57102b1991076dc71f0712f3e7eb5d0391f Author: Horhik Date: Mon Jan 11 18:49:54 2021 +0200 add lots of 'client to node' request types diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..96ef6c0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..526ab87 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "FCPv2" +version = "0.0.1" +authors = ["Horhik "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..027ffaf --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,9 @@ +mod types; + +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + assert_eq!(2 + 2, 4); + } +} diff --git a/src/types/client/mod.rs b/src/types/client/mod.rs new file mode 100644 index 0000000..fe642b3 --- /dev/null +++ b/src/types/client/mod.rs @@ -0,0 +1,2 @@ +mod types; +pub use types::*; diff --git a/src/types/client/types.rs b/src/types/client/types.rs new file mode 100644 index 0000000..0534659 --- /dev/null +++ b/src/types/client/types.rs @@ -0,0 +1,198 @@ +use std::ffi::OsStr; +use std::net::Ipv4Addr; +use std::path::Path; +pub enum NodeIdentifier { + Name(String), + Identity(String), + Addr(Ipv4Addr), +} + +pub enum TrustLevel { + Low, + Normal, + High, +} + +pub enum VisibilityLevel { + No, + NameOnly, + Yes, +} +pub enum VerbosityPut { + SimpleProgress, + ExpectedHashes, + PutFetchable, + StartedCompressionANDFinishedCompression, +} +pub enum VerbosityGet { + SimpleProgress, + SendingToNetwork, + CompatibilityMode, + ExpectedHashes, + ExpectedMIME, + ExpectedDataLength, +} + +pub enum Retry { + None, + Forever, + Num(i32), +} + +pub enum Persistence { + Connection, + Reboot, + Forever, +} + +pub enum UploadForm { + Direct, + Disk, + Redirect, +} + +pub enum ReturnType { + Direct, + None, + Disk, +} + +pub enum NumOrNone { + None, + Num(u32), +} + +pub enum Priority { + A, // 0 + B, // 1 + C, // 2 + D, // 3 + E, // 4 + F, // 5 + G, // 6 +} + +pub struct ClientHello { + message_name: String, + name: String, + expected_version: f32, +} +// TODO not implemented ListPeer +pub struct ListPeer { + message_name: String, + node_identifier: NodeIdentifier, + with_volatile: Option, + with_metadata: Option, +} +pub struct ListPeers { + message_name: String, + with_volatile: Option, + with_metadata: Option, +} + +pub struct ListPeerNotes { + message_name: String, + node_identifier: NodeIdentifier, +} +pub struct AddPeer { + message_name: String, + trust: TrustLevel, + visibility: VisibilityLevel, + file: Option, + url: Option, + raw: Option, +} +pub struct ModifyPeer { + message_name: String, + node_identifier: NodeIdentifier, + allow_local_addresses: Option, + is_disabled: Option, + is_listen_only: Option, + is_burst_only: Option, + ignore_source_port: Option, +} +pub struct ModifyPeerNote { + message_name: String, + node_text: String, + peer_note_type: i32, +} +pub struct RemovePeer { + message_name: String, + node_identifier: NodeIdentifier, +} + +pub struct GetNode { + message_name: String, + identifier: Option, + give_opennet_ref: Option, + with_private: Option, + with_volatile: Option, +} + +pub struct GenerateSSK { + message_name: String, + identifier: Option, +} + +pub struct ClientPut { + message_name: String, + uri: String, //TODO create key type + content_type: Option, + identifier: Option, + verbosity: Option, + max_retries: Option, + priority_class: Option, + get_chk_only: Option, + global: Option, + dont_compress: Option, + codecs: Option>, + client_token: Option, + persistence: Option>, + early_encode: Option, + upload_ffrom: Option, + data_length: u64, + filename: String, + target_uri: Option, // cloning uri if does not exists + file_hash: Option, //TODO SHAA256 type + binary_blob: Option, + fork_on_cacheable: Option, + extra_inserts_single_block: Option, + extra_inserts_splitfile_header_block: Option, + compatibility_mode: Option, //TODO create enum??? + local_request_only: Option, + override_splitfile_crypto_key: Option, //key in hex + real_time_flag: Option, + metadata_threshold: Option, + data: Option, // Data fromdirect +} + +pub struct ClientGet { + message_name: String, + ignore_ds: Option, + ds_only: Option, + uri: String, //FIXME freenet uri type + identifier: String, + verbosity: Option, + max_size: Option, + max_retries: Option, + priority_class: Option, + persistence: Option, + client_token: Option, + global: Option, + return_type: Option, + binary_blob: Option, + filter_data: Option, + allowed_mime_types: Option>, + filename: Option>, + temp_filename: Option>, + real_time_flag: Option, + initial_metadata_data_length: u64, +} + +pub struct Disconnect { + message_name: String, +} + +pub struct Shutdown { + message_name: String, +} diff --git a/src/types/mod.rs b/src/types/mod.rs new file mode 100644 index 0000000..f0b2737 --- /dev/null +++ b/src/types/mod.rs @@ -0,0 +1,4 @@ +mod client; +mod node; + +pub use client::*; diff --git a/src/types/node/mod.rs b/src/types/node/mod.rs new file mode 100644 index 0000000..e69de29