possible fixes
This commit is contained in:
parent
55a9993572
commit
8ef7757267
@ -25,16 +25,26 @@ do
|
||||
ip="172.17.0.${i}"
|
||||
random_key=$(curl -s "${ip}:31372" | grep true | tail -1 | awk '{ print $4 }')
|
||||
message="ValyDoesNotLikeMyCodeSoHeIsSilentAboutIt"
|
||||
mkdir -p .tmp
|
||||
status=$(curl -sG \
|
||||
-o /dev/null -w "%{http_code}\n" \
|
||||
-o .tmp/output -w "%{http_code}\n" \
|
||||
--data-urlencode "pubkey=${random_key}" \
|
||||
--data-urlencode "something=${message}" \
|
||||
"172.17.0.${i}:31372/sign")
|
||||
|
||||
if (( "$status" != "200" )); then
|
||||
echo Container at ip ${ip} could not sign string with key ${random_key}
|
||||
echo The status was $status
|
||||
echo The error was $(cat .tmp/output)
|
||||
echo Output of keys on 172.17.0.${i}:
|
||||
curl 172.17.0.${i}:31372
|
||||
father_of_key=$(curl 172.17.0.${i}:31372 | grep ${random_key} | awk '{ print $2 }')
|
||||
echo Output of keys on ${father_of_key}:
|
||||
curl ${father_of_key}:31372
|
||||
rm -rf .tmp
|
||||
exit 1
|
||||
fi
|
||||
|
||||
done
|
||||
echo OK!
|
||||
rm -rf .tmp
|
||||
|
@ -117,7 +117,8 @@ impl Store {
|
||||
None => return Err(SigningError::KeyNotFound),
|
||||
};
|
||||
|
||||
let signature = format!("{:?}", signing_key.sign(message.as_bytes()));
|
||||
// let signature = format!("{:?}", signing_key.sign(message.as_bytes()));
|
||||
let signature = hex::encode(signing_key.sign(message.as_bytes()).to_bytes());
|
||||
|
||||
Ok(signature)
|
||||
}
|
||||
@ -189,6 +190,16 @@ impl Store {
|
||||
|
||||
/// returns old pubkey if node got updated
|
||||
async fn update_node(&self, ip: String, info: NodeInfo) -> Option<NodeInfo> {
|
||||
// if let Some(old_node) = self.nodes.get(&ip) {
|
||||
// if SystemTime::now()
|
||||
// .duration_since(old_node.updated_at)
|
||||
// .unwrap_or(Duration::ZERO)
|
||||
// .as_secs()
|
||||
// < 50
|
||||
// {
|
||||
// return None;
|
||||
// }
|
||||
// }
|
||||
self.nodes.insert(ip, info.clone())
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ use crate::datastore::Store;
|
||||
use crate::grpc::challenge::update_client::UpdateClient;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::broadcast::Sender;
|
||||
use tokio::time::Duration;
|
||||
use tokio::time::{sleep, Duration};
|
||||
use tokio_stream::wrappers::BroadcastStream;
|
||||
use tokio_stream::StreamExt;
|
||||
|
||||
@ -23,14 +23,13 @@ impl ConnManager {
|
||||
}
|
||||
|
||||
pub async fn start(self) {
|
||||
let mut interval = tokio::time::interval(Duration::from_secs(3));
|
||||
loop {
|
||||
if let Some(node) = self.ds.get_random_node().await {
|
||||
if node != "localhost" {
|
||||
self.connect_wrapper(node.clone()).await;
|
||||
}
|
||||
}
|
||||
interval.tick().await;
|
||||
sleep(Duration::from_secs(3)).await;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,13 +9,12 @@ use std::fs::File;
|
||||
use std::io::{BufRead, BufReader};
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::broadcast;
|
||||
use tokio::time::Duration;
|
||||
use tokio::time::{sleep, Duration};
|
||||
|
||||
async fn cycle_keys(ds: Arc<Store>, tx: Sender<NodeUpdate>) {
|
||||
let mut interval = tokio::time::interval(Duration::from_secs(60));
|
||||
loop {
|
||||
let _ = tx.send(ds.reset_localhost_keys().await);
|
||||
interval.tick().await;
|
||||
sleep(Duration::from_secs(60)).await;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user