|
@@ -134,15 +134,20 @@ pub async fn main() {
|
|
|
// Level trusted users up to level 4
|
|
|
|
|
|
// Advance LA's time
|
|
|
- la_net_test
|
|
|
+ let result = la_net_test
|
|
|
.request(
|
|
|
"/advancedays".to_string(),
|
|
|
serde_json::to_string(&(UNTRUSTED_INTERVAL as u16))
|
|
|
.unwrap()
|
|
|
.into(),
|
|
|
)
|
|
|
- .await
|
|
|
- .unwrap();
|
|
|
+ .await;
|
|
|
+ if result.is_ok() {
|
|
|
+ result.unwrap();
|
|
|
+ } else {
|
|
|
+ eprintln!("Failed to advance time for LA");
|
|
|
+ }
|
|
|
+
|
|
|
// Advance simulated time
|
|
|
set_simulated_date(get_date() + UNTRUSTED_INTERVAL);
|
|
|
|
|
@@ -170,15 +175,20 @@ pub async fn main() {
|
|
|
|
|
|
for i in 1..LEVEL_INTERVAL.len() - 2 {
|
|
|
// Advance LA's time
|
|
|
- la_net_test
|
|
|
+ let result = la_net_test
|
|
|
.request(
|
|
|
"/advancedays".to_string(),
|
|
|
serde_json::to_string(&(LEVEL_INTERVAL[i] as u16))
|
|
|
.unwrap()
|
|
|
.into(),
|
|
|
)
|
|
|
- .await
|
|
|
- .unwrap();
|
|
|
+ .await;
|
|
|
+ if result.is_ok() {
|
|
|
+ result.unwrap();
|
|
|
+ } else {
|
|
|
+ eprintln!("Failed to advance time for LA");
|
|
|
+ }
|
|
|
+
|
|
|
// Advance simulated time
|
|
|
set_simulated_date(get_date() + LEVEL_INTERVAL[i]);
|
|
|
|
|
@@ -186,16 +196,20 @@ pub async fn main() {
|
|
|
let reachcred_res = get_bucket(&sconfig.la_net, &user.primary_cred).await;
|
|
|
if reachcred_res.is_ok() {
|
|
|
let reachcred = reachcred_res.unwrap().1;
|
|
|
- let new_cred = level_up(
|
|
|
- &sconfig.la_net,
|
|
|
- &user.primary_cred,
|
|
|
- &reachcred.unwrap(),
|
|
|
- get_lox_pub(&sconfig.la_pubkeys),
|
|
|
- get_reachability_pub(&sconfig.la_pubkeys),
|
|
|
- )
|
|
|
- .await;
|
|
|
- if new_cred.is_ok() {
|
|
|
- user.primary_cred = new_cred.unwrap();
|
|
|
+ if reachcred.is_some() {
|
|
|
+ let new_cred = level_up(
|
|
|
+ &sconfig.la_net,
|
|
|
+ &user.primary_cred,
|
|
|
+ &reachcred.unwrap(),
|
|
|
+ get_lox_pub(&sconfig.la_pubkeys),
|
|
|
+ get_reachability_pub(&sconfig.la_pubkeys),
|
|
|
+ )
|
|
|
+ .await;
|
|
|
+ if new_cred.is_ok() {
|
|
|
+ user.primary_cred = new_cred.unwrap();
|
|
|
+ } else {
|
|
|
+ eprintln!("Failed to level up trusted user's credential at start");
|
|
|
+ }
|
|
|
} else {
|
|
|
eprintln!("Failed to level up trusted user's credential at start");
|
|
|
}
|
|
@@ -204,13 +218,17 @@ pub async fn main() {
|
|
|
}
|
|
|
|
|
|
// Advance LA's time to tomorrow
|
|
|
- la_net_test
|
|
|
+ let result = la_net_test
|
|
|
.request(
|
|
|
"/advancedays".to_string(),
|
|
|
serde_json::to_string(&(1 as u16)).unwrap().into(),
|
|
|
)
|
|
|
- .await
|
|
|
- .unwrap();
|
|
|
+ .await;
|
|
|
+ if result.is_ok() {
|
|
|
+ result.unwrap();
|
|
|
+ } else {
|
|
|
+ eprintln!("Failed to advance time for LA");
|
|
|
+ }
|
|
|
|
|
|
// Advance simulated time to tomorrow
|
|
|
increment_simulated_date();
|
|
@@ -243,6 +261,11 @@ pub async fn main() {
|
|
|
" The censor has learned {} bridges",
|
|
|
censor.known_bridges.len()
|
|
|
);
|
|
|
+ println!(" Accuracy thus far:");
|
|
|
+ println!(" True Positives: {}", true_pos);
|
|
|
+ println!(" True Negatives: {}", true_neg);
|
|
|
+ println!(" False Positives: {}", false_pos);
|
|
|
+ println!(" False Negatives: {}", false_neg);
|
|
|
|
|
|
if let Some(usage) = memory_stats() {
|
|
|
if usage.physical_mem > max_physical_mem {
|
|
@@ -364,21 +387,36 @@ pub async fn main() {
|
|
|
}
|
|
|
|
|
|
// Publish all the bridges' extra-infos for today
|
|
|
- extra_infos_net
|
|
|
+ let result = extra_infos_net
|
|
|
.request(
|
|
|
"/add".to_string(),
|
|
|
serde_json::to_string(&new_extra_infos).unwrap().into(),
|
|
|
)
|
|
|
- .await
|
|
|
- .unwrap();
|
|
|
+ .await;
|
|
|
+ if result.is_ok() {
|
|
|
+ result.unwrap();
|
|
|
+ } else {
|
|
|
+ eprintln!("Failed to publish new extra-infos");
|
|
|
+ }
|
|
|
|
|
|
// TROLL PATROL TASKS
|
|
|
- let new_blockages_resp = tp_net_test
|
|
|
- .request("/update".to_string(), vec![])
|
|
|
- .await
|
|
|
- .unwrap();
|
|
|
- let new_blockages: HashMap<String, HashSet<String>> =
|
|
|
- serde_json::from_slice(&new_blockages_resp).unwrap();
|
|
|
+ let new_blockages_resp = tp_net_test.request("/update".to_string(), vec![]).await;
|
|
|
+ let new_blockages = match new_blockages_resp {
|
|
|
+ Ok(resp) => match serde_json::from_slice(&resp) {
|
|
|
+ Ok(new_blockages) => new_blockages,
|
|
|
+ Err(e) => {
|
|
|
+ eprintln!("Failed to deserialize new blockages, error: {}", e);
|
|
|
+ HashMap::<String, HashSet<String>>::new()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ Err(e) => {
|
|
|
+ eprintln!(
|
|
|
+ "Failed to get new blockages from Troll Patrol, error: {}",
|
|
|
+ e
|
|
|
+ );
|
|
|
+ HashMap::<String, HashSet<String>>::new()
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
// Since we have only one censor, just convert to a set of bridges
|
|
|
let mut blocked_bridges = HashSet::<[u8; 20]>::new();
|
|
@@ -417,13 +455,17 @@ pub async fn main() {
|
|
|
// LOX AUTHORITY TASKS
|
|
|
|
|
|
// Advance LA's time to tomorrow
|
|
|
- la_net_test
|
|
|
+ let result = la_net_test
|
|
|
.request(
|
|
|
"/advancedays".to_string(),
|
|
|
serde_json::to_string(&(1 as u16)).unwrap().into(),
|
|
|
)
|
|
|
- .await
|
|
|
- .unwrap();
|
|
|
+ .await;
|
|
|
+ if result.is_ok() {
|
|
|
+ result.unwrap();
|
|
|
+ } else {
|
|
|
+ eprintln!("Failed to advance time for LA");
|
|
|
+ }
|
|
|
|
|
|
// SIMULATION TASKS
|
|
|
|