diff --git a/Cargo.lock b/Cargo.lock index 8c90196..e420127 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2203,6 +2203,48 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rust-nex" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-trait", + "bytemuck", + "chacha20", + "chrono", + "ctrlc", + "dotenv", + "futures", + "hex", + "hmac", + "json", + "log", + "macros", + "md-5", + "once_cell", + "paste", + "prost", + "rand 0.8.5", + "rc4", + "reqwest", + "rocket", + "rsa", + "rustls", + "rustls-pki-types", + "rustls-webpki", + "serde", + "sha2", + "simplelog", + "thiserror", + "tokio", + "tokio-rustls", + "tokio-stream", + "tonic", + "tonic-build", + "typenum", + "v_byte_macros", +] + [[package]] name = "rustc-demangle" version = "0.1.25" @@ -2483,48 +2525,6 @@ dependencies = [ "der", ] -[[package]] -name = "splatoon-server-rust" -version = "0.1.0" -dependencies = [ - "anyhow", - "async-trait", - "bytemuck", - "chacha20", - "chrono", - "ctrlc", - "dotenv", - "futures", - "hex", - "hmac", - "json", - "log", - "macros", - "md-5", - "once_cell", - "paste", - "prost", - "rand 0.8.5", - "rc4", - "reqwest", - "rocket", - "rsa", - "rustls", - "rustls-pki-types", - "rustls-webpki", - "serde", - "sha2", - "simplelog", - "thiserror", - "tokio", - "tokio-rustls", - "tokio-stream", - "tonic", - "tonic-build", - "typenum", - "v_byte_macros", -] - [[package]] name = "stable-pattern" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 64ffb4b..83c5de6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "splatoon-server-rust" +name = "rust-nex" version = "0.1.0" edition = "2021" diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 122a0a4..835ea6b 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -189,7 +189,7 @@ pub fn rmc_serialize(input: TokenStream) -> TokenStream { quote! { #pre_inner - splatoon_server_rust::rmc::structures::rmc_struct::write_struct(writer, #version, |mut writer|{ + rust_nex::rmc::structures::rmc_struct::write_struct(writer, #version, |mut writer|{ #serialize_base_content })?; @@ -218,7 +218,7 @@ pub fn rmc_serialize(input: TokenStream) -> TokenStream { quote! { #pre_inner - Ok(splatoon_server_rust::rmc::structures::rmc_struct::read_struct(reader, #version, move |mut reader|{ + Ok(rust_nex::rmc::structures::rmc_struct::read_struct(reader, #version, move |mut reader|{ #deserialize_base_content })?) } @@ -229,14 +229,14 @@ pub fn rmc_serialize(input: TokenStream) -> TokenStream { let ident = derive_input.ident; let tokens = quote! { - impl splatoon_server_rust::rmc::structures::RmcSerialize for #ident{ - fn serialize(&self, writer: &mut dyn ::std::io::Write) -> splatoon_server_rust::rmc::structures::Result<()>{ + impl rust_nex::rmc::structures::RmcSerialize for #ident{ + fn serialize(&self, writer: &mut dyn ::std::io::Write) -> rust_nex::rmc::structures::Result<()>{ #serialize_base_content } - fn deserialize(reader: &mut dyn ::std::io::Read) -> splatoon_server_rust::rmc::structures::Result{ + fn deserialize(reader: &mut dyn ::std::io::Read) -> rust_nex::rmc::structures::Result{ #deserialize_base_content } } @@ -367,8 +367,8 @@ pub fn rmc_struct(attr: TokenStream, input: TokenStream) -> TokenStream{ } - impl splatoon_server_rust::rmc::protocols::RmcCallable for #struct_name{ - async fn rmc_call(&self, remote_response_connection: &splatoon_server_rust::util::SendingBufferConnection, protocol_id: u16, method_id: u32, call_id: u32, rest: Vec){ + impl rust_nex::rmc::protocols::RmcCallable for #struct_name{ + async fn rmc_call(&self, remote_response_connection: &rust_nex::util::SendingBufferConnection, protocol_id: u16, method_id: u32, call_id: u32, rest: Vec){ ::rmc_call(self, remote_response_connection, protocol_id, method_id, call_id, rest).await; } } diff --git a/macros/src/protos.rs b/macros/src/protos.rs index d7d84c1..8efedb4 100644 --- a/macros/src/protos.rs +++ b/macros/src/protos.rs @@ -73,7 +73,7 @@ impl RmcProtocolData{ for (param_name, param_type) in parameters{ quote!{ let Ok(#param_name) = - <#param_type as splatoon_server_rust::rmc::structures::RmcSerialize>::deserialize( + <#param_type as rust_nex::rmc::structures::RmcSerialize>::deserialize( &mut cursor ) else }.to_tokens(tokens); @@ -84,7 +84,7 @@ impl RmcProtocolData{ quote! { { log::error!(#error_msg); - return Err(splatoon_server_rust::rmc::response::ErrorCode::Core_InvalidArgument); + return Err(rust_nex::rmc::response::ErrorCode::Core_InvalidArgument); }; }.to_tokens(tokens) } else { @@ -116,7 +116,7 @@ impl RmcProtocolData{ quote!{ let retval = retval?; let mut vec = Vec::new(); - splatoon_server_rust::rmc::structures::RmcSerialize::serialize(&retval, &mut vec).ok(); + rust_nex::rmc::structures::RmcSerialize::serialize(&retval, &mut vec).ok(); Ok(vec) }.to_tokens(tokens); } @@ -126,7 +126,7 @@ impl RmcProtocolData{ quote!{ async fn rmc_call_proto( &self, - remote_response_connection: &splatoon_server_rust::util::SendingBufferConnection, + remote_response_connection: &rust_nex::util::SendingBufferConnection, method_id: u32, call_id: u32, data: Vec, @@ -165,7 +165,7 @@ impl RmcProtocolData{ }.to_tokens(tokens); if self.has_returns { quote! { - Err(splatoon_server_rust::rmc::response::ErrorCode::Core_NotImplemented) + Err(rust_nex::rmc::response::ErrorCode::Core_NotImplemented) }.to_tokens(tokens); } }); @@ -176,7 +176,7 @@ impl RmcProtocolData{ if *has_returns{ quote!{ - splatoon_server_rust::rmc::response::send_result( + rust_nex::rmc::response::send_result( remote_response_connection, ret, #id, @@ -209,7 +209,7 @@ impl RmcProtocolData{ // boilerplate tokens which all raw traits need quote!{ #[doc(hidden)] - pub trait #remote_name: splatoon_server_rust::rmc::protocols::HasRmcConnection + pub trait #remote_name: rust_nex::rmc::protocols::HasRmcConnection }.to_tokens(tokens); // generate the body of the raw protocol trait @@ -247,12 +247,12 @@ impl RmcProtocolData{ for (param_name, param_type) in parameters{ quote!{ - splatoon_server_rust::result::ResultExtension::display_err_or_some( - <#param_type as splatoon_server_rust::rmc::structures::RmcSerialize>::serialize( + rust_nex::result::ResultExtension::display_err_or_some( + <#param_type as rust_nex::rmc::structures::RmcSerialize>::serialize( &#param_name, &mut cursor ) - ).ok_or(splatoon_server_rust::rmc::response::ErrorCode::Core_InvalidArgument) + ).ok_or(rust_nex::rmc::response::ErrorCode::Core_InvalidArgument) }.to_tokens(tokens); if self.has_returns { quote! { @@ -268,25 +268,25 @@ impl RmcProtocolData{ quote!{ let call_id = rand::random(); - let message = splatoon_server_rust::rmc::message::RMCMessage{ + let message = rust_nex::rmc::message::RMCMessage{ call_id, method_id: #method_id, protocol_id: #proto_id, rest_of_data: send_data }; - let rmc_conn = ::get_connection(self); + let rmc_conn = ::get_connection(self); }.to_tokens(tokens); if *has_returns{ quote!{ - splatoon_server_rust::result::ResultExtension::display_err_or_some( + rust_nex::result::ResultExtension::display_err_or_some( rmc_conn.make_raw_call(&message).await - ).ok_or(splatoon_server_rust::rmc::response::ErrorCode::Core_Exception) + ).ok_or(rust_nex::rmc::response::ErrorCode::Core_Exception) }.to_tokens(tokens); } else { quote!{ - splatoon_server_rust::result::ResultExtension::display_err_or_some( + rust_nex::result::ResultExtension::display_err_or_some( rmc_conn.make_raw_call_no_response(&message).await ); }.to_tokens(tokens); diff --git a/src/executables/backend_server.rs b/src/executables/backend_server.rs index 71da3e2..4dd5d71 100644 --- a/src/executables/backend_server.rs +++ b/src/executables/backend_server.rs @@ -9,8 +9,8 @@ use rustls::{ SignatureScheme, }; use rustls_pki_types::PrivateKeyDer; -use splatoon_server_rust::common::setup; -use splatoon_server_rust::reggie::{get_configured_tls_acceptor, TestStruct, ROOT_TRUST_ANCHOR, SELF_CERT, SELF_KEY}; +use rust_nex::common::setup; +use rust_nex::reggie::{get_configured_tls_acceptor, TestStruct, ROOT_TRUST_ANCHOR, SELF_CERT, SELF_KEY}; use std::borrow::ToOwned; use std::fs; use std::io::Cursor; @@ -21,10 +21,10 @@ use tokio::io::AsyncReadExt; use tokio::net::{TcpListener, TcpSocket}; use tokio::task; use tokio_rustls::TlsAcceptor; -use splatoon_server_rust::define_rmc_proto; -use splatoon_server_rust::rmc::protocols::new_rmc_gateway_connection; -use splatoon_server_rust::rmc::response::ErrorCode; -use splatoon_server_rust::rmc::structures::RmcSerialize; +use rust_nex::define_rmc_proto; +use rust_nex::rmc::protocols::new_rmc_gateway_connection; +use rust_nex::rmc::response::ErrorCode; +use rust_nex::rmc::structures::RmcSerialize; diff --git a/src/executables/proxy_insecure.rs b/src/executables/proxy_insecure.rs index b147163..17454f2 100644 --- a/src/executables/proxy_insecure.rs +++ b/src/executables/proxy_insecure.rs @@ -17,13 +17,13 @@ use rsa::signature::{RandomizedSigner, SignatureEncoding}; use sha2::Sha256; use tokio::net::TcpSocket; use tokio::task; -use splatoon_server_rust::common::setup; -use splatoon_server_rust::prudp::packet::VirtualPort; -use splatoon_server_rust::prudp::router::Router; -use splatoon_server_rust::prudp::unsecure::Unsecure; -use splatoon_server_rust::reggie::{establish_tls_connection_to, UnitPacketRead, UnitPacketWrite}; -use splatoon_server_rust::rmc::structures::RmcSerialize; -use splatoon_server_rust::rnex_proxy_common::ConnectionInitData; +use rust_nex::common::setup; +use rust_nex::prudp::packet::VirtualPort; +use rust_nex::prudp::router::Router; +use rust_nex::prudp::unsecure::Unsecure; +use rust_nex::reggie::{establish_tls_connection_to, UnitPacketRead, UnitPacketWrite}; +use rust_nex::rmc::structures::RmcSerialize; +use rust_nex::rnex_proxy_common::ConnectionInitData; static OWN_IP_PRIVATE: Lazy = Lazy::new(|| { env::var("SERVER_IP") diff --git a/src/lib.rs b/src/lib.rs index f16450f..775b940 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -extern crate self as splatoon_server_rust; +extern crate self as rust_nex; pub mod endianness; pub mod prudp; diff --git a/src/main.rs b/src/main.rs index 68539bf..af9a3bd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,7 @@ //! also the first and only current usage of rnex, expect this and rnex to be split into seperate //! repos soon. -extern crate self as splatoon_server_rust; +extern crate self as rust_nex; use crate::nex::account::Account; use crate::nex::auth_handler::{AuthHandler, RemoteAuthClientProtocol}; diff --git a/src/rmc/protocols/mod.rs b/src/rmc/protocols/mod.rs index 9333937..6c9b1c3 100644 --- a/src/rmc/protocols/mod.rs +++ b/src/rmc/protocols/mod.rs @@ -157,7 +157,7 @@ macro_rules! define_rmc_proto { }) => { paste::paste!{ pub trait []: std::any::Any $( + [] + $protocol)* { - async fn rmc_call(&self, remote_response_connection: &splatoon_server_rust::util::SendingBufferConnection, protocol_id: u16, method_id: u32, call_id: u32, rest: Vec){ + async fn rmc_call(&self, remote_response_connection: &rust_nex::util::SendingBufferConnection, protocol_id: u16, method_id: u32, call_id: u32, rest: Vec){ match protocol_id{ $( []::PROTOCOL_ID => ]>::rmc_call_proto(self, remote_response_connection, method_id, call_id, rest).await, @@ -167,16 +167,16 @@ macro_rules! define_rmc_proto { } } - pub struct [](splatoon_server_rust::rmc::protocols::RmcConnection); + pub struct [](rust_nex::rmc::protocols::RmcConnection); - impl splatoon_server_rust::rmc::protocols::RemoteInstantiatable for []{ - fn new(conn: splatoon_server_rust::rmc::protocols::RmcConnection) -> Self{ + impl rust_nex::rmc::protocols::RemoteInstantiatable for []{ + fn new(conn: rust_nex::rmc::protocols::RmcConnection) -> Self{ Self(conn) } } - impl splatoon_server_rust::rmc::protocols::HasRmcConnection for []{ - fn get_connection(&self) -> &splatoon_server_rust::rmc::protocols::RmcConnection{ + impl rust_nex::rmc::protocols::HasRmcConnection for []{ + fn get_connection(&self) -> &rust_nex::rmc::protocols::RmcConnection{ &self.0 } } diff --git a/src/util.rs b/src/util.rs index 03664d8..7556fc2 100644 --- a/src/util.rs +++ b/src/util.rs @@ -5,7 +5,7 @@ use log::error; use tokio::io::{AsyncRead, AsyncWrite}; use tokio::sync::mpsc::{channel, Receiver, Sender}; use tokio::task; -use splatoon_server_rust::reggie::{UnitPacketRead, UnitPacketWrite}; +use rust_nex::reggie::{UnitPacketRead, UnitPacketWrite}; #[derive(Clone)] pub struct SendingBufferConnection(Sender>);