feat: a lot of things(i lost track)
This commit is contained in:
parent
29f3ab6348
commit
98193a58d8
42 changed files with 1207 additions and 366 deletions
|
|
@ -1,7 +1,12 @@
|
|||
use std::env;
|
||||
use std::net::Ipv4Addr;
|
||||
use std::net::{Ipv4Addr, SocketAddrV4};
|
||||
use macros::{method_id, rmc_proto, RmcSerialize};
|
||||
use once_cell::sync::Lazy;
|
||||
use tonic::transport::Server;
|
||||
use rust_nex::define_rmc_proto;
|
||||
use rust_nex::prudp::station_url::StationUrl;
|
||||
use crate::nex::account::Account;
|
||||
use crate::rmc::response::ErrorCode;
|
||||
|
||||
pub static OWN_IP_PRIVATE: Lazy<Ipv4Addr> = Lazy::new(|| {
|
||||
env::var("SERVER_IP")
|
||||
|
|
@ -10,6 +15,13 @@ pub static OWN_IP_PRIVATE: Lazy<Ipv4Addr> = Lazy::new(|| {
|
|||
.expect("no private ip specified")
|
||||
});
|
||||
|
||||
pub static OWN_IP_PUBLIC: Lazy<Ipv4Addr> = Lazy::new(|| {
|
||||
env::var("SERVER_IP_PUBLIC")
|
||||
.ok()
|
||||
.and_then(|s| s.parse().ok())
|
||||
.expect("no private ip specified")
|
||||
});
|
||||
|
||||
pub static SERVER_PORT: Lazy<u16> = Lazy::new(|| {
|
||||
env::var("SERVER_PORT")
|
||||
.ok()
|
||||
|
|
@ -27,3 +39,52 @@ pub static AUTH_SERVER_ACCOUNT: Lazy<Account> =
|
|||
Lazy::new(|| Account::new(1, "Quazal Authentication", &KERBEROS_SERVER_PASSWORD));
|
||||
pub static SECURE_SERVER_ACCOUNT: Lazy<Account> =
|
||||
Lazy::new(|| Account::new(2, "Quazal Rendez-Vous", &KERBEROS_SERVER_PASSWORD));
|
||||
|
||||
|
||||
#[rmc_proto(1)]
|
||||
pub trait ProxyManagement {
|
||||
#[method_id(1)]
|
||||
async fn update_url(&self, url: String) -> Result<(), ErrorCode>;
|
||||
}
|
||||
|
||||
define_rmc_proto!(
|
||||
proto Proxy{
|
||||
ProxyManagement
|
||||
}
|
||||
);
|
||||
|
||||
#[rmc_proto(2)]
|
||||
pub trait ControllerManagement {
|
||||
#[method_id(1)]
|
||||
async fn get_secure_proxy_url(&self) -> Result<String, ErrorCode>;
|
||||
|
||||
#[method_id(2)]
|
||||
async fn get_secure_account(&self) -> Result<Account, ErrorCode>;
|
||||
}
|
||||
|
||||
define_rmc_proto!(
|
||||
proto Controller{
|
||||
ControllerManagement
|
||||
}
|
||||
);
|
||||
|
||||
#[derive(RmcSerialize)]
|
||||
#[repr(u32)]
|
||||
pub enum ServerCluster{
|
||||
Auth = 0,
|
||||
Secure = 1
|
||||
}
|
||||
|
||||
#[derive(RmcSerialize)]
|
||||
#[repr(u32)]
|
||||
pub enum ServerType{
|
||||
Proxy{
|
||||
addr: SocketAddrV4,
|
||||
cluster: ServerCluster
|
||||
} = 1,
|
||||
Backend{
|
||||
name: String,
|
||||
cluster: ServerCluster
|
||||
} = 2,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue