forked from navos/sheepd
📝 docs
This commit is contained in:
parent
a567214f58
commit
164c71ddfe
9 changed files with 36 additions and 2 deletions
|
@ -17,6 +17,7 @@ fn domain(host: &str) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
/// Join a herd as client
|
||||
pub fn join(conf: JoinCommand) {
|
||||
// TODO : check for root
|
||||
// TODO : check if joined somewhere already
|
||||
|
@ -34,7 +35,6 @@ pub fn join(conf: JoinCommand) {
|
|||
};
|
||||
|
||||
let url = format!("{}/join", domain(&conf.home));
|
||||
println!("{url}");
|
||||
let mut res = ureq::post(url)
|
||||
.send_json(&api::JoinParams {
|
||||
join_token: None,
|
||||
|
|
|
@ -2,12 +2,18 @@ use owl::{Deserialize, Serialize};
|
|||
|
||||
use crate::api::JoinResponse;
|
||||
|
||||
/// Client agent configuration at `/etc/sheepd/config.toml`
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct AgentConfig {
|
||||
/// Homeserver Domain
|
||||
pub home: String,
|
||||
/// Homeserver Token
|
||||
pub token: String,
|
||||
/// MQTT endpoint
|
||||
pub mqtt: String,
|
||||
/// Server Public Encryption Key
|
||||
pub server_age: String,
|
||||
/// Server Public Sign Key
|
||||
pub server_sign: String,
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@ use crate::{api, sheepd_core::config::AgentConfig};
|
|||
|
||||
use super::mqtt::send_back;
|
||||
|
||||
/// Report online status back to the server.
|
||||
/// By default every 60 seconds.
|
||||
pub async fn report_online(client: AsyncClient) {
|
||||
loop {
|
||||
send_back(&client, "online", json!(crate::api::Result::Ok())).await;
|
||||
|
@ -15,6 +17,7 @@ pub async fn report_online(client: AsyncClient) {
|
|||
}
|
||||
}
|
||||
|
||||
/// Start the daemon loop
|
||||
pub async fn start_daemon() {
|
||||
log::info!("Starting sheepd");
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ pub async fn handle_mqtt(topic: String, data: Vec<u8>) {
|
|||
);
|
||||
}
|
||||
|
||||
/// Send something back to the server on `topic`
|
||||
pub async fn send_back<T: Serialize>(client: &AsyncClient, topic: &str, request: T) {
|
||||
let data = serde_json::to_string(&request).unwrap();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue