Add handling of gone, not blocked, resources
This commit is contained in:
parent
1adf145671
commit
292827fa63
|
@ -111,6 +111,15 @@ impl LoxServerContext {
|
|||
ba_obj.add_spare_bucket(bucket);
|
||||
}
|
||||
|
||||
pub fn replace_with_new(&self, bridgeline: BridgeLine) -> bool {
|
||||
let mut ba_obj = self.ba.lock().unwrap();
|
||||
let mut db_obj = self.db.lock().unwrap();
|
||||
let mut eb_obj = self.extra_bridges.lock().unwrap();
|
||||
let mut available_bridge = eb_obj.last();
|
||||
|
||||
ba_obj.bridge_replace(&bridgeline, available_bridge, &mut db_obj)
|
||||
|
||||
}
|
||||
pub fn add_unreachable(&self, bridgeline: BridgeLine) -> bool {
|
||||
let mut ba_obj = self.ba.lock().unwrap();
|
||||
let mut db_obj = self.db.lock().unwrap();
|
||||
|
|
|
@ -292,6 +292,12 @@ async fn context_manager(mut context_rx: mpsc::Receiver<Command>) {
|
|||
}
|
||||
}
|
||||
}
|
||||
// gone resources are not the same as blocked resources.
|
||||
// Instead, these are bridges which have either failed to pass tests for some period
|
||||
// or have expired bridge descriptors. In both cases, the bridge is unusable, but this
|
||||
// is not likely due to censorship. Therefore, we replace gone resources with new resources
|
||||
// TODO: create a notion of blocked resources from information collected through various means:
|
||||
// https://gitlab.torproject.org/tpo/anti-censorship/censorship-analysis/-/issues/40035
|
||||
if let Some(gone_resources) = resourcediff.gone {
|
||||
for pt in gone_resources {
|
||||
println!("A NEW GONE RESOURCE: {:?}", pt);
|
||||
|
@ -320,7 +326,7 @@ async fn context_manager(mut context_rx: mpsc::Receiver<Command>) {
|
|||
uid_fingerprint: resource_uid,
|
||||
info: info_bytes,
|
||||
};
|
||||
|
||||
/* // Marking bridges as unreachable is reserved for blocked bridges
|
||||
println!("BridgeLine to be removed: {:?}", bridgeline);
|
||||
let res = context.add_unreachable(bridgeline);
|
||||
if res {
|
||||
|
@ -332,12 +338,26 @@ async fn context_manager(mut context_rx: mpsc::Receiver<Command>) {
|
|||
println!("'Gone' BridgeLine NOT REMOVED!! : {:?}", bridgeline);
|
||||
//TODO probably do something else here
|
||||
}
|
||||
*/
|
||||
println!("BridgeLine to be replaced: {:?}", bridgeline);
|
||||
let res = context.replace_with_new(bridgeline);
|
||||
if res {
|
||||
println!(
|
||||
"BridgeLine successfully replaced: {:?}",
|
||||
bridgeline
|
||||
);
|
||||
} else {
|
||||
println!("'Gone' BridgeLine NOT replaced, marked removed!! : {:?}", bridgeline);
|
||||
//TODO probably do something else here
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
context.encrypt_table();
|
||||
sleep(Duration::from_millis(1)).await;
|
||||
}
|
||||
|
||||
Request { req, sender } => {
|
||||
let response = handle(context.clone(), req).await;
|
||||
if let Err(e) = sender.send(response) {
|
||||
|
|
Loading…
Reference in New Issue