feat: added config for master node

This commit is contained in:
Strix 2023-10-15 18:06:28 +02:00
parent 1132f8c5fb
commit b3fb589e36
No known key found for this signature in database
GPG key ID: 49B2E37B8915B774

View file

@ -1,10 +1,14 @@
use serde::{Deserialize, Serialize};
use std::fmt::{Display, Formatter};
use domo_proto::packet::identifier::Identifier;
#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum NodeType {
#[serde(rename = "master")]
Master,
Master {
bind: String,
identifier: String
},
#[serde(rename = "relay")]
Relay {
master_address: String
@ -18,7 +22,7 @@ pub enum NodeType {
impl Display for NodeType {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
NodeType::Master => write!(f, "master"),
NodeType::Master { .. } => write!(f, "master"),
NodeType::Relay { .. } => write!(f, "relay"),
NodeType::Subnet { .. } => write!(f, "subnet"),
}
@ -27,7 +31,10 @@ impl Display for NodeType {
impl Default for NodeType {
fn default() -> Self {
Self::Master
Self::Master {
bind: String::from("0.0.0.0:4480"),
identifier: hex::encode(Identifier::random().to_string())
}
}
}