Compare commits
No commits in common. "29a8b015bddd4e804c3bce2d1f2182f77cfacaaa" and "547ae0d76d6a3129be94ce80f71ae71b674f5630" have entirely different histories.
29a8b015bd
...
547ae0d76d
4 changed files with 37 additions and 90 deletions
|
|
@ -3,7 +3,6 @@
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
TMP_FEATURES_TRAILINGCOMMA=$(yq ea ".$EDITION.features" editions.yaml | sed 's/- //g' | tr '\n' ',')
|
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}
|
export EDITION_FEATURES=${TMP_FEATURES_TRAILINGCOMMA::-1}
|
||||||
SETTINGS=$(yq ea ".$EDITION.settings" editions.yaml | yq 'keys[]')
|
SETTINGS=$(yq ea ".$EDITION.settings" editions.yaml | yq 'keys[]')
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
use crate::prudp::router::Router;
|
use crate::prudp::router::Router;
|
||||||
use crate::prudp::secure::Secure;
|
use crate::prudp::secure::Secure;
|
||||||
use log::error;
|
use log::error;
|
||||||
use log::warn;
|
|
||||||
use proxy_common::{ProxyStartupParam, RNEX_ACCESS_KEY};
|
use proxy_common::{ProxyStartupParam, RNEX_ACCESS_KEY};
|
||||||
use rnex_core::executables::common::SECURE_SERVER_ACCOUNT;
|
use rnex_core::executables::common::SECURE_SERVER_ACCOUNT;
|
||||||
use rnex_core::prudp::virtual_port::VirtualPort;
|
use rnex_core::prudp::virtual_port::VirtualPort;
|
||||||
|
|
@ -34,24 +33,6 @@ pub async fn start(param: ProxyStartupParam) {
|
||||||
};
|
};
|
||||||
|
|
||||||
task::spawn(async move {
|
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 {
|
let mut stream = match TcpStream::connect(param.forward_destination).await {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
|
||||||
|
|
@ -103,41 +103,6 @@ impl Client {
|
||||||
Ok(val.as_bytes().try_into().map_err(|_| SomethingHappened)?)
|
Ok(val.as_bytes().try_into().map_err(|_| SomethingHappened)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_user_level(&mut self, pid: PID) -> Result<i32> {
|
|
||||||
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<PID> {
|
pub async fn get_pid_from_token(&mut self, token: String) -> Result<PID> {
|
||||||
let req = self
|
let req = self
|
||||||
.do_request(object! {
|
.do_request(object! {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ trait Version {
|
||||||
/// This struct contains nothing and is used to represent specific versions as an instance of
|
/// This struct contains nothing and is used to represent specific versions as an instance of
|
||||||
/// [`Version`]. It is instances as `Ver<Major, Minor>`
|
/// [`Version`]. It is instances as `Ver<Major, Minor>`
|
||||||
struct Ver<MAJ: Unsigned, MIN: Unsigned>{
|
struct Ver<MAJ: Unsigned, MIN: Unsigned>{
|
||||||
_phantom: PhantomData<(MAJ, MIN)>,
|
_phantom: PhantomData<(MAJ, MIN)>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<MAJ: Unsigned, MIN: Unsigned> Version for Ver<MAJ, MIN>{
|
impl<MAJ: Unsigned, MIN: Unsigned> Version for Ver<MAJ, MIN>{
|
||||||
|
|
@ -24,12 +24,15 @@ trait ComparableVersion<T: Version>: Version {
|
||||||
type IsAtLeast: SameOrUnit;
|
type IsAtLeast: SameOrUnit;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Version, U: Version> ComparableVersion<T> for U
|
impl<T: Version, U: Version> ComparableVersion<T> for U where
|
||||||
where
|
|
||||||
<T as Version>::Major: Cmp<Self::Major>,
|
<T as Version>::Major: Cmp<Self::Major>,
|
||||||
<T as Version>::Minor: IsLessOrEqual<Self::Minor>,
|
<T as Version>::Minor: IsLessOrEqual<Self::Minor>,
|
||||||
<T as Version>::Major:
|
<T as Version>::Major: IsEqual<
|
||||||
IsEqual<Self::Major, Output: BitAnd<typenum::LeEq<T::Minor, Self::Minor>>>,
|
Self::Major,
|
||||||
|
Output: BitAnd<
|
||||||
|
typenum::LeEq<T::Minor, Self::Minor>
|
||||||
|
>,
|
||||||
|
>,
|
||||||
<T as Version>::Major: IsLess<
|
<T as Version>::Major: IsLess<
|
||||||
Self::Major,
|
Self::Major,
|
||||||
Output: BitOr<
|
Output: BitOr<
|
||||||
|
|
@ -37,25 +40,27 @@ where
|
||||||
typenum::Eq<T::Major, Self::Major>,
|
typenum::Eq<T::Major, Self::Major>,
|
||||||
typenum::LeEq<T::Minor, Self::Minor>,
|
typenum::LeEq<T::Minor, Self::Minor>,
|
||||||
>,
|
>,
|
||||||
Output: SameOrUnit,
|
Output: SameOrUnit
|
||||||
>,
|
>
|
||||||
>,
|
> {
|
||||||
{
|
|
||||||
type IsAtLeast = typenum::Or<
|
type IsAtLeast = typenum::Or<
|
||||||
typenum::Le<T::Major, Self::Major>,
|
typenum::Le<T::Major, Self::Major>,
|
||||||
typenum::And<typenum::Eq<T::Major, Self::Major>, typenum::LeEq<T::Minor, Self::Minor>>,
|
typenum::And<
|
||||||
|
typenum::Eq<T::Major, Self::Major>,
|
||||||
|
typenum::LeEq<T::Minor, Self::Minor>,
|
||||||
|
>
|
||||||
>;
|
>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Simple check for testing if the `TEST` version is at least `REQ` or higher.
|
/// Simple check for testing if the `TEST` version is at least `REQ` or higher.
|
||||||
type VersionAbove<REQ, TEST> = <TEST as ComparableVersion<REQ>>::IsAtLeast;
|
type VersionAbove<REQ, TEST> = <TEST as ComparableVersion<REQ>>::IsAtLeast;
|
||||||
|
|
||||||
trait VersionIsAtLeast<VER: Version>{}
|
trait VersionIsAtLeast<VER: Version>{}
|
||||||
|
|
||||||
impl<VER: Version, T: ComparableVersion<VER, IsAtLeast = typenum::True>> VersionIsAtLeast<VER>
|
impl<VER: Version, T: ComparableVersion<VER, IsAtLeast = typenum::True>> VersionIsAtLeast<VER> for T{}
|
||||||
for T
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Trait for containing the result of elements which only conditionally exist
|
/// Trait for containing the result of elements which only conditionally exist
|
||||||
trait CondElemResult{
|
trait CondElemResult{
|
||||||
|
|
@ -66,7 +71,7 @@ trait CondElemResult {
|
||||||
/// structs which have a version requirement. This is not meant to be used directly, use
|
/// structs which have a version requirement. This is not meant to be used directly, use
|
||||||
/// [`MinVersion`] instead.
|
/// [`MinVersion`] instead.
|
||||||
struct MinVersionElementHelper<T, REQUIRED: Version, VER: Version + ComparableVersion<REQUIRED>>{
|
struct MinVersionElementHelper<T, REQUIRED: Version, VER: Version + ComparableVersion<REQUIRED>>{
|
||||||
_phantom: PhantomData<(T, REQUIRED, VER)>,
|
_phantom: PhantomData<(T, REQUIRED, VER)>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This should be used either with [`typenum::True`] or [`typenum::False`]. When `True` the [`Self::Output`]
|
/// This should be used either with [`typenum::True`] or [`typenum::False`]. When `True` the [`Self::Output`]
|
||||||
|
|
@ -83,13 +88,10 @@ impl SameOrUnit for typenum::False {
|
||||||
type Output<T> = ();
|
type Output<T> = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, REQUIRED: Version, VER: Version + ComparableVersion<REQUIRED>> CondElemResult
|
impl<T, REQUIRED: Version, VER: Version + ComparableVersion<REQUIRED>> CondElemResult for MinVersionElementHelper<T, REQUIRED, VER> where {
|
||||||
for MinVersionElementHelper<T, REQUIRED, VER>
|
|
||||||
{
|
|
||||||
type Output = <<VER as ComparableVersion<REQUIRED>>::IsAtLeast as SameOrUnit>::Output<T>;
|
type Output = <<VER as ComparableVersion<REQUIRED>>::IsAtLeast as SameOrUnit>::Output<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// When the version condition is met the field will exist and will simply be `T` if not it will be
|
/// 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.
|
/// replaced by `()`. Use this when you need to add versioning to rmc structs.
|
||||||
type MinVersion<T, REQUIRED, VER> =
|
type MinVersion<T, REQUIRED, VER> = <MinVersionElementHelper<T, REQUIRED, VER> as CondElemResult>::Output;
|
||||||
<MinVersionElementHelper<T, REQUIRED, VER> as CondElemResult>::Output;
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue