broker, sphinx-key: remove variable session id

This commit is contained in:
irriden
2023-07-26 23:07:51 +00:00
parent 58f0f169dd
commit 39e7c3dab8
3 changed files with 6 additions and 10 deletions

View File

@@ -6,7 +6,7 @@ use std::collections::HashMap;
#[derive(Debug, Serialize, Deserialize)]
pub struct Connections {
pub pubkey: Option<String>,
pub clients: HashMap<String, String>,
pub clients: HashMap<String, bool>,
pub current: String,
}
@@ -25,12 +25,10 @@ impl Connections {
self.current = cid;
}
pub fn add_client(&mut self, cid: &str) {
let (value, key) = cid.split_once("_").expect("id is missing _ delimeter");
self.clients.insert(value.to_string(), key.to_string());
self.clients.insert(cid.to_string(), false);
}
pub fn remove_client(&mut self, cid: &str) {
let (value, _key) = cid.split_once("_").expect("id is missing _ delimeter");
self.clients.remove(value);
self.clients.remove(cid);
}
pub fn client_action(&mut self, cid: &str, connected: bool) {
if connected {

View File

@@ -177,13 +177,12 @@ fn pub_and_wait(
let mut rep = pub_timeout(&current, &msg.topic, &msg.message, &msg_rx, link_tx);
// If that failed, try looking for some other signer
if rep.is_none() {
for (id, session) in client_list.iter() {
let cid = format!("{}_{}", id, session);
for cid in client_list.keys() {
rep = pub_timeout(&cid, &msg.topic, &msg.message, &msg_rx, link_tx);
if rep.is_some() {
let mut cs = conns_.lock().unwrap();
log::debug!("got the list lock!");
cs.set_current(cid);
cs.set_current(cid.to_string());
drop(cs);
break;
}

View File

@@ -141,7 +141,7 @@ fn main() -> Result<()> {
fn make_and_launch_client(
config: Config,
seed: [u8; 32],
id: String,
client_id: String,
policy: &Policy,
velocity: &Option<Velocity>,
led_tx: mpsc::Sender<Status>,
@@ -166,7 +166,6 @@ fn make_and_launch_client(
let token = ctrlr.make_auth_token().expect("couldnt make auth token");
log::info!("PUBKEY {} TOKEN {}", &pubkey_str, &token);
let client_id = format!("{}_{}", id, random_word(8));
let mqtt_client =
conn::mqtt::make_client(&config.broker, &client_id, &pubkey_str, &token, tx.clone())?;
// let mqtt_client = conn::mqtt::start_listening(mqtt, connection, tx)?;