diff --git a/.devcontainer.json b/.devcontainer.json deleted file mode 100644 index ac711b7..0000000 --- a/.devcontainer.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "image": "ci.virintox.com/spfn/rust-nex/dev-container:latest" -} diff --git a/.dockerignore b/.dockerignore index ab0f8c4..13007b0 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,10 +3,8 @@ target .dockerignore Dockerfile CODE_OF_CONDUCT.md -CONTRIBUTING.md README.md .gitignore LICENSE -.devcontainer.json -.ci-scripts/make-edition.sh +.forgejo/workflows/build.sh .forgejo/workflows/build.yml \ No newline at end of file diff --git a/.ci-scripts/make-edition.sh b/.forgejo/workflows/build.sh similarity index 90% rename from .ci-scripts/make-edition.sh rename to .forgejo/workflows/build.sh index 7545040..c5ad945 100755 --- a/.ci-scripts/make-edition.sh +++ b/.forgejo/workflows/build.sh @@ -21,7 +21,7 @@ cp $TARGET_DIR/proxy_secure dist/ cp $TARGET_DIR/rnex-server-backend-auth dist/ cp $TARGET_DIR/rnex-server-backend-secure dist/ -TARGETS=("node-holder" "proxy-secure" "proxy-insecure" "backend-auth" "backend-secure") +TARGETS=("proxy-secure" "proxy-insecure" "backend-auth" "backend-secure") for TARGET in "${TARGETS[@]}"; do $RNEX_CONTAINER_PLATFORM build \ diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 38f18a7..a98dee3 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -62,4 +62,4 @@ jobs: run: | echo "SHORT_SHA=${SHORT_SHA::6}" >> $GITHUB_ENV export CI_COMMIT_SHORT_SHA="${SHORT_SHA::6}" - ./.ci-scripts/make-edition.sh ${{ matrix.edition }} \ No newline at end of file + ./.forgejo/workflows/build.sh ${{ matrix.edition }} \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 7b9a013..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,30 +0,0 @@ -default: - image: quay.io/podman/stable - cache: - key: image-cache - paths: - - /var/lib/containers/storage - - /run/containers/storage - - .local/share/containers/storage - before_script: - - git submodule update --init - - podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - -variables: - DOCKER_TLS_CERTDIR: "/certs" - IMAGE_TAG: "${CI_COMMIT_REF_SLUG}" - -stages: - - build_and_test - -splatoon: - stage: build_and_test - script: ./.ci-scripts/make-edition.sh splatoon - -friends: - stage: build_and_test - script: ./.ci-scripts/make-edition.sh friends - -super-mario-maker: - stage: build_and_test - script: ./.ci-scripts/make-edition.sh super-mario-maker diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 4626a0b..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,89 +0,0 @@ -# How to contribute - -### Content -- [Making Issues](#making-issues) -- [Code Changes](#code-changes) - - [Consistency](#consistency) - - [Quality and Substance](#quality-and-substance) -- [Commits](#commits) - - [Scale and Scope](#scale-and-scope) - - [Messages](#messages) -- [Pull Requests](#pull-requests) -- [Tests](#tests) -- [Licensing](#licensing) - -# Making Issues -Before contributing any code, you should understand how we use issues and how to make them in a way which ensures you will get the response you want. - -Issues are used by all repositories for most interactions. Issues are used for reporting actual issues with the codebase, as well as making feature requests and asking general questions. When making an issue, please use one of the provided issue templates. Using the provided templates keeps things consistent, as well as makes it easier for any of our 3rd party tools to interact with issues. If a template does not exist for what you wish to do, create a feature request for one. Not using an issue template may result in your issue being closed without completion. - -When making code changes, an issue for the changes must be made and marked as approved before making the relevant changes. This ensures that your time is not wasted on changes we are not interested in making. - -When making issues we ask that you be as detailed as possible. Do not make issues with titles like "I had an issue", "Found a bug", etc. The issue title should be an adequate summary of the information found within the issue's contents. When writing the issue body, provide as much detail as possible. Make the issue as long as it needs to be in order to adequately get the information across. We welcome the use of images, videos, etc. as well when applicable. Provide error codes, error messages, timestamps, the actions leading up errors, etc. Relevant links and even code snippets are also asked for when applicable. The more details we have from the start, the less time we spend asking clarifying questions resulting in faster resolutions. If you do not have much information, that is alright as well. We simply ask that you provide us with as much as you can from the start, and have patience as we work things out. - -# Code Changes -As stated in [Making Issues](#making-issues), before making any code changes there must be an open, approved, issue for them. If you can not find an approved issue for the changes you wish to make, please make one before continuing. - -There are 2 main goals when making code contributions: - -1. [Consistency](#consistency) -2. [Quality/Substance](#quality-and-substance) - -## Consistency -Arguably the most important thing about contributions is keeping them consistent with the rest of the codebase/project. With very few exceptions, contributions should be consistent with the existing codebases style, implementations/patterns, tech stack, etc. Doing so will ensure that anyone can jump into any repository and easily navigate about it. If you would like to make changes which go against any current consistency guidelines or implementations (such as changing linter rules, or swapping to a different tool in the stack), we ask that you make an issue specifically for these ideas first so they can be discussed by the core team. - -See each repository for it's style and linting rules, however some higher level guidelines are: - -- NEX (game) servers are written in Rust. -- Game servers which require databases use MySQL. -- All other servers (with few exceptions) are written in TypeScript with the intention of being run on Node. If a server is not written in TypeScript, it needs to be migrated to it. Runtimes besides Node (Bun, Deno, etc.) are not accounted for. If compatibility for another runtime can be added without introducing regressions when running under Node, and without significant refactoring, then support may be added via a pull request. -- Package managers besides npm are not accounted for. If compatibility for another package manager can be added without introducing regressions when running under npm, and without significant refactoring, then support may be added via a pull request. -- TypeScript servers which require databases use MongoDB. -- Given that our stacks are mostly Go and TypeScript, our tools and libraries are also written in Go and TypeScript depending on where they will be used. For desktop applications we typically prefer [Electron](https://electronjs.org/), as it allows us to reuse our existing libraries. - -## Quality and Substance -We do not accept changes for the sake of changes. Changes should solve real problems, not change things for your personal preferences. This does not mean changes need to be *large*, however. A spelling error is a "real problem" and is worth changing, despite being a small change. However changes such as "Changed from `for...of` to `forEach`" will likely be rejected unless some additional problem is being solved with the change. - -This does not mean we do not value the opinions of others, however. If you feel that a change should be made, but does not solve a specific problem (such as a refactoring change), we welcome opening a feature request for these changes. We do not claim to be infallible, and we are open to making stylistic changes to our codebases when they make sense. However changes like these must still be approved, and justified. If the changes do not provide any true substance, they will likely be rejected. - -Requiring changes to be approved and having substance is essential to not wasting the time of both contributors (who may spend time making changes we are not interested in) and our developers (who will have to spend time reviewing changes which ultimately get rejected). - -# Commits -Besides the changes themselves, commits are the most important part of contributions. There are 2 major things to keep in mind for commits: - -1. [Scale/Scope](#scale-and-scope) -2. [Messages](#messages) - -## Scale and Scope -The scale and scope of a commit should be reasonable. Do not commit for every line when making multiple changes, for example. However you should not include many unrelated changes in a single commit. By limiting the scope of the commit we can ensure that if any regressions or new bugs are introduced we can easily revert those changes without the need for major refactors or reimplementations. Limiting the scale of commits also makes review of the changes easier and faster. - -## Messages -Commit messages should adequately explain the changes in the commit. Messages like "Updated file.md" and "spelling error" should not be used. Nonsense messages such as "oops" or "fixed" are especially not allowed. Commit messages should, at minimum, be in the format `type: message` where `type` represents the type or scope of the changes (`feat`, `chore`, `docs`, `fix`, etc.) and `message` is the actual changes. Unless the word is from the codebase and starts with a capital letter (such as an exported Go struct), the `message` should be lowercase. We also recommend using both "subject" and "body" commits. This can be achieved through the git CLI by using multiple `-m`/`--message` flags. For example `git commit -m "short subject" -m "longer description of the changes"`. - -The following are examples of good commit messages: - -- `chore: renamed nnid service to nnas` -- `fix: fixed hang in MutexMap.Has` - -Please refer to [Conventional Commits](https://conventionalcommits.org/) for a detailed guide on how to structure commit messages. Writing good, detailed, commit messages helps ensure that we can refer back to the git history and quickly find where specific changes occurred in the event that they need further review, reverting, etc. - -# Pull Requests -As stated in [Making Issues](#making-issues), before making a pull request there must be an open, approved, issue for the changes being made. If you can not find an approved issue for the changes you wish to make, please make one before continuing. Unless a single update closes multiple issues, each pull request should target a single issue. If you wish to work on multiple issues, please open a pull request for each. This keeps the pull request scope limited and allows for easier discussion of the individual issues and your related changes to them. - -Before making a pull request ensure you have tested all changes and that no regressions have been introduced. - -Pull requests should never be made against the default (`main`/`master`) branch of a repository. The default branch contains the most recent, stable, version of the codebase. All work on the codebase should take place in other branches. Unless otherwise specified, your target branch should typically be the `dev` branch. You may target other feature branches, however, if need be. If a `dev` branch does not exist for the repository you are working on, please submit a feature request for one to be added before continuing. - -A pull request does not necessarily need to *close* an issue. A pull request may be made which implements only a subset of the requirements to close an issue, but does not fully complete the task itself. A pull request should never be *unfinished* code, however. All code must be tested and shippable. A pull request must at minimum bring an issue closer to closing without introducing any new regressions. - -Like everything else, pull requests should be as detailed as possible. Your title should adequately summarize the changes being made, and the body of the pull request should fully explain your changes. We ask that, if applicable, the rationale behind your changes also be noted. For example rather than simply "Changed from `for...of` to `forEach`", if the change was made for a performance reason you should say "Changed from `for...of` to `forEach` due to `forEach` being X times faster in this case" and provide some benchmarks. Adding images, videos, etc. is also welcomed in order to illustrate changes. If the changes being made are directly tied to some form of visual (such as a change to the website, a tools GUI, etc.) then images or videos is ***REQUIRED***. If none are provided, then we may delay review until they are given. Providing visual examples of these changes allow us to quickly assess whether or not we wish to proceed with the changes being made. - -If a pull request requires any database migrations, describe them in detail and leave any migration queries inside of a code block within a `
` tag. This should happen either at the very beginning of the pull request message, or at the very end, but not somewhere in between. Doing so makes it clear at a glance that there are migrations required and makes it easy to find the related queries. - -We ask that you have patience with us as we review your pull request. SPFN only has a single full time developer, all other work is done by volunteers on their own time. Due to the sheer number of issues and pull requests, alongside our other general work and research, it may take us some time to fully review and decide on whether or not to merge your changes. - -# Tests -We do not require 100% code coverage in any tests. We do not currently have strict rules regarding tests, however we may ask that tests be provided for large or complex changes. - -# Licensing -Unless otherwise specified all code is licensed under [GNU AGPLv3](https://choosealicense.com/licenses/agpl-3.0), including that of outside contributions. This license allows users many freedoms to use our code in their own applications, including private and commercial use, while ensuring that all derivatives remain under this same license and keeps the source available, even when used over a network. A repository's license may not be changed by outside contributors unless that change is done with good reason, has been approved by the core development team, and is done with the consent of all relevant contributors. diff --git a/Cargo.lock b/Cargo.lock index deb30a3..3112347 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2160,7 +2160,6 @@ version = "0.1.0" dependencies = [ "hex", "rnex-prudp", - "rnex-reggie-protos", "rnex-rmc", "rnex-server", "rnex-util", @@ -2422,9 +2421,9 @@ dependencies = [ "rand 0.10.2", "rnex-auth-protos", "rnex-prudp", - "rnex-reggie-protos", "rnex-rmc", "rnex-server", + "thiserror", "tokio", "tonic", "tracing", @@ -2581,16 +2580,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "rnex-node-holder" -version = "0.1.0" -dependencies = [ - "rnex-reggie-protos", - "rnex-rmc", - "rnex-server", - "tokio", -] - [[package]] name = "rnex-prudp" version = "0.1.0" @@ -2607,15 +2596,6 @@ dependencies = [ "v-byte-helpers", ] -[[package]] -name = "rnex-reggie-protos" -version = "0.1.0" -dependencies = [ - "ctor", - "rnex-rmc", - "tracing", -] - [[package]] name = "rnex-rk" version = "0.1.0" @@ -2695,16 +2675,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "rnex-server-backend-node-holder" -version = "0.1.0" -dependencies = [ - "rnex-node-holder", - "rnex-reggie-protos", - "rnex-server", - "tokio", -] - [[package]] name = "rnex-server-backend-secure" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index f51de18..1ee5657 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,19 +13,16 @@ members = [ "rnex-protocols/rk-protos", "rnex-protocols/base-protos", "rnex-protocols/auth-protos", - "rnex-protocols/reggie-protos", "rnex-protocols/msg-protos", "rnex-protocols/fpd-protos", "rnex-prudp", "rnex-server", "rnex-server/backend-auth", "rnex-server/backend-secure", - "rnex-server/backend-node-holder", "rnex-server-nex-modules/rnex-mm", "rnex-server-nex-modules/rnex-ds", "rnex-server-nex-modules/rnex-rk", "rnex-server-nex-modules/rnex-fpd", - "rnex-server-nex-modules/rnex-node-holder", "rnex-server-nex-modules/rnex-base", "rnex-server-nex-modules/rnex-msg", "rnex-server-nex-modules/rnex-auth", diff --git a/Dockerfile b/Dockerfile index 34f1517..821ad12 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,10 +5,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libssl3 \ && rm -rf /var/lib/apt/lists/* -FROM base AS node-holder -COPY dist/rnex-server-backend-node-holder /rnex-server-backend-node-holder -ENTRYPOINT ["/rnex-server-backend-node-holder"] - FROM base AS proxy-insecure COPY dist/proxy_insecure /proxy_insecure ENTRYPOINT ["/proxy_insecure"] diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9634fba..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,3 +0,0 @@ -# Security Policy - -Report security vulnerabilities through the security tab on this repo. Only vulnerabilities on the latest commit of any branch will be considered. diff --git a/SUPPORT.md b/SUPPORT.md deleted file mode 100644 index 7cfc89e..0000000 --- a/SUPPORT.md +++ /dev/null @@ -1,3 +0,0 @@ -# Support - -For support, join [our discord](https://discord.gg/splatfestival). diff --git a/check-edition.sh b/check-edition.sh index d41cb81..ac623bb 100755 --- a/check-edition.sh +++ b/check-edition.sh @@ -14,5 +14,5 @@ echo FEATURES: echo $EDITION_FEATURES # RUSTFLAGS="--deny warnings" cargo clippy --workspace --features "$EDITION_FEATURES" -RUSTFLAGS="--deny warnings" cargo check --workspace --features "$EDITION_FEATURES" +cargo check --workspace --features "$EDITION_FEATURES" # echo "edition checks are disabled right now due to being in" diff --git a/flake.lock b/flake.lock deleted file mode 100644 index 7826732..0000000 --- a/flake.lock +++ /dev/null @@ -1,61 +0,0 @@ -{ - "nodes": { - "flake-parts": { - "inputs": { - "nixpkgs-lib": "nixpkgs-lib" - }, - "locked": { - "lastModified": 1767609335, - "narHash": "sha256-feveD98mQpptwrAEggBQKJTYbvwwglSbOv53uCfH9PY=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "250481aafeb741edfe23d29195671c19b36b6dca", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1767640445, - "narHash": "sha256-UWYqmD7JFBEDBHWYcqE6s6c77pWdcU/i+bwD6XxMb8A=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "9f0c42f8bc7151b8e7e5840fb3bd454ad850d8c5", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-lib": { - "locked": { - "lastModified": 1765674936, - "narHash": "sha256-k00uTP4JNfmejrCLJOwdObYC9jHRrr/5M/a/8L2EIdo=", - "owner": "nix-community", - "repo": "nixpkgs.lib", - "rev": "2075416fcb47225d9b68ac469a5c4801a9c4dd85", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nixpkgs.lib", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index 0863018..0000000 --- a/flake.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ - description = "rust nex server"; - - inputs = { - nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; - flake-parts.url = "github:hercules-ci/flake-parts"; - }; - - outputs = - inputs@{ - self, - nixpkgs, - flake-parts, - }: - flake-parts.lib.mkFlake { inherit inputs; } { - systems = [ - "x86_64-linux" - "aarch64-linux" - "x86_64-darwin" - "aarch64-darwin" - ]; - perSystem = - { pkgs, lib, ... }: - rec { - devShells.default = import ./shell.nix { inherit pkgs; }; - }; - }; -} diff --git a/proxy-common/Cargo.toml b/proxy-common/Cargo.toml index 32ad8de..1226bf0 100644 --- a/proxy-common/Cargo.toml +++ b/proxy-common/Cargo.toml @@ -11,7 +11,6 @@ thiserror = "2.0.12" rnex-prudp = { path = "../rnex-prudp" } rnex-server = { path = "../rnex-server" } rnex-util = { path = "../rnex-util" } -rnex-reggie-protos = { path = "../rnex-protocols/reggie-protos" } rnex-rmc = { path = "../rnex-rmc" } tokio = { version = "1.47.0", features = ["full"] } hex = "0.4.3" diff --git a/proxy-common/src/lib.rs b/proxy-common/src/lib.rs index 258834c..07d610d 100644 --- a/proxy-common/src/lib.rs +++ b/proxy-common/src/lib.rs @@ -1,8 +1,7 @@ use rnex_prudp::{socket_addr::PRUDPSockAddr, virtual_port::VirtualPort}; -use rnex_reggie_protos::reggie::{EdgeNodeHolderConnectOption, RemoteEdgeNodeHolder}; use rnex_rmc::{ RemoteDisconnectable, RmcCallable, RmcConnection, RmcPureRemoteObject, - new_rmc_gateway_connection, serialization::RmcSerialize, + serialization::RmcSerialize, }; use rnex_server::{ConnectionInitData, try_get_ip}; use rnex_util::{PID, SendingBufferConnection, SplittableBufferConnection, UnitPacketWrite}; @@ -13,7 +12,7 @@ use std::{ ops::Deref, panic, str::FromStr, - sync::{Arc, LazyLock}, + sync::LazyLock, }; use thiserror::Error; use tokio::net::TcpStream; @@ -120,6 +119,7 @@ impl Deref for OnR impl OnRemoteDrop { + #[allow(dead_code)] pub fn new(conn: RmcConnection, drop_func: C) -> Self { Self(T::new(conn), Some(drop_func)) } @@ -152,34 +152,6 @@ impl Drop for OnRe } } -pub async fn setup_edge_node_connection( - param: &ProxyStartupParam, - shutdown_callback: impl FnOnce() + Send + Sync + 'static, -) { - let conn = tokio::net::TcpStream::connect(¶m.edge_node_holder) - .await - .unwrap(); - - let conn: SplittableBufferConnection = conn.into(); - - conn.send( - EdgeNodeHolderConnectOption::Register(param.self_public) - .to_data() - .unwrap(), - ) - .await; - - println!("{:?}", param.self_public); - //leave the inner object floating so that it gets destroyed once we disconnect - new_rmc_gateway_connection(conn, async move |r| { - Arc::new(OnRemoteDrop::::new( - r, - shutdown_callback, - )) - }) - .await; -} - pub async fn new_backend_connection( param: &ProxyStartupParam, addr: PRUDPSockAddr, diff --git a/proxy/src/secure.rs b/proxy/src/secure.rs index 7901177..ca08d69 100644 --- a/proxy/src/secure.rs +++ b/proxy/src/secure.rs @@ -1,5 +1,4 @@ -use proxy::edge_node_dc_callback; -use proxy_common::{ProxyStartupParam, setup_edge_node_connection}; +use proxy_common::ProxyStartupParam; use rnex_server::with_setup; #[tokio::main] @@ -8,7 +7,7 @@ async fn main() { let param = ProxyStartupParam::new(proxy_common::ProxyType::Secure) .expect("unable to get startup parameters"); - setup_edge_node_connection(¶m, edge_node_dc_callback).await; + // setup_edge_node_connection(¶m, edge_node_dc_callback).await; proxy::start_secure(param).await; Ok(()) }) diff --git a/prudpv1/src/prudp/socket.rs b/prudpv1/src/prudp/socket.rs index e498718..77d4e72 100644 --- a/prudpv1/src/prudp/socket.rs +++ b/prudpv1/src/prudp/socket.rs @@ -360,8 +360,6 @@ impl InternalSocket { async fn connection_thread( connection: Weak>, ) { - //todo: handle stuff like resending packets if they arent acknowledged in here - while let Some(conn) = connection.upgrade() { let mut conn = conn.lock().await; diff --git a/renovate.json b/renovate.json index ddd61d7..5b0a6b2 100644 --- a/renovate.json +++ b/renovate.json @@ -2,5 +2,6 @@ "$schema": "https://docs.renovatebot.com/renovate-schema.json", "git-submodules": { "enabled": true - } + }, + "reviewers": ["redbinder0526", "bloxerhd018"] } \ No newline at end of file diff --git a/rnex-protocols/reggie-protos/Cargo.toml b/rnex-protocols/reggie-protos/Cargo.toml deleted file mode 100644 index 39cd547..0000000 --- a/rnex-protocols/reggie-protos/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -[package] -name = "rnex-reggie-protos" -version = "0.1.0" -edition = "2024" - -[dependencies] -ctor = "1.0.8" -rnex-rmc = { path = "../../rnex-rmc" } -tracing = "0.1.44" - -[features] -splatoon = ["v3-5-0"] -datastore = ["database-support", "v3-8-15"] -database-support = [] -nx = [] -third-notif-param = [] -v3-3-2 = [] -v3-4-0 = ["v3-3-2", "third-notif-param"] -v3-5-0 = ["v3-4-0"] -v3-8-13 = ["v3-5-0"] -v3-8-15 = ["v3-5-0"] -v3-10-22 = ["v3-8-15"] -v4-3-11 = ["v3-8-15"] -friends = [] -rmc_struct_header = [] -big_pid = [] - -[lints] -workspace = true diff --git a/rnex-protocols/reggie-protos/src/lib.rs b/rnex-protocols/reggie-protos/src/lib.rs deleted file mode 100644 index 62f02a1..0000000 --- a/rnex-protocols/reggie-protos/src/lib.rs +++ /dev/null @@ -1,3 +0,0 @@ -#![allow(async_fn_in_trait)] - -pub mod reggie; diff --git a/rnex-protocols/reggie-protos/src/reggie.rs b/rnex-protocols/reggie-protos/src/reggie.rs deleted file mode 100644 index 85a9565..0000000 --- a/rnex-protocols/reggie-protos/src/reggie.rs +++ /dev/null @@ -1,22 +0,0 @@ -use std::net::SocketAddrV4; - -use rnex_rmc::{RmcSerialize, define_rmc_proto, method_id, response::ErrorCode, rmc_proto}; - -#[rmc_proto(1)] -pub trait EdgeNodeManagement { - #[method_id(1)] - async fn get_url(&self, seed: u64) -> Result; -} - -define_rmc_proto!( - proto EdgeNodeHolder{ - EdgeNodeManagement - } -); - -#[derive(RmcSerialize, Debug)] -#[repr(u32)] -pub enum EdgeNodeHolderConnectOption { - DontRegister = 0, - Register(SocketAddrV4) = 1, -} diff --git a/rnex-protocols/rk-protos/src/ranking.rs b/rnex-protocols/rk-protos/src/ranking.rs index d9d2b57..4b56fe6 100644 --- a/rnex-protocols/rk-protos/src/ranking.rs +++ b/rnex-protocols/rk-protos/src/ranking.rs @@ -1,12 +1,13 @@ use bytemuck::{Pod, Zeroable}; use rnex_base_protos::ResultsRange; use rnex_rmc::{ - RmcSerialize, method_id, + RmcSerialize, qbuffer::QBuffer, - response::ErrorCode, rmc_proto, util::{PID, date_time::DateTime}, }; +#[cfg(feature = "splatoon")] +use rnex_rmc::{method_id, response::ErrorCode}; #[derive(RmcSerialize, Debug)] #[rmc_struct(0)] diff --git a/rnex-server-nex-modules/rnex-auth/Cargo.toml b/rnex-server-nex-modules/rnex-auth/Cargo.toml index bd994d0..5fd969b 100644 --- a/rnex-server-nex-modules/rnex-auth/Cargo.toml +++ b/rnex-server-nex-modules/rnex-auth/Cargo.toml @@ -6,7 +6,6 @@ edition = "2024" [dependencies] rnex-rmc = { path = "../../rnex-rmc" } rnex-auth-protos = { path = "../../rnex-protocols/auth-protos" } -rnex-reggie-protos = { path = "../../rnex-protocols/reggie-protos" } rnex-server = { path = "../../rnex-server" } rnex-prudp = { path = "../../rnex-prudp" } hex = "0.4.3" @@ -17,6 +16,7 @@ tracing = "0.1.44" cfg-if = "1.0.4" anyhow = "1.0.103" tokio = { version = "1.52.3", features = ["net"] } +thiserror = "2.0.20" [features] rmc_struct_header = [] diff --git a/rnex-server-nex-modules/rnex-auth/src/auth_handler.rs b/rnex-server-nex-modules/rnex-auth/src/auth_handler.rs index b48719c..5ae783a 100644 --- a/rnex-server-nex-modules/rnex-auth/src/auth_handler.rs +++ b/rnex-server-nex-modules/rnex-auth/src/auth_handler.rs @@ -1,9 +1,5 @@ -use std::{ - hash::{DefaultHasher, Hasher}, - net::SocketAddrV4, - sync::LazyLock, -}; - +use std::{env, hash::{DefaultHasher, Hasher}, net::SocketAddrV4, sync::LazyLock}; +use std::str::FromStr; use cfg_if::cfg_if; use nex_account::{grpc, grpc_client}; use rnex_auth_protos::{ @@ -11,7 +7,6 @@ use rnex_auth_protos::{ auth::{Auth, ConnectionData, ConnectionDataOld}, }; use rnex_prudp::kerberos::{Ticket, TicketInternalData}; -use rnex_reggie_protos::reggie::RemoteEdgeNodeManagement; use rnex_rmc::{ any::Any, qresult::QResult, @@ -47,6 +42,14 @@ pub fn generate_ticket( } .encrypt(source_key, &encrypted_inner) } + +fn try_get_env(name: &'static str) -> Result { + env::var(name) + .ok() + .and_then(|val| val.parse::().ok()) + .ok_or(ErrorCode::Core_Unknown) +} + pub fn generate_ticket_with_string_user_key( source_act: PID, dest_act_login_data: (PID, [u8; 16]), @@ -193,9 +196,14 @@ impl Auth for AuthHandler { hasher.write(name.as_bytes()); - let Ok(addr) = self.am.control_server.get_url(hasher.finish()).await else { - warn!("no secure proxies"); - return Err(ErrorCode::Core_Exception); + // let Ok(addr) = self.am.control_server.get_url(hasher.finish()).await else { + // warn!("no secure proxies"); + // return Err(ErrorCode::Core_Exception); + // }; + + let addr = match try_get_env("FORWARD_DESTINATION") { + Ok(val) => val, + Err(e) => return Err(e), }; let connection_data = ConnectionDataOld { @@ -231,9 +239,14 @@ impl Auth for AuthHandler { hasher.write(name.as_bytes()); - let Ok(addr) = self.control_server.get_url(hasher.finish()).await else { - warn!("no secure proxies"); - return Err(ErrorCode::Core_Exception); + // let Ok(addr) = self.control_server.get_url(hasher.finish()).await else { + // warn!("no secure proxies"); + // return Err(ErrorCode::Core_Exception); + // }; + + let addr = match try_get_env("FORWARD_DESTINATION") { + Ok(val) => val, + Err(e) => return Err(e), }; let connection_data = ConnectionData { @@ -291,9 +304,14 @@ impl Auth for AuthHandler { hasher.write(name.as_bytes()); - let Ok(addr) = self.am.control_server.get_url(hasher.finish()).await else { - warn!("no secure proxies"); - return Err(ErrorCode::Core_Exception); + // let Ok(addr) = self.am.control_server.get_url(hasher.finish()).await else { + // warn!("no secure proxies"); + // return Err(ErrorCode::Core_Exception); + // }; + + let addr = match try_get_env("FORWARD_DESTINATION") { + Ok(val) => val, + Err(e) => return Err(e), }; let connection_data = ConnectionData { diff --git a/rnex-server-nex-modules/rnex-auth/src/lib.rs b/rnex-server-nex-modules/rnex-auth/src/lib.rs index 0b27e1b..c0b576e 100644 --- a/rnex-server-nex-modules/rnex-auth/src/lib.rs +++ b/rnex-server-nex-modules/rnex-auth/src/lib.rs @@ -1,16 +1,8 @@ #[allow(async_fn_in_trait)] pub mod auth_handler; -use std::{env, sync::Arc}; -use tokio::net::TcpStream; - use nex_account::{grpc::Pid, grpc_client}; -use rnex_reggie_protos::reggie::{EdgeNodeHolderConnectOption::DontRegister, RemoteEdgeNodeHolder}; -use rnex_rmc::{ - OnlyRemote, new_rmc_gateway_connection, - serialization::RmcSerialize, - util::{SplittableBufferConnection, account::Account}, -}; +use rnex_rmc::util::account::Account; use rnex_server::{ConnectionInitData, RnexManager, RnexModule, WeakPassthroughInitModule}; use tracing::info; @@ -20,7 +12,6 @@ use crate::auth_handler::AuthHandler; pub struct AuthManager { pub destination_server_acct: Account, pub build_name: &'static str, - pub control_server: Arc>, } #[derive(Debug)] pub struct AuthModule; @@ -40,35 +31,14 @@ impl RnexManager for AuthManager { } } -/* -pub static FORWARD_EDGE_NODE_HOLDER: Lazy = Lazy::new(|| { - env::var("FORWARD_EDGE_NODE_HOLDER") - .ok() - .and_then(|s| Some(s.parse().unwrap())) - .expect("FORWARD_EDGE_NODE_HOLDER not set") -});*/ - impl RnexModule for AuthModule { type Manager = AuthManager; type InitError = anyhow::Error; async fn create_manager( _: &rnex_server::ModuleHolder, ) -> Result { - let conn = TcpStream::connect(env::var("FORWARD_EDGE_NODE_HOLDER")?) - .await - .unwrap(); - - let conn: SplittableBufferConnection = conn.into(); - - conn.send(DontRegister.to_data().unwrap()).await; - - let conn = new_rmc_gateway_connection(conn, async |r| { - Arc::new(OnlyRemote::::new(r)) - }) - .await; Ok(AuthManager { build_name: option_env!("AUTH_REPORT_VERSION").unwrap_or("no version specified"), - control_server: conn, // todo: update nex-account to allow pulling the entire account info for rnex destination_server_acct: Account::new_raw_key( 2, diff --git a/rnex-server-nex-modules/rnex-node-holder/Cargo.toml b/rnex-server-nex-modules/rnex-node-holder/Cargo.toml deleted file mode 100644 index b62e267..0000000 --- a/rnex-server-nex-modules/rnex-node-holder/Cargo.toml +++ /dev/null @@ -1,31 +0,0 @@ -[package] -name = "rnex-node-holder" -version = "0.1.0" -edition = "2024" - -[features] -rmc_struct_header = [] -guest_login = [] -friends = ["guest_login", "database-support"] -big_pid = [] -third-notif-param = [] -v3-3-2 = [] -v3-4-0 = ["v3-3-2", "third-notif-param", "rmc_struct_header"] -v3-5-0 = ["v3-4-0"] -v3-8-13 = ["v3-5-0"] -v3-8-15 = ["v3-5-0"] -v3-10-22 = ["v3-8-15"] -v4-3-11 = ["v3-8-15"] -nx = ["big_pid"] -splatoon = ["v3-5-0"] -datastore = ["database-support", "v3-8-15"] -database-support = [] - -[dependencies] -rnex-rmc = { path = "../../rnex-rmc" } -rnex-reggie-protos = { path = "../../rnex-protocols/reggie-protos" } -rnex-server = { path = "../../rnex-server" } -tokio = { version = "1.52.3", features = ["sync"] } - -[lints] -workspace = true diff --git a/rnex-server-nex-modules/rnex-node-holder/src/lib.rs b/rnex-server-nex-modules/rnex-node-holder/src/lib.rs deleted file mode 100644 index eb880bf..0000000 --- a/rnex-server-nex-modules/rnex-node-holder/src/lib.rs +++ /dev/null @@ -1,84 +0,0 @@ -use std::{ - convert::Infallible, - net::{Ipv4Addr, SocketAddrV4}, - sync::{Arc, Weak}, -}; - -use rnex_reggie_protos::reggie::{ - EdgeNodeHolderConnectOption, EdgeNodeManagement, LocalEdgeNodeHolder, -}; -use rnex_rmc::{response::ErrorCode, rmc_struct}; -use rnex_server::{ - PassthroughInitModule, RnexManager, RnexModule, WeakPassthroughInitModule, -}; -use tokio::sync::RwLock; - -#[derive(Debug)] -#[rmc_struct(EdgeNodeHolder)] -pub struct EdgeNode { - em: PassthroughInitModule, - address: SocketAddrV4, -} - -impl EdgeNodeManagement for EdgeNode { - async fn get_url(&self, seed: u64) -> Result { - let nodes = self.em.edge_nodes.read().await; - - let nodes: Vec<_> = nodes.iter().filter_map(|n| n.upgrade()).collect(); - - // avoid a devide by zero - if nodes.len() == 0 { - return Err(ErrorCode::Core_InvalidIndex); - }; - - let node = &nodes[seed as usize % nodes.len()]; - - Ok(node.address) - } -} - -#[derive(Default, Debug)] -pub struct NodeHolderManager { - edge_nodes: RwLock>>, -} -#[derive(Default, Debug)] -pub struct NodeHolderModule; - -impl RnexManager for NodeHolderManager { - type User = Arc; - type InitData = EdgeNodeHolderConnectOption; - async fn init_new_user( - this: PassthroughInitModule, - _mod_holder: &rnex_server::ModuleHolder, - _remote: &rnex_rmc::RmcConnection, - init_data: &Self::InitData, - _: WeakPassthroughInitModule, - ) -> Self::User { - match init_data { - EdgeNodeHolderConnectOption::DontRegister => Arc::new(EdgeNode { - em: this, - address: SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, 0), - }), - EdgeNodeHolderConnectOption::Register(socket_addr_v4) => { - let node = Arc::new(EdgeNode { - em: this.clone(), - address: *socket_addr_v4, - }); - this.edge_nodes.write().await.push(Arc::downgrade(&node)); - - node - } - } - } -} - -impl RnexModule for NodeHolderModule { - type Manager = NodeHolderManager; - type InitError = Infallible; - - async fn create_manager( - _: &rnex_server::ModuleHolder, - ) -> Result { - Ok(NodeHolderManager::default()) - } -} diff --git a/rnex-server/backend-node-holder/Cargo.toml b/rnex-server/backend-node-holder/Cargo.toml deleted file mode 100644 index 17cd2e6..0000000 --- a/rnex-server/backend-node-holder/Cargo.toml +++ /dev/null @@ -1,27 +0,0 @@ -[package] -name = "rnex-server-backend-node-holder" -version = "0.1.0" -edition = "2024" - -[dependencies] -rnex-server = {path = ".."} -rnex-node-holder = {path = "../../rnex-server-nex-modules/rnex-node-holder"} -rnex-reggie-protos = { path = "../../rnex-protocols/reggie-protos" } -tokio = { version = "1.52.3", features = ["rt-multi-thread"] } - -[features] -splatoon = ["v3-5-0"] -datastore = ["database-support", "v3-8-15"] -database-support = [] -nx = [] -third-notif-param = [] -v3-3-2 = [] -v3-4-0 = ["v3-3-2", "third-notif-param"] -v3-5-0 = ["v3-4-0"] -v3-8-13 = ["v3-5-0"] -v3-8-15 = ["v3-5-0"] -v3-10-22 = ["v3-8-15"] -v4-3-11 = ["v3-8-15"] -friends = [] -rmc_struct_header = [] -big_pid = [] diff --git a/rnex-server/backend-node-holder/src/main.rs b/rnex-server/backend-node-holder/src/main.rs deleted file mode 100644 index d216192..0000000 --- a/rnex-server/backend-node-holder/src/main.rs +++ /dev/null @@ -1,11 +0,0 @@ -use rnex_node_holder::NodeHolderModule; -use rnex_reggie_protos::reggie::EdgeNodeHolderConnectOption; -use rnex_server::launch_rnex_module_server; - -#[tokio::main] -async fn main() { - launch_rnex_module_server! { - EdgeNodeHolderConnectOption; - NodeHolderModule - } -} diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 3ac2963..0000000 --- a/shell.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ - pkgs ? import { }, - pkg ? pkgs.callPackage ./. { }, -}: -pkgs.mkShell { - # Get dependencies from the main package - # inputsFrom = [ pkg ]; - # Additional tooling - buildInputs = with pkgs; [ - cargo - rust-analyzer # LSP Server - rustfmt # Formatter - clippy # Linter - podman - yq - jq - ]; -}