diff --git a/buildscripts/common.sh b/buildscripts/common.sh index e4b346c..697ae87 100755 --- a/buildscripts/common.sh +++ b/buildscripts/common.sh @@ -3,7 +3,6 @@ set -euo pipefail TMP_FEATURES_TRAILINGCOMMA=$(yq ea ".$EDITION.features" editions.yaml | sed 's/- //g' | tr '\n' ',') -echo "tmpfeatures: $TMP_FEATURES_TRAILINGCOMMA" export EDITION_FEATURES=${TMP_FEATURES_TRAILINGCOMMA::-1} SETTINGS=$(yq ea ".$EDITION.settings" editions.yaml | yq 'keys[]') IFS=$'\n' diff --git a/prudpv1/src/executables/proxy_secure.rs b/prudpv1/src/executables/proxy_secure.rs index c338ef9..2e79317 100644 --- a/prudpv1/src/executables/proxy_secure.rs +++ b/prudpv1/src/executables/proxy_secure.rs @@ -1,7 +1,6 @@ use crate::prudp::router::Router; use crate::prudp::secure::Secure; use log::error; -use log::warn; use proxy_common::{ProxyStartupParam, RNEX_ACCESS_KEY}; use rnex_core::executables::common::SECURE_SERVER_ACCOUNT; use rnex_core::prudp::virtual_port::VirtualPort; @@ -34,24 +33,6 @@ pub async fn start(param: ProxyStartupParam) { }; task::spawn(async move { - let Ok(mut c) = rnex_core::grpc::account::Client::new().await else { - error!("failed to initialize gql client"); - return; - }; - - let v = match c.get_user_level(conn.user_id).await { - Ok(v) => v, - Err(e) => { - error!("failed to get user level: {}", e); - return; - } - }; - - if v < 0 { - warn!("person with too low account level joined"); - return; - } - let mut stream = match TcpStream::connect(param.forward_destination).await { Ok(v) => v, Err(e) => { diff --git a/rnex-core/src/grpc/account.rs b/rnex-core/src/grpc/account.rs index 9d2d4e8..d6ad140 100644 --- a/rnex-core/src/grpc/account.rs +++ b/rnex-core/src/grpc/account.rs @@ -103,41 +103,6 @@ impl Client { Ok(val.as_bytes().try_into().map_err(|_| SomethingHappened)?) } - pub async fn get_user_level(&mut self, pid: PID) -> Result { - let req = self - .do_request(object! { - "query": r"query($pid: Int!){ - userByPid(pid: $pid){ - accountLevel - } - }", - "variables": { - "pid": pid - } - }) - .await?; - - let Some(val) = req - .entries() - .find(|v| v.0 == "data") - .ok_or(SomethingHappened)? - .1 - .entries() - .find(|v| v.0 == "userByPid") - .ok_or(SomethingHappened)? - .1 - .entries() - .find(|v| v.0 == "accountLevel") - .ok_or(SomethingHappened)? - .1 - .as_i32() - else { - return Err(SomethingHappened); - }; - - Ok(val) - } - pub async fn get_pid_from_token(&mut self, token: String) -> Result { let req = self .do_request(object! { diff --git a/rnex-core/src/versions.rs b/rnex-core/src/versions.rs index 03b71b5..7b5ec30 100644 --- a/rnex-core/src/versions.rs +++ b/rnex-core/src/versions.rs @@ -3,93 +3,95 @@ use std::ops::{BitAnd, BitOr}; use typenum::{Cmp, IsEqual, IsLess, IsLessOrEqual, Unsigned}; /// This trait represents a version at compile time -trait Version { +trait Version{ type Major: Unsigned; type Minor: Unsigned; } /// This struct contains nothing and is used to represent specific versions as an instance of /// [`Version`]. It is instances as `Ver` -struct Ver { - _phantom: PhantomData<(MAJ, MIN)>, +struct Ver{ + _phantom: PhantomData<(MAJ, MIN)> } -impl Version for Ver { +impl Version for Ver{ type Major = MAJ; type Minor = MIN; } /// Represents two versions which can be compared -trait ComparableVersion: Version { +trait ComparableVersion: Version{ type IsAtLeast: SameOrUnit; } -impl ComparableVersion for U -where +impl ComparableVersion for U where ::Major: Cmp, ::Minor: IsLessOrEqual, - ::Major: - IsEqual>>, - ::Major: IsLess< - Self::Major, - Output: BitOr< - typenum::And< - typenum::Eq, - typenum::LeEq, - >, - Output: SameOrUnit, - >, + ::Major: IsEqual< + Self::Major, + Output: BitAnd< + typenum::LeEq >, -{ + >, + ::Major: IsLess< + Self::Major, + Output: BitOr< + typenum::And< + typenum::Eq, + typenum::LeEq, + >, + Output: SameOrUnit + > + > { + type IsAtLeast = typenum::Or< typenum::Le, - typenum::And, typenum::LeEq>, + typenum::And< + typenum::Eq, + typenum::LeEq, + > >; } + /// Simple check for testing if the `TEST` version is at least `REQ` or higher. type VersionAbove = >::IsAtLeast; -trait VersionIsAtLeast {} +trait VersionIsAtLeast{} + +impl> VersionIsAtLeast for T{} -impl> VersionIsAtLeast - for T -{ -} /// Trait for containing the result of elements which only conditionally exist -trait CondElemResult { +trait CondElemResult{ type Output; } /// Empty helper struct which only servers to give a concrete type when creating fields in rmc /// structs which have a version requirement. This is not meant to be used directly, use /// [`MinVersion`] instead. -struct MinVersionElementHelper> { - _phantom: PhantomData<(T, REQUIRED, VER)>, +struct MinVersionElementHelper>{ + _phantom: PhantomData<(T, REQUIRED, VER)> } /// This should be used either with [`typenum::True`] or [`typenum::False`]. When `True` the [`Self::Output`] /// will be the same as the `T` you put into Output. When `False` it will always be `()` -trait SameOrUnit { +trait SameOrUnit{ type Output; } -impl SameOrUnit for typenum::True { +impl SameOrUnit for typenum::True{ type Output = T; } -impl SameOrUnit for typenum::False { +impl SameOrUnit for typenum::False{ type Output = (); } -impl> CondElemResult - for MinVersionElementHelper -{ +impl> CondElemResult for MinVersionElementHelper where { type Output = <>::IsAtLeast as SameOrUnit>::Output; } /// When the version condition is met the field will exist and will simply be `T` if not it will be /// replaced by `()`. Use this when you need to add versioning to rmc structs. -type MinVersion = - as CondElemResult>::Output; +type MinVersion = as CondElemResult>::Output; \ No newline at end of file