mqtt connections

almost working, need encryption
This commit is contained in:
JMARyA 2025-04-28 23:33:11 +02:00
parent 20ab0153d1
commit 125d50530d
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
15 changed files with 1259 additions and 42 deletions
src/sheepd_core

View file

@ -1,16 +1,28 @@
use owl::{Deserialize, Serialize};
use crate::api::JoinResponse;
#[derive(Serialize, Deserialize)]
pub struct AgentConfig {
pub home: String,
pub token: String,
pub mqtt: String,
pub server_age: String,
pub server_sign: String,
}
impl AgentConfig {
pub fn new(home_server: &str, token: &str) -> Self {
pub fn try_load() -> Option<Self> {
toml::from_str(&std::fs::read_to_string("/etc/sheepd/config.toml").ok()?).ok()
}
pub fn new(home: &str, join: JoinResponse) -> Self {
Self {
home: home_server.to_string(),
token: token.to_string(),
token: join.token,
mqtt: join.mqtt,
home: home.to_string(),
server_age: join.identity.0,
server_sign: join.identity.1,
}
}
}