Add option to restrict positive reports to 1 per bridge per cred
This commit is contained in:
parent
d8a3f3b564
commit
bbf582078a
|
@ -55,6 +55,7 @@ pub struct Config {
|
||||||
pub num_days: u32,
|
pub num_days: u32,
|
||||||
// We start with this many level 4 users
|
// We start with this many level 4 users
|
||||||
pub num_initial_trusted_users: u32,
|
pub num_initial_trusted_users: u32,
|
||||||
|
pub one_positive_report_per_cred: bool,
|
||||||
pub prob_connection_fails: f64,
|
pub prob_connection_fails: f64,
|
||||||
pub prob_user_invites_friend: f64,
|
pub prob_user_invites_friend: f64,
|
||||||
pub prob_user_is_censor: f64,
|
pub prob_user_is_censor: f64,
|
||||||
|
@ -98,6 +99,7 @@ pub async fn main() {
|
||||||
censor_totality: config.censor_totality,
|
censor_totality: config.censor_totality,
|
||||||
censor_partial_blocking_percent: config.censor_partial_blocking_percent,
|
censor_partial_blocking_percent: config.censor_partial_blocking_percent,
|
||||||
country: config.country,
|
country: config.country,
|
||||||
|
one_positive_report_per_cred: config.one_positive_report_per_cred,
|
||||||
prob_connection_fails: config.prob_connection_fails,
|
prob_connection_fails: config.prob_connection_fails,
|
||||||
prob_user_invites_friend: config.prob_user_invites_friend,
|
prob_user_invites_friend: config.prob_user_invites_friend,
|
||||||
prob_user_is_censor: config.prob_user_is_censor,
|
prob_user_is_censor: config.prob_user_is_censor,
|
||||||
|
|
|
@ -97,6 +97,7 @@ impl Censor {
|
||||||
|| config.censor_speed == Speed::Random && self.delay_date <= get_date()
|
|| config.censor_speed == Speed::Random && self.delay_date <= get_date()
|
||||||
{
|
{
|
||||||
let bridge = bridges.get_mut(fingerprint).unwrap();
|
let bridge = bridges.get_mut(fingerprint).unwrap();
|
||||||
|
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
let num_connections = rng.gen_range(1000..30000);
|
let num_connections = rng.gen_range(1000..30000);
|
||||||
|
|
||||||
|
@ -107,11 +108,18 @@ impl Censor {
|
||||||
// positive reports
|
// positive reports
|
||||||
if self.has_lox_cred(fingerprint) {
|
if self.has_lox_cred(fingerprint) {
|
||||||
let lox_pub = get_lox_pub(&config.la_pubkeys);
|
let lox_pub = get_lox_pub(&config.la_pubkeys);
|
||||||
for _ in 0..num_connections {
|
let (cred, cred_count) =
|
||||||
|
&self.lox_credentials.get(&bridge.fingerprint).unwrap();
|
||||||
|
let num_prs = if config.one_positive_report_per_cred {
|
||||||
|
*cred_count
|
||||||
|
} else {
|
||||||
|
rng.gen_range(1000..30000)
|
||||||
|
};
|
||||||
|
for _ in 0..num_prs {
|
||||||
let pr = PositiveReport::from_lox_credential(
|
let pr = PositiveReport::from_lox_credential(
|
||||||
bridge.fingerprint,
|
bridge.fingerprint,
|
||||||
None,
|
None,
|
||||||
&self.lox_credentials.get(&bridge.fingerprint).unwrap().0,
|
cred,
|
||||||
lox_pub,
|
lox_pub,
|
||||||
config.country.clone(),
|
config.country.clone(),
|
||||||
)
|
)
|
||||||
|
|
|
@ -16,6 +16,7 @@ pub struct Config {
|
||||||
// We model only one country at a time because Lox assumes censors
|
// We model only one country at a time because Lox assumes censors
|
||||||
// share information with each other.
|
// share information with each other.
|
||||||
pub country: String,
|
pub country: String,
|
||||||
|
pub one_positive_report_per_cred: bool,
|
||||||
// Probability that a connection randomly fails, even though censor
|
// Probability that a connection randomly fails, even though censor
|
||||||
// does not block the bridge
|
// does not block the bridge
|
||||||
pub prob_connection_fails: f64,
|
pub prob_connection_fails: f64,
|
||||||
|
|
Loading…
Reference in New Issue