WIP on impl redirect use remote addr

using remote address on daemon registration as pubsub endpoint
validating pubsub node using client req remote address
remove fetching public ip
This commit is contained in:
Noor 2025-06-10 20:48:16 +05:30
parent af7d4157ee
commit 786489fcbd
Signed by: noormohammedb
GPG Key ID: D83EFB8B3B967146
7 changed files with 65 additions and 354 deletions

339
Cargo.lock generated

@ -263,7 +263,7 @@ dependencies = [
"fnv",
"futures-timer",
"futures-util",
"http 1.3.1",
"http",
"indexmap 2.9.0",
"mime",
"multer",
@ -285,7 +285,7 @@ checksum = "29db05b624fb6352fc11bfe30c54ab1b16a1fe937d7c05a783f4e88ef1292b3b"
dependencies = [
"Inflector",
"async-graphql-parser",
"darling 0.20.11",
"darling",
"proc-macro-crate",
"proc-macro2",
"quote",
@ -390,8 +390,8 @@ dependencies = [
"axum-core",
"bytes",
"futures-util",
"http 1.3.1",
"http-body 1.0.1",
"http",
"http-body",
"http-body-util",
"itoa",
"matchit",
@ -416,8 +416,8 @@ dependencies = [
"async-trait",
"bytes",
"futures-util",
"http 1.3.1",
"http-body 1.0.1",
"http",
"http-body",
"http-body-util",
"mime",
"pin-project-lite",
@ -908,38 +908,14 @@ dependencies = [
"syn 2.0.100",
]
[[package]]
name = "darling"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858"
dependencies = [
"darling_core 0.10.2",
"darling_macro 0.10.2",
]
[[package]]
name = "darling"
version = "0.20.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee"
dependencies = [
"darling_core 0.20.11",
"darling_macro 0.20.11",
]
[[package]]
name = "darling_core"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote",
"strsim 0.9.3",
"syn 1.0.109",
"darling_core",
"darling_macro",
]
[[package]]
@ -952,28 +928,17 @@ dependencies = [
"ident_case",
"proc-macro2",
"quote",
"strsim 0.11.1",
"strsim",
"syn 2.0.100",
]
[[package]]
name = "darling_macro"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72"
dependencies = [
"darling_core 0.10.2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "darling_macro"
version = "0.20.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead"
dependencies = [
"darling_core 0.20.11",
"darling_core",
"quote",
"syn 2.0.100",
]
@ -1032,31 +997,6 @@ dependencies = [
"serde",
]
[[package]]
name = "derive_builder"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2658621297f2cf68762a6f7dc0bb7e1ff2cfd6583daef8ee0fed6f7ec468ec0"
dependencies = [
"darling 0.10.2",
"derive_builder_core",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "derive_builder_core"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2791ea3e372c8495c0bc2033991d76b512cd799d07491fbd6890124db9458bef"
dependencies = [
"darling 0.10.2",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "detee-shared"
version = "0.1.0"
@ -1132,18 +1072,6 @@ dependencies = [
"urlencoding",
]
[[package]]
name = "dns-lookup"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53ecafc952c4528d9b51a458d1a8904b81783feff9fde08ab6ed2545ff396872"
dependencies = [
"cfg-if",
"libc",
"socket2 0.4.10",
"winapi",
]
[[package]]
name = "doc-comment"
version = "0.3.3"
@ -1221,18 +1149,6 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d"
[[package]]
name = "enum-as-inner"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "570d109b813e904becc80d8d5da38376818a143348413f7149f1340fe04754d4"
dependencies = [
"heck 0.4.1",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "env_filter"
version = "0.1.3"
@ -1583,7 +1499,7 @@ dependencies = [
"fnv",
"futures-core",
"futures-sink",
"http 1.3.1",
"http",
"indexmap 2.9.0",
"slab",
"tokio",
@ -1693,17 +1609,6 @@ dependencies = [
"syn 2.0.100",
]
[[package]]
name = "http"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1"
dependencies = [
"bytes",
"fnv",
"itoa",
]
[[package]]
name = "http"
version = "1.3.1"
@ -1715,17 +1620,6 @@ dependencies = [
"itoa",
]
[[package]]
name = "http-body"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2"
dependencies = [
"bytes",
"http 0.2.12",
"pin-project-lite",
]
[[package]]
name = "http-body"
version = "1.0.1"
@ -1733,7 +1627,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184"
dependencies = [
"bytes",
"http 1.3.1",
"http",
]
[[package]]
@ -1744,8 +1638,8 @@ checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a"
dependencies = [
"bytes",
"futures-core",
"http 1.3.1",
"http-body 1.0.1",
"http",
"http-body",
"pin-project-lite",
]
@ -1767,29 +1661,6 @@ version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b112acc8b3adf4b107a8ec20977da0273a8c386765a3ec0229bd500a1443f9f"
[[package]]
name = "hyper"
version = "0.14.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7"
dependencies = [
"bytes",
"futures-channel",
"futures-core",
"futures-util",
"http 0.2.12",
"http-body 0.4.6",
"httparse",
"httpdate",
"itoa",
"pin-project-lite",
"socket2 0.5.9",
"tokio",
"tower-service",
"tracing",
"want",
]
[[package]]
name = "hyper"
version = "1.6.0"
@ -1800,8 +1671,8 @@ dependencies = [
"futures-channel",
"futures-util",
"h2",
"http 1.3.1",
"http-body 1.0.1",
"http",
"http-body",
"httparse",
"httpdate",
"itoa",
@ -1818,8 +1689,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2"
dependencies = [
"futures-util",
"http 1.3.1",
"hyper 1.6.0",
"http",
"hyper",
"hyper-util",
"rustls",
"rustls-pki-types",
@ -1829,27 +1700,13 @@ dependencies = [
"webpki-roots",
]
[[package]]
name = "hyper-system-resolver"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6eea26c5d0b6ab9d72219f65000af310f042a740926f7b2fa3553e774036e2e7"
dependencies = [
"derive_builder",
"dns-lookup",
"hyper 0.14.32",
"tokio",
"tower-service",
"tracing",
]
[[package]]
name = "hyper-timeout"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0"
dependencies = [
"hyper 1.6.0",
"hyper",
"hyper-util",
"pin-project-lite",
"tokio",
@ -1865,12 +1722,12 @@ dependencies = [
"bytes",
"futures-channel",
"futures-util",
"http 1.3.1",
"http-body 1.0.1",
"hyper 1.6.0",
"http",
"http-body",
"hyper",
"libc",
"pin-project-lite",
"socket2 0.5.9",
"socket2",
"tokio",
"tower-service",
"tracing",
@ -2024,17 +1881,6 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "idna"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8"
dependencies = [
"matches",
"unicode-bidi",
"unicode-normalization",
]
[[package]]
name = "idna"
version = "1.0.3"
@ -2335,12 +2181,6 @@ dependencies = [
"tendril",
]
[[package]]
name = "matches"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5"
[[package]]
name = "matchit"
version = "0.7.3"
@ -2441,7 +2281,7 @@ dependencies = [
"bytes",
"encoding_rs",
"futures-util",
"http 1.3.1",
"http",
"httparse",
"memchr",
"mime",
@ -2986,27 +2826,6 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "public-ip"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b4c40db5262d93298c363a299f8bc1b3a956a78eecddba3bc0e58b76e2f419a"
dependencies = [
"dns-lookup",
"futures-core",
"futures-util",
"http 0.2.12",
"hyper 0.14.32",
"hyper-system-resolver",
"pin-project-lite",
"thiserror 1.0.69",
"tokio",
"tracing",
"tracing-futures",
"trust-dns-client",
"trust-dns-proto",
]
[[package]]
name = "quick_cache"
version = "0.5.2"
@ -3032,7 +2851,7 @@ dependencies = [
"quinn-udp",
"rustc-hash",
"rustls",
"socket2 0.5.9",
"socket2",
"thiserror 2.0.12",
"tokio",
"tracing",
@ -3068,7 +2887,7 @@ dependencies = [
"cfg_aliases",
"libc",
"once_cell",
"socket2 0.5.9",
"socket2",
"tracing",
"windows-sys 0.59.0",
]
@ -3284,10 +3103,10 @@ dependencies = [
"bytes",
"futures-core",
"futures-util",
"http 1.3.1",
"http-body 1.0.1",
"http",
"http-body",
"http-body-util",
"hyper 1.6.0",
"hyper",
"hyper-rustls",
"hyper-util",
"ipnet",
@ -3698,7 +3517,7 @@ version = "3.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d00caa5193a3c8362ac2b73be6b9e768aa5a4b2f721d8f4b339600c3cb51f8e"
dependencies = [
"darling 0.20.11",
"darling",
"proc-macro2",
"quote",
"syn 2.0.100",
@ -3830,16 +3649,6 @@ version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b6b67fb9a61334225b5b790716f609cd58395f895b3fe8b328786812a40bc3b"
[[package]]
name = "socket2"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "socket2"
version = "0.5.9"
@ -3940,12 +3749,6 @@ dependencies = [
"quote",
]
[[package]]
name = "strsim"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c"
[[package]]
name = "strsim"
version = "0.11.1"
@ -3998,7 +3801,6 @@ dependencies = [
"itertools 0.14.0",
"log",
"nanoid",
"public-ip",
"rand 0.8.5",
"serde",
"serde_json",
@ -4084,7 +3886,7 @@ dependencies = [
"geo",
"geo-types",
"hex",
"http 1.3.1",
"http",
"ipnet",
"jsonwebtoken",
"lexicmp",
@ -4122,7 +3924,7 @@ dependencies = [
"sha2",
"snap",
"storekey",
"strsim 0.11.1",
"strsim",
"subtle",
"sysinfo",
"thiserror 1.0.69",
@ -4373,7 +4175,7 @@ dependencies = [
"libc",
"mio",
"pin-project-lite",
"socket2 0.5.9",
"socket2",
"tokio-macros",
"windows-sys 0.52.0",
]
@ -4469,17 +4271,17 @@ dependencies = [
"base64 0.22.1",
"bytes",
"h2",
"http 1.3.1",
"http-body 1.0.1",
"http",
"http-body",
"http-body-util",
"hyper 1.6.0",
"hyper",
"hyper-timeout",
"hyper-util",
"percent-encoding",
"pin-project",
"prost",
"rustls-pemfile",
"socket2 0.5.9",
"socket2",
"tokio",
"tokio-rustls",
"tokio-stream",
@ -4581,18 +4383,6 @@ dependencies = [
"once_cell",
]
[[package]]
name = "tracing-futures"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
dependencies = [
"futures",
"futures-task",
"pin-project",
"tracing",
]
[[package]]
name = "trice"
version = "0.4.0"
@ -4604,51 +4394,6 @@ dependencies = [
"web-sys",
]
[[package]]
name = "trust-dns-client"
version = "0.20.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b4ef9b9bde0559b78a4abb00339143750085f05e5a453efb7b8bef1061f09dc"
dependencies = [
"cfg-if",
"data-encoding",
"futures-channel",
"futures-util",
"lazy_static",
"log",
"radix_trie",
"rand 0.8.5",
"thiserror 1.0.69",
"time",
"tokio",
"trust-dns-proto",
]
[[package]]
name = "trust-dns-proto"
version = "0.20.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca94d4e9feb6a181c690c4040d7a24ef34018d8313ac5044a61d21222ae24e31"
dependencies = [
"async-trait",
"cfg-if",
"data-encoding",
"enum-as-inner",
"futures-channel",
"futures-io",
"futures-util",
"idna 0.2.3",
"ipnet",
"lazy_static",
"log",
"rand 0.8.5",
"smallvec",
"thiserror 1.0.69",
"tinyvec",
"tokio",
"url",
]
[[package]]
name = "try-lock"
version = "0.2.5"
@ -4664,7 +4409,7 @@ dependencies = [
"byteorder",
"bytes",
"data-encoding",
"http 1.3.1",
"http",
"httparse",
"log",
"rand 0.8.5",
@ -4705,12 +4450,6 @@ version = "2.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539"
[[package]]
name = "unicode-bidi"
version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5"
[[package]]
name = "unicode-ident"
version = "1.0.18"
@ -4779,7 +4518,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60"
dependencies = [
"form_urlencoded",
"idna 1.0.3",
"idna",
"percent-encoding",
]

@ -23,7 +23,6 @@ thiserror = "2.0.12"
nanoid = "0.4.0"
dotenv = "0.15.0"
hex = "0.4.3"
public-ip = { version = "0.2.2", features = ["dns-resolver"] }
[profile.release]
lto = true

@ -32,6 +32,8 @@ async fn main() {
let db = db::db_connection(&db_url, &db_user, &db_pass, &db_ns, &db_name).await.unwrap();
let db_arc = Arc::new(db);
let addr = BRAIN_GRPC_ADDR.parse().unwrap();
let snp_daemon_server = BrainVmDaemonServer::new(VmDaemonServer::new(db_arc.clone()));
let snp_cli_server = BrainVmCliServer::new(VmCliServer::new(db_arc.clone()));
let general_service_server = BrainGeneralCliServer::new(GeneralCliServer::new(db_arc.clone()));
@ -53,7 +55,7 @@ async fn main() {
.add_service(general_service_server)
.add_service(sgx_daemon_server)
.add_service(sgx_cli_server)
.serve(*BRAIN_GRPC_ADDR)
.serve(addr)
.await
.unwrap();
}

@ -1,14 +1,6 @@
use std::{
net::{IpAddr, SocketAddr},
sync::LazyLock,
};
use tokio::sync::OnceCell;
use std::sync::LazyLock;
pub const BRAIN_GRPC_PORT: u16 = 31337;
pub static BRAIN_GRPC_ADDR: LazyLock<SocketAddr> = LazyLock::new(|| {
let ip = IpAddr::from([0, 0, 0, 0]);
SocketAddr::new(ip, BRAIN_GRPC_PORT)
});
pub const BRAIN_GRPC_ADDR: &str = "0.0.0.0:31337";
pub const CERT_PATH: &str = "/etc/detee/brain/brain-crt.pem";
pub const CERT_KEY_PATH: &str = "/etc/detee/brain/brain-key.pem";
@ -29,21 +21,6 @@ pub static ADMIN_ACCOUNTS: LazyLock<Vec<String>> = LazyLock::new(|| {
.unwrap_or(default_admin_keys)
});
pub static CURRENT_BRAIN_ENDPOINT: OnceCell<SocketAddr> = OnceCell::const_new();
pub async fn current_brain_endpoint() -> Result<SocketAddr, &'static str> {
if !CURRENT_BRAIN_ENDPOINT.initialized() {
let pub_ip = public_ip::addr().await.ok_or("Could not determine public IP")?;
let brain_endpoint = *CURRENT_BRAIN_ENDPOINT
.get_or_init(|| async { SocketAddr::new(pub_ip, BRAIN_GRPC_PORT) })
.await;
Ok(brain_endpoint)
} else {
let brain_endpoint = *CURRENT_BRAIN_ENDPOINT.get().unwrap_or(&BRAIN_GRPC_ADDR);
Ok(brain_endpoint)
}
}
pub const OLD_BRAIN_DATA_PATH: &str = "./saved_data.yaml";
pub const ACCOUNT: &str = "account";

@ -3,7 +3,7 @@ pub mod general;
pub mod types;
pub mod vm;
use crate::constants::{current_brain_endpoint, ADMIN_ACCOUNTS};
use crate::constants::ADMIN_ACCOUNTS;
use crate::db::prelude as db;
use detee_shared::app_proto::*;
use detee_shared::common_proto::{Empty, Pubkey};
@ -16,26 +16,21 @@ use surrealdb::engine::remote::ws::Client;
use surrealdb::{RecordId, Surreal};
use tonic::{Request, Status};
pub async fn set_pubsub_node(db: &Surreal<Client>, id: RecordId) {
match current_brain_endpoint().await {
Ok(public_endpoint) => {
let addr = public_endpoint.to_string();
match db
.query(format!("UPDATE $id SET pub_sub_node = '{addr}'",))
.bind(("id", id))
.await
pub async fn set_pubsub_node(db: &Surreal<Client>, local_addr: &str, id: RecordId) {
dbg!(&local_addr);
match db.query(format!("UPDATE $id SET pub_sub_node = '{local_addr}'",)).bind(("id", id)).await
{
Ok(res) => log::info!("Updated pub_sub_node {:?}", res),
Err(e) => log::error!("Could not update pub_sub_node {:?}", e),
}
}
_ => {
log::error!("Could not determine public brain endpoint. Using local one.");
}
}
}
pub async fn check_pubsub_node(db: &Surreal<Client>, id: RecordId) -> Result<String, db::Error> {
pub async fn check_pubsub_node(
db: &Surreal<Client>,
local_addr: &str,
id: RecordId,
) -> Result<String, db::Error> {
dbg!(&local_addr);
#[derive(Deserialize, Debug)]
struct PubSubNode {
pub pub_sub_node: String,
@ -46,13 +41,9 @@ pub async fn check_pubsub_node(db: &Surreal<Client>, id: RecordId) -> Result<Str
.ok_or(Status::internal("Could not get current brain endpoint"))?
.pub_sub_node;
let current_endpoint = crate::constants::current_brain_endpoint()
.await
.map_err(|_| Status::internal("Could not get current brain endpoint"))?;
dbg!(&local_addr, &node_endpoint);
dbg!(&current_endpoint, &node_endpoint);
if current_endpoint.to_string() == node_endpoint {
if local_addr == node_endpoint {
return Ok(node_endpoint);
}

@ -36,6 +36,7 @@ impl BrainVmDaemon for VmDaemonServer {
&self,
req: Request<RegisterVmNodeReq>,
) -> Result<Response<Self::RegisterVmNodeStream>, Status> {
let local_addr = req.local_addr().map(|addr| addr.to_string()).unwrap_or_default();
let req = check_sig_from_req(req)?;
info!("Starting registration process for {:?}", req);
let id = surrealdb::RecordId::from((VM_NODE, req.node_pubkey.clone()));
@ -59,7 +60,7 @@ impl BrainVmDaemon for VmDaemonServer {
}
.register(&self.db)
.await?;
set_pubsub_node(&self.db, id).await;
set_pubsub_node(&self.db, &local_addr, id).await;
info!("Sending deleted contracts to {}", req.node_pubkey);
let deleted_vms = db::DeletedVm::list_by_node(&self.db, &req.node_pubkey).await?;
@ -223,9 +224,11 @@ impl BrainVmCli for VmCliServer {
type ListVmNodesStream = Pin<Box<dyn Stream<Item = Result<VmNodeListResp, Status>> + Send>>;
async fn new_vm(&self, req: Request<NewVmReq>) -> Result<Response<NewVmResp>, Status> {
let local_addr = req.local_addr().map(|addr| addr.to_string()).unwrap_or_default();
let req = check_sig_from_req(req)?;
let id = surrealdb::RecordId::from((VM_NODE, req.node_pubkey.clone()));
check_pubsub_node(&self.db, id).await?;
check_pubsub_node(&self.db, &local_addr, id).await?;
// TODO: make it atleast 1 hour
if req.locked_nano < 100 {

@ -344,7 +344,7 @@ async fn test_pub_sub_redirect() {
let id = surrealdb::RecordId::from((VM_NODE, node_key.pubkey.clone()));
let endpoint = check_pubsub_node(&db, id).await;
let endpoint = check_pubsub_node(&db, "", id).await;
dbg!(&endpoint);
// let mut client_vm_cli = BrainVmCliClient::new(brain_channel.clone());