Skip to content

Commit

Permalink
Fix exit debts
Browse files Browse the repository at this point in the history
Exit debt computation has been broken since the commit "Add config
options for exit routing overhaul" due to confusion about mutable
references that somehow did not trigger rusts usuall warning about
unused mutated references.

This caused debts from the previous loop to not persist resulting in
client overbilling as each loop iteration they would be billed for
traffic from all previous loops.
  • Loading branch information
jkilpatr committed Mar 3, 2025
1 parent 9e3017f commit 35d030d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions rita_exit/src/rita_loop/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ pub async fn start_rita_exit_loop(client_and_ip_info: Arc<RwLock<ClientListAnIpA
babel_port,
start,
rita_exit_cache.get_all_registered_clients(),
rita_exit_cache.usage_history.clone(),
&mut rita_exit_cache.usage_history,
);
info!(
"Finished Rita billing in {}ms",
Expand Down Expand Up @@ -342,7 +342,7 @@ fn bill(
babel_port: u16,
start: Instant,
ids: HashSet<Identity>,
usage_history: HashMap<WgKey, WgUsage>,
usage_history: &mut HashMap<WgKey, WgUsage>,
) {
trace!("about to try opening babel stream");

Expand Down
4 changes: 2 additions & 2 deletions rita_exit/src/traffic_watcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ fn debts_logging(debts: &HashMap<Identity, i128>) {

/// This traffic watcher watches how much traffic each we send and receive from each client.
pub fn watch_exit_traffic(
mut usage_history: HashMap<WgKey, WgUsage>,
usage_history: &mut HashMap<WgKey, WgUsage>,
routes: &[Route],
clients: Vec<Identity>,
) -> Result<(), Box<RitaExitError>> {
Expand Down Expand Up @@ -194,7 +194,7 @@ pub fn watch_exit_traffic(
trace!("merged counters are : {:?}", counters);

// creates new usage entires does not actualy update the values
prepare_usage_history(&counters, &mut usage_history);
prepare_usage_history(&counters, usage_history);

counters_logging(&counters, &usage_history, our_price as u32);

Expand Down

0 comments on commit 35d030d

Please sign in to comment.