author
int64
658
755k
date
stringlengths
19
19
timezone
int64
-46,800
43.2k
hash
stringlengths
40
40
message
stringlengths
5
490
mods
list
language
stringclasses
20 values
license
stringclasses
3 values
repo
stringlengths
5
68
original_message
stringlengths
12
491
20,253
07.02.2022 09:57:05
28,800
ef4f83b49863f7189c37a2afdd964044a5d483b8
migrating traffic watcher to async/await
[ { "change_type": "MODIFY", "old_path": "rita_common/src/rita_loop/fast_loop.rs", "new_path": "rita_common/src/rita_loop/fast_loop.rs", "diff": "@@ -9,7 +9,7 @@ use crate::payment_validator::validate;\nuse crate::peer_listener::get_peers;\nuse crate::peer_listener::tick;\nuse crate::tm_trigger_gc;\n-use crate::traffic_watcher::{TrafficWatcher, Watch};\n+use crate::traffic_watcher::watch;\nuse crate::tunnel_manager::gc::TriggerGc;\nuse crate::tunnel_manager::tm_contact_peers;\nuse crate::tunnel_manager::tm_get_neighbors;\n@@ -113,10 +113,7 @@ impl Handler<Tick> for RitaFastLoop {\n.and_then(move |stream| {\nstart_connection_legacy(stream).and_then(move |stream| {\nparse_routes_legacy(stream).and_then(move |routes| {\n- TrafficWatcher::from_registry()\n- .send(Watch::new(neighbors, routes.1))\n- .timeout(FAST_LOOP_TIMEOUT)\n- .then(move |_res| {\n+ let _res = watch(routes.1, &neighbors);\ninfo!(\n\"TrafficWatcher completed in {}s {}ms\",\nneigh.elapsed().as_secs(),\n@@ -126,7 +123,6 @@ impl Handler<Tick> for RitaFastLoop {\n})\n})\n})\n- })\n.then(|ret| {\nif let Err(e) = ret {\nerror!(\"Failed to watch client traffic with {:?}\", e)\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/rita_loop/mod.rs", "new_path": "rita_common/src/rita_loop/mod.rs", "diff": "//! halt essential functions like opening tunnels and managing peers\nuse crate::network_endpoints::*;\n+use crate::traffic_watcher::init_traffic_watcher;\nuse actix::SystemService;\nuse actix_web::http::Method;\nuse actix_web::{server, App};\n@@ -74,8 +75,8 @@ pub fn start_core_rita_endpoints(workers: usize) {\n}\npub fn check_rita_common_actors() {\n+ init_traffic_watcher();\nassert!(crate::hello_handler::HelloHandler::from_registry().connected());\n- assert!(crate::traffic_watcher::TrafficWatcher::from_registry().connected());\nassert!(crate::rita_loop::fast_loop::RitaFastLoop::from_registry().connected());\ncrate::rita_loop::slow_loop::start_rita_slow_loop();\ncrate::rita_loop::fast_loop::start_rita_fast_loop();\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/traffic_watcher/mod.rs", "new_path": "rita_common/src/traffic_watcher/mod.rs", "diff": "@@ -10,7 +10,6 @@ use crate::usage_tracker::UpdateUsage;\nuse crate::usage_tracker::UsageType;\nuse crate::RitaCommonError;\nuse crate::KI;\n-use actix::{Actor, Context, Handler, Message, Supervised, SystemService};\nuse althea_kernel_interface::open_tunnel::is_link_local;\nuse althea_kernel_interface::FilterTarget;\nuse althea_types::Identity;\n@@ -23,27 +22,6 @@ use std::net::IpAddr;\n#[derive(Default)]\npub struct TrafficWatcher;\n-impl Actor for TrafficWatcher {\n- type Context = Context<Self>;\n-}\n-\n-impl Supervised for TrafficWatcher {}\n-\n-impl SystemService for TrafficWatcher {\n- fn service_started(&mut self, _ctx: &mut Context<Self>) {\n- KI.init_counter(&FilterTarget::Input)\n- .expect(\"Is ipset installed?\");\n- KI.init_counter(&FilterTarget::Output)\n- .expect(\"Is ipset installed?\");\n- KI.init_counter(&FilterTarget::ForwardInput)\n- .expect(\"Is ipset installed?\");\n- KI.init_counter(&FilterTarget::ForwardOutput)\n- .expect(\"Is ipset installed?\");\n-\n- info!(\"Traffic Watcher started\");\n- }\n-}\n-\npub struct Watch {\n/// List of neighbors to watch\npub neighbors: Vec<Neighbor>,\n@@ -56,16 +34,17 @@ impl Watch {\n}\n}\n-impl Message for Watch {\n- type Result = Result<(), RitaCommonError>;\n-}\n-\n-impl Handler<Watch> for TrafficWatcher {\n- type Result = Result<(), RitaCommonError>;\n+pub fn init_traffic_watcher() {\n+ KI.init_counter(&FilterTarget::Input)\n+ .expect(\"Is ipset installed?\");\n+ KI.init_counter(&FilterTarget::Output)\n+ .expect(\"Is ipset installed?\");\n+ KI.init_counter(&FilterTarget::ForwardInput)\n+ .expect(\"Is ipset installed?\");\n+ KI.init_counter(&FilterTarget::ForwardOutput)\n+ .expect(\"Is ipset installed?\");\n- fn handle(&mut self, msg: Watch, _: &mut Context<Self>) -> Self::Result {\n- watch(msg.routes, &msg.neighbors)\n- }\n+ info!(\"Traffic Watcher started\");\n}\npub fn prepare_helper_maps(\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
migrating traffic watcher to async/await
20,255
08.02.2022 11:53:57
28,800
5534c6bce9f5ee73538eacb7dc98d50065e440fe
Migrated Exit endpoints to async/await
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -3281,12 +3281,15 @@ dependencies = [\nname = \"rita_exit\"\nversion = \"0.19.1\"\ndependencies = [\n+ \"actix 0.12.0\",\n\"actix 0.7.11\",\n\"actix-web 0.7.19\",\n+ \"actix-web 4.0.0-beta.20\",\n\"actix-web-httpauth\",\n\"althea_kernel_interface\",\n\"althea_types\",\n\"arrayvec 0.7.2\",\n+ \"awc\",\n\"babel_monitor\",\n\"babel_monitor_legacy\",\n\"clarity\",\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/Cargo.toml", "new_path": "rita_exit/Cargo.toml", "diff": "@@ -16,6 +16,8 @@ althea_types = { path = \"../althea_types\" }\nsettings = { path = \"../settings\" }\nbabel_monitor = { path = \"../babel_monitor\" }\nactix = \"0.7\"\n+actix-async = { package = \"actix\", version = \"0.12\"}\n+awc = \"3.0.0-beta.18\"\nhandlebars = \"4.0\"\nrand = \"0.8.0\"\nlazy_static = \"1.4\"\n@@ -35,6 +37,7 @@ exit_db = { path = \"../exit_db\" }\nbabel_monitor_legacy = {path = \"../babel_monitor_legacy\"}\nactix-web-httpauth = {git = \"https://github.com/althea-net/actix-web-httpauth\"}\nactix-web = { version = \"0.7\", default_features = false, features= [\"ssl\"] }\n+actix-web-async = {package=\"actix-web\", version = \"4.0.0-beta.8\", default_features = false, features= [\"openssl\"] }\ndiesel = { version = \"1.4\", features = [\"postgres\", \"r2d2\"] }\nfutures01 = { package = \"futures\", version = \"0.1\"}\n[features]\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/database_tools.rs", "new_path": "rita_exit/src/database/database_tools.rs", "diff": "@@ -13,8 +13,6 @@ use diesel::r2d2::ConnectionManager;\nuse diesel::r2d2::PooledConnection;\nuse diesel::select;\nuse exit_db::{models, schema};\n-use futures01::future;\n-use futures01::future::Future;\nuse std::net::IpAddr;\nuse std::net::Ipv4Addr;\n@@ -314,20 +312,14 @@ pub fn update_mail_sent_time(\n/// Gets the Postgres database connection from the threadpool, since there are dedicated\n/// connections for each threadpool member error if non is available right away\npub fn get_database_connection(\n-) -> impl Future<Item = PooledConnection<ConnectionManager<PgConnection>>, Error = RitaExitError> {\n+) -> Result<PooledConnection<ConnectionManager<PgConnection>>, RitaExitError> {\nmatch DB_POOL.read().unwrap().try_get() {\n- Some(connection) => Box::new(future::ok(connection))\n- as Box<\n- dyn Future<\n- Item = PooledConnection<ConnectionManager<PgConnection>>,\n- Error = RitaExitError,\n- >,\n- >,\n+ Some(connection) => Ok(connection),\nNone => {\nerror!(\"No available db connection!\");\n- Box::new(future::err(RitaExitError::MiscStringError(\n+ Err(RitaExitError::MiscStringError(\n\"No Database connection available!\".to_string(),\n- )))\n+ ))\n}\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/db_client.rs", "new_path": "rita_exit/src/database/db_client.rs", "diff": "use actix::Actor;\n-use actix::Arbiter;\nuse actix::Context;\nuse actix::Handler;\nuse actix::Message;\n@@ -9,7 +8,6 @@ use actix_web::Result;\nuse diesel::dsl::delete;\nuse diesel::*;\nuse exit_db::schema;\n-use futures01::future::Future;\nuse crate::database::database_tools::get_database_connection;\nuse crate::RitaExitError;\n@@ -39,14 +37,8 @@ impl Handler<TruncateTables> for DbClient {\nfn handle(&mut self, _: TruncateTables, _: &mut Self::Context) -> Self::Result {\nuse self::schema::clients::dsl::*;\ninfo!(\"Deleting all clients in database\");\n- Arbiter::spawn(\n- get_database_connection()\n- .and_then(|connection| {\n+ let connection = get_database_connection()?;\n(delete(clients).execute(&connection).unwrap());\n- Ok(())\n- })\n- .then(|_| Ok(())),\n- );\nOk(())\n}\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/email.rs", "new_path": "rita_exit/src/database/email.rs", "diff": "@@ -8,8 +8,6 @@ use crate::RitaExitError;\nuse althea_types::{ExitClientDetails, ExitClientIdentity, ExitState};\nuse diesel::prelude::PgConnection;\nuse exit_db::models;\n-use futures01::future;\n-use futures01::future::Future;\nuse handlebars::Handlebars;\nuse lettre::file::FileTransport;\nuse lettre::smtp::authentication::{Credentials, Mechanism};\n@@ -74,14 +72,14 @@ pub fn handle_email_registration(\ntheir_record: &exit_db::models::Client,\nconn: &PgConnection,\ncooldown: i64,\n-) -> impl Future<Item = ExitState, Error = RitaExitError> {\n+) -> Result<ExitState, RitaExitError> {\nlet mut their_record = their_record.clone();\nif client.reg_details.email_code == Some(their_record.email_code.clone()) {\ninfo!(\"email verification complete for {:?}\", client);\nmatch verify_client(client, true, conn) {\nOk(_) => (),\n- Err(e) => return future::err(e),\n+ Err(e) => return Err(e),\n}\ntheir_record.verified = true;\n}\n@@ -91,9 +89,9 @@ pub fn handle_email_registration(\nlet client_internal_ip = match their_record.internal_ip.parse() {\nOk(ip) => ip,\n- Err(e) => return future::err(RitaExitError::AddrParseError(e)),\n+ Err(e) => return Err(RitaExitError::AddrParseError(e)),\n};\n- future::ok(ExitState::Registered {\n+ Ok(ExitState::Registered {\nour_details: ExitClientDetails { client_internal_ip },\ngeneral_details: get_exit_info(),\nmessage: \"Registration OK\".to_string(),\n@@ -102,7 +100,7 @@ pub fn handle_email_registration(\nlet time_since_last_email = secs_since_unix_epoch() - their_record.email_sent_time;\nif time_since_last_email < cooldown {\n- future::ok(ExitState::GotInfo {\n+ Ok(ExitState::GotInfo {\ngeneral_details: get_exit_info(),\nmessage: format!(\n\"Wait {} more seconds for verification cooldown\",\n@@ -112,13 +110,13 @@ pub fn handle_email_registration(\n} else {\nmatch update_mail_sent_time(client, conn) {\nOk(_) => (),\n- Err(e) => return future::err(e),\n+ Err(e) => return Err(e),\n}\nmatch send_mail(&their_record) {\nOk(_) => (),\n- Err(e) => return future::err(e),\n+ Err(e) => return Err(e),\n}\n- future::ok(ExitState::Pending {\n+ Ok(ExitState::Pending {\ngeneral_details: get_exit_info(),\nmessage: \"awaiting email verification\".to_string(),\nemail_code: None,\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/geoip.rs", "new_path": "rita_exit/src/database/geoip.rs", "diff": "+use babel_monitor::open_babel_stream;\n+use babel_monitor::parse_routes;\nuse babel_monitor_legacy::open_babel_stream_legacy;\nuse babel_monitor_legacy::parse_routes_legacy;\nuse babel_monitor_legacy::start_connection_legacy;\n-use futures01::future;\nuse futures01::future::Future;\nuse ipnetwork::IpNetwork;\nuse rita_common::utils::ip_increment::is_unicast_link_local;\n@@ -19,23 +20,15 @@ lazy_static! {\n}\n/// gets the gateway ip for a given mesh IP\n-pub fn get_gateway_ip_single(\n- mesh_ip: IpAddr,\n-) -> Box<dyn Future<Item = IpAddr, Error = RitaExitError>> {\n+pub fn get_gateway_ip_single(mesh_ip: IpAddr) -> Result<IpAddr, RitaExitError> {\nlet babel_port = settings::get_rita_exit().network.babel_port;\n- Box::new(\n- open_babel_stream_legacy(babel_port)\n- .from_err()\n- .and_then(move |stream| {\n- start_connection_legacy(stream)\n- .from_err()\n- .and_then(move |stream| {\n- parse_routes_legacy(stream)\n- .from_err()\n- .and_then(move |routes| {\n+ match open_babel_stream(babel_port, Duration::from_secs(5)) {\n+ Ok(mut stream) => {\n+ match parse_routes(&mut stream) {\n+ Ok(routes) => {\nlet mut route_to_des = None;\n- for route in routes.1.iter() {\n+ for route in routes.iter() {\n// Only ip6\nif let IpNetwork::V6(ref ip) = route.prefix {\n// Only host addresses and installed routes\n@@ -52,10 +45,22 @@ pub fn get_gateway_ip_single(\nSome(route) => Ok(KI.get_wg_remote_ip(&route.iface)?),\nNone => Err(RitaExitError::IpAddrError(mesh_ip)),\n}\n- })\n- })\n- }),\n- )\n+ }\n+ Err(e) => {\n+ return Err(RitaExitError::MiscStringError(format!(\n+ \"Parse routes babel monitor error, {:?}\",\n+ e\n+ )))\n+ }\n+ }\n+ }\n+ Err(e) => {\n+ return Err(RitaExitError::MiscStringError(format!(\n+ \"Error opening babel stream, {:?}\",\n+ e\n+ )));\n+ }\n+ }\n}\n#[derive(Debug, Clone, Copy)]\n@@ -141,10 +146,10 @@ struct CountryDetails {\niso_code: String,\n}\n-pub fn get_country_async(ip: IpAddr) -> impl Future<Item = String, Error = RitaExitError> {\n+pub fn get_country_async(ip: IpAddr) -> Result<String, RitaExitError> {\nmatch get_country(ip) {\n- Ok(res) => future::ok(res),\n- Err(e) => future::err(e),\n+ Ok(res) => Ok(res),\n+ Err(e) => Err(e),\n}\n}\n@@ -233,10 +238,10 @@ pub fn get_country(ip: IpAddr) -> Result<String, RitaExitError> {\n/// Returns true or false if an ip is confirmed to be inside or outside the region and error\n/// if an api error is encountered trying to figure that out.\n-pub fn verify_ip(request_ip: IpAddr) -> impl Future<Item = bool, Error = RitaExitError> {\n+pub fn verify_ip(request_ip: IpAddr) -> Result<bool, RitaExitError> {\nmatch verify_ip_sync(request_ip) {\n- Ok(item) => future::ok(item),\n- Err(e) => future::err(e),\n+ Ok(item) => Ok(item),\n+ Err(e) => Err(e),\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/mod.rs", "new_path": "rita_exit/src/database/mod.rs", "diff": "@@ -29,8 +29,7 @@ use althea_kernel_interface::ExitClient;\nuse althea_types::Identity;\nuse althea_types::{ExitClientDetails, ExitClientIdentity, ExitDetails, ExitState, ExitVerifMode};\nuse diesel::prelude::PgConnection;\n-use futures01::future;\n-use futures01::Future;\n+\nuse ipnetwork::IpNetwork;\nuse rita_common::blockchain_oracle::get_oracle_close_thresh;\nuse rita_common::debt_keeper::get_debts_list;\n@@ -106,79 +105,73 @@ pub fn secs_since_unix_epoch() -> i64 {\n/// Handles a new client registration api call. Performs a geoip lookup\n/// on their registration ip to make sure that they are coming from a valid gateway\n/// ip and then sends out an email of phone message\n-pub fn signup_client(\n- client: ExitClientIdentity,\n-) -> impl Future<Item = ExitState, Error = RitaExitError> {\n+pub async fn signup_client(client: ExitClientIdentity) -> Result<ExitState, RitaExitError> {\ninfo!(\"got setup request {:?}\", client);\n- get_gateway_ip_single(client.global.mesh_ip).and_then(move |gateway_ip| {\n+ let gateway_ip = get_gateway_ip_single(client.global.mesh_ip)?;\ninfo!(\"got gateway ip {:?}\", client);\n- verify_ip(gateway_ip).and_then(move |verify_status| {\n+\n+ let verify_status = verify_ip(gateway_ip)?;\ninfo!(\"verified the ip country {:?}\", client);\n- get_country_async(gateway_ip).and_then(move |user_country| {\n+\n+ let user_country = get_country_async(gateway_ip)?;\ninfo!(\"got the country {:?}\", client);\n- get_database_connection().and_then(move |conn| {\n- info!(\"Doing database work for {:?} in country {} with verify_status {}\", client, user_country, verify_status);\n+\n+ let conn = get_database_connection()?;\n+\n+ info!(\n+ \"Doing database work for {:?} in country {} with verify_status {}\",\n+ client, user_country, verify_status\n+ );\n// check if we have any users with conflicting details\n+\nmatch client_conflict(&client, &conn) {\nOk(true) => {\n- return Box::new(future::ok(ExitState::Denied {\n+ return Ok(ExitState::Denied {\nmessage: format!(\n\"Partially changed registration details! Please reset your router and re-register with all new details. Backup your key first! {}\",\ndisplay_hashset(&*EXIT_ALLOWED_COUNTRIES),\n),\n- }))\n- as Box<dyn Future<Item = ExitState, Error = RitaExitError>>\n- }\n+ })\n+ },\nOk(false) => {}\n- Err(e) => return Box::new(future::err(e)),\n+ Err(e) => return Err(e),\n}\n- let their_record =\n- match create_or_update_user_record(&conn, &client, user_country) {\n+ let their_record = match create_or_update_user_record(&conn, &client, user_country) {\nOk(record) => record,\n- Err(e) => return Box::new(future::err(e)),\n+ Err(e) => return Err(e),\n};\n// either update and grab an existing entry or create one\nmatch (verify_status, EXIT_VERIF_SETTINGS.clone()) {\n(true, Some(ExitVerifSettings::Email(mailer))) => {\n- Box::new(handle_email_registration(\n- &client,\n- &their_record,\n- &conn,\n- mailer.email_cooldown as i64,\n- ))\n+ handle_email_registration(&client, &their_record, &conn, mailer.email_cooldown as i64)\n+ }\n+ (true, Some(ExitVerifSettings::Phone(phone))) => {\n+ handle_sms_registration(client, their_record, phone.auth_api_key).await\n}\n- (true, Some(ExitVerifSettings::Phone(phone))) => Box::new(\n- handle_sms_registration(client, their_record, phone.auth_api_key),\n- ),\n(true, None) => {\nmatch verify_client(&client, true, &conn) {\nOk(_) => (),\n- Err(e) => return Box::new(future::err(e)),\n+ Err(e) => return Err(e),\n}\nlet client_internal_ip = match their_record.internal_ip.parse() {\nOk(ip) => ip,\n- Err(e) => return Box::new(future::err(RitaExitError::AddrParseError(e))),\n+ Err(e) => return Err(RitaExitError::AddrParseError(e)),\n};\n-\n- Box::new(future::ok(ExitState::Registered {\n+ Ok(ExitState::Registered {\nour_details: ExitClientDetails { client_internal_ip },\ngeneral_details: get_exit_info(),\nmessage: \"Registration OK\".to_string(),\n- }))\n+ })\n}\n- (false, _) => Box::new(future::ok(ExitState::Denied {\n+ (false, _) => Ok(ExitState::Denied {\nmessage: format!(\n\"This exit only accepts connections from {}\",\ndisplay_hashset(&*EXIT_ALLOWED_COUNTRIES),\n),\n- })),\n+ }),\n}\n- })\n- })\n- })\n- })\n}\n/// Gets the status of a client and updates it in the database\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/sms.rs", "new_path": "rita_exit/src/database/sms.rs", "diff": "@@ -5,12 +5,7 @@ use crate::database::get_exit_info;\nuse crate::database::struct_tools::texts_sent;\nuse crate::RitaExitError;\n-use actix_web::client as actix_client;\n-use actix_web::client::ClientResponse;\nuse althea_types::{ExitClientDetails, ExitClientIdentity, ExitState};\n-use futures01::future;\n-use futures01::future::Either;\n-use futures01::future::Future;\nuse phonenumber::PhoneNumber;\nuse settings::exit::ExitVerifSettings;\nuse std::time::Duration;\n@@ -25,33 +20,36 @@ pub struct SmsCheck {\n/// Posts to the validation endpoint with the code, will return success if the code\n/// is the same as the one sent to the user\n-fn check_text(\n- number: String,\n- code: String,\n- api_key: String,\n-) -> impl Future<Item = bool, Error = RitaExitError> {\n+async fn check_text(number: String, code: String, api_key: String) -> Result<bool, RitaExitError> {\ntrace!(\"About to check text message status for {}\", number);\nlet number: PhoneNumber = match number.parse() {\nOk(number) => number,\n- Err(e) => return Either::A(future::err(e.into())),\n+ Err(e) => return Err(e.into()),\n};\nlet url = \"https://api.authy.com/protected/json/phones/verification/check\";\n- Either::B(\n- actix_client::get(&url)\n- .form(&SmsCheck {\n+\n+ let client = awc::Client::default();\n+ let response = match client\n+ .get(url)\n+ .send_form(&SmsCheck {\napi_key,\nverification_code: code,\nphone_number: number.national().to_string(),\ncountry_code: number.code().value().to_string(),\n})\n- .unwrap()\n- .send()\n- .from_err()\n- .and_then(|value| {\n- trace!(\"Got {} back from check text\", value.status());\n- Ok(value.status().is_success())\n- }),\n- )\n+ .await\n+ {\n+ Ok(a) => a,\n+ Err(e) => {\n+ return Err(RitaExitError::MiscStringError(format!(\n+ \"Send request error: {:?}\",\n+ e\n+ )))\n+ }\n+ };\n+\n+ trace!(\"Got {} back from check text\", response.status());\n+ Ok(response.status().is_success())\n}\n#[derive(Serialize)]\n@@ -63,36 +61,41 @@ pub struct SmsRequest {\n}\n/// Sends the authy verification text by hitting the api endpoint\n-fn send_text(\n- number: String,\n- api_key: String,\n-) -> impl Future<Item = ClientResponse, Error = RitaExitError> {\n+async fn send_text(number: String, api_key: String) -> Result<(), RitaExitError> {\ninfo!(\"Sending message for {}\", number);\nlet url = \"https://api.authy.com/protected/json/phones/verification/start\";\nlet number: PhoneNumber = match number.parse() {\nOk(number) => number,\n- Err(e) => return Either::A(future::err(e.into())),\n+ Err(e) => return Err(e.into()),\n};\n- Either::B(\n- actix_client::post(&url)\n- .form(&SmsRequest {\n+\n+ let client = awc::Client::default();\n+ match client\n+ .post(url)\n+ .send_form(&SmsRequest {\napi_key,\nvia: \"sms\".to_string(),\nphone_number: number.national().to_string(),\ncountry_code: number.code().value().to_string(),\n})\n- .unwrap()\n- .send()\n- .from_err(),\n- )\n+ .await\n+ {\n+ Ok(_a) => Ok(()),\n+ Err(e) => {\n+ return Err(RitaExitError::MiscStringError(format!(\n+ \"Send text error: {:?}\",\n+ e\n+ )))\n+ }\n+ }\n}\n/// Handles the minutia of phone registration states\n-pub fn handle_sms_registration(\n+pub async fn handle_sms_registration(\nclient: ExitClientIdentity,\ntheir_record: exit_db::models::Client,\napi_key: String,\n-) -> impl Future<Item = ExitState, Error = RitaExitError> {\n+) -> Result<ExitState, RitaExitError> {\ninfo!(\n\"Handling phone registration for {}\",\nclient.global.wg_public_key\n@@ -106,11 +109,10 @@ pub fn handle_sms_registration(\n) {\n// all texts exhausted, but they can still submit the correct code\n(Some(number), Some(code), true) => {\n- Box::new(check_text(number, code, api_key).and_then(move |result| {\n- get_database_connection().and_then(move |conn| {\n+ let result = check_text(number, code, api_key).await?;\n+ let conn = get_database_connection()?;\nif result {\nverify_client(&client, true, &conn)?;\n-\ninfo!(\n\"Phone registration complete for {}\",\nclient.global.wg_public_key\n@@ -130,20 +132,18 @@ pub fn handle_sms_registration(\nphone_code: None,\n})\n}\n- })\n- })) as Box<dyn Future<Item = ExitState, Error = RitaExitError>>\n}\n// user has exhausted attempts but is still not submitting code\n- (Some(_number), None, true) => Box::new(future::ok(ExitState::Pending {\n+ (Some(_number), None, true) => Ok(ExitState::Pending {\ngeneral_details: get_exit_info(),\nmessage: \"awaiting phone verification\".to_string(),\nemail_code: None,\nphone_code: None,\n- })),\n+ }),\n// user has attempts remaining and is requesting the code be resent\n(Some(number), None, false) => {\n- Box::new(send_text(number, api_key).and_then(move |_result| {\n- get_database_connection().and_then(move |conn| {\n+ let _res = send_text(number, api_key).await?;\n+ let conn = get_database_connection()?;\ntext_sent(&client, &conn, text_num)?;\nOk(ExitState::Pending {\ngeneral_details: get_exit_info(),\n@@ -151,17 +151,15 @@ pub fn handle_sms_registration(\nemail_code: None,\nphone_code: None,\n})\n- })\n- })) as Box<dyn Future<Item = ExitState, Error = RitaExitError>>\n}\n// user has attempts remaining and is submitting a code\n(Some(number), Some(code), false) => {\n- Box::new(check_text(number, code, api_key).and_then(move |result| {\n- get_database_connection().and_then(move |conn| {\n+ let result = check_text(number, code, api_key).await?;\n+ let conn = get_database_connection()?;\n+\ntrace!(\"Check text returned {}\", result);\nif result {\nverify_client(&client, true, &conn)?;\n-\ninfo!(\n\"Phone registration complete for {}\",\nclient.global.wg_public_key\n@@ -181,13 +179,11 @@ pub fn handle_sms_registration(\nphone_code: None,\n})\n}\n- })\n- })) as Box<dyn Future<Item = ExitState, Error = RitaExitError>>\n}\n// user did not submit a phonenumber\n- (None, _, _) => Box::new(future::ok(ExitState::Denied {\n+ (None, _, _) => Ok(ExitState::Denied {\nmessage: \"This exit requires a phone number to register!\".to_string(),\n- })) as Box<dyn Future<Item = ExitState, Error = RitaExitError>>,\n+ }),\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/network_endpoints/mod.rs", "new_path": "rita_exit/src/network_endpoints/mod.rs", "diff": "@@ -12,14 +12,12 @@ use crate::rita_exit::database::db_client::TruncateTables;\nuse actix::SystemService;\n#[cfg(feature = \"development\")]\nuse actix_web::AsyncResponder;\n-use actix_web::{HttpRequest, HttpResponse, Json, Result};\n+use actix_web_async::{http::StatusCode, web::Json, HttpRequest, HttpResponse, Result};\nuse althea_types::Identity;\nuse althea_types::WgKey;\nuse althea_types::{\nEncryptedExitClientIdentity, EncryptedExitState, ExitClientIdentity, ExitState,\n};\n-use futures01::future;\n-use futures01::Future;\nuse num256::Int256;\nuse rita_common::debt_keeper::get_debts_list;\nuse sodiumoxide::crypto::box_;\n@@ -49,7 +47,7 @@ fn secure_setup_return(\nenum DecryptResult {\nSuccess(ExitClientIdentity),\n- Failure(Box<dyn Future<Item = Json<EncryptedExitState>, Error = RitaExitError>>),\n+ Failure(Result<Json<EncryptedExitState>, RitaExitError>),\n}\nfn decrypt_exit_client_id(\n@@ -72,11 +70,11 @@ fn decrypt_exit_client_id(\nlet state = ExitState::Denied {\nmessage: \"could not decrypt your message!\".to_string(),\n};\n- return DecryptResult::Failure(Box::new(future::ok(secure_setup_return(\n+ return DecryptResult::Failure(Ok(secure_setup_return(\nstate,\nour_secretkey,\ntheir_nacl_pubkey,\n- ))));\n+ )));\n}\n};\n@@ -90,11 +88,11 @@ fn decrypt_exit_client_id(\nlet state = ExitState::Denied {\nmessage: \"could not decrypt your message!\".to_string(),\n};\n- return DecryptResult::Failure(Box::new(future::ok(secure_setup_return(\n+ return DecryptResult::Failure(Ok(secure_setup_return(\nstate,\nour_secretkey,\ntheir_nacl_pubkey,\n- ))));\n+ )));\n}\n};\n@@ -108,20 +106,20 @@ fn decrypt_exit_client_id(\nlet state = ExitState::Denied {\nmessage: \"could not deserialize your message!\".to_string(),\n};\n- return DecryptResult::Failure(Box::new(future::ok(secure_setup_return(\n+ return DecryptResult::Failure(Ok(secure_setup_return(\nstate,\nour_secretkey,\ntheir_nacl_pubkey,\n- ))));\n+ )));\n}\n};\nDecryptResult::Success(decrypted_id)\n}\n-pub fn secure_setup_request(\n+pub async fn secure_setup_request(\nrequest: (Json<EncryptedExitClientIdentity>, HttpRequest),\n-) -> Box<dyn Future<Item = Json<EncryptedExitState>, Error = RitaExitError>> {\n+) -> HttpResponse {\nlet our_secretkey: WgKey = *EXIT_WG_PRIVATE_KEY;\nlet our_secretkey = our_secretkey.into();\n@@ -130,34 +128,25 @@ pub fn secure_setup_request(\nlet socket = request.1;\nlet decrypted_id = match decrypt_exit_client_id(request.0.into_inner(), &our_secretkey) {\nDecryptResult::Success(val) => val,\n- DecryptResult::Failure(val) => {\n- return val;\n- }\n+ DecryptResult::Failure(val) => match val {\n+ Ok(val) => return HttpResponse::Ok().json(val),\n+ Err(_) => return HttpResponse::InternalServerError().finish(),\n+ },\n};\ninfo!(\"Received Encrypted setup request from, {}\", their_wg_pubkey);\n- let remote_mesh_socket: SocketAddr = match socket.connection_info().remote() {\n- Some(val) => match val.parse() {\n- Ok(val) => val,\n- Err(e) => {\n- error!(\n- \"Error in exit setup for {} malformed packet header {:?}!\",\n- their_wg_pubkey, e\n- );\n- return Box::new(future::err(RitaExitError::MiscStringError(\n- \"Invalid packet!\".to_string(),\n- )));\n- }\n- },\n+ let remote_mesh_socket: SocketAddr = match socket.peer_addr() {\n+ Some(val) => val,\nNone => {\nerror!(\n- \"Error in exit setup for {} invalid remote_mesh_sender!\",\n- their_wg_pubkey\n+ \"Error in exit setup for {} malformed packet header!\",\n+ their_wg_pubkey,\n);\n- return Box::new(future::err(RitaExitError::MiscStringError(\n- \"Invalid packet!\".to_string(),\n- )));\n+ return HttpResponse::build(StatusCode::INTERNAL_SERVER_ERROR).json(format!(\n+ \"Error in exit setup for {} malformed packet header!\",\n+ their_wg_pubkey\n+ ));\n}\n};\n@@ -166,34 +155,32 @@ pub fn secure_setup_request(\nlet remote_mesh_ip = remote_mesh_socket.ip();\nif remote_mesh_ip == client_mesh_ip {\n- Box::new(signup_client(client).then(move |result| match result {\n- Ok(exit_state) => Ok(secure_setup_return(\n+ let result = signup_client(client).await;\n+ match result {\n+ Ok(exit_state) => HttpResponse::Ok().json(secure_setup_return(\nexit_state,\n&our_secretkey,\ntheir_nacl_pubkey,\n)),\nErr(e) => {\nerror!(\"Signup client failed with {:?}\", e);\n- Err(RitaExitError::MiscStringError(\n- \"There was an internal server error!\".to_string(),\n- ))\n+ return HttpResponse::build(StatusCode::INTERNAL_SERVER_ERROR)\n+ .json(format!(\"Signup client failed with {:?}\", e));\n+ }\n}\n- }))\n} else {\nlet state = ExitState::Denied {\nmessage: \"The request ip does not match the signup ip\".to_string(),\n};\n- Box::new(future::ok(secure_setup_return(\n+ HttpResponse::Ok().json(secure_setup_return(\nstate,\n&our_secretkey,\ntheir_nacl_pubkey,\n- )))\n+ ))\n}\n}\n-pub fn secure_status_request(\n- request: Json<EncryptedExitClientIdentity>,\n-) -> Box<dyn Future<Item = Json<EncryptedExitState>, Error = RitaExitError>> {\n+pub fn secure_status_request(request: Json<EncryptedExitClientIdentity>) -> HttpResponse {\nlet our_secretkey: WgKey = *EXIT_WG_PRIVATE_KEY;\nlet our_secretkey = our_secretkey.into();\n@@ -201,13 +188,20 @@ pub fn secure_status_request(\nlet their_nacl_pubkey = request.pubkey.into();\nlet decrypted_id = match decrypt_exit_client_id(request.into_inner(), &our_secretkey) {\nDecryptResult::Success(val) => val,\n- DecryptResult::Failure(val) => {\n- return val;\n- }\n+ DecryptResult::Failure(val) => match val {\n+ Ok(val) => return HttpResponse::Ok().json(val),\n+ Err(_) => return HttpResponse::InternalServerError().finish(),\n+ },\n};\ntrace!(\"got status request from {}\", their_wg_pubkey);\n- Box::new(get_database_connection().and_then(move |conn| {\n+ let conn = match get_database_connection() {\n+ Ok(conn) => conn,\n+ Err(e) => {\n+ return HttpResponse::build(StatusCode::INTERNAL_SERVER_ERROR)\n+ .json(format!(\"Error getting database connection: {:?}\", e))\n+ }\n+ };\nlet state = match client_status(decrypted_id, &conn) {\nOk(state) => state,\nErr(e) => {\n@@ -215,24 +209,24 @@ pub fn secure_status_request(\n\"Internal error in client status for {} with {:?}\",\ntheir_wg_pubkey, e\n);\n- return Err(RitaExitError::MiscStringError(\n- \"There was an internal error!\".to_string(),\n+ return HttpResponse::build(StatusCode::INTERNAL_SERVER_ERROR).json(format!(\n+ \"Internal error in client status for {} with {:?}\",\n+ their_wg_pubkey, e\n));\n}\n};\n- Ok(secure_setup_return(\n+ HttpResponse::Ok().json(secure_setup_return(\nstate,\n&our_secretkey,\ntheir_nacl_pubkey,\n))\n- }))\n}\n-pub fn get_exit_info_http(_req: HttpRequest) -> Json<ExitState> {\n- Json(ExitState::GotInfo {\n+pub fn get_exit_info_http(_req: HttpRequest) -> HttpResponse {\n+ HttpResponse::Ok().json(Json(ExitState::GotInfo {\ngeneral_details: get_exit_info(),\nmessage: \"Got info successfully\".to_string(),\n- })\n+ }))\n}\n/// Used by clients to get their debt from the exits. While it is in theory possible for the\n@@ -253,9 +247,9 @@ pub fn get_client_debt(client: Json<Identity>) -> HttpResponse {\n}\n#[cfg(not(feature = \"development\"))]\n-pub fn nuke_db(_req: HttpRequest) -> Result<HttpResponse, RitaExitError> {\n+pub fn nuke_db(_req: actix_web::HttpRequest) -> Result<actix_web::HttpResponse, RitaExitError> {\n// This is returned on production builds.\n- Ok(HttpResponse::NotFound().finish())\n+ Ok(actix_web::HttpResponse::NotFound().finish())\n}\n#[cfg(feature = \"development\")]\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/rita_loop/mod.rs", "new_path": "rita_exit/src/rita_loop/mod.rs", "diff": "@@ -21,8 +21,8 @@ use crate::traffic_watcher::{TrafficWatcher, Watch};\nuse actix::Addr;\nuse actix::System;\nuse actix::SystemService;\n-use actix_web::http::Method;\n-use actix_web::{server, App};\n+use actix_async::System as AsyncSystem;\n+use actix_web_async::{web, App, HttpServer};\nuse althea_kernel_interface::ExitClient;\nuse althea_types::Identity;\nuse babel_monitor_legacy::open_babel_stream_legacy;\n@@ -260,21 +260,16 @@ pub fn check_rita_exit_actors() {\n}\npub fn start_rita_exit_endpoints(workers: usize) {\n+ thread::spawn(move || {\n+ let runner = AsyncSystem::new();\n+ runner.block_on(async move {\n// Exit stuff, huge threadpool to offset Pgsql blocking\n- server::new(|| {\n+ let _res = HttpServer::new(|| {\nApp::new()\n- .resource(\"/secure_setup\", |r| {\n- r.method(Method::POST).with(secure_setup_request)\n- })\n- .resource(\"/secure_status\", |r| {\n- r.method(Method::POST).with(secure_status_request)\n- })\n- .resource(\"/exit_info\", |r| {\n- r.method(Method::GET).with(get_exit_info_http)\n- })\n- .resource(\"/client_debt\", |r| {\n- r.method(Method::POST).with(get_client_debt)\n- })\n+ .route(\"/secure_setup\", web::post().to(secure_setup_request))\n+ .route(\"/secure_status\", web::post().to(secure_status_request))\n+ .route(\"/exit_info\", web::get().to(get_exit_info_http))\n+ .route(\"/client_debt\", web::post().to(get_client_debt))\n})\n.workers(workers)\n.bind(format!(\n@@ -283,5 +278,8 @@ pub fn start_rita_exit_endpoints(workers: usize) {\n))\n.unwrap()\n.shutdown_timeout(0)\n- .start();\n+ .run()\n+ .await;\n+ });\n+ });\n}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Migrated Exit endpoints to async/await
20,255
04.02.2022 10:43:58
28,800
cb9a12b88e5cf0f7125b292e70be54aa142d2c66
Migrated Rita common and client endpoints and light client manager to async/await Rita Client endpoint had light client manager, so that module was also migrated to async/await
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -3203,6 +3203,7 @@ dependencies = [\n\"actix 0.12.0\",\n\"actix 0.7.11\",\n\"actix-web 0.7.19\",\n+ \"actix-web 4.0.0-beta.20\",\n\"althea_kernel_interface\",\n\"althea_types\",\n\"antenna_forwarding_client\",\n@@ -3243,6 +3244,7 @@ dependencies = [\n\"actix 0.12.0\",\n\"actix 0.7.11\",\n\"actix-web 0.7.19\",\n+ \"actix-web 4.0.0-beta.20\",\n\"actix-web-httpauth\",\n\"althea_kernel_interface\",\n\"althea_types\",\n" }, { "change_type": "MODIFY", "old_path": "rita_client/Cargo.toml", "new_path": "rita_client/Cargo.toml", "diff": "@@ -39,6 +39,7 @@ awc = \"3.0.0-beta.18\"\nipnetwork = \"0.18\"\nactix-async = {package=\"actix\", version = \"0.12\"}\nactix-web = { version = \"0.7\", default_features = false, features= [\"ssl\"] }\n+actix-web-async = { package=\"actix-web\", version = \"4.0.0-beta.8\", default_features = false, features= [\"openssl\"]}\nclarity = \"0.5\"\n[lib]\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/light_client_manager/mod.rs", "new_path": "rita_client/src/light_client_manager/mod.rs", "diff": "//! especially since the client traffic exits unencrypted at one point on the participating Rita Client router. Sadly this is unavoidable as\n//! far as I can tell due to the restrictive nature of how and when Android allows ipv6 routing.\n-use actix::{Actor, Context, Handler, Message, Supervised, SystemService};\n-use actix_web::http::StatusCode;\n-use actix_web::{HttpRequest, HttpResponse, Json};\n+use actix_web_async::http::StatusCode;\n+use actix_web_async::{web::Json, HttpRequest, HttpResponse};\nuse althea_kernel_interface::wg_iface_counter::prepare_usage_history;\nuse althea_kernel_interface::wg_iface_counter::WgUsage;\nuse althea_types::{Identity, LightClientLocalIdentity, LocalIdentity, WgKey};\n-use futures01::future::Either;\n-use futures01::{future, Future};\nuse rita_common::debt_keeper::traffic_update;\nuse rita_common::debt_keeper::Traffic;\nuse rita_common::peer_listener::Peer;\n@@ -19,15 +16,19 @@ use rita_common::tunnel_manager::id_callback::IdentityCallback;\nuse rita_common::tunnel_manager::Tunnel;\nuse rita_common::utils::ip_increment::incrementv4;\nuse rita_common::{tm_identity_callback, KI};\n-use std::boxed::Box;\nuse std::collections::HashMap;\nuse std::collections::HashSet;\nuse std::net::Ipv4Addr;\n-use std::net::SocketAddr;\n+use std::sync::{Arc, RwLock};\nuse crate::traffic_watcher::get_exit_dest_price;\nuse crate::RitaClientError;\n+lazy_static! {\n+ static ref LIGHT_CLIENT_MANAGER: Arc<RwLock<LightClientManager>> =\n+ Arc::new(RwLock::new(LightClientManager::default()));\n+}\n+\n/// Sets up a variant of the exit tunnel nat rules, assumes that the exit\n/// tunnel is already created and doesn't change the system routing table\nfn setup_light_client_forwarding(client_addr: Ipv4Addr, nic: &str) -> Result<(), RitaClientError> {\n@@ -68,64 +69,36 @@ fn setup_light_client_forwarding(client_addr: Ipv4Addr, nic: &str) -> Result<(),\n/// Response to the light_client_hello endpoint on the Rita client module with a modified hello packet\n/// this modified packet includes an ipv4 address and opens a modified tunnel that is attached to the\n/// phone network bridge into a natted ipv4 network rather than into a Babel network.\n-pub fn light_client_hello_response(\n- req: (Json<LocalIdentity>, HttpRequest),\n-) -> Box<dyn Future<Item = HttpResponse, Error = RitaClientError>> {\n+pub async fn light_client_hello_response(req: (Json<LocalIdentity>, HttpRequest)) -> HttpResponse {\nlet their_id = *req.0;\n- let a = LightClientManager::from_registry().send(GetAddress(their_id));\n+ let light_client_address = lcm_get_address(GetAddress(their_id));\nlet exit_dest_price = get_exit_dest_price();\n- Box::new(a.from_err().and_then(move |light_client_address| {\nlet err_mesg = \"Malformed light client hello tcp packet!\";\n- let socket = match req.1.connection_info().remote() {\n- Some(val) => match val.parse::<SocketAddr>() {\n- Ok(val) => val,\n- Err(e) => {\n- error!(\"{}\", e);\n- return Either::A(future::ok(\n- HttpResponse::new(StatusCode::INTERNAL_SERVER_ERROR)\n- .into_builder()\n- .json(err_mesg),\n- ));\n- }\n- },\n+ let socket = match req.1.peer_addr() {\n+ Some(val) => val,\nNone => {\nerror!(\"{}\", err_mesg);\n- return Either::A(future::ok(\n- HttpResponse::new(StatusCode::INTERNAL_SERVER_ERROR)\n- .into_builder()\n- .json(err_mesg),\n- ));\n+ return HttpResponse::build(StatusCode::INTERNAL_SERVER_ERROR).json(err_mesg);\n}\n};\n-\nlet (light_client_address_option, light_client_address) = match light_client_address {\nOk(addr) => (Some(addr), addr),\nErr(e) => {\nlet err_mesg = \"Could not allocate address!\";\nerror!(\"{} {}\", err_mesg, e);\n- return Either::A(future::ok(\n- HttpResponse::new(StatusCode::INTERNAL_SERVER_ERROR)\n- .into_builder()\n- .json(err_mesg),\n- ));\n+ return HttpResponse::build(StatusCode::INTERNAL_SERVER_ERROR).json(err_mesg);\n}\n};\n-\n- trace!(\n- \"Got light client Hello from {:?}\",\n- req.1.connection_info().remote()\n- );\n+ trace!(\"Got light client Hello from {:?}\", req.1.peer_addr());\ntrace!(\n\"opening tunnel in light_client_hello_response for {:?}\",\ntheir_id\n);\n-\nlet peer = Peer {\ncontact_socket: socket,\nifidx: 0, // only works because we lookup ifname in kernel interface\n};\n-\nlet tunnel = tm_identity_callback(IdentityCallback::new(\ntheir_id,\npeer,\n@@ -136,11 +109,7 @@ pub fn light_client_hello_response(\nSome(val) => val,\nNone => {\nerror!(\"Light Client Manager: tunnel open failure!\");\n- return Either::A(future::ok(\n- HttpResponse::new(StatusCode::INTERNAL_SERVER_ERROR)\n- .into_builder()\n- .json(err_mesg),\n- ));\n+ return HttpResponse::build(StatusCode::INTERNAL_SERVER_ERROR).json(err_mesg);\n}\n};\nlet lci = LightClientLocalIdentity {\n@@ -148,11 +117,7 @@ pub fn light_client_hello_response(\nSome(id) => id,\nNone => {\nerror!(\"Light Client Manager: Identity has no mesh IP ready yet\");\n- return Either::A(future::ok(\n- HttpResponse::new(StatusCode::INTERNAL_SERVER_ERROR)\n- .into_builder()\n- .json(err_mesg),\n- ));\n+ return HttpResponse::build(StatusCode::INTERNAL_SERVER_ERROR).json(err_mesg);\n}\n},\nwg_port: tunnel.listen_port,\n@@ -169,26 +134,19 @@ pub fn light_client_hello_response(\n// true true only case where we don't need to run this\nif let Some(they_have_tunnel) = their_id.have_tunnel {\nif !(have_tunnel && they_have_tunnel) {\n- if let Err(e) =\n- setup_light_client_forwarding(light_client_address, &tunnel.iface_name)\n+ if let Err(e) = setup_light_client_forwarding(light_client_address, &tunnel.iface_name)\n{\nerror!(\"Light Client Manager: {}\", e);\n- return Either::A(future::ok(\n- HttpResponse::new(StatusCode::INTERNAL_SERVER_ERROR)\n- .into_builder()\n- .json(err_mesg),\n- ));\n+ return HttpResponse::build(StatusCode::INTERNAL_SERVER_ERROR).json(err_mesg);\n}\n}\n} else {\nerror!(\"Light clients should never send the none tunnel option!\");\n}\n- let response = HttpResponse::Ok().json(lci);\n// We send the callback, which can safely allocate a port because it already successfully\n// contacted a neighbor. The exception to this is when the TCP session fails at exactly\n// the wrong time.\n- Either::B(future::ok(response))\n- }))\n+ HttpResponse::Ok().json(lci)\n}\npub struct LightClientManager {\n@@ -209,38 +167,18 @@ impl Default for LightClientManager {\n}\n}\n-impl Actor for LightClientManager {\n- type Context = Context<Self>;\n-\n- fn started(&mut self, _ctx: &mut Context<Self>) {\n- info!(\"Started LightClientManager\")\n- }\n-}\n-\n-impl Supervised for LightClientManager {}\n-impl SystemService for LightClientManager {\n- fn service_started(&mut self, _ctx: &mut Context<Self>) {}\n-}\n-\npub struct GetAddress(LocalIdentity);\n-impl Message for GetAddress {\n- type Result = Result<Ipv4Addr, RitaClientError>;\n-}\n-\n-impl Handler<GetAddress> for LightClientManager {\n- type Result = Result<Ipv4Addr, RitaClientError>;\n-\n- fn handle(&mut self, msg: GetAddress, _: &mut Context<Self>) -> Self::Result {\n+pub fn lcm_get_address(msg: GetAddress) -> Result<Ipv4Addr, RitaClientError> {\n+ let lcm = &mut *LIGHT_CLIENT_MANAGER.write().unwrap();\nlet requester_id = msg.0;\nassign_client_address(\n- &mut self.assigned_addresses,\n+ &mut lcm.assigned_addresses,\nrequester_id.global,\n- self.start_address,\n- self.prefix,\n+ lcm.start_address,\n+ lcm.prefix,\n)\n}\n-}\nfn assign_client_address(\nassigned_addresses: &mut HashMap<Identity, Ipv4Addr>,\n@@ -323,14 +261,8 @@ pub struct Watch {\npub exit_dest_price: u128,\n}\n-impl Message for Watch {\n- type Result = ();\n-}\n-\n-impl Handler<Watch> for LightClientManager {\n- type Result = ();\n-\n- fn handle(&mut self, msg: Watch, _: &mut Context<Self>) -> Self::Result {\n+pub fn lcm_watch(msg: Watch) {\n+ let lcm = &mut *LIGHT_CLIENT_MANAGER.write().unwrap();\ntrace!(\"Starting light client traffic watcher\");\nlet our_price =\nsettings::get_rita_client().payment.light_client_fee as u128 + msg.exit_dest_price;\n@@ -339,14 +271,14 @@ impl Handler<Watch> for LightClientManager {\nfor tunnel in tunnels.iter() {\nif let Some(_val) = tunnel.light_client_details {\nif let Ok(counter) = KI.read_wg_counters(&tunnel.iface_name) {\n- prepare_usage_history(&counter, &mut self.last_seen_bytes);\n+ prepare_usage_history(&counter, &mut lcm.last_seen_bytes);\n// there should only be one, more than one client on a single\n// interface is not supported\nassert!(counter.len() == 1);\n// get only the first element\nlet (key, usage) = counter.iter().next().unwrap();\n// unwrap is safe before prepare usage history will ensure an entry exits\n- let last_seen_usage = self.last_seen_bytes.get_mut(key).unwrap();\n+ let last_seen_usage = lcm.last_seen_bytes.get_mut(key).unwrap();\nlet round_upload = usage.upload - last_seen_usage.upload;\nlet round_download = usage.download - last_seen_usage.download;\n*last_seen_usage = *usage;\n@@ -355,7 +287,6 @@ impl Handler<Watch> for LightClientManager {\n}\n}\n}\n-\nlet mut traffic_vec = Vec::new();\nfor (from, amount) in debts {\ntraffic_vec.push(Traffic {\n@@ -364,10 +295,8 @@ impl Handler<Watch> for LightClientManager {\n})\n}\ntraffic_update(traffic_vec);\n-\n// tunnel address garbage collection\n- return_addresses(&tunnels, &mut self.assigned_addresses);\n- }\n+ return_addresses(&tunnels, &mut lcm.assigned_addresses);\n}\n/// inserts and also negates since negative means they owe us and we can never owe phone clients\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/rita_loop/mod.rs", "new_path": "rita_client/src/rita_loop/mod.rs", "diff": "use crate::exit_manager::exit_manager_tick;\nuse crate::heartbeat::send_udp_heartbeat;\nuse crate::heartbeat::HEARTBEAT_SERVER_KEY;\n+use crate::light_client_manager::lcm_watch;\nuse crate::light_client_manager::light_client_hello_response;\n-use crate::light_client_manager::LightClientManager;\nuse crate::light_client_manager::Watch;\nuse crate::operator_fee_manager::tick_operator_payments;\nuse crate::operator_update::operator_update;\nuse crate::traffic_watcher::get_exit_dest_price;\n-use crate::RitaClientError;\n-use actix::{\n- Actor, ActorContext, Addr, Arbiter, AsyncContext, Context, Handler, Message, Supervised,\n- System, SystemService,\n-};\n+use actix::System;\nuse actix_async::System as AsyncSystem;\n-use actix_web::http::Method;\n-use actix_web::{server, App};\n+use actix_web_async::web;\n+use actix_web_async::{App, HttpServer};\nuse althea_kernel_interface::KI;\nuse althea_types::ExitState;\nuse antenna_forwarding_client::start_antenna_forwarding_proxy;\n-use futures01::future::Future;\nuse rita_common::rita_loop::set_gateway;\nuse rita_common::tunnel_manager::tm_get_neighbors;\nuse rita_common::tunnel_manager::tm_get_tunnels;\n@@ -33,6 +28,11 @@ use std::sync::atomic::{AtomicBool, Ordering};\nuse std::thread;\nuse std::time::{Duration, Instant};\n+use crate::RitaClientError;\n+use actix::{\n+ Actor, ActorContext, Addr, AsyncContext, Context, Handler, Message, Supervised, SystemService,\n+};\n+\nlazy_static! {\n/// see the comment on check_for_gateway_client_billing_corner_case()\n/// to identify why this variable is needed. In short it identifies\n@@ -62,13 +62,13 @@ pub fn metrics_permitted() -> bool {\n.is_some()\n}\n-#[derive(Default)]\n-pub struct RitaLoop {}\n-\n// the speed in seconds for the client loop\npub const CLIENT_LOOP_SPEED: u64 = 5;\npub const CLIENT_LOOP_TIMEOUT: Duration = Duration::from_secs(4);\n+#[derive(Default)]\n+pub struct RitaLoop {}\n+\nimpl Actor for RitaLoop {\ntype Context = Context<Self>;\n@@ -114,18 +114,6 @@ impl Handler<Tick> for RitaLoop {\nlet start = Instant::now();\ntrace!(\"Client Tick!\");\n- let exit_dest_price = get_exit_dest_price();\n- let tunnels = tm_get_tunnels().unwrap();\n-\n- Arbiter::spawn(\n- LightClientManager::from_registry()\n- .send(Watch {\n- tunnels,\n- exit_dest_price,\n- })\n- .then(|_res| Ok(())),\n- );\n-\nif metrics_permitted() {\nsend_udp_heartbeat();\n}\n@@ -161,6 +149,14 @@ pub fn start_rita_loop() {\nrunner.block_on(async move {\nmanage_gateway();\n+ let exit_dest_price = get_exit_dest_price();\n+ let tunnels = tm_get_tunnels().unwrap();\n+\n+ lcm_watch(Watch {\n+ tunnels,\n+ exit_dest_price,\n+ });\n+\ncheck_for_gateway_client_billing_corner_case();\n// update the client exit manager, which handles exit registrations\n// and manages the exit state machine in general. This includes\n@@ -172,6 +168,12 @@ pub fn start_rita_loop() {\noperator_update().await;\n});\n+ info!(\n+ \"Rita Client loop completed in {}s {}ms\",\n+ start.elapsed().as_secs(),\n+ start.elapsed().subsec_millis()\n+ );\n+\n// sleep until it has been CLIENT_LOOP_SPEED seconds from start, whenever that may be\n// if it has been more than CLIENT_LOOP_SPEED seconds from start, go right ahead\nlet client_loop_speed = Duration::from_secs(CLIENT_LOOP_SPEED);\n@@ -239,12 +241,16 @@ fn check_for_gateway_client_billing_corner_case() {\npub fn start_rita_client_endpoints(workers: usize) {\n// listen on the light client gateway ip if it's not none\n+ thread::spawn(move || {\n+ let runner = AsyncSystem::new();\n+ runner.block_on(async move {\nif let Some(gateway_ip) = settings::get_rita_client().network.light_client_router_ip {\ntrace!(\"Listening for light client hellos on {}\", gateway_ip);\n- let unstarted_server = server::new(|| {\n- App::new().resource(\"/light_client_hello\", |r| {\n- r.method(Method::POST).with(light_client_hello_response)\n- })\n+ let unstarted_server = HttpServer::new(|| {\n+ App::new().route(\n+ \"/light_client_hello\",\n+ web::post().to(light_client_hello_response),\n+ )\n})\n.workers(workers)\n.bind(format!(\n@@ -253,11 +259,14 @@ pub fn start_rita_client_endpoints(workers: usize) {\nsettings::get_rita_client().network.light_client_hello_port\n));\nif let Ok(val) = unstarted_server {\n- val.shutdown_timeout(0).start();\n+ info!(\"Starting client endpoint: light client\");\n+ let _res = val.shutdown_timeout(0).run().await;\n} else {\ntrace!(\"Failed to bind to light client ip, probably toggled off!\")\n}\n}\n+ });\n+ });\n}\npub fn start_antenna_forwarder(settings: RitaClientSettings) {\n" }, { "change_type": "MODIFY", "old_path": "rita_common/Cargo.toml", "new_path": "rita_common/Cargo.toml", "diff": "@@ -35,6 +35,7 @@ lazy_static = \"1.4\"\nalthea_kernel_interface = { path = \"../althea_kernel_interface\" }\nactix-web-httpauth = {git = \"https://github.com/althea-net/actix-web-httpauth\"}\nactix-web = { version = \"0.7\", default_features = false, features= [\"ssl\"] }\n+actix-web-async = { package=\"actix-web\", version = \"4.0.0-beta.8\", default_features = false, features= [\"openssl\"]}\nawc = {version = \"3.0.0-beta.8\", default-features = false, features=[\"openssl\", \"compress-gzip\", \"compress-zstd\"]}\nweb30 = \"0.18\"\nalthea_types = { path = \"../althea_types\" }\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/dashboard/settings.rs", "new_path": "rita_common/src/dashboard/settings.rs", "diff": "-use crate::{network_endpoints::JsonStatusResponse, RitaCommonError};\n-use actix_web::{HttpRequest, Json, Result};\n+use crate::RitaCommonError;\n+use actix_web::{HttpRequest, HttpResponse, Json, Result};\npub fn get_settings(_req: HttpRequest) -> Result<Json<serde_json::Value>, RitaCommonError> {\ndebug!(\"Get settings endpoint hit!\");\n@@ -8,9 +8,9 @@ pub fn get_settings(_req: HttpRequest) -> Result<Json<serde_json::Value>, RitaCo\npub fn set_settings(\nnew_settings: Json<serde_json::Value>,\n-) -> Result<Json<JsonStatusResponse>, RitaCommonError> {\n+) -> Result<HttpResponse, RitaCommonError> {\ndebug!(\"Set settings endpoint hit!\");\nsettings::merge_config_json(new_settings.into_inner())?;\n- JsonStatusResponse::new(Ok(\"New settings applied\".to_string()))\n+ Ok(HttpResponse::Ok().finish())\n}\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/network_endpoints/mod.rs", "new_path": "rita_common/src/network_endpoints/mod.rs", "diff": "use crate::payment_validator::{validate_later, ToValidate};\nuse crate::peer_listener::Peer;\n+use crate::tm_identity_callback;\nuse crate::tunnel_manager::id_callback::IdentityCallback;\n-use crate::{tm_identity_callback, RitaCommonError};\n-use actix_web::http::StatusCode;\n-use actix_web::{HttpRequest, HttpResponse, Json, Result};\n+use actix_web::HttpRequest as OldHttpRequest;\n+use actix_web_async::http::StatusCode;\n+use actix_web_async::web::Json;\n+\n+use actix_web_async::{HttpRequest, HttpResponse};\nuse althea_types::{LocalIdentity, PaymentTx};\n-use std::net::SocketAddr;\nuse std::time::Instant;\n-#[derive(Serialize)]\n-pub struct JsonStatusResponse {\n- response: String,\n-}\n-\n-impl JsonStatusResponse {\n- pub fn new(\n- ret_val: Result<String, RitaCommonError>,\n- ) -> Result<Json<JsonStatusResponse>, RitaCommonError> {\n- let res_string = match ret_val {\n- Ok(msg) => msg,\n- Err(e) => format!(\"{}\", e),\n- };\n-\n- Ok(Json(JsonStatusResponse {\n- response: res_string,\n- }))\n- }\n-}\n-\n/// The recieve side of the make payments call\npub fn make_payments(pmt: (Json<PaymentTx>, HttpRequest)) -> HttpResponse {\nlet txid = pmt.0.txid.clone();\n@@ -40,13 +22,10 @@ pub fn make_payments(pmt: (Json<PaymentTx>, HttpRequest)) -> HttpResponse {\n// why don't we need an Either up here? Because the types ultimately match?\nif txid.is_none() {\nerror!(\"Did not find txid, payment failed!\");\n- return HttpResponse::new(StatusCode::from_u16(400u16).unwrap())\n- .into_builder()\n+ return HttpResponse::build(StatusCode::from_u16(400u16).unwrap())\n.json(\"txid not provided! Invalid payment!\");\n} else if pmt.0.to.eth_address != our_address {\n- return HttpResponse::new(StatusCode::from_u16(400u16).unwrap())\n- .into_builder()\n- .json(format!(\n+ return HttpResponse::build(StatusCode::from_u16(400u16).unwrap()).json(format!(\n\"We are not {} our address is {}! Invalid payment\",\npmt.0.to.eth_address, our_address\n));\n@@ -66,21 +45,16 @@ pub fn make_payments(pmt: (Json<PaymentTx>, HttpRequest)) -> HttpResponse {\nHttpResponse::Ok().json(\"Payment Received!\")\n}\n-pub fn hello_response(\n- req: (Json<LocalIdentity>, HttpRequest),\n-) -> Result<Json<LocalIdentity>, RitaCommonError> {\n+pub fn hello_response(req: (Json<LocalIdentity>, HttpRequest)) -> HttpResponse {\nlet their_id = *req.0;\nlet err_mesg = \"Malformed hello tcp packet!\";\n- let socket = match req.1.connection_info().remote() {\n- Some(val) => match val.parse::<SocketAddr>() {\n- Ok(val) => val,\n- Err(_e) => return Err(RitaCommonError::MiscStringError(err_mesg.to_string())),\n- },\n- None => return Err(RitaCommonError::MiscStringError(err_mesg.to_string())),\n+ let socket = match req.1.peer_addr() {\n+ Some(val) => val,\n+ None => return HttpResponse::build(StatusCode::from_u16(400u16).unwrap()).json(err_mesg),\n};\n- trace!(\"Got Hello from {:?}\", req.1.connection_info().remote());\n+ trace!(\"Got Hello from {:?}\", req.1.peer_addr());\ntrace!(\"opening tunnel in hello_response for {:?}\", their_id);\nlet peer = Peer {\n@@ -92,27 +66,25 @@ pub fn hello_response(\nlet tunnel = match tunnel {\nSome(val) => val,\nNone => {\n- return Err(RitaCommonError::MiscStringError(\n- \"tunnel open failure!\".to_string(),\n- ))\n+ return HttpResponse::build(StatusCode::from_u16(400u16).unwrap())\n+ .json(\"Tunnel open failure\")\n}\n};\n- Ok(Json(LocalIdentity {\n+ HttpResponse::Ok().json(LocalIdentity {\nglobal: match settings::get_rita_common().get_identity() {\nSome(id) => id,\nNone => {\n- return Err(RitaCommonError::MiscStringError(\n- \"Identity has no mesh IP ready yet\".to_string(),\n- ))\n+ return HttpResponse::build(StatusCode::from_u16(400u16).unwrap())\n+ .json(\"Identity has no mesh ip ready\")\n}\n},\nwg_port: tunnel.0.listen_port,\nhave_tunnel: Some(tunnel.1),\n- }))\n+ })\n}\n-pub fn version(_req: HttpRequest) -> String {\n+pub fn version(_req: OldHttpRequest) -> String {\nformat!(\n\"crate ver {}\\ngit hash {}\",\nenv!(\"CARGO_PKG_VERSION\"),\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/rita_loop/mod.rs", "new_path": "rita_common/src/rita_loop/mod.rs", "diff": "use crate::network_endpoints::*;\nuse crate::traffic_watcher::init_traffic_watcher;\nuse actix::SystemService;\n-use actix_web::http::Method;\n-use actix_web::{server, App};\n+use actix_async::System;\n+use actix_web_async::{web, App, HttpServer};\nuse rand::thread_rng;\nuse rand::Rng;\nuse std::sync::atomic::AtomicBool;\nuse std::sync::atomic::Ordering;\n+use std::thread;\npub mod fast_loop;\npub mod slow_loop;\n@@ -52,26 +53,42 @@ pub fn get_web3_server() -> String {\n}\npub fn start_core_rita_endpoints(workers: usize) {\n- let common = settings::get_rita_common();\n// Rita hello function\n- server::new(|| App::new().resource(\"/hello\", |r| r.method(Method::POST).with(hello_response)))\n+\n+ thread::spawn(move || {\n+ let runner = System::new();\n+ runner.block_on(async move {\n+ let common = settings::get_rita_common();\n+ let res =\n+ HttpServer::new(|| App::new().route(\"/hello\", web::post().to(hello_response)))\n.workers(workers)\n.bind(format!(\"[::0]:{}\", common.network.rita_hello_port))\n.unwrap()\n.shutdown_timeout(0)\n- .start();\n+ .run()\n+ .await;\n+\n+ info!(\"Hello handler endpoint started with: {:?}\", res);\n+ });\n+ });\n+ thread::spawn(move || {\n+ let runner = System::new();\n+ runner.block_on(async move {\n+ let common = settings::get_rita_common();\n// Rita accept payment function, on a different port\n- server::new(|| {\n- App::new().resource(\"/make_payment\", |r| {\n- r.method(Method::POST).with(make_payments)\n- })\n+ let res = HttpServer::new(|| {\n+ App::new().route(\"/make_payment\", web::post().to(make_payments))\n})\n.workers(workers)\n.bind(format!(\"[::0]:{}\", common.network.rita_contact_port))\n.unwrap()\n.shutdown_timeout(0)\n- .start();\n+ .run()\n+ .await;\n+ info!(\"Make payment endpoint started with: {:?}\", res);\n+ });\n+ });\n}\npub fn check_rita_common_actors() {\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Migrated Rita common and client endpoints and light client manager to async/await Rita Client endpoint had light client manager, so that module was also migrated to async/await
20,253
11.02.2022 01:18:42
28,800
8d13c978bf9d5dd6bb89b22476cac4f184345c09
migrating heartbeat sender to async/await actix resolver has been replaced with use of to_socket_addrs heartbeat sender now has its own loop to keep to_socket_addrs from blocking forever
[ { "change_type": "MODIFY", "old_path": "rita_bin/Cargo.toml", "new_path": "rita_bin/Cargo.toml", "diff": "@@ -52,6 +52,7 @@ jemallocator = {version = \"0.3\", optional = true}\nopenssl = {version = \"0.10\", features = [\"vendored\"], optional = true}\n[features]\n+default = [\"bundle_openssl\"]\njemalloc = [\"jemallocator\"]\nbundle_openssl = [\"openssl\"]\n# Features for big iron devices with more ram\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/heartbeat/mod.rs", "new_path": "rita_client/src/heartbeat/mod.rs", "diff": "//! This packet is encrypted using the usual LibSodium box construction and sent to the heartbeat server in the following format\n//! WgKey, Nonce, Ciphertext for the HeartBeatMessage. This consumes 32 bytes, 24 bytes, and to the end of the message\n-use crate::rita_loop::CLIENT_LOOP_TIMEOUT;\nuse althea_types::ExitDetails;\nuse babel_monitor::get_installed_route;\n@@ -26,17 +25,19 @@ use rita_common::network_monitor::get_network_info;\nuse rita_common::network_monitor::GetNetworkInfo;\nuse rita_common::tunnel_manager::Neighbor as RitaNeighbor;\n-use actix::actors::resolver;\n-use actix::{Arbiter, SystemService};\n+use actix::System;\nuse althea_types::HeartbeatMessage;\nuse althea_types::Identity;\nuse althea_types::WgKey;\nuse babel_monitor::Neighbor as NeighborLegacy;\nuse babel_monitor::Route as RouteLegacy;\n-use futures01::future::Future;\nuse settings::client::ExitServer;\nuse sodiumoxide::crypto::box_;\nuse std::collections::VecDeque;\n+use std::iter::FromIterator;\n+use std::net::ToSocketAddrs;\n+use std::thread;\n+use std::time::Instant;\n#[allow(unused_imports)]\nuse dummy::dummy_neigh_babel;\n@@ -51,7 +52,7 @@ use std::sync::Arc;\nuse std::sync::RwLock;\nuse std::time::Duration;\n-type Resolver = resolver::Resolver;\n+pub const HEARTBEAT_LOOP_SPEED: u64 = 5;\nmod dummy;\npub struct HeartbeatCache {\n@@ -78,7 +79,49 @@ lazy_static! {\nArc::new(RwLock::new(None));\n}\n-pub fn send_udp_heartbeat() {\n+pub fn send_heartbeat_loop() {\n+ let mut last_restart = Instant::now();\n+ // this is a reference to the non-async actix system since this can bring down the whole process\n+ let system = System::current();\n+\n+ // outer thread is a watchdog inner thread is the runner\n+ thread::spawn(move || {\n+ // this will always be an error, so it's really just a loop statement\n+ // with some fancy destructuring\n+\n+ while let Err(e) = {\n+ thread::spawn(move || loop {\n+ let start = Instant::now();\n+ trace!(\"Client tick!\");\n+\n+ send_udp_heartbeat();\n+\n+ info!(\n+ \"Heartbeat loop completed in {}s {}ms\",\n+ start.elapsed().as_secs(),\n+ start.elapsed().subsec_millis()\n+ );\n+\n+ // sleep until it has been HEARTBEAT_LOOP_SPEED seconds from start, whenever that may be\n+ // if it has been more than HEARTBEAT_LOOP_SPEED seconds from start, go right ahead\n+ let heartbeat_loop_speed = Duration::from_secs(HEARTBEAT_LOOP_SPEED);\n+ if start.elapsed() < heartbeat_loop_speed {\n+ thread::sleep(heartbeat_loop_speed - start.elapsed());\n+ }\n+ })\n+ .join()\n+ } {\n+ error!(\"Heartbeat loop thread panicked! Respawning {:?}\", e);\n+ if Instant::now() - last_restart < Duration::from_secs(60) {\n+ error!(\"Restarting too quickly, leaving it to auto rescue!\");\n+ system.stop_with_code(121)\n+ }\n+ last_restart = Instant::now();\n+ }\n+ });\n+}\n+\n+fn send_udp_heartbeat() {\nlet heartbeat_url: &str;\nif cfg!(feature = \"dev_env\") {\nheartbeat_url = \"0.0.0.0:33333\";\n@@ -92,9 +135,7 @@ pub fn send_udp_heartbeat() {\n}\ntrace!(\"attempting to send heartbeat\");\n- let dns_request = Resolver::from_registry()\n- .send(resolver::Resolve::host(heartbeat_url.to_string()))\n- .timeout(CLIENT_LOOP_TIMEOUT);\n+ let dns_request = heartbeat_url.to_socket_addrs();\n// Check for the basics first, before doing any of the hard futures work\n#[allow(unused_assignments, unused_mut)]\n@@ -135,28 +176,33 @@ pub fn send_udp_heartbeat() {\n}\n};\n- let res = dns_request.then(move |res| {\n// In this block we handle gathering all the info and the many ways gathering it could fail\n// once we have succeeded even if only once we have a cached value that is updated regularly\n// if for some reason the cache update fails, we can still progress with the heartbeat\n- match res {\n- Ok(Ok(dnsresult)) => {\n- #[cfg(not(feature = \"operator_debug\"))]\n- let selected_exit_route = get_selected_exit_route(&network_info.babel_routes);\n- #[cfg(feature = \"operator_debug\")]\n- let selected_exit_route: Result<RouteLegacy, BabelMonitorError> = Ok(dummy_route());\n+ match dns_request {\n+ Ok(dnsres) => {\n+ let dnsresult = VecDeque::from_iter(dnsres);\n+ let selected_exit_route: Result<RouteLegacy, BabelMonitorError>;\n+ if cfg!(feature = \"operator_debug\") {\n+ selected_exit_route = Ok(dummy_route());\n+ } else {\n+ selected_exit_route = get_selected_exit_route(&network_info.babel_routes);\n+ }\nmatch selected_exit_route {\nOk(route) => {\n- #[allow(unused_variables)]\n- let neigh_option =\n+ // #[allow(unused_variables)]\n+ // let neigh_option =\n+ // get_neigh_given_route(&route, &network_info.babel_neighbors);\n+ let neigh_option;\n+ if cfg!(feature = \"operator_debug\") {\n+ neigh_option = Some((dummy_neigh_babel(), dummy_neigh_tunnel()));\n+ } else {\n+ let neigh_option1 =\nget_neigh_given_route(&route, &network_info.babel_neighbors);\n-\n- #[cfg(not(feature = \"operator_debug\"))]\n- let neigh_option =\n- get_rita_neigh_option(neigh_option, &network_info.rita_neighbors);\n- #[cfg(feature = \"operator_debug\")]\n- let neigh_option = Some((dummy_neigh_babel(), dummy_neigh_tunnel()));\n+ neigh_option =\n+ get_rita_neigh_option(neigh_option1, &network_info.rita_neighbors);\n+ }\nif let Some((neigh, rita_neigh)) = neigh_option {\n// Now that we have all the info we can stop and try to update the\n@@ -190,9 +236,6 @@ pub fn send_udp_heartbeat() {\n}\n}\nErr(e) => {\n- warn!(\"Failed to resolve domain and get network info! {:?}\", e);\n- }\n- Ok(Err(e)) => {\nwarn!(\"DNS resolution failed with {:?}\", e);\n}\n}\n@@ -216,10 +259,6 @@ pub fn send_udp_heartbeat() {\n} else {\nwarn!(\"Cache not populated, can't heartbeat!\");\n}\n- Ok(())\n- });\n-\n- Arbiter::spawn(res);\n}\n#[allow(dead_code)]\n@@ -351,3 +390,25 @@ fn send_udp_heartbeat_packet(\nrita_client.payment = payment;\nsettings::set_rita_client(rita_client);\n}\n+\n+#[cfg(test)]\n+mod tests {\n+ use std::net::ToSocketAddrs;\n+\n+ #[test]\n+ fn check_resolver() {\n+ let heartbeat_url = \"dai.althea.net:33333\";\n+ println!(\"heartbeat url set to {}\", heartbeat_url);\n+ //let mut length = false;\n+ let dns_request = heartbeat_url.to_socket_addrs();\n+ println!(\"dns_req set\");\n+ let res = match dns_request {\n+ Ok(iter) => iter.len() > 1,\n+ Err(_e) => {\n+ println!(\"Number of returned dns entries must be >1\");\n+ false\n+ }\n+ };\n+ println!(\"{}\", res)\n+ }\n+}\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/rita_loop/mod.rs", "new_path": "rita_client/src/rita_loop/mod.rs", "diff": "//! tunnel if the signup was successful on the selected exit.\nuse crate::exit_manager::exit_manager_tick;\n-use crate::heartbeat::send_udp_heartbeat;\n+use crate::heartbeat::send_heartbeat_loop;\nuse crate::heartbeat::HEARTBEAT_SERVER_KEY;\nuse crate::light_client_manager::lcm_watch;\nuse crate::light_client_manager::light_client_hello_response;\n@@ -114,10 +114,6 @@ impl Handler<Tick> for RitaLoop {\nlet start = Instant::now();\ntrace!(\"Client Tick!\");\n- if metrics_permitted() {\n- send_udp_heartbeat();\n- }\n-\ninfo!(\n\"Rita Client loop completed in {}s {}ms\",\nstart.elapsed().as_secs(),\n@@ -195,6 +191,9 @@ pub fn start_rita_loop() {\npub fn check_rita_client_actors() {\nassert!(crate::rita_loop::RitaLoop::from_registry().connected());\n+ if metrics_permitted() {\n+ send_heartbeat_loop();\n+ }\ncrate::rita_loop::start_rita_loop();\n}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
migrating heartbeat sender to async/await actix resolver has been replaced with use of to_socket_addrs heartbeat sender now has its own loop to keep to_socket_addrs from blocking forever
20,253
18.02.2022 00:58:39
28,800
1d4b18bdcfb8b5c23af6c97ff46f2e5096fc434e
migrating conditional compilation statements to if statements to remove dead code tags
[ { "change_type": "MODIFY", "old_path": "rita_bin/Cargo.toml", "new_path": "rita_bin/Cargo.toml", "diff": "@@ -52,7 +52,6 @@ jemallocator = {version = \"0.3\", optional = true}\nopenssl = {version = \"0.10\", features = [\"vendored\"], optional = true}\n[features]\n-default = [\"bundle_openssl\"]\njemalloc = [\"jemallocator\"]\nbundle_openssl = [\"openssl\"]\n# Features for big iron devices with more ram\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/heartbeat/mod.rs", "new_path": "rita_client/src/heartbeat/mod.rs", "diff": "@@ -138,17 +138,14 @@ fn send_udp_heartbeat() {\nlet dns_request = heartbeat_url.to_socket_addrs();\n// Check for the basics first, before doing any of the hard futures work\n- #[allow(unused_assignments, unused_mut)]\nlet mut our_id: Identity = if settings::get_rita_client().get_identity().is_some() {\nsettings::get_rita_client().get_identity().unwrap()\n} else {\nreturn;\n};\n- #[allow(unused_assignments, unused_mut)]\nlet mut selected_exit_details: ExitDetails = dummy_selected_exit_details();\n- #[cfg(not(feature = \"operator_debug\"))]\n- {\n+ if !cfg!(feature = \"operator_debug\") {\nif let (Some(id), Some(exit)) = (\nsettings::get_rita_client().get_identity(),\nget_selected_exit(),\n@@ -191,9 +188,6 @@ fn send_udp_heartbeat() {\nmatch selected_exit_route {\nOk(route) => {\n- // #[allow(unused_variables)]\n- // let neigh_option =\n- // get_neigh_given_route(&route, &network_info.babel_neighbors);\nlet neigh_option;\nif cfg!(feature = \"operator_debug\") {\nneigh_option = Some((dummy_neigh_babel(), dummy_neigh_tunnel()));\n@@ -261,7 +255,6 @@ fn send_udp_heartbeat() {\n}\n}\n-#[allow(dead_code)]\nfn get_selected_exit_route(route_dump: &[RouteLegacy]) -> Result<RouteLegacy, BabelMonitorError> {\nlet rita_client = settings::get_rita_client();\nlet exit_client = rita_client.exit_client;\n@@ -275,7 +268,6 @@ fn get_selected_exit_route(route_dump: &[RouteLegacy]) -> Result<RouteLegacy, Ba\nget_installed_route(&exit_mesh_ip, route_dump)\n}\n-#[allow(dead_code)]\nfn get_selected_exit() -> Option<ExitServer> {\nlet rita_client = settings::get_rita_client();\nlet exit_client = rita_client.exit_client;\n@@ -283,7 +275,6 @@ fn get_selected_exit() -> Option<ExitServer> {\nSome(exit.clone())\n}\n-#[allow(dead_code)]\nfn get_rita_neigh_option(\nneigh: Option<NeighborLegacy>,\nrita_neighbors: &[RitaNeighbor],\n@@ -296,7 +287,6 @@ fn get_rita_neigh_option(\n}\n}\n-#[allow(dead_code)]\nfn get_rita_neighbor(\nneigh: &NeighborLegacy,\nrita_neighbors: &[RitaNeighbor],\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
migrating conditional compilation statements to if statements to remove dead code tags
20,253
22.02.2022 14:44:01
28,800
1a08b5657961a86ed1bf2e552965f66b8d7b2be9
Migrates openwrt_build scripts to use cross which maintains the openwrt toolchain
[ { "change_type": "DELETE", "old_path": "scripts/bridge.sh", "new_path": null, "diff": "-#!/usr/bin/env bash\n-# this bridges a router into the integration test mesh\n-\n-# ip link set enx000ec6a0b495 netns netlab-1\n-# ip netns exec netlab-1 ifconfig enx000ec6a0b495 up\n-\n-ifconfig enp7s0f3u3u2u1 down\n-dhclient enp7s0f3u3u2u1\n-ip route delete default dev enp7s0f3u3u2u1\n-ifconfig enp7s0f3u3u2u1 up\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "scripts/linux_build_static.sh", "new_path": null, "diff": "-#!/bin/bash\n-# Usage: ./linux_build_static [--debug] [--release]\n-#\n-# This script builds a static Linux binaries.\n-#\n-# Options:\n-# --debug (optional) Use debug profile\n-# --release (optional) Use release profile (default)\n-# --features (optional) List of features to build\n-#\n-# Note: You may need to disable or modify selinux, or add $USER to docker group\n-# to be able to use `docker`.\n-set -eux\n-\n-DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" >/dev/null && pwd )\"\n-\n-# Parse command line arguments\n-source $DIR/build_common.sh\n-\n-RUST_TOOLCHAIN=\"stable\"\n-CARGO_ROOT=\"$HOME/.cargo\"\n-CARGO_GIT=\"$CARGO_ROOT/.git\"\n-CARGO_REGISTRY=\"$CARGO_ROOT/registry\"\n-\n-docker pull ekidd/rust-musl-builder\n-RUST_MUSL_BUILDER=\"docker run --rm -it -v \"$(pwd)\":/home/rust/src -v $CARGO_GIT:/home/rust/.cargo/git -v $CARGO_REGISTRY:/home/rust/.cargo/registry ekidd/rust-musl-builder\"\n-$RUST_MUSL_BUILDER sudo chown -R rust:rust /home/rust/.cargo/git /home/rust/.cargo/registry\n-\n-$RUST_MUSL_BUILDER cargo build --all ${PROFILE} ${FEATURES}\n" }, { "change_type": "MODIFY", "old_path": "scripts/openwrt_build_aarch64.sh", "new_path": "scripts/openwrt_build_aarch64.sh", "diff": "@@ -5,21 +5,6 @@ DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\n# Parse command line arguments\nsource $DIR/build_common.sh\n-if [[ ! -d $DIR/staging_dir ]]; then\n- pushd $DIR\n- wget -N https://updates.altheamesh.com/staging.tar.xz -O staging.tar.xz > /dev/null; tar -xf staging.tar.xz\n-fi\n+cargo install cross\n-export TOOLCHAIN=toolchain-aarch64_generic_gcc-8.4.0_musl\n-export TARGET_CC=$DIR/staging_dir/$TOOLCHAIN/bin/aarch64-openwrt-linux-gcc\n-export TARGET_LD=$DIR/staging_dir/$TOOLCHAIN/bin/aarch64-openwrt-linux-ld\n-export TARGET_AR=$DIR/staging_dir/$TOOLCHAIN/bin/aarch64-openwrt-linux-ar\n-export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=$TARGET_CC\n-export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_AR=$TARGET_AR\n-export SQLITE3_LIB_DIR=$DIR/staging_dir/target-aarch64_generic_musl/usr/lib/\n-export AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=$DIR/staging_dir/target-aarch64_generic_musl/usr/\n-export OPENSSL_STATIC=1\n-\n-rustup target add aarch64-unknown-linux-musl\n-\n-cargo build --target aarch64-unknown-linux-musl ${PROFILE} ${FEATURES} -p rita_bin --bin rita\n+cross build --target aarch64-unknown-linux-musl ${PROFILE} ${FEATURES} -p rita_bin --bin rita --features rita_bin/bundle_openssl\n" }, { "change_type": "MODIFY", "old_path": "scripts/openwrt_build_ipq40xx.sh", "new_path": "scripts/openwrt_build_ipq40xx.sh", "diff": "@@ -5,23 +5,6 @@ DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\n# Parse command line arguments\nsource $DIR/build_common.sh\n-if [[ ! -d $DIR/staging_dir ]]; then\n- pushd $DIR\n- wget -N https://updates.altheamesh.com/staging.tar.xz -O staging.tar.xz > /dev/null; tar -xf staging.tar.xz\n-fi\n+cargo install cross\n-\n-\n-export TOOLCHAIN=toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.3.0_musl_eabi\n-export TARGET_CC=$DIR/staging_dir/$TOOLCHAIN/bin/arm-openwrt-linux-gcc\n-export TARGET_LD=$DIR/staging_dir/$TOOLCHAIN/bin/arm-openwrt-linux-ld\n-export TARGET_AR=$DIR/staging_dir/$TOOLCHAIN/bin/arm-openwrt-linux-ar\n-export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_LINKER=$TARGET_CC\n-export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_AR=$TARGET_AR\n-export SQLITE3_LIB_DIR=$DIR/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/usr/lib/\n-export ARMV7_UNKNOWN_LINUX_MUSLEABIHF_OPENSSL_DIR=$DIR/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/usr/\n-export OPENSSL_STATIC=1\n-\n-rustup target add armv7-unknown-linux-musleabihf\n-\n-cargo build --target armv7-unknown-linux-musleabihf ${PROFILE} ${FEATURES} -p rita_bin --bin rita\n+cross build --target armv7-unknown-linux-musleabihf ${PROFILE} ${FEATURES} -p rita_bin --bin rita --features rita_bin/bundle_openssl\n" }, { "change_type": "MODIFY", "old_path": "scripts/openwrt_build_mips.sh", "new_path": "scripts/openwrt_build_mips.sh", "diff": "@@ -5,21 +5,6 @@ DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\n# Parse command line arguments\nsource $DIR/build_common.sh\n-if [[ ! -d $DIR/staging_dir ]]; then\n- pushd $DIR\n- wget -N https://updates.altheamesh.com/staging.tar.xz -O staging.tar.xz > /dev/null; tar -xf staging.tar.xz\n-fi\n+cargo install cross\n-export TOOLCHAIN=toolchain-mips_24kc_gcc-7.3.0_musl\n-export TARGET_CC=$DIR/staging_dir/$TOOLCHAIN/bin/mips-openwrt-linux-gcc\n-export TARGET_LD=$DIR/staging_dir/$TOOLCHAIN/bin/mips-openwrt-linux-ld\n-export TARGET_AR=$DIR/staging_dir/$TOOLCHAIN/bin/mips-openwrt-linux-ar\n-export CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_LINKER=$TARGET_CC\n-export CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_AR=$TARGET_AR\n-export SQLITE3_LIB_DIR=$DIR/staging_dir/target-mips_24kc_musl/usr/lib/\n-export MIPS_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=$DIR/staging_dir/target-mips_24kc_musl/usr/\n-export OPENSSL_STATIC=1\n-\n-rustup target add mips-unknown-linux-musl\n-\n-cargo build --target mips-unknown-linux-musl ${PROFILE} ${FEATURES} -p rita_bin --bin rita\n+cross build --target mips-unknown-linux-musl ${PROFILE} ${FEATURES} -p rita_bin --bin rita --features rita_bin/bundle_openssl\n" }, { "change_type": "MODIFY", "old_path": "scripts/openwrt_build_mipsel.sh", "new_path": "scripts/openwrt_build_mipsel.sh", "diff": "@@ -5,21 +5,6 @@ DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\n# Parse command line arguments\nsource $DIR/build_common.sh\n-if [[ ! -d $DIR/staging_dir ]]; then\n- pushd $DIR\n- wget -N https://updates.altheamesh.com/staging.tar.xz -O staging.tar.xz > /dev/null; tar -xf staging.tar.xz\n-fi\n+cargo install cross\n-export TOOLCHAIN=toolchain-mipsel_24kc_gcc-7.3.0_musl\n-export TARGET_CC=$DIR/staging_dir/$TOOLCHAIN/bin/mipsel-openwrt-linux-gcc\n-export TARGET_LD=$DIR/staging_dir/$TOOLCHAIN/bin/mipsel-openwrt-linux-ld\n-export TARGET_AR=$DIR/staging_dir/$TOOLCHAIN/bin/mipsel-openwrt-linux-ar\n-export CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_LINKER=$TARGET_CC\n-export CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_AR=$TARGET_AR\n-export SQLITE3_LIB_DIR=$DIR/staging_dir/target-mipsel_24kc_musl/usr/lib/\n-export MIPSEL_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=$DIR/staging_dir/target-mipsel_24kc_musl/usr/\n-export OPENSSL_STATIC=1\n-\n-rustup target add mipsel-unknown-linux-musl\n-\n-cargo build --target mipsel-unknown-linux-musl ${PROFILE} ${FEATURES} -p rita_bin --bin rita\n+cross build --target mipsel-unknown-linux-musl ${PROFILE} ${FEATURES} -p rita_bin --bin rita --features rita_bin/bundle_openssl\n" }, { "change_type": "MODIFY", "old_path": "scripts/openwrt_build_mvebu.sh", "new_path": "scripts/openwrt_build_mvebu.sh", "diff": "@@ -5,21 +5,6 @@ DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\n# Parse command line arguments\nsource $DIR/build_common.sh\n-if [[ ! -d $DIR/staging_dir ]]; then\n- pushd $DIR\n- wget -N https://updates.altheamesh.com/staging.tar.xz -O staging.tar.xz > /dev/null; tar -xf staging.tar.xz\n-fi\n+cargo install cross\n-export TOOLCHAIN=toolchain-arm_cortex-a9+vfpv3_gcc-7.3.0_musl_eabi\n-export TARGET_CC=$DIR/staging_dir/$TOOLCHAIN/bin/arm-openwrt-linux-gcc\n-export TARGET_LD=$DIR/staging_dir/$TOOLCHAIN/bin/arm-openwrt-linux-ld\n-export TARGET_AR=$DIR/staging_dir/$TOOLCHAIN/bin/arm-openwrt-linux-ar\n-export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_LINKER=$TARGET_CC\n-export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_AR=$TARGET_AR\n-export SQLITE3_LIB_DIR=$DIR/staging_dir/target-arm_cortex-a9+vfpv3_musl_eabi/usr/lib/\n-export ARMV7_UNKNOWN_LINUX_MUSLEABIHF_OPENSSL_DIR=$DIR/staging_dir/target-arm_cortex-a9+vfpv3_musl_eabi/usr/\n-export OPENSSL_STATIC=1\n-\n-rustup target add armv7-unknown-linux-musleabihf\n-\n-cargo build --target armv7-unknown-linux-musleabihf ${PROFILE} ${FEATURES} -p rita_bin --bin rita\n+cross build --target armv7-unknown-linux-musleabihf ${PROFILE} ${FEATURES} -p rita_bin --bin rita --features rita_bin/bundle_openssl\n" }, { "change_type": "DELETE", "old_path": "scripts/openwrt_build_octeon.sh", "new_path": null, "diff": "-#!/bin/bash\n-set -eux\n-DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\n-\n-# Parse command line arguments\n-source $DIR/build_common.sh\n-\n-if [[ ! -d $DIR/staging_dir ]]; then\n- pushd $DIR\n- wget -N https://updates.altheamesh.com/staging.tar.xz -O staging.tar.xz > /dev/null; tar -xf staging.tar.xz\n-fi\n-\n-export TOOLCHAIN=toolchain-mips64_octeon_64_gcc-7.3.0_glibc\n-export TARGET_CC=$DIR/staging_dir/$TOOLCHAIN/bin/mips64-openwrt-linux-gcc\n-export TARGET_LD=$DIR/staging_dir/$TOOLCHAIN/bin/mips64-openwrt-linux-ld\n-export TARGET_AR=$DIR/staging_dir/$TOOLCHAIN/bin/mips64-openwrt-linux-ar\n-export CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=$TARGET_CC\n-export CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_AR=$TARGET_AR\n-export SQLITE3_LIB_DIR=$DIR/staging_dir/target-mips64_octeon_64_glibc/usr/lib/\n-export MIPS64_UNKNOWN_LINUX_GNUABI64_OPENSSL_DIR=$DIR/staging_dir/target-mips64_octeon_64_glibc/usr/\n-export OPENSSL_STATIC=1\n-\n-rustup target add mips64-unknown-linux-gnuabi64\n-\n-cargo build --target mips64-unknown-linux-gnuabi64 ${PROFILE} ${FEATURES} -p rita_bin --bin rita\n" }, { "change_type": "ADD", "old_path": null, "new_path": "scripts/openwrt_build_x86_64.sh", "diff": "+#!/bin/bash\n+set -eux\n+DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\n+\n+# Parse command line arguments\n+source $DIR/build_common.sh\n+\n+cargo install cross\n+\n+cross build --target x86_64-unknown-linux-musl ${PROFILE} ${FEATURES} -p rita_bin --bin rita --features rita_bin/bundle_openssl\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Migrates openwrt_build scripts to use cross which maintains the openwrt toolchain
20,244
20.02.2022 08:44:41
18,000
311932eed82ced289d2e869c15e4a1d76af8bedb
Remove fudge_factor setting This has never been used in production and is not currently being used. Therefore it's safe to remove as dead code.
[ { "change_type": "MODIFY", "old_path": "rita_common/src/debt_keeper/mod.rs", "new_path": "rita_common/src/debt_keeper/mod.rs", "diff": "@@ -514,7 +514,6 @@ impl DebtKeeper {\nlet payment_settings = settings::get_rita_common().payment;\nlet close_threshold = get_oracle_close_thresh();\nlet pay_threshold = get_oracle_pay_thresh();\n- let fudge_factor = payment_settings.fudge_factor;\nlet debt_limit_enabled = payment_settings.debt_limit_enabled;\nlet apply_incoming_credit_immediately = payment_settings.apply_incoming_credit_immediately;\n@@ -553,16 +552,11 @@ impl DebtKeeper {\nOk(DebtAction::SuspendTunnel)\n}\n(false, true, false) => {\n- let mut to_pay: Uint256 = debt_data.debt.to_uint256().ok_or_else(|| {\n+ let to_pay: Uint256 = debt_data.debt.to_uint256().ok_or_else(|| {\nRitaCommonError::ConversionError(\n\"Unable to convert debt data into unsigned 256 bit integer\".to_string(),\n)\n})?;\n- // overpay by the fudge_factor to encourage convergence, this is currently set\n- // to zero in all production networks, so maybe it can be removed\n- if fudge_factor != 0 {\n- to_pay = to_pay.clone() + (to_pay / fudge_factor.into());\n- }\ndebt_data.payment_in_flight = true;\ndebt_data.payment_in_flight_start = Some(Instant::now());\n" }, { "change_type": "MODIFY", "old_path": "settings/src/payment.rs", "new_path": "settings/src/payment.rs", "diff": "@@ -18,10 +18,6 @@ fn default_dynamic_fee_multiplier() -> u32 {\nXDAI_FEE_MULTIPLIER\n}\n-fn default_fudge_factor() -> u8 {\n- 0\n-}\n-\nfn default_free_tier_throughput() -> u32 {\n1000\n}\n@@ -127,13 +123,6 @@ pub struct PaymentSettings {\npub debts_file: String,\n#[serde(default = \"default_bridge_enabled\")]\npub bridge_enabled: bool,\n- /// A value used to divide and add to a payment, essentailly a cheating tool for\n- /// payment convergence. Computed as payment_amount + (payment_amount/fudge_factor)\n- /// so a factor of 100 would be a 1% overpayment this helps cover up errors in accounting\n- /// by pushing the system into overpayment and therefore convergence. Currently not used\n- /// probably should be axed as cruft\n- #[serde(default = \"default_fudge_factor\")]\n- pub fudge_factor: u8,\n/// See where this is referenced in debt keeper, this option is on for exits and off everywhere\n/// else. The problem requiring it's creation is that the Exit has it's debts observed by clients\n/// who pay when it exceeds the pay threshold. Relays have no such issue and their internal balances\n@@ -181,7 +170,6 @@ impl Default for PaymentSettings {\nwithdraw_chain: default_system_chain(),\ndebts_file: default_debts_file(),\nbridge_enabled: default_bridge_enabled(),\n- fudge_factor: 0u8,\ndebt_limit_enabled: default_debt_limit_enabled(),\napply_incoming_credit_immediately: default_apply_incoming_credit(),\nbridge_addresses: default_bridge_addresses(),\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Remove fudge_factor setting This has never been used in production and is not currently being used. Therefore it's safe to remove as dead code.
20,247
28.02.2022 12:23:19
28,800
6b774ebcfa3c7cbe4ea42807db449c7e651c8c4c
Bump for Beta 19 RC 2
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -3176,7 +3176,7 @@ dependencies = [\n[[package]]\nname = \"rita_bin\"\n-version = \"0.19.1\"\n+version = \"0.19.2\"\ndependencies = [\n\"actix 0.12.0\",\n\"actix 0.7.11\",\n@@ -3213,7 +3213,7 @@ dependencies = [\n[[package]]\nname = \"rita_client\"\n-version = \"0.19.1\"\n+version = \"0.19.2\"\ndependencies = [\n\"actix 0.12.0\",\n\"actix 0.7.11\",\n@@ -3255,7 +3255,7 @@ dependencies = [\n[[package]]\nname = \"rita_common\"\n-version = \"0.19.1\"\n+version = \"0.19.2\"\ndependencies = [\n\"actix 0.12.0\",\n\"actix 0.7.11\",\n@@ -3298,7 +3298,7 @@ dependencies = [\n[[package]]\nname = \"rita_exit\"\n-version = \"0.19.1\"\n+version = \"0.19.2\"\ndependencies = [\n\"actix 0.12.0\",\n\"actix 0.7.11\",\n" }, { "change_type": "MODIFY", "old_path": "rita_bin/Cargo.toml", "new_path": "rita_bin/Cargo.toml", "diff": "[package]\nname = \"rita_bin\"\n-version = \"0.19.1\"\n+version = \"0.19.2\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\nbuild = \"build.rs\"\n" }, { "change_type": "MODIFY", "old_path": "rita_client/Cargo.toml", "new_path": "rita_client/Cargo.toml", "diff": "[package]\nname = \"rita_client\"\n-version = \"0.19.1\"\n+version = \"0.19.2\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" }, { "change_type": "MODIFY", "old_path": "rita_common/Cargo.toml", "new_path": "rita_common/Cargo.toml", "diff": "[package]\nname = \"rita_common\"\n-version = \"0.19.1\"\n+version = \"0.19.2\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/dashboard/own_info.rs", "new_path": "rita_common/src/dashboard/own_info.rs", "diff": "@@ -6,7 +6,7 @@ use actix_web_async::HttpResponse;\nuse clarity::Address;\nuse num256::{Int256, Uint256};\n-pub static READABLE_VERSION: &str = \"Beta 18 RC11\";\n+pub static READABLE_VERSION: &str = \"Beta 19 RC2\";\n#[derive(Serialize)]\npub struct OwnInfo {\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/Cargo.toml", "new_path": "rita_exit/Cargo.toml", "diff": "[package]\nname = \"rita_exit\"\n-version = \"0.19.1\"\n+version = \"0.19.2\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Bump for Beta 19 RC 2
20,255
28.02.2022 10:27:49
28,800
32690246319a5a2744fc856258bda1c8ed788ad9
Completely Migrated Rita Client to asnyc await. Removed the following dependencies: futures01 0.1 babel-monitor-legacy tokio 0.1 tokio-codec 0.1 actix 0.1 actix-web 0.7
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -3216,8 +3216,6 @@ name = \"rita_client\"\nversion = \"0.19.2\"\ndependencies = [\n\"actix 0.12.0\",\n- \"actix 0.7.11\",\n- \"actix-web 0.7.19\",\n\"actix-web 4.0.0-beta.20\",\n\"actix-web-httpauth 0.6.0-beta.7\",\n\"althea_kernel_interface\",\n@@ -3226,11 +3224,9 @@ dependencies = [\n\"arrayvec 0.7.2\",\n\"awc\",\n\"babel_monitor\",\n- \"babel_monitor_legacy\",\n\"clarity\",\n\"clu\",\n\"compressed_log\",\n- \"futures 0.1.31\",\n\"hex-literal\",\n\"ipnetwork 0.18.0\",\n\"lazy_static\",\n@@ -3247,9 +3243,6 @@ dependencies = [\n\"settings\",\n\"sha3\",\n\"sodiumoxide\",\n- \"tokio 0.1.22\",\n- \"tokio-codec\",\n- \"tokio-io\",\n\"web30\",\n]\n" }, { "change_type": "MODIFY", "old_path": "rita_bin/src/client.rs", "new_path": "rita_bin/src/client.rs", "diff": "@@ -27,9 +27,9 @@ use althea_kernel_interface::LinuxCommandRunner;\nuse docopt::Docopt;\nuse rita_client::dashboard::start_client_dashboard;\nuse rita_client::get_client_usage;\n-use rita_client::rita_loop::check_rita_client_actors;\nuse rita_client::rita_loop::start_antenna_forwarder;\nuse rita_client::rita_loop::start_rita_client_endpoints;\n+use rita_client::rita_loop::start_rita_client_loops;\nuse rita_client::wait_for_settings;\nuse rita_client::Args;\nuse rita_common::debt_keeper::save_debt_on_shutdown;\n@@ -138,7 +138,7 @@ fn main() {\nlet system = actix::System::new(format!(\"main {:?}\", settings.network.mesh_ip));\ncheck_rita_common_actors();\n- check_rita_client_actors();\n+ start_rita_client_loops();\nstart_core_rita_endpoints(4);\nstart_rita_client_endpoints(1);\nstart_client_dashboard(settings.network.rita_dashboard_port);\n" }, { "change_type": "MODIFY", "old_path": "rita_client/Cargo.toml", "new_path": "rita_client/Cargo.toml", "diff": "@@ -15,7 +15,6 @@ serde_json = \"1.0\"\nlazy_static = \"1.4\"\nhex-literal = \"0.3\"\nrita_common = { path = \"../rita_common\" }\n-futures01 = { package = \"futures\", version = \"0.1\"}\nlog = { version = \"0.4\", features = [\"release_max_level_info\"] }\nalthea_types = { path = \"../althea_types\" }\nalthea_kernel_interface = { path = \"../althea_kernel_interface\" }\n@@ -26,19 +25,13 @@ lettre = \"0.9\"\nlettre_email = \"0.9\"\nphonenumber = \"0.3\"\nbabel_monitor = { path = \"../babel_monitor\" }\n-babel_monitor_legacy = {path = \"../babel_monitor_legacy\"}\narrayvec = {version= \"0.7\", features = [\"serde\"]}\n-tokio = \"0.1\"\n-tokio-io = \"0.1\"\n-tokio-codec = \"0.1\"\nsodiumoxide = \"0.2\"\nclu = { path = \"../clu\" }\nweb30 = \"0.18\"\n-actix = \"0.7\"\nawc = \"3.0.0-beta.18\"\nipnetwork = \"0.18\"\nactix-async = {package=\"actix\", version = \"0.12\"}\n-actix-web = { version = \"0.7\", default_features = false, features= [\"ssl\"] }\nactix-web-async = { package=\"actix-web\", version = \"4.0.0-beta.8\", default_features = false, features= [\"openssl\"]}\nactix-web-httpauth-async = { package=\"actix-web-httpauth\", version = \"0.6.0-beta.7\"}\nclarity = \"0.5\"\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/error.rs", "new_path": "rita_client/src/error.rs", "diff": "@@ -6,9 +6,6 @@ use std::{\nstring::FromUtf8Error,\n};\n-use actix::MailboxError;\n-use actix_web::client::SendRequestError as OldSendRequestError;\n-use actix_web::error::JsonPayloadError as OldJsonPayloadError;\nuse althea_kernel_interface::KernelInterfaceError;\nuse awc::error::{JsonPayloadError, SendRequestError};\nuse babel_monitor::BabelMonitorError;\n@@ -76,21 +73,11 @@ impl From<SendRequestError> for RitaClientError {\nRitaClientError::TimeoutError(error.to_string())\n}\n}\n-impl From<OldSendRequestError> for RitaClientError {\n- fn from(error: OldSendRequestError) -> Self {\n- RitaClientError::RitaCommonError(RitaCommonError::OldSendRequestError(error.to_string()))\n- }\n-}\nimpl From<JsonPayloadError> for RitaClientError {\nfn from(error: JsonPayloadError) -> Self {\nRitaClientError::JsonPayloadError(error.to_string())\n}\n}\n-impl From<OldJsonPayloadError> for RitaClientError {\n- fn from(error: OldJsonPayloadError) -> Self {\n- RitaClientError::OldJsonPayloadError(error.to_string())\n- }\n-}\nimpl From<serde_json::Error> for RitaClientError {\nfn from(error: serde_json::Error) -> Self {\nRitaClientError::SerdeJsonError(error)\n@@ -111,11 +98,6 @@ impl From<BabelMonitorError> for RitaClientError {\nRitaClientError::RitaCommonError(RitaCommonError::BabelMonitorError(error))\n}\n}\n-impl From<MailboxError> for RitaClientError {\n- fn from(error: MailboxError) -> Self {\n- RitaClientError::RitaCommonError(RitaCommonError::MailboxError(error))\n- }\n-}\nimpl From<ParseIntError> for RitaClientError {\nfn from(error: ParseIntError) -> Self {\nRitaClientError::ParseIntError(error)\n@@ -166,5 +148,3 @@ impl Display for RitaClientError {\n}\nimpl Error for RitaClientError {}\n-\n-impl actix_web::ResponseError for RitaClientError {}\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/heartbeat/mod.rs", "new_path": "rita_client/src/heartbeat/mod.rs", "diff": "@@ -25,7 +25,6 @@ use rita_common::network_monitor::get_network_info;\nuse rita_common::network_monitor::GetNetworkInfo;\nuse rita_common::tunnel_manager::Neighbor as RitaNeighbor;\n-use actix::System;\nuse althea_types::HeartbeatMessage;\nuse althea_types::Identity;\nuse althea_types::WgKey;\n@@ -81,8 +80,6 @@ lazy_static! {\npub fn send_heartbeat_loop() {\nlet mut last_restart = Instant::now();\n- // this is a reference to the non-async actix system since this can bring down the whole process\n- let system = System::current();\n// outer thread is a watchdog inner thread is the runner\nthread::spawn(move || {\n@@ -114,7 +111,8 @@ pub fn send_heartbeat_loop() {\nerror!(\"Heartbeat loop thread panicked! Respawning {:?}\", e);\nif Instant::now() - last_restart < Duration::from_secs(60) {\nerror!(\"Restarting too quickly, leaving it to auto rescue!\");\n- system.stop_with_code(121)\n+ let sys = actix_async::System::current();\n+ sys.stop_with_code(121);\n}\nlast_restart = Instant::now();\n}\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/rita_loop/mod.rs", "new_path": "rita_client/src/rita_loop/mod.rs", "diff": "@@ -13,7 +13,6 @@ use crate::light_client_manager::Watch;\nuse crate::operator_fee_manager::tick_operator_payments;\nuse crate::operator_update::operator_update;\nuse crate::traffic_watcher::get_exit_dest_price;\n-use actix::System;\nuse actix_async::System as AsyncSystem;\nuse actix_web_async::web;\nuse actix_web_async::{App, HttpServer};\n@@ -28,11 +27,6 @@ use std::sync::atomic::{AtomicBool, Ordering};\nuse std::thread;\nuse std::time::{Duration, Instant};\n-use crate::RitaClientError;\n-use actix::{\n- Actor, ActorContext, Addr, AsyncContext, Context, Handler, Message, Supervised, SystemService,\n-};\n-\nlazy_static! {\n/// see the comment on check_for_gateway_client_billing_corner_case()\n/// to identify why this variable is needed. In short it identifies\n@@ -66,70 +60,11 @@ pub fn metrics_permitted() -> bool {\npub const CLIENT_LOOP_SPEED: u64 = 5;\npub const CLIENT_LOOP_TIMEOUT: Duration = Duration::from_secs(4);\n-#[derive(Default)]\n-pub struct RitaLoop {}\n-\n-impl Actor for RitaLoop {\n- type Context = Context<Self>;\n-\n- fn started(&mut self, ctx: &mut Context<Self>) {\n- ctx.run_interval(Duration::from_secs(CLIENT_LOOP_SPEED), |_act, ctx| {\n- let addr: Addr<Self> = ctx.address();\n- addr.do_send(Tick);\n- });\n- }\n-}\n-\n-impl SystemService for RitaLoop {}\n-impl Supervised for RitaLoop {\n- fn restarting(&mut self, _ctx: &mut Context<RitaLoop>) {\n- error!(\"Rita Client loop actor died! recovering!\");\n- }\n-}\n-\n-/// Used to test actor respawning\n-pub struct Crash;\n-\n-impl Message for Crash {\n- type Result = Result<(), RitaClientError>;\n-}\n-\n-impl Handler<Crash> for RitaLoop {\n- type Result = Result<(), RitaClientError>;\n- fn handle(&mut self, _: Crash, ctx: &mut Context<Self>) -> Self::Result {\n- ctx.stop();\n- Ok(())\n- }\n-}\n-\n-pub struct Tick;\n-\n-impl Message for Tick {\n- type Result = Result<(), RitaClientError>;\n-}\n-\n-impl Handler<Tick> for RitaLoop {\n- type Result = Result<(), RitaClientError>;\n- fn handle(&mut self, _: Tick, _ctx: &mut Context<Self>) -> Self::Result {\n- let start = Instant::now();\n- trace!(\"Client Tick!\");\n-\n- info!(\n- \"Rita Client loop completed in {}s {}ms\",\n- start.elapsed().as_secs(),\n- start.elapsed().subsec_millis()\n- );\n- Ok(())\n- }\n-}\n-\n/// Rita loop thread spawning function, there are currently two rita loops, one that\n/// runs as a thread with async/await support and one that runs as a actor using old futures\n/// slowly things will be migrated into this new sync loop as we move to async/await\npub fn start_rita_loop() {\nlet mut last_restart = Instant::now();\n- // this is a reference to the non-async actix system since this can bring down the whole process\n- let system = System::current();\n// outer thread is a watchdog inner thread is the runner\nthread::spawn(move || {\n@@ -182,15 +117,15 @@ pub fn start_rita_loop() {\nerror!(\"Rita client loop thread paniced! Respawning {:?}\", e);\nif Instant::now() - last_restart < Duration::from_secs(60) {\nerror!(\"Restarting too quickly, leaving it to auto rescue!\");\n- system.stop_with_code(121)\n+ let sys = AsyncSystem::current();\n+ sys.stop_with_code(121);\n}\nlast_restart = Instant::now();\n}\n});\n}\n-pub fn check_rita_client_actors() {\n- assert!(crate::rita_loop::RitaLoop::from_registry().connected());\n+pub fn start_rita_client_loops() {\nif metrics_permitted() {\nsend_heartbeat_loop();\n}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Completely Migrated Rita Client to asnyc await. Removed the following dependencies: futures01 0.1 babel-monitor-legacy tokio 0.1 tokio-codec 0.1 actix 0.1 actix-web 0.7
20,255
28.02.2022 11:24:45
28,800
9d3ceaed1513c36e819050011085c88b9d47aaa8
Completely Migrated Rita Common to async/await. Removed the following dependencies: actix 0.7 actix-web 0.7 tokio 0.1 babel-monitor-legacy
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -3251,9 +3251,7 @@ name = \"rita_common\"\nversion = \"0.19.2\"\ndependencies = [\n\"actix 0.12.0\",\n- \"actix 0.7.11\",\n\"actix-service\",\n- \"actix-web 0.7.19\",\n\"actix-web 4.0.0-beta.20\",\n\"actix-web-httpauth 0.6.0-beta.7\",\n\"althea_kernel_interface\",\n@@ -3262,7 +3260,6 @@ dependencies = [\n\"auto-bridge\",\n\"awc\",\n\"babel_monitor\",\n- \"babel_monitor_legacy\",\n\"bincode\",\n\"byteorder\",\n\"bytes 1.1.0\",\n@@ -3285,7 +3282,6 @@ dependencies = [\n\"serde_derive\",\n\"serde_json\",\n\"settings\",\n- \"tokio 0.1.22\",\n\"web30\",\n]\n" }, { "change_type": "MODIFY", "old_path": "rita_bin/src/client.rs", "new_path": "rita_bin/src/client.rs", "diff": "@@ -34,8 +34,8 @@ use rita_client::wait_for_settings;\nuse rita_client::Args;\nuse rita_common::debt_keeper::save_debt_on_shutdown;\nuse rita_common::logging::enable_remote_logging;\n-use rita_common::rita_loop::check_rita_common_actors;\nuse rita_common::rita_loop::start_core_rita_endpoints;\n+use rita_common::rita_loop::start_rita_common_loops;\nuse rita_common::usage_tracker::save_usage_on_shutdown;\nuse rita_common::utils::env_vars_contains;\nuse settings::client::RitaClientSettings;\n@@ -137,7 +137,7 @@ fn main() {\nlet system = actix::System::new(format!(\"main {:?}\", settings.network.mesh_ip));\n- check_rita_common_actors();\n+ start_rita_common_loops();\nstart_rita_client_loops();\nstart_core_rita_endpoints(4);\nstart_rita_client_endpoints(1);\n" }, { "change_type": "MODIFY", "old_path": "rita_bin/src/exit.rs", "new_path": "rita_bin/src/exit.rs", "diff": "@@ -25,8 +25,8 @@ extern crate log;\nuse docopt::Docopt;\nuse rita_common::debt_keeper::save_debt_on_shutdown;\nuse rita_common::logging::enable_remote_logging;\n-use rita_common::rita_loop::check_rita_common_actors;\nuse rita_common::rita_loop::start_core_rita_endpoints;\n+use rita_common::rita_loop::start_rita_common_loops;\nuse rita_common::usage_tracker::save_usage_on_shutdown;\nuse rita_common::utils::env_vars_contains;\nuse rita_exit::database::sms::send_admin_notification_sms;\n@@ -123,7 +123,7 @@ fn main() {\nlet system = actix::System::new(format!(\"main {:?}\", settings.network.mesh_ip));\n- check_rita_common_actors();\n+ start_rita_common_loops();\ncheck_rita_exit_actors();\nstart_rita_exit_loop();\nlet workers = settings.workers;\n" }, { "change_type": "MODIFY", "old_path": "rita_common/Cargo.toml", "new_path": "rita_common/Cargo.toml", "diff": "@@ -5,7 +5,6 @@ edition = \"2018\"\nlicense = \"Apache-2.0\"\n[dependencies]\n-actix = \"0.7\"\nrand = \"0.8.0\"\nipnetwork = \"0.18\"\nserde_derive = \"1.0\"\n@@ -28,19 +27,16 @@ futures = { version = \"0.3\", features = [\"compat\"] }\nnum256 = \"0.3\"\nnum-traits=\"0.2\"\nfutures01 = { package = \"futures\", version = \"0.1\"}\n-tokio = \"0.1\"\nbincode = \"1.3\"\nserde_cbor = \"0.11\"\nlazy_static = \"1.4\"\nalthea_kernel_interface = { path = \"../althea_kernel_interface\" }\nactix-web-httpauth-async = { package=\"actix-web-httpauth\", version = \"0.6.0-beta.7\"}\n-actix-web = { version = \"0.7\", default_features = false, features= [\"ssl\"] }\nactix-web-async = { package=\"actix-web\", version = \"4.0.0-beta.8\", default_features = false, features= [\"openssl\"]}\nawc = {version = \"3.0.0-beta.8\", default-features = false, features=[\"openssl\", \"compress-gzip\", \"compress-zstd\"]}\nactix-service = \"2.0.2\"\nweb30 = \"0.18\"\nalthea_types = { path = \"../althea_types\" }\n-babel_monitor_legacy = {path = \"../babel_monitor_legacy\"}\n[dependencies.regex]\nversion = \"1.4\"\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/dashboard/mod.rs", "new_path": "rita_common/src/dashboard/mod.rs", "diff": "//! management and automation. They exist on port 4877 by default and should be firewalled\n//! from the outside world for obvious security reasons.\n-use actix::prelude::*;\n-use actix::registry::SystemService;\n-\npub mod babel;\npub mod debts;\npub mod development;\n@@ -15,17 +12,3 @@ pub mod token_bridge;\npub mod usage;\npub mod wallet;\npub mod wg_key;\n-\n-#[derive(Default)]\n-pub struct Dashboard;\n-\n-impl Actor for Dashboard {\n- type Context = Context<Self>;\n-}\n-\n-impl Supervised for Dashboard {}\n-impl SystemService for Dashboard {\n- fn service_started(&mut self, _ctx: &mut Context<Self>) {\n- info!(\"Dashboard started\");\n- }\n-}\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/error.rs", "new_path": "rita_common/src/error.rs", "diff": "@@ -4,8 +4,6 @@ use std::{\ntime::SystemTimeError,\n};\n-use actix::MailboxError;\n-use actix_web::ResponseError;\nuse althea_kernel_interface::KernelInterfaceError;\nuse babel_monitor::BabelMonitorError;\nuse compressed_log::builder::LoggerError;\n@@ -24,7 +22,6 @@ pub enum RitaCommonError {\nSettingsError(SettingsError),\nCapacityError(String),\nMiscStringError(String),\n- MailboxError(actix::MailboxError),\nKernelInterfaceError(KernelInterfaceError),\nStdError(std::io::Error),\nLowest20Error(usize),\n@@ -49,11 +46,6 @@ impl From<SettingsError> for RitaCommonError {\nRitaCommonError::SettingsError(error)\n}\n}\n-impl From<MailboxError> for RitaCommonError {\n- fn from(error: MailboxError) -> Self {\n- RitaCommonError::MailboxError(error)\n- }\n-}\nimpl From<KernelInterfaceError> for RitaCommonError {\nfn from(error: KernelInterfaceError) -> Self {\nRitaCommonError::KernelInterfaceError(error)\n@@ -80,8 +72,6 @@ impl From<std::boxed::Box<bincode::ErrorKind>> for RitaCommonError {\n}\n}\n-impl ResponseError for RitaCommonError {}\n-\nimpl Display for RitaCommonError {\nfn fmt(&self, f: &mut Formatter) -> FmtResult {\nmatch self {\n@@ -102,7 +92,6 @@ impl Display for RitaCommonError {\nf, \"Capacity Error: {}\", a,\n),\nRitaCommonError::MiscStringError(a) => write!(f, \"{}\", a,),\n- RitaCommonError::MailboxError(a) => write!(f, \"{}\", a,),\nRitaCommonError::KernelInterfaceError(a) => write!(f, \"{}\", a,),\nRitaCommonError::StdError(a) => write!(f, \"{}\", a,),\nRitaCommonError::Lowest20Error(a) => write!(\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/payment_validator/mod.rs", "new_path": "rita_common/src/payment_validator/mod.rs", "diff": "@@ -13,7 +13,6 @@ use crate::rita_loop::fast_loop::FAST_LOOP_TIMEOUT;\nuse crate::rita_loop::get_web3_server;\nuse crate::usage_tracker::update_payments;\n-use actix::System;\nuse althea_types::PaymentTx;\nuse num256::Uint256;\nuse web30::client::Web3;\n@@ -197,9 +196,9 @@ pub async fn validate() {\nerror!(\"{}\", msg);\n// drop the lock to prevent poisoning if we don't manage to crash\ndrop(history);\n- // get the non-async actix system and try to shut down the whole process\n- let system = System::current();\n- system.stop_with_code(121);\n+\n+ let sys = actix_async::System::current();\n+ sys.stop_with_code(121);\n// this satisfies the borrow checker to let us drop history so that if we\n// fail to get the current actix system we don't poison the lock fatally\nreturn;\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/rita_loop/fast_loop.rs", "new_path": "rita_common/src/rita_loop/fast_loop.rs", "diff": "@@ -15,20 +15,12 @@ use crate::tunnel_manager::tm_contact_peers;\nuse crate::tunnel_manager::tm_get_neighbors;\nuse crate::tunnel_manager::PeersToContact;\nuse crate::update_neighbor_status;\n-use crate::RitaCommonError;\n-use actix::{\n- Actor, ActorContext, Addr, Arbiter, AsyncContext, Context, Handler, Message, Supervised,\n- System, SystemService,\n-};\n+\nuse actix_async::System as AsyncSystem;\nuse babel_monitor::open_babel_stream;\nuse babel_monitor::parse_interfaces;\nuse babel_monitor::parse_neighs;\nuse babel_monitor::parse_routes;\n-use babel_monitor_legacy::open_babel_stream_legacy;\n-use babel_monitor_legacy::parse_routes_legacy;\n-use babel_monitor_legacy::start_connection_legacy;\n-use futures01::Future;\nuse std::thread;\nuse std::time::{Duration, Instant};\n@@ -44,53 +36,22 @@ pub const FAST_LOOP_TIMEOUT: Duration = Duration::from_secs(4);\npub const TUNNEL_TIMEOUT: Duration = Duration::from_secs(900);\npub const TUNNEL_HANDSHAKE_TIMEOUT: Duration = TUNNEL_TIMEOUT;\n-#[derive(Default)]\n-pub struct RitaFastLoop {}\n-\n-impl Actor for RitaFastLoop {\n- type Context = Context<Self>;\n-\n- fn started(&mut self, ctx: &mut Context<Self>) {\n- trace!(\"Common rita loop started!\");\n-\n- ctx.run_interval(FAST_LOOP_SPEED, |_act, ctx| {\n- let addr: Addr<Self> = ctx.address();\n- addr.do_send(Tick);\n- });\n- }\n-}\n-\n-impl SystemService for RitaFastLoop {}\n-impl Supervised for RitaFastLoop {\n- fn restarting(&mut self, _ctx: &mut Context<RitaFastLoop>) {\n- error!(\"Rita Common loop actor died! recovering!\");\n- }\n-}\n-\n-/// Used to test actor respawning\n-pub struct Crash;\n-\n-impl Message for Crash {\n- type Result = Result<(), RitaCommonError>;\n-}\n-\n-impl Handler<Crash> for RitaFastLoop {\n- type Result = Result<(), RitaCommonError>;\n- fn handle(&mut self, _: Crash, ctx: &mut Context<Self>) -> Self::Result {\n- ctx.stop();\n- Ok(())\n- }\n-}\n-\n-pub struct Tick;\n-\n-impl Message for Tick {\n- type Result = Result<(), RitaCommonError>;\n-}\n+/// Rita fast loop thread spawning function, there are currently two rita fast loops, one that\n+/// runs as a thread with async/await support and one that runs as a actor using old futures\n+/// slowly things will be migrated into this new sync loop as we move to async/await\n+pub fn start_rita_fast_loop() {\n+ let mut last_restart = Instant::now();\n+ // outer thread is a watchdog inner thread is the runner\n+ thread::spawn(move || {\n+ // this will always be an error, so it's really just a loop statement\n+ // with some fancy destructuring\n+ while let Err(e) = {\n+ thread::spawn(move || loop {\n+ let start = Instant::now();\n+ trace!(\"Common Fast tick!\");\n-impl Handler<Tick> for RitaFastLoop {\n- type Result = Result<(), RitaCommonError>;\n- fn handle(&mut self, _: Tick, _ctx: &mut Context<Self>) -> Self::Result {\n+ let runner = AsyncSystem::new();\n+ runner.block_on(async move {\nlet babel_port = settings::get_rita_common().network.babel_port;\ntrace!(\"Common tick!\");\n@@ -106,30 +67,18 @@ impl Handler<Tick> for RitaFastLoop {\nstart.elapsed().subsec_millis()\n);\n- //watch neighbors for billing\n- Arbiter::spawn(\n- open_babel_stream_legacy(babel_port)\n- .from_err()\n- .and_then(move |stream| {\n- start_connection_legacy(stream).and_then(move |stream| {\n- parse_routes_legacy(stream).and_then(move |routes| {\n- let _res = watch(routes.1, &neighbors);\n+ if let Ok(mut stream) = open_babel_stream(babel_port, FAST_LOOP_TIMEOUT) {\n+ if let Ok(babel_routes) = parse_routes(&mut stream) {\n+ if let Err(e) = watch(babel_routes, &neighbors) {\n+ error!(\"Error for Rita common traffic watcher {}\", e);\n+ }\ninfo!(\n\"TrafficWatcher completed in {}s {}ms\",\nneigh.elapsed().as_secs(),\nneigh.elapsed().subsec_millis()\n);\n- Ok(())\n- })\n- })\n- })\n- .then(|ret| {\n- if let Err(e) = ret {\n- error!(\"Failed to watch client traffic with {:?}\", e)\n}\n- Ok(())\n- }),\n- );\n+ }\n// Observe the dataplane for status and problems. Tunnel GC checks for specific issues\n// (tunnels that are installed but not active) and cleans up cruft. We put these together\n@@ -140,7 +89,9 @@ impl Handler<Tick> for RitaFastLoop {\nlet babel_neighbors = parse_neighs(&mut stream);\nlet babel_interfaces = parse_interfaces(&mut stream);\nlet babel_routes = parse_routes(&mut stream);\n- if let (Ok(babel_neighbors), Ok(babel_routes)) = (babel_neighbors, babel_routes) {\n+ if let (Ok(babel_neighbors), Ok(babel_routes)) =\n+ (babel_neighbors, babel_routes)\n+ {\ntrace!(\"Sending network monitor tick\");\nupdate_network_info(NetworkMonitorTick {\nbabel_neighbors,\n@@ -167,28 +118,6 @@ impl Handler<Tick> for RitaFastLoop {\nupdate_neighbor_status();\nhandle_shaping();\n- Ok(())\n- }\n-}\n-\n-/// Rita fast loop thread spawning function, there are currently two rita fast loops, one that\n-/// runs as a thread with async/await support and one that runs as a actor using old futures\n-/// slowly things will be migrated into this new sync loop as we move to async/await\n-pub fn start_rita_fast_loop() {\n- let mut last_restart = Instant::now();\n- // this is a reference to the non-async actix system since this can bring down the whole process\n- let system = System::current();\n- // outer thread is a watchdog inner thread is the runner\n- thread::spawn(move || {\n- // this will always be an error, so it's really just a loop statement\n- // with some fancy destructuring\n- while let Err(e) = {\n- thread::spawn(move || loop {\n- let start = Instant::now();\n- trace!(\"Common Fast tick!\");\n-\n- let runner = AsyncSystem::new();\n- runner.block_on(async move {\n// updating blockchain info often is easier than dealing with edge cases\n// like out of date nonces or balances, also users really really want fast\n// balance updates, think very long and very hard before running this more slowly\n@@ -217,7 +146,8 @@ pub fn start_rita_fast_loop() {\nerror!(\"Rita common fast loop thread paniced! Respawning {:?}\", e);\nif Instant::now() - last_restart < Duration::from_secs(60) {\nerror!(\"Restarting too quickly, leaving it to auto rescue!\");\n- system.stop_with_code(121)\n+ let sys = AsyncSystem::current();\n+ sys.stop_with_code(121);\n}\nlast_restart = Instant::now();\n}\n@@ -228,8 +158,6 @@ pub fn start_rita_fast_loop() {\n/// to block the entire loop\npub fn peer_discovery_loop() {\nlet mut last_restart = Instant::now();\n- // this is a reference to the non-async actix system since this can bring down the whole process\n- let system = System::current();\n// outer thread is a watchdog inner thread is the runner\nthread::spawn(move || {\n// this will always be an error, so it's really just a loop statement\n@@ -274,7 +202,8 @@ pub fn peer_discovery_loop() {\n);\nif Instant::now() - last_restart < Duration::from_secs(60) {\nerror!(\"Restarting too quickly, leaving it to auto rescue!\");\n- system.stop_with_code(121)\n+ let sys = AsyncSystem::current();\n+ sys.stop_with_code(121);\n}\nlast_restart = Instant::now();\n}\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/rita_loop/mod.rs", "new_path": "rita_common/src/rita_loop/mod.rs", "diff": "use crate::network_endpoints::*;\nuse crate::traffic_watcher::init_traffic_watcher;\n-use actix::SystemService;\nuse actix_async::System;\nuse actix_web_async::{web, App, HttpServer};\nuse rand::thread_rng;\n@@ -91,9 +90,8 @@ pub fn start_core_rita_endpoints(workers: usize) {\n});\n}\n-pub fn check_rita_common_actors() {\n+pub fn start_rita_common_loops() {\ninit_traffic_watcher();\n- assert!(crate::rita_loop::fast_loop::RitaFastLoop::from_registry().connected());\ncrate::rita_loop::slow_loop::start_rita_slow_loop();\ncrate::rita_loop::fast_loop::start_rita_fast_loop();\ncrate::rita_loop::fast_loop::peer_discovery_loop();\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/rita_loop/slow_loop.rs", "new_path": "rita_common/src/rita_loop/slow_loop.rs", "diff": "use crate::simulated_txfee_manager::tick_simulated_tx;\nuse crate::token_bridge::tick_token_bridge;\n-use actix::System;\nuse actix_async::System as AsyncSystem;\nuse babel_monitor::open_babel_stream;\nuse babel_monitor::set_local_fee;\n@@ -14,7 +13,6 @@ pub const SLOW_LOOP_SPEED: Duration = Duration::from_secs(60);\npub const SLOW_LOOP_TIMEOUT: Duration = Duration::from_secs(15);\npub fn start_rita_slow_loop() {\n- let system = System::current();\nlet mut last_restart = Instant::now();\nthread::spawn(move || {\n// this will always be an error, so it's really just a loop statement\n@@ -50,7 +48,8 @@ pub fn start_rita_slow_loop() {\nerror!(\"Rita common slow loop thread panicked! Respawning {:?}\", e);\nif Instant::now() - last_restart < Duration::from_secs(120) {\nerror!(\"Restarting too quickly, leaving it to auto rescue!\");\n- system.stop_with_code(121)\n+ let sys = AsyncSystem::current();\n+ sys.stop_with_code(121);\n}\nlast_restart = Instant::now();\n}\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/usage_tracker/mod.rs", "new_path": "rita_common/src/usage_tracker/mod.rs", "diff": "//! the handler updates the storage to reflect the new total. When a user would like to inspect\n//! or graph usage they query an endpoint which will request the data from this module.\n-use actix::Message;\nuse althea_types::Identity;\nuse althea_types::PaymentTx;\nuse bincode::Error as BincodeError;\n@@ -299,10 +298,6 @@ pub struct UpdateUsage {\npub price: u32,\n}\n-impl Message for UpdateUsage {\n- type Result = Result<(), RitaCommonError>;\n-}\n-\npub fn update_usage_data(msg: UpdateUsage) {\nlet curr_hour = match get_current_hour() {\nOk(hour) => hour,\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Completely Migrated Rita Common to async/await. Removed the following dependencies: actix 0.7 actix-web 0.7 tokio 0.1 babel-monitor-legacy
20,255
28.02.2022 10:11:37
28,800
b38356b907e09de37292fb022170dcb30a78c087
Migrated exit dbclient, geoip and traffic watcher to async/await
[ { "change_type": "MODIFY", "old_path": "rita_bin/src/exit.rs", "new_path": "rita_bin/src/exit.rs", "diff": "@@ -30,7 +30,6 @@ use rita_common::rita_loop::start_rita_common_loops;\nuse rita_common::usage_tracker::save_usage_on_shutdown;\nuse rita_common::utils::env_vars_contains;\nuse rita_exit::database::sms::send_admin_notification_sms;\n-use rita_exit::rita_loop::check_rita_exit_actors;\nuse rita_exit::rita_loop::start_rita_exit_endpoints;\nuse rita_exit::rita_loop::start_rita_exit_loop;\nuse rita_exit::start_rita_exit_dashboard;\n@@ -124,7 +123,6 @@ fn main() {\nlet system = actix::System::new(format!(\"main {:?}\", settings.network.mesh_ip));\nstart_rita_common_loops();\n- check_rita_exit_actors();\nstart_rita_exit_loop();\nlet workers = settings.workers;\nstart_core_rita_endpoints(workers as usize);\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/db_client.rs", "new_path": "rita_exit/src/database/db_client.rs", "diff": "-use actix::Actor;\n-use actix::Context;\n-use actix::Handler;\n-use actix::Message;\n-use actix::Supervised;\n-use actix::SystemService;\n-use actix_web::Result;\nuse diesel::dsl::delete;\nuse diesel::*;\nuse exit_db::schema;\n@@ -12,29 +5,7 @@ use exit_db::schema;\nuse crate::database::database_tools::get_database_connection;\nuse crate::RitaExitError;\n-#[derive(Default)]\n-pub struct DbClient;\n-\n-impl Actor for DbClient {\n- type Context = Context<Self>;\n-}\n-\n-impl Supervised for DbClient {}\n-impl SystemService for DbClient {\n- fn service_started(&mut self, _ctx: &mut Context<Self>) {\n- info!(\"DB Client started\");\n- }\n-}\n-\n-pub struct TruncateTables;\n-impl Message for TruncateTables {\n- type Result = Result<(), RitaExitError>;\n-}\n-\n-impl Handler<TruncateTables> for DbClient {\n- type Result = Result<(), RitaExitError>;\n-\n- fn handle(&mut self, _: TruncateTables, _: &mut Self::Context) -> Self::Result {\n+pub fn truncate_db_tables() -> Result<(), RitaExitError> {\nuse self::schema::clients::dsl::*;\ninfo!(\"Deleting all clients in database\");\nlet connection = get_database_connection()?;\n@@ -42,4 +13,3 @@ impl Handler<TruncateTables> for DbClient {\nOk(())\n}\n-}\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/geoip.rs", "new_path": "rita_exit/src/database/geoip.rs", "diff": "use babel_monitor::open_babel_stream;\nuse babel_monitor::parse_routes;\n-use babel_monitor_legacy::open_babel_stream_legacy;\n-use babel_monitor_legacy::parse_routes_legacy;\n-use babel_monitor_legacy::start_connection_legacy;\n-use futures01::future::Future;\nuse ipnetwork::IpNetwork;\nuse rita_common::utils::ip_increment::is_unicast_link_local;\nuse rita_common::KI;\n@@ -73,23 +69,20 @@ pub struct IpPair {\n/// not appear in the result vec\npub fn get_gateway_ip_bulk(\nmesh_ip_list: Vec<IpAddr>,\n-) -> Box<dyn Future<Item = Vec<IpPair>, Error = RitaExitError>> {\n+ timeout: Duration,\n+) -> Result<Vec<IpPair>, RitaExitError> {\nlet babel_port = settings::get_rita_exit().network.babel_port;\ntrace!(\"getting gateway ip bulk\");\n- Box::new(\n- open_babel_stream_legacy(babel_port)\n- .from_err()\n- .and_then(|stream| {\n- start_connection_legacy(stream)\n- .from_err()\n- .and_then(|stream| {\n- parse_routes_legacy(stream).from_err().and_then(|routes| {\n+ match open_babel_stream(babel_port, timeout) {\n+ Ok(mut stream) => {\n+ match parse_routes(&mut stream) {\n+ Ok(routes) => {\ntrace!(\"done talking to babel for gateway ip bulk\");\nlet mut remote_ip_cache: HashMap<String, IpAddr> = HashMap::new();\nlet mut results = Vec::new();\nfor mesh_ip in mesh_ip_list {\n- for route in routes.1.iter() {\n+ for route in routes.iter() {\n// Only ip6\nif let IpNetwork::V6(ref ip) = route.prefix {\n// Only host addresses and installed routes\n@@ -99,9 +92,7 @@ pub fn get_gateway_ip_bulk(\n{\n// check if we've already looked up this interface this round, since gateways\n// have many clients this will often be the case\n- if let Some(remote_ip) =\n- remote_ip_cache.get(&route.iface)\n- {\n+ if let Some(remote_ip) = remote_ip_cache.get(&route.iface) {\nresults.push(IpPair {\nmesh_ip,\ngateway_ip: *remote_ip,\n@@ -117,10 +108,7 @@ pub fn get_gateway_ip_bulk(\n})\n}\nErr(e) => {\n- error!(\n- \"Failure looking up remote ip {:?}\",\n- e\n- )\n+ error!(\"Failure looking up remote ip {:?}\", e)\n}\n}\n}\n@@ -130,10 +118,12 @@ pub fn get_gateway_ip_bulk(\n}\nOk(results)\n- })\n- })\n- }),\n- )\n+ }\n+ Err(e) => Err(e.into()),\n+ }\n+ }\n+ Err(e) => Err(e.into()),\n+ }\n}\n#[derive(Deserialize, Debug)]\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/mod.rs", "new_path": "rita_exit/src/database/mod.rs", "diff": "@@ -34,8 +34,6 @@ use ipnetwork::IpNetwork;\nuse rita_common::blockchain_oracle::get_oracle_close_thresh;\nuse rita_common::debt_keeper::get_debts_list;\nuse rita_common::debt_keeper::DebtAction;\n-use rita_common::utils::wait_timeout::wait_timeout;\n-use rita_common::utils::wait_timeout::WaitResult;\nuse settings::exit::ExitVerifSettings;\nuse std::collections::HashMap;\nuse std::collections::HashSet;\n@@ -252,12 +250,9 @@ pub fn validate_clients_region(\nErr(_e) => error!(\"Database entry with invalid mesh ip! {:?}\", item),\n}\n}\n- let list = match wait_timeout(get_gateway_ip_bulk(ip_vec), EXIT_LOOP_TIMEOUT) {\n- WaitResult::Err(e) => return Err(e),\n- WaitResult::Ok(val) => val,\n- WaitResult::TimedOut(_) => {\n- return Err(RitaExitError::MiscStringError(\"Timed out!\".to_string()))\n- }\n+ let list = match get_gateway_ip_bulk(ip_vec, EXIT_LOOP_TIMEOUT) {\n+ Err(e) => return Err(e),\n+ Ok(val) => val,\n};\nfor item in list.iter() {\nlet res = verify_ip_sync(item.gateway_ip);\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/network_endpoints/mod.rs", "new_path": "rita_exit/src/network_endpoints/mod.rs", "diff": "@@ -253,11 +253,12 @@ pub fn nuke_db(_req: HttpRequest) -> HttpResponse {\n}\n#[cfg(feature = \"development\")]\n-pub fn nuke_db(_req: HttpRequest) -> Box<dyn Future<Item = HttpResponse, Error = Error>> {\n+pub fn nuke_db(_req: HttpRequest) -> HttpResponse {\n+ use crate::truncate_db_tables;\n+\ntrace!(\"nuke_db: Truncating all data from the database\");\n- DbClient::from_registry()\n- .send(TruncateTables {})\n- .from_err()\n- .and_then(move |_| Ok(HttpResponse::NoContent().finish()))\n- .responder()\n+ if let Err(e) = truncate_db_tables() {\n+ error!(\"Error: {}\", e);\n+ }\n+ HttpResponse::NoContent().finish()\n}\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/rita_loop/mod.rs", "new_path": "rita_exit/src/rita_loop/mod.rs", "diff": "@@ -17,23 +17,18 @@ use crate::database::struct_tools::clients_to_ids;\nuse crate::database::{\ncleanup_exit_clients, enforce_exit_clients, setup_clients, validate_clients_region,\n};\n-use crate::traffic_watcher::{TrafficWatcher, Watch};\n-use actix::Addr;\n+use crate::traffic_watcher::{watch_exit_traffic, Watch};\nuse actix::System;\n-use actix::SystemService;\nuse actix_async::System as AsyncSystem;\nuse actix_web_async::{web, App, HttpServer};\nuse althea_kernel_interface::ExitClient;\nuse althea_types::Identity;\n-use babel_monitor_legacy::open_babel_stream_legacy;\n-use babel_monitor_legacy::parse_routes_legacy;\n-use babel_monitor_legacy::start_connection_legacy;\n+use babel_monitor::{open_babel_stream, parse_routes};\n+\nuse diesel::{query_dsl::RunQueryDsl, PgConnection};\nuse exit_db::models;\n-use futures01::future::Future;\nuse rita_common::debt_keeper::DebtAction;\n-use rita_common::utils::wait_timeout::wait_timeout;\n-use rita_common::utils::wait_timeout::WaitResult;\n+\nuse std::collections::HashSet;\nuse std::thread;\nuse std::time::Duration;\n@@ -65,7 +60,6 @@ pub fn start_rita_exit_loop() {\nwhile let Err(e) = {\nlet system_ref = system.clone();\nthread::spawn(move || {\n- let tw = system_ref.registry().get();\n// a cache of what tunnels we had setup last round, used to prevent extra setup ops\nlet mut wg_clients: HashSet<ExitClient> = HashSet::new();\n// a list of client debts from the last round, to prevent extra enforcement ops\n@@ -74,13 +68,9 @@ pub fn start_rita_exit_loop() {\n// setup exit clients and should crash if we fail to do so, otherwise we are preventing\n// proper failover\nlet mut successful_setup: bool = false;\n- // wait until the system gets started\n- while !tw.connected() {\n- trace!(\"Waiting for actors to start\");\n- }\n+\nloop {\nrita_exit_loop(\n- tw.clone(),\n&mut wg_clients,\n&mut debt_actions,\n&mut successful_setup,\n@@ -101,7 +91,6 @@ pub fn start_rita_exit_loop() {\n}\nfn rita_exit_loop(\n- tw: Addr<TrafficWatcher>,\nwg_clients: &mut HashSet<ExitClient>,\ndebt_actions: &mut HashSet<(Identity, DebtAction)>,\nsuccessful_setup: &mut bool,\n@@ -125,7 +114,7 @@ fn rita_exit_loop(\nlet ids = clients_to_ids(clients_list.clone());\n// watch and bill for traffic\n- bill(babel_port, &tw, start, ids);\n+ bill(babel_port, start, ids);\ninfo!(\"about to setup clients\");\n// Create and update client tunnels\n@@ -183,40 +172,41 @@ fn rita_exit_loop(\n}\n}\n-fn bill(babel_port: u16, tw: &Addr<TrafficWatcher>, start: Instant, ids: Vec<Identity>) {\n+fn bill(babel_port: u16, start: Instant, ids: Vec<Identity>) {\ntrace!(\"about to try opening babel stream\");\n- let res = wait_timeout(\n- open_babel_stream_legacy(babel_port)\n- .from_err()\n- .and_then(|stream| {\n- trace!(\"got babel stream\");\n- start_connection_legacy(stream).and_then(|stream| {\n- parse_routes_legacy(stream).and_then(|routes| {\n+\n+ match open_babel_stream(babel_port, EXIT_LOOP_TIMEOUT) {\n+ Ok(mut stream) => match parse_routes(&mut stream) {\n+ Ok(routes) => {\ntrace!(\"Sending traffic watcher message?\");\n- tw.do_send(Watch {\n- users: ids,\n- routes: routes.1,\n- });\n- Ok(())\n- })\n- })\n- }),\n- EXIT_LOOP_TIMEOUT,\n- );\n- match res {\n- WaitResult::Err(e) => warn!(\n- \"Failed to watch exit traffic with {:?} {}ms since start\",\n+ if let Err(e) = watch_exit_traffic(Watch { users: ids, routes }) {\n+ error!(\n+ \"Watch exit traffic failed with {}, in {} millis\",\ne,\nstart.elapsed().as_millis()\n- ),\n- WaitResult::Ok(_) => info!(\n- \"watch exit traffic completed successfully {}ms since loop start\",\n+ );\n+ } else {\n+ info!(\n+ \"Watch exit traffic completed successfully in {} millis\",\nstart.elapsed().as_millis()\n- ),\n- WaitResult::TimedOut(_) => error!(\n- \"watch exit traffic timed out! {}ms since loop start\",\n+ );\n+ }\n+ }\n+ Err(e) => {\n+ error!(\n+ \"Watch exit traffic failed with: {} in {} millis\",\n+ e,\nstart.elapsed().as_millis()\n- ),\n+ );\n+ }\n+ },\n+ Err(e) => {\n+ error!(\n+ \"Watch exit traffic failed with: {} in {} millis\",\n+ e,\n+ start.elapsed().as_millis()\n+ );\n+ }\n}\n}\n@@ -254,11 +244,6 @@ fn setup_exit_wg_tunnel() {\n.unwrap();\n}\n-pub fn check_rita_exit_actors() {\n- assert!(crate::traffic_watcher::TrafficWatcher::from_registry().connected());\n- assert!(crate::database::db_client::DbClient::from_registry().connected());\n-}\n-\npub fn start_rita_exit_endpoints(workers: usize) {\nthread::spawn(move || {\nlet runner = AsyncSystem::new();\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/traffic_watcher/mod.rs", "new_path": "rita_exit/src/traffic_watcher/mod.rs", "diff": "@@ -14,7 +14,6 @@ use rita_common::usage_tracker::update_usage_data;\nuse rita_common::usage_tracker::UpdateUsage;\nuse rita_common::usage_tracker::UsageType;\n-use actix::{Actor, Context, Handler, Message, Supervised, SystemService};\nuse althea_kernel_interface::wg_iface_counter::prepare_usage_history;\nuse althea_kernel_interface::wg_iface_counter::WgUsage;\nuse althea_kernel_interface::KI;\n@@ -24,40 +23,33 @@ use babel_monitor::Route as RouteLegacy;\nuse ipnetwork::IpNetwork;\nuse std::collections::HashMap;\nuse std::net::IpAddr;\n+use std::sync::Arc;\n+use std::sync::RwLock;\nuse crate::RitaExitError;\n+lazy_static! {\n+ static ref TRAFFIC_WATCHER: Arc<RwLock<TrafficWatcher>> =\n+ Arc::new(RwLock::new(TrafficWatcher::default()));\n+}\n+\n#[derive(Default)]\npub struct TrafficWatcher {\nlast_seen_bytes: HashMap<WgKey, WgUsage>,\n}\n-impl Actor for TrafficWatcher {\n- type Context = Context<Self>;\n-}\n-\n-impl Supervised for TrafficWatcher {}\n-impl SystemService for TrafficWatcher {\n- fn service_started(&mut self, _ctx: &mut Context<Self>) {\n- info!(\"Traffic Watcher started\");\n- }\n-}\n-\npub struct Watch {\npub users: Vec<Identity>,\npub routes: Vec<RouteLegacy>,\n}\n-impl Message for Watch {\n- type Result = Result<(), RitaExitError>;\n-}\n-\n-impl Handler<Watch> for TrafficWatcher {\n- type Result = Result<(), RitaExitError>;\n-\n- fn handle(&mut self, msg: Watch, _: &mut Context<Self>) -> Self::Result {\n- watch(&mut self.last_seen_bytes, &msg.routes, &msg.users)\n- }\n+pub fn watch_exit_traffic(msg: Watch) -> Result<(), RitaExitError> {\n+ let traffic_watcher = &mut *TRAFFIC_WATCHER.write().unwrap();\n+ watch(\n+ &mut traffic_watcher.last_seen_bytes,\n+ &msg.routes,\n+ &msg.users,\n+ )\n}\nfn get_babel_info(\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Migrated exit dbclient, geoip and traffic watcher to async/await
20,255
28.02.2022 12:14:43
28,800
28fd1d66f2cb422f973d51403016a9e107e07d5c
Completely Migrated Rita Exit to asnyc/await. Removed the following dependencies: actix 0.7 actix-web 0.7 babel-monitor-legacy futures01 0.1
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -3290,20 +3290,16 @@ name = \"rita_exit\"\nversion = \"0.19.2\"\ndependencies = [\n\"actix 0.12.0\",\n- \"actix 0.7.11\",\n- \"actix-web 0.7.19\",\n\"actix-web 4.0.0-beta.20\",\n\"althea_kernel_interface\",\n\"althea_types\",\n\"arrayvec 0.7.2\",\n\"awc\",\n\"babel_monitor\",\n- \"babel_monitor_legacy\",\n\"clarity\",\n\"compressed_log\",\n\"diesel\",\n\"exit_db\",\n- \"futures 0.1.31\",\n\"handlebars\",\n\"ipnetwork 0.18.0\",\n\"lazy_static\",\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/Cargo.toml", "new_path": "rita_exit/Cargo.toml", "diff": "@@ -15,7 +15,6 @@ althea_kernel_interface = { path = \"../althea_kernel_interface\" }\nalthea_types = { path = \"../althea_types\" }\nsettings = { path = \"../settings\" }\nbabel_monitor = { path = \"../babel_monitor\" }\n-actix = \"0.7\"\nactix-async = { package = \"actix\", version = \"0.12\"}\nawc = \"3.0.0-beta.18\"\nhandlebars = \"4.0\"\n@@ -34,9 +33,6 @@ arrayvec = {version= \"0.7\", features = [\"serde\"]}\nlog = { version = \"0.4\", features = [\"release_max_level_info\"] }\nreqwest = { version = \"0.11\", features = [\"blocking\", \"json\"] }\nexit_db = { path = \"../exit_db\" }\n-babel_monitor_legacy = {path = \"../babel_monitor_legacy\"}\n-actix-web = { version = \"0.7\", default_features = false, features= [\"ssl\"] }\nactix-web-async = {package=\"actix-web\", version = \"4.0.0-beta.8\", default_features = false, features= [\"openssl\"] }\ndiesel = { version = \"1.4\", features = [\"postgres\", \"r2d2\"] }\n-futures01 = { package = \"futures\", version = \"0.1\"}\n[features]\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/database_tools.rs", "new_path": "rita_exit/src/database/database_tools.rs", "diff": "@@ -4,7 +4,6 @@ use crate::database::ONE_DAY;\nuse rita_common::utils::ip_increment::increment;\nuse crate::{RitaExitError, DB_POOL};\n-use actix_web::Result;\nuse althea_kernel_interface::ExitClient;\nuse althea_types::ExitClientIdentity;\nuse diesel::dsl::{delete, exists};\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/error.rs", "new_path": "rita_exit/src/error.rs", "diff": "-use actix_web::client::SendRequestError as OldSendRequestError;\nuse althea_kernel_interface::KernelInterfaceError;\nuse althea_types::{error::AltheaTypesError, ExitClientIdentity};\nuse babel_monitor::BabelMonitorError;\n@@ -95,11 +94,6 @@ impl From<BabelMonitorError> for RitaExitError {\nRitaExitError::RitaCommonError(RitaCommonError::BabelMonitorError(error))\n}\n}\n-impl From<OldSendRequestError> for RitaExitError {\n- fn from(error: OldSendRequestError) -> Self {\n- RitaExitError::RitaCommonError(RitaCommonError::OldSendRequestError(error.to_string()))\n- }\n-}\nimpl Display for RitaExitError {\nfn fmt(&self, f: &mut Formatter) -> FmtResult {\n@@ -124,5 +118,3 @@ impl Display for RitaExitError {\n}\nimpl Error for RitaExitError {}\n-\n-impl actix_web::ResponseError for RitaExitError {}\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/rita_loop/mod.rs", "new_path": "rita_exit/src/rita_loop/mod.rs", "diff": "@@ -18,7 +18,6 @@ use crate::database::{\ncleanup_exit_clients, enforce_exit_clients, setup_clients, validate_clients_region,\n};\nuse crate::traffic_watcher::{watch_exit_traffic, Watch};\n-use actix::System;\nuse actix_async::System as AsyncSystem;\nuse actix_web_async::{web, App, HttpServer};\nuse althea_kernel_interface::ExitClient;\n@@ -50,15 +49,12 @@ pub const EXIT_LOOP_TIMEOUT: Duration = Duration::from_secs(4);\n/// TODO remove futures on the actix parts of this by moving to thread local state\npub fn start_rita_exit_loop() {\nsetup_exit_wg_tunnel();\n- // this is a reference to the non-async actix system\n- let system = System::current();\nlet mut last_restart = Instant::now();\n// outer thread is a watchdog, inner thread is the runner\nthread::spawn(move || {\n// this will always be an error, so it's really just a loop statement\n// with some fancy destructuring\nwhile let Err(e) = {\n- let system_ref = system.clone();\nthread::spawn(move || {\n// a cache of what tunnels we had setup last round, used to prevent extra setup ops\nlet mut wg_clients: HashSet<ExitClient> = HashSet::new();\n@@ -70,12 +66,7 @@ pub fn start_rita_exit_loop() {\nlet mut successful_setup: bool = false;\nloop {\n- rita_exit_loop(\n- &mut wg_clients,\n- &mut debt_actions,\n- &mut successful_setup,\n- &system_ref,\n- )\n+ rita_exit_loop(&mut wg_clients, &mut debt_actions, &mut successful_setup)\n}\n})\n.join()\n@@ -83,7 +74,8 @@ pub fn start_rita_exit_loop() {\nerror!(\"Exit loop thread panicked! Respawning {:?}\", e);\nif Instant::now() - last_restart < Duration::from_secs(60) {\nerror!(\"Restarting too quickly, leaving it to systemd!\");\n- system.stop_with_code(121)\n+ let sys = AsyncSystem::current();\n+ sys.stop_with_code(121);\n}\nlast_restart = Instant::now();\n}\n@@ -94,7 +86,6 @@ fn rita_exit_loop(\nwg_clients: &mut HashSet<ExitClient>,\ndebt_actions: &mut HashSet<(Identity, DebtAction)>,\nsuccessful_setup: &mut bool,\n- system: &System,\n) {\nlet start = Instant::now();\n// opening a database connection takes at least several milliseconds, as the database server\n@@ -160,7 +151,8 @@ fn rita_exit_loop(\ndb_uri\n);\nerror!(\"{}\", message);\n- system.stop();\n+ let sys = AsyncSystem::current();\n+ sys.stop();\npanic!(\"{}\", message);\n}\n}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Completely Migrated Rita Exit to asnyc/await. Removed the following dependencies: actix 0.7 actix-web 0.7 babel-monitor-legacy futures01 0.1
20,244
01.03.2022 07:50:54
18,000
7d47948d00cb57a99880d1be58813466c5957636
Restore linux_build_static as build_exit.sh This pulls a recently deleted file out of the history becuase I simply can't figure out how to staticly link postgresql without it.
[ { "change_type": "MODIFY", "old_path": "scripts/build_exit.sh", "new_path": "scripts/build_exit.sh", "diff": "#!/bin/bash\n+# Usage: ./linux_build_static [--debug] [--release]\n+#\n+# This script builds a static Linux binaries.\n+#\n+# Options:\n+# --debug (optional) Use debug profile\n+# --release (optional) Use release profile (default)\n+# --features (optional) List of features to build\n+#\n+# Note: You may need to disable or modify selinux, or add $USER to docker group\n+# to be able to use `docker`.\nset -eux\n-DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\n-echo $DIR\n-\n-pushd $DIR/../cross-builders/exit\n-docker build -t cross-with-clang-ssl .\n-cp Cross.toml ../..\n-popd\n-pushd $DIR/..\n-cross build --release --target x86_64-unknown-linux-gnu -p rita_bin --bin rita_exit\n-rm Cross.toml\n+\n+DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" >/dev/null && pwd )\"\n+\n+# Parse command line arguments\n+source $DIR/build_common.sh\n+\n+RUST_TOOLCHAIN=\"stable\"\n+CARGO_ROOT=\"$HOME/.cargo\"\n+CARGO_GIT=\"$CARGO_ROOT/.git\"\n+CARGO_REGISTRY=\"$CARGO_ROOT/registry\"\n+\n+docker pull ekidd/rust-musl-builder\n+RUST_MUSL_BUILDER=\"docker run --rm -it -v \"$(pwd)\":/home/rust/src -v $CARGO_GIT:/home/rust/.cargo/git -v $CARGO_REGISTRY:/home/rust/.cargo/registry ekidd/rust-musl-builder\"\n+$RUST_MUSL_BUILDER sudo chown -R rust:rust /home/rust/.cargo/git /home/rust/.cargo/registry\n+\n+$RUST_MUSL_BUILDER cargo build --all ${PROFILE} ${FEATURES}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Restore linux_build_static as build_exit.sh This pulls a recently deleted file out of the history becuase I simply can't figure out how to staticly link postgresql without it.
20,244
01.03.2022 11:23:44
18,000
f6ca50a40f4949512d0dda13ea131602b29a8a28
Correct new clippy nits for Rust v1.59.0
[ { "change_type": "MODIFY", "old_path": "althea_kernel_interface/src/open_tunnel.rs", "new_path": "althea_kernel_interface/src/open_tunnel.rs", "diff": "@@ -103,7 +103,7 @@ impl dyn KernelInterface {\n\"listen-port\",\n&format!(\"{}\", args.port),\n\"private-key\",\n- &args.private_key_path.to_str().unwrap().to_string(),\n+ args.private_key_path.to_str().unwrap(),\n\"peer\",\n&format!(\"{}\", args.remote_pub_key),\n\"endpoint\",\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/dashboard/auth.rs", "new_path": "rita_client/src/dashboard/auth.rs", "diff": "@@ -16,7 +16,7 @@ pub fn set_pass(router_pass: Json<RouterPassword>) -> HttpResponse {\ndebug!(\"Using {} as sha3 512 input\", input_string);\nlet mut hasher = Sha3_512::new();\nhasher.update(input_string.as_bytes());\n- let hashed_pass = bytes_to_hex_str(&hasher.finalize().to_vec());\n+ let hashed_pass = bytes_to_hex_str(&hasher.finalize());\nlet mut rita_client = settings::get_rita_client();\nrita_client.network.rita_dashboard_password = Some(hashed_pass);\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/dashboard/interfaces.rs", "new_path": "rita_client/src/dashboard/interfaces.rs", "diff": "@@ -80,7 +80,7 @@ pub fn get_interfaces() -> Result<HashMap<String, InterfaceMode>, RitaClientErro\ncontinue;\n}\nretval.insert(\n- list_member.replace(\" \", \"\").to_string(),\n+ list_member.replace(' ', \"\").to_string(),\nethernet2mode(&value, &setting_name)?,\n);\n}\n@@ -211,7 +211,7 @@ pub fn ethernet_transform_mode(\nlet mut return_codes = Vec::new();\n// in case of failure we revert to here\nlet old_network_settings = { network.clone() };\n- let filtered_ifname = format!(\"network.rita_{}\", ifname.replace(\".\", \"\"));\n+ let filtered_ifname = format!(\"network.rita_{}\", ifname.replace('.', \"\"));\nmatch a {\n// Wan is very simple, just delete it\n@@ -563,7 +563,7 @@ pub fn list_remove(list: &str, entry: &str) -> String {\ntrace!(\"{} is not {} it's on the list!\", filtered_item, entry);\nlet tmp_list = new_list.to_string();\nif first {\n- new_list = tmp_list + &filtered_item.to_string();\n+ new_list = tmp_list + filtered_item;\nfirst = false;\n} else {\nnew_list = tmp_list + &format!(\" {}\", filtered_item);\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/heartbeat/mod.rs", "new_path": "rita_client/src/heartbeat/mod.rs", "diff": "@@ -177,24 +177,22 @@ fn send_udp_heartbeat() {\nmatch dns_request {\nOk(dnsres) => {\nlet dnsresult = VecDeque::from_iter(dnsres);\n- let selected_exit_route: Result<RouteLegacy, BabelMonitorError>;\n- if cfg!(feature = \"operator_debug\") {\n- selected_exit_route = Ok(dummy_route());\n+ let selected_exit_route = if cfg!(feature = \"operator_debug\") {\n+ Ok(dummy_route())\n} else {\n- selected_exit_route = get_selected_exit_route(&network_info.babel_routes);\n- }\n+ get_selected_exit_route(&network_info.babel_routes)\n+ };\nmatch selected_exit_route {\nOk(route) => {\n- let neigh_option;\n- if cfg!(feature = \"operator_debug\") {\n- neigh_option = Some((dummy_neigh_babel(), dummy_neigh_tunnel()));\n+ let neigh_option = if cfg!(feature = \"operator_debug\") {\n+ Some((dummy_neigh_babel(), dummy_neigh_tunnel()))\n} else {\nlet neigh_option1 =\nget_neigh_given_route(&route, &network_info.babel_neighbors);\n- neigh_option =\n- get_rita_neigh_option(neigh_option1, &network_info.rita_neighbors);\n- }\n+\n+ get_rita_neigh_option(neigh_option1, &network_info.rita_neighbors)\n+ };\nif let Some((neigh, rita_neigh)) = neigh_option {\n// Now that we have all the info we can stop and try to update the\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/blockchain_oracle/mod.rs", "new_path": "rita_common/src/blockchain_oracle/mod.rs", "diff": "@@ -273,9 +273,7 @@ fn update_gas_price(\npayment_settings: &mut PaymentSettings,\n) {\n//local variables to be set\n- let oracle_gas_price: Uint256;\nlet mut oracle_pay_thresh: Int256 = 0u128.into();\n- let oracle_close_thresh: Int256;\n// Minimum gas price. When gas is below this, we set gasprice to this value, which is then used to\n// calculate pay and close thresh\nlet min_gas = payment_settings.min_gas.clone();\n@@ -288,7 +286,7 @@ fn update_gas_price(\n// taking the latest gas value for pay_thres and close_thres calculation does better\n// in the worst case compared to averaging\n- oracle_gas_price = value;\n+ let oracle_gas_price = value;\nlet oracle_gas_price = if oracle_gas_price < min_gas {\ninfo!(\"gas price is low setting to! {}\", min_gas);\n@@ -307,7 +305,7 @@ fn update_gas_price(\n}\ntrace!(\"Dynamically set pay threshold to {:?}\", oracle_pay_thresh);\n- oracle_close_thresh = sign_flip * CLOSE_THRESH_MULT.into() * oracle_pay_thresh.clone();\n+ let oracle_close_thresh = sign_flip * CLOSE_THRESH_MULT.into() * oracle_pay_thresh.clone();\ntrace!(\n\"Dynamically set close threshold to {:?}\",\noracle_close_thresh\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/peer_listener/mod.rs", "new_path": "rita_common/src/peer_listener/mod.rs", "diff": "@@ -246,7 +246,7 @@ fn receive_im_here(\nsock_addr\n);\n- let ipaddr = match PeerMessage::decode(&datagram.to_vec()) {\n+ let ipaddr = match PeerMessage::decode(datagram.as_ref()) {\nOk(PeerMessage::ImHere(ipaddr)) => ipaddr,\nErr(e) => {\nwarn!(\"ImHere decode failed: {:?}\", e);\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Correct new clippy nits for Rust v1.59.0
20,255
01.03.2022 13:11:29
28,800
7f44d4cd64f9a67f710cdad54f8b524d083450c0
Patch to 'Prevent repeated payments' commit 1.) Calling an unwrap on a negative debt value was fixed 2.) Sending a i32 '0' instead of Int256 was leading to a deserialization error, fixed
[ { "change_type": "MODIFY", "old_path": "rita_exit/src/network_endpoints/mod.rs", "new_path": "rita_exit/src/network_endpoints/mod.rs", "diff": "@@ -255,18 +255,29 @@ pub fn get_client_debt(client: Json<Identity>) -> HttpResponse {\nlet incoming_payments = debt.payment_details.incoming_payments;\nlet we_owe_them = client_debt > zero;\n- let they_owe_more_than_in_queue =\n- client_debt.to_uint256().unwrap() > unverified_payments_uint;\n+ let they_owe_more_than_in_queue = if we_owe_them {\n+ false\n+ } else {\n+ (neg_one.clone() * client_debt.clone())\n+ .to_uint256()\n+ .unwrap()\n+ > unverified_payments_uint\n+ };\n// they have more credit than they owe, wait for this to unwind\n// we apply credit right before enforcing or on payment.\n- if !we_owe_them && incoming_payments > client_debt.to_uint256().unwrap() {\n- return HttpResponse::Ok().json(0);\n+ if !we_owe_them\n+ && incoming_payments\n+ > (neg_one.clone() * client_debt.clone())\n+ .to_uint256()\n+ .unwrap()\n+ {\n+ return HttpResponse::Ok().json(zero);\n}\nmatch (we_owe_them, they_owe_more_than_in_queue) {\n// in this case we owe them, return zero\n- (true, _) => return HttpResponse::Ok().json(0),\n+ (true, _) => return HttpResponse::Ok().json(zero),\n// they owe us more than is in the queue\n(false, true) => {\n// client debt is negative, they owe us, so we make it positive and subtract\n@@ -275,7 +286,7 @@ pub fn get_client_debt(client: Json<Identity>) -> HttpResponse {\nreturn HttpResponse::Ok().json(ret);\n}\n// they owe us less than what is in the queue, return zero\n- (false, false) => return HttpResponse::Ok().json(0),\n+ (false, false) => return HttpResponse::Ok().json(zero),\n}\n}\n}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Patch to 'Prevent repeated payments' commit 1.) Calling an unwrap on a negative debt value was fixed 2.) Sending a i32 '0' instead of Int256 was leading to a deserialization error, fixed
20,243
02.03.2022 06:49:29
28,800
68612ceb182d24b4839743bfb4ce06f7443132e8
Removed migration code and old exit member struct and instances and updated config The config has been migrated and updated in the firmware repo. The old exit code is no longer needed. It's not necessary to run every time on first boot, so deleting this code is useful.
[ { "change_type": "MODIFY", "old_path": "rita_client/src/exit_manager/exit_switcher.rs", "new_path": "rita_client/src/exit_manager/exit_switcher.rs", "diff": "@@ -1109,7 +1109,6 @@ mod tests {\nlet path = \"./src/exit_manager/config_in_use.toml\".to_string();\nlet settings = RitaClientSettings::new(&path).unwrap();\n- println!(\"Old Settings: {:#?}\", settings.exit_client.old_exits);\nprintln!(\"\\n\\n\\n\\nNew Settings: {:#?}\", settings.exit_client.exits);\n}\n" }, { "change_type": "MODIFY", "old_path": "settings/src/client.rs", "new_path": "settings/src/client.rs", "diff": "@@ -3,9 +3,7 @@ use crate::logging::LoggingSettings;\nuse crate::network::NetworkSettings;\nuse crate::operator::OperatorSettings;\nuse crate::payment::PaymentSettings;\n-use crate::{\n- json_merge, set_rita_client, spawn_watch_thread_client, update_config, SettingsError, SUBNET,\n-};\n+use crate::{json_merge, set_rita_client, spawn_watch_thread_client, SettingsError};\nuse althea_types::wg_key::WgKey;\nuse althea_types::{ContactStorage, ExitState, Identity};\nuse clarity::Address;\n@@ -57,22 +55,6 @@ pub struct ExitServer {\npub info: ExitState,\n}\n-#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]\n-pub struct OldExitServer {\n- pub id: Identity,\n- /// The port over which we will reach the exit apis on over the mesh\n-\n- #[serde(default)]\n- pub subnet_len: Option<u8>,\n-\n- pub registration_port: u16,\n- #[serde(default)]\n- pub description: String,\n- /// The state and data about the exit\n- #[serde(default, flatten)]\n- pub info: ExitState,\n-}\n-\n/// Simple struct that keeps track of details related to the exit we are currently connected to, as well as the next potential exit to switch to\n#[derive(Default, Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]\npub struct SelectedExit {\n@@ -123,10 +105,8 @@ fn default_balance_notification() -> bool {\n/// to a exit and to setup the exit tunnel\n#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]\npub struct ExitClientSettings {\n- #[serde(rename = \"exits\", default)]\n- pub old_exits: HashMap<String, OldExitServer>,\n/// This stores a mapping between an identifier (any string) to exits\n- #[serde(rename = \"new_exits\", default)]\n+ #[serde(alias = \"new_exits\", default)]\npub exits: HashMap<String, ExitServer>,\n/// This stores the current exit identifier\npub current_exit: Option<String>,\n@@ -147,7 +127,6 @@ pub struct ExitClientSettings {\nimpl Default for ExitClientSettings {\nfn default() -> Self {\nExitClientSettings {\n- old_exits: HashMap::new(),\nexits: HashMap::new(),\ncurrent_exit: None,\nwg_listen_port: 59999,\n@@ -169,14 +148,13 @@ impl RitaClientSettings {\nlet mut s = Config::new();\nassert!(Path::new(file_name).exists());\ns.merge(config::File::with_name(file_name).required(false))?;\n- let settings: Self = update_config(s.try_into()?, SUBNET)?;\n- Ok(settings)\n+ Ok(s.try_into()?)\n}\npub fn new_watched(file_name: &str) -> Result<Self, SettingsError> {\nlet mut s = Config::new();\ns.merge(config::File::with_name(file_name).required(false))?;\n- let settings: Self = update_config(s.try_into()?, SUBNET)?;\n+ let settings: RitaClientSettings = s.try_into()?;\nset_rita_client(settings.clone());\n@@ -222,7 +200,7 @@ impl RitaClientSettings {\nmatch serde_json::from_value(settings_value) {\nOk(new_settings) => {\n- *self = update_config(new_settings, SUBNET)?;\n+ *self = new_settings;\nOk(())\n}\nErr(e) => Err(e.into()),\n" }, { "change_type": "MODIFY", "old_path": "settings/src/lib.rs", "new_path": "settings/src/lib.rs", "diff": "@@ -17,14 +17,11 @@ extern crate serde_derive;\nextern crate log;\nextern crate arrayvec;\n-use crate::client::{ExitClientSettings, ExitServer, SelectedExit};\nuse althea_types::Identity;\n-use ipnetwork::IpNetwork;\nuse network::NetworkSettings;\nuse payment::PaymentSettings;\nuse serde::Serialize;\nuse serde_json::Value;\n-use std::collections::HashMap;\nuse std::fmt::Debug;\nuse std::fs::File;\nuse std::io::Write;\n@@ -386,98 +383,6 @@ where\n}\n}\n-///Takes a file config and updates the config to use the new ExitServer struct\n-pub fn update_config(\n- old_settings: RitaClientSettings,\n- subnet: u8,\n-) -> Result<RitaClientSettings, SettingsError> {\n- let mut new_settings = RitaClientSettings {\n- payment: old_settings.payment,\n- log: old_settings.log,\n- operator: old_settings.operator,\n- localization: old_settings.localization,\n- network: old_settings.network,\n- exit_client: old_settings.exit_client.clone(),\n- future: old_settings.future,\n- app_name: old_settings.app_name,\n- };\n-\n- // we have already updated to reading the new settings\n- if old_settings.exit_client.old_exits.is_empty() {\n- return Ok(new_settings);\n- }\n-\n- let mut new_exits: HashMap<String, ExitServer> = HashMap::new();\n- for (k, v) in old_settings.exit_client.clone().old_exits {\n- let s_len = if v.subnet_len.is_some() {\n- v.subnet_len.unwrap()\n- } else {\n- subnet\n- };\n- let mut new_exit: ExitServer = ExitServer {\n- subnet: IpNetwork::new(v.id.mesh_ip, s_len)?,\n- id: Some(v.id),\n- subnet_len: s_len,\n- selected_exit: SelectedExit::default(),\n- eth_address: v.id.eth_address,\n- wg_public_key: v.id.wg_public_key,\n- registration_port: v.registration_port,\n- description: v.description,\n- info: v.info,\n- };\n-\n- // we set the selected exit (starting exit) to be the one provided in config. This is required for registration\n- new_exit.selected_exit.selected_id = Some(v.id.mesh_ip);\n-\n- // Special case for us_west, making it subnet 116. For africa, apac and sa, migrate ip such that they dont collide with uswest subnet\n- if v.id.mesh_ip == IpAddr::V6(\"fd00::1337:e2f\".parse().unwrap()) {\n- new_exit = migrate_exit_ip(\n- new_exit.clone(),\n- new_exit.id.unwrap().mesh_ip,\n- US_WEST_SUBNET,\n- );\n- } else if v.id.mesh_ip == IpAddr::V6(\"fd00::1337:e7f\".parse().unwrap()) {\n- //africa\n- new_exit = migrate_exit_ip(new_exit, AFRICA_IP, SUBNET);\n- } else if v.id.mesh_ip == IpAddr::V6(\"fd00::1337:e4f\".parse().unwrap()) {\n- //apac\n- new_exit = migrate_exit_ip(new_exit, APAC_IP, SUBNET);\n- } else if v.id.mesh_ip == IpAddr::V6(\"fd00::1337:e8f\".parse().unwrap()) {\n- //South Africa\n- new_exit = migrate_exit_ip(new_exit, SA_IP, SUBNET);\n- }\n-\n- new_exits.insert(k, new_exit);\n- }\n-\n- let exit_client = old_settings.exit_client;\n- new_settings.exit_client = ExitClientSettings {\n- old_exits: exit_client.clone().old_exits,\n- exits: exit_client.clone().exits,\n- current_exit: exit_client.clone().current_exit,\n- wg_listen_port: exit_client.wg_listen_port,\n- contact_info: exit_client.clone().contact_info,\n- lan_nics: exit_client.clone().lan_nics,\n- low_balance_notification: exit_client.low_balance_notification,\n- };\n- new_settings.exit_client.exits = new_exits.clone();\n- //remove old info after migrating over\n- new_settings.exit_client.old_exits = HashMap::new();\n- Ok(new_settings)\n-}\n-\n-/// This function updates RitaClient struct with hardcoded values for exit. For US West the subnet is expanded to 116 and for those\n-/// exits colliding within this subnet, they're ip gets mapped to a dummy ip\n-fn migrate_exit_ip(exit: ExitServer, exit_ip: IpAddr, subnet: u8) -> ExitServer {\n- let mut new_exit = exit;\n- new_exit.subnet = IpNetwork::new(exit_ip, subnet).unwrap();\n- new_exit.subnet_len = subnet;\n- let mut id = new_exit.id.as_mut().unwrap();\n- id.mesh_ip = exit_ip;\n- new_exit.selected_exit.selected_id = Some(exit_ip);\n- new_exit\n-}\n-\n#[cfg(test)]\nmod tests {\nuse crate::client::RitaClientSettings;\n@@ -488,12 +393,6 @@ mod tests {\nRitaClientSettings::new(\"test.toml\").unwrap();\n}\n- #[test]\n- fn test_settings_example() {\n- let settings = RitaClientSettings::new(\"old_example.toml\").unwrap();\n- assert!(!settings.exit_client.exits.is_empty())\n- }\n-\n#[test]\nfn test_exit_settings_test() {\nRitaExitSettingsStruct::new(\"test_exit.toml\").unwrap();\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Removed migration code and old exit member struct and instances and updated config The config has been migrated and updated in the firmware repo. The old exit code is no longer needed. It's not necessary to run every time on first boot, so deleting this code is useful.
20,255
04.03.2022 14:45:34
28,800
53548481c59a52738b6d8fbbcdf09fa74b63a2bf
Added Wifi info to HardwareInfo For every wifi device in /proc/net/wireless, we add the survey dump and station dump to the hardware info struct which will then be send to display on op tools
[ { "change_type": "MODIFY", "old_path": "althea_kernel_interface/src/hardware_info.rs", "new_path": "althea_kernel_interface/src/hardware_info.rs", "diff": "use crate::file_io::get_lines;\nuse crate::KernelInterfaceError as Error;\n+use althea_types::extract_wifi_station_data;\n+use althea_types::extract_wifi_survey_data;\nuse althea_types::EthOperationMode;\nuse althea_types::EthernetStats;\nuse althea_types::HardwareInfo;\nuse althea_types::SensorReading;\n+use althea_types::WifiDevice;\n+use althea_types::WifiStationData;\n+use althea_types::WifiSurveyData;\nuse std::fs;\n+use std::process::Command;\n+use std::process::Stdio;\nuse std::time::Duration;\nuse std::u64;\n@@ -39,6 +46,8 @@ pub fn get_hardware_info(device_name: Option<String>) -> Result<HardwareInfo, Er\nlet ethernet_stats = get_ethernet_stats();\n+ let wifi_devices = get_wifi_devices();\n+\nOk(HardwareInfo {\nlogical_processors: num_cpus,\nload_avg_one_minute: one_minute_load_avg,\n@@ -52,6 +61,7 @@ pub fn get_hardware_info(device_name: Option<String>) -> Result<HardwareInfo, Er\nsystem_kernel_version,\nentire_system_kernel_version,\nethernet_stats,\n+ wifi_devices,\n})\n}\n@@ -313,6 +323,72 @@ fn get_ethernet_stats() -> Option<Vec<EthernetStats>> {\n}\n}\n+fn get_wifi_devices() -> Vec<WifiDevice> {\n+ let mut ret: Vec<WifiDevice> = Vec::new();\n+ //get devices\n+ let devices = parse_wifi_device_names();\n+ if devices.is_err() {\n+ warn!(\"Unable to get wifi devices: {:?}\", devices);\n+ return Vec::new();\n+ }\n+\n+ for dev in devices.unwrap() {\n+ let device = WifiDevice {\n+ name: dev.clone(),\n+ survey_data: get_wifi_survey_info(&dev),\n+ station_data: get_wifi_station_info(&dev),\n+ };\n+ info!(\"Created the following wifi struct: {:?}\", device.clone());\n+ ret.push(device);\n+ }\n+\n+ ret\n+}\n+\n+fn parse_wifi_device_names() -> Result<Vec<String>, Error> {\n+ let mut ret = Vec::new();\n+ let path = \"/proc/net/wireless\";\n+ let lines = get_lines(path)?;\n+ for line in lines {\n+ if line.contains(':') {\n+ let name: Vec<&str> = line.split(':').collect();\n+ let name = name[0];\n+ let name = name.replace(' ', \"\");\n+ ret.push(name.to_string());\n+ }\n+ }\n+ Ok(ret)\n+}\n+\n+fn get_wifi_survey_info(dev: &str) -> Vec<WifiSurveyData> {\n+ let res = Command::new(\"iw\")\n+ .args(&[dev, \"survey\", \"dump\"])\n+ .stdout(Stdio::piped())\n+ .output();\n+\n+ if res.is_err() {\n+ error!(\"Unable to run survey dump {:?}\", res);\n+ return Vec::new();\n+ }\n+ let res = String::from_utf8(res.unwrap().stdout).unwrap();\n+ extract_wifi_survey_data(&res, dev)\n+}\n+\n+fn get_wifi_station_info(dev: &str) -> Vec<WifiStationData> {\n+ let res = Command::new(\"iw\")\n+ .args(&[dev, \"station\", \"dump\"])\n+ .stdout(Stdio::piped())\n+ .output();\n+\n+ if res.is_err() {\n+ error!(\"Unable to run station dump {:?}\", res);\n+ return Vec::new();\n+ }\n+\n+ let res = String::from_utf8(res.unwrap().stdout).unwrap();\n+ extract_wifi_station_data(&res)\n+}\n+\n/// Take eth speed and duplex mode and create an enum\nfn get_ethernet_operation_mode(speed: u64, duplex: String) -> EthOperationMode {\nmatch (speed, duplex.contains(\"full\")) {\n" }, { "change_type": "MODIFY", "old_path": "althea_types/src/interop.rs", "new_path": "althea_types/src/interop.rs", "diff": "+use crate::WifiDevice;\nuse crate::{contact_info::ContactType, wg_key::WgKey, BillingDetails, InstallationDetails};\nuse arrayvec::ArrayString;\nuse babel_monitor::Neighbor as NeighborLegacy;\n@@ -572,6 +573,8 @@ pub struct HardwareInfo {\npub entire_system_kernel_version: String,\n/// Vector of eth data i.e. whether a link is up and if so what the link speed is\npub ethernet_stats: Option<Vec<EthernetStats>>,\n+ // Vector of wifi devices on router with staion and survey data for each\n+ pub wifi_devices: Vec<WifiDevice>,\n}\nfn default_kernel_version() -> String {\n" }, { "change_type": "MODIFY", "old_path": "althea_types/src/lib.rs", "new_path": "althea_types/src/lib.rs", "diff": "@@ -7,10 +7,12 @@ pub mod interop;\npub mod monitoring;\npub mod user_info;\npub mod wg_key;\n+pub mod wifi_info;\npub use crate::contact_info::*;\npub use crate::interop::*;\npub use crate::monitoring::*;\npub use crate::user_info::*;\npub use crate::wg_key::WgKey;\n+pub use crate::wifi_info::*;\npub use std::str::FromStr;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "althea_types/src/wifi_info.rs", "diff": "+/// This struct contains information for wifi survey data\n+#[derive(Default, Debug, Clone, Serialize, Deserialize)]\n+pub struct WifiSurveyData {\n+ /// Frequency in MHz\n+ pub frequency_mhz: u16,\n+ /// Noise in dBm\n+ pub noise_dbm: i32,\n+ /// Time in ms\n+ pub channel_active_time: u64,\n+ pub channel_busy_time: u64,\n+ pub channel_receive_time: u64,\n+ pub channel_transmit_time: u64,\n+}\n+\n+/// This struct contains information for wifi station data\n+#[derive(Default, Debug, Clone, Serialize, Deserialize)]\n+pub struct WifiStationData {\n+ pub station: String,\n+ pub inactive_time_ms: u64,\n+ pub rx_bytes: u64,\n+ pub rx_packets: u64,\n+ pub tx_bytes: u64,\n+ pub tx_packets: u64,\n+ pub tx_retries: u16,\n+ pub tx_failed: u16,\n+ pub rx_drop_misc: u16,\n+ pub signal_dbm: String,\n+ pub signal_avg_dbm: String,\n+ pub tx_bitrate: f32,\n+ pub tx_duration_us: u64,\n+ pub rx_bitrate: f32,\n+ pub rx_duration_us: u64,\n+ pub airtime_weight: Option<u16>,\n+ pub authorized: bool,\n+ pub authenticated: bool,\n+ pub associated: bool,\n+ pub preamble: String,\n+ pub wmm_wme: bool,\n+ pub mfp: bool,\n+ pub tdls_peer: bool,\n+ pub dtim_period: u16,\n+ pub beacon_interval: u16,\n+ pub short_slot_time: bool,\n+ pub connected_time_sec: u16,\n+ pub associated_at_boottime_sec: Option<String>,\n+ pub associated_at_ms: Option<u64>,\n+ pub current_time_ms: Option<u64>,\n+}\n+\n+#[derive(Debug, Default, Clone, Serialize, Deserialize)]\n+pub struct WifiDevice {\n+ pub name: String,\n+ pub survey_data: Vec<WifiSurveyData>,\n+ pub station_data: Vec<WifiStationData>,\n+}\n+\n+impl From<Vec<&str>> for WifiSurveyData {\n+ fn from(survey: Vec<&str>) -> Self {\n+ get_struct_sur(survey)\n+ }\n+}\n+\n+impl From<Vec<&str>> for WifiStationData {\n+ fn from(station: Vec<&str>) -> Self {\n+ get_struct_stat(station)\n+ }\n+}\n+\n+fn get_struct_sur(survey: Vec<&str>) -> WifiSurveyData {\n+ let mut iter = survey.iter();\n+ let mut ret = WifiSurveyData::default();\n+ while let Some(str) = iter.next() {\n+ match *str {\n+ \"frequency\" => ret.frequency_mhz = iter.next().unwrap().parse::<u16>().unwrap_or(0u16),\n+ \"noise\" => ret.noise_dbm = iter.next().unwrap().parse::<i32>().unwrap_or(0i32),\n+ \"activetime\" => {\n+ ret.channel_active_time = iter.next().unwrap().parse::<u64>().unwrap_or(0u64)\n+ }\n+ \"busytime\" => {\n+ ret.channel_busy_time = iter.next().unwrap().parse::<u64>().unwrap_or(0u64)\n+ }\n+ \"receivetime\" => {\n+ ret.channel_receive_time = iter.next().unwrap().parse::<u64>().unwrap_or(0u64)\n+ }\n+ \"transmittime\" => {\n+ ret.channel_transmit_time = iter.next().unwrap().parse::<u64>().unwrap_or(0u64)\n+ }\n+ _ => {}\n+ }\n+ }\n+ ret\n+}\n+\n+fn get_struct_stat(station: Vec<&str>) -> WifiStationData {\n+ let mut iter = station.iter();\n+ // Set station\n+ let station = iter.next();\n+ let mut ret = WifiStationData::default();\n+\n+ if station.is_none() {\n+ return ret;\n+ }\n+ ret.station = station.unwrap().to_string();\n+ while let Some(str) = iter.next() {\n+ match *str {\n+ \"inactive\" => {\n+ iter.next();\n+ ret.inactive_time_ms = iter.next().unwrap().parse::<u64>().unwrap_or(0u64);\n+ }\n+ \"rx\" => {\n+ let next_str = iter.next().unwrap();\n+ match *next_str {\n+ \"bytes:\" => ret.rx_bytes = iter.next().unwrap().parse::<u64>().unwrap_or(0u64),\n+ \"packets:\" => {\n+ ret.rx_packets = iter.next().unwrap().parse::<u64>().unwrap_or(0u64)\n+ }\n+ \"drop\" => {\n+ iter.next();\n+ ret.rx_drop_misc = iter.next().unwrap().parse::<u16>().unwrap_or(0u16);\n+ }\n+ \"bitrate:\" => {\n+ ret.rx_bitrate = iter.next().unwrap().parse::<f32>().unwrap_or(0f32);\n+ }\n+ \"duration:\" => {\n+ ret.rx_duration_us = iter.next().unwrap().parse::<u64>().unwrap_or(0u64)\n+ }\n+ _ => {}\n+ }\n+ }\n+ \"tx\" => {\n+ let next_str = iter.next().unwrap();\n+ match *next_str {\n+ \"bytes:\" => ret.tx_bytes = iter.next().unwrap().parse::<u64>().unwrap_or(0u64),\n+ \"packets:\" => {\n+ ret.tx_packets = iter.next().unwrap().parse::<u64>().unwrap_or(0u64)\n+ }\n+ \"retries:\" => {\n+ ret.tx_retries = iter.next().unwrap().parse::<u16>().unwrap_or(0u16);\n+ }\n+ \"failed:\" => {\n+ ret.tx_failed = iter.next().unwrap().parse::<u16>().unwrap_or(0u16)\n+ }\n+ \"bitrate:\" => {\n+ ret.tx_bitrate = iter.next().unwrap().parse::<f32>().unwrap_or(0f32);\n+ }\n+ \"duration:\" => {\n+ ret.tx_duration_us = iter.next().unwrap().parse::<u64>().unwrap_or(0u64)\n+ }\n+ _ => {}\n+ }\n+ }\n+ \"signal:\" => {\n+ let mut sig_arr = vec![*iter.next().unwrap()];\n+ for str_val in iter.by_ref() {\n+ let next = *str_val;\n+ if next != \"dBm\" {\n+ sig_arr.push(next);\n+ if sig_arr.len() > 10 {\n+ sig_arr.clear();\n+ sig_arr.push(\"Error with signal parsing logic, please fix\");\n+ break;\n+ }\n+ } else {\n+ sig_arr.push(\"dBm\");\n+ break;\n+ }\n+ }\n+ let sig_str: String = sig_arr.into_iter().collect();\n+ ret.signal_dbm = sig_str;\n+ }\n+ \"avg:\" => {\n+ let mut sig_arr = vec![*iter.next().unwrap()];\n+ for str_val in iter.by_ref() {\n+ let next = *str_val;\n+ if next != \"dBm\" {\n+ sig_arr.push(next);\n+ if sig_arr.len() > 10 {\n+ sig_arr.clear();\n+ sig_arr.push(\"Error with signal parsing logic, please fix\");\n+ break;\n+ }\n+ } else {\n+ sig_arr.push(\"dBm\");\n+ break;\n+ }\n+ }\n+ let sig_str: String = sig_arr.into_iter().collect();\n+ ret.signal_avg_dbm = sig_str;\n+ }\n+ \"airtime\" => {\n+ iter.next();\n+ ret.airtime_weight = Some(iter.next().unwrap().parse::<u16>().unwrap_or(0u16));\n+ }\n+ \"authorized:\" => {\n+ let next_str = iter.next().unwrap();\n+ if *next_str == \"yes\" {\n+ ret.authorized = true;\n+ } else {\n+ ret.authorized = false;\n+ }\n+ }\n+ \"authenticated:\" => {\n+ let next_str = iter.next().unwrap();\n+ if *next_str == \"yes\" {\n+ ret.authenticated = true;\n+ } else {\n+ ret.authenticated = false;\n+ }\n+ }\n+ \"[boottime]:\" => {\n+ ret.associated_at_boottime_sec = Some(iter.next().unwrap().to_string())\n+ }\n+ \"at:\" => {\n+ ret.associated_at_ms = Some(iter.next().unwrap().parse::<u64>().unwrap_or(0u64));\n+ }\n+ \"associated:\" => {\n+ let next_str = iter.next().unwrap();\n+ if *next_str == \"yes\" {\n+ ret.associated = true;\n+ } else {\n+ ret.associated = false;\n+ }\n+ }\n+ \"preamble:\" => ret.preamble = iter.next().unwrap().to_string(),\n+ \"WMM/WME:\" => {\n+ let next_str = iter.next().unwrap();\n+ if *next_str == \"yes\" {\n+ ret.wmm_wme = true;\n+ } else {\n+ ret.wmm_wme = false;\n+ }\n+ }\n+ \"MFP:\" => {\n+ let next_str = iter.next().unwrap();\n+ if *next_str == \"yes\" {\n+ ret.mfp = true;\n+ } else {\n+ ret.mfp = false;\n+ }\n+ }\n+ \"peer:\" => {\n+ let next_str = iter.next().unwrap();\n+ if *next_str == \"yes\" {\n+ ret.tdls_peer = true;\n+ } else {\n+ ret.tdls_peer = false;\n+ }\n+ }\n+ \"period:\" => ret.dtim_period = iter.next().unwrap().parse::<u16>().unwrap_or(0u16),\n+ \"beacon\" => {\n+ let next_str = *iter.next().unwrap();\n+ let next_str = next_str.replace(\"interval:\", \"\");\n+ ret.beacon_interval = next_str.parse::<u16>().unwrap_or(0u16);\n+ }\n+ \"slot\" => {\n+ let next_str = *iter.next().unwrap();\n+ if next_str.contains(\"yes\") {\n+ ret.short_slot_time = true;\n+ } else {\n+ ret.short_slot_time = false;\n+ }\n+ }\n+ \"connected\" => {\n+ iter.next();\n+ ret.connected_time_sec = iter.next().unwrap().parse::<u16>().unwrap_or(0u16);\n+ }\n+ \"current\" => {\n+ iter.next();\n+ ret.current_time_ms = Some(iter.next().unwrap().parse::<u64>().unwrap_or(0u64));\n+ }\n+ _ => {}\n+ }\n+ }\n+ ret\n+}\n+\n+pub fn extract_wifi_survey_data(survey_str: &str, dev_name: &str) -> Vec<WifiSurveyData> {\n+ let mut ret: Vec<WifiSurveyData> = vec![];\n+\n+ // Preprocess String\n+ let freq_list: &str = &survey_str.replace(\"Survey data from \", \"\");\n+ let freq_list: &str = &freq_list.replace(\"active time\", \"activetime\");\n+ let freq_list: &str = &freq_list.replace(\"busy time\", \"busytime\");\n+ let freq_list: &str = &freq_list.replace(\"transmit time\", \"transmittime\");\n+ let freq_list: &str = &freq_list.replace(\"receive time\", \"receivetime\");\n+ let freq_list: &str = &freq_list.replace(':', \" \");\n+ let freq_list: Vec<&str> = freq_list.split_ascii_whitespace().collect();\n+\n+ // Split on device name (wlan0)\n+ let mut iter = freq_list.split(|dev| *dev == dev_name);\n+ loop {\n+ let to_struct = iter.next();\n+ if let Some(to_struct) = to_struct {\n+ let to_struct = to_struct.to_vec();\n+ let survey_struct = WifiSurveyData::from(to_struct);\n+ //if channel active time is 0, we dont need that data\n+ if survey_struct.channel_active_time != 0 {\n+ ret.push(survey_struct)\n+ }\n+ } else {\n+ break;\n+ }\n+ }\n+\n+ ret\n+}\n+\n+pub fn extract_wifi_station_data(station_str: &str) -> Vec<WifiStationData> {\n+ let mut ret: Vec<WifiStationData> = vec![];\n+\n+ // Preprocess String\n+ let freq_list: Vec<&str> = station_str.split_ascii_whitespace().collect();\n+\n+ // Split on \"Station\"\n+ let mut iter = freq_list.split(|dev| *dev == \"Station\");\n+ loop {\n+ let to_struct = iter.next();\n+ if let Some(to_struct) = to_struct {\n+ let to_struct = to_struct.to_vec();\n+ let station_struct = WifiStationData::from(to_struct);\n+ // If not station, its an empty struct\n+ if !station_struct.station.is_empty() {\n+ ret.push(station_struct);\n+ }\n+ } else {\n+ break;\n+ }\n+ }\n+\n+ ret\n+}\n+\n+#[test]\n+fn test_extract_surveydata() {\n+ let str = \"Survey data from wlan0\n+ frequency: 2412 MHz\n+Survey data from wlan0\n+ frequency: 2417 MHz\n+Survey data from wlan0\n+ frequency: 2422 MHz\n+Survey data from wlan0\n+ frequency: 2427 MHz\n+Survey data from wlan0\n+ frequency: 2432 MHz\n+Survey data from wlan0\n+ frequency: 2437 MHz\n+Survey data from wlan0\n+ frequency: 2442 MHz\n+Survey data from wlan0\n+ frequency: 2447 MHz\n+Survey data from wlan0\n+ frequency: 2452 MHz\n+Survey data from wlan0\n+ frequency: 2457 MHz\n+Survey data from wlan0\n+ frequency: 2462 MHz [in use]\n+ noise: -102 dBm\n+ channel active time: 4172127 ms\n+ channel busy time: 828107 ms\n+ channel receive time: 1448 ms\n+ channel transmit time: 20225 ms\n+Survey data from wlan0\n+ frequency: 24062 MHz [in use]\n+ noise: -1002 dBm\n+ channel active time: 5127 ms\n+ channel busy time: 5 ms\n+ channel receive time: 5 ms\n+ channel transmit time: 5 ms\";\n+\n+ let ret = extract_wifi_survey_data(str, \"wlan0\");\n+\n+ println!(\"{:?}\", ret);\n+}\n+\n+#[test]\n+fn test_extract_stationdata() {\n+ let str = \"Station 08:66:98:b6:bd:6d (on wlan1)\n+ inactive time: 22430 ms\n+ rx bytes: 718014\n+ rx packets: 2754\n+ tx bytes: 158437\n+ tx packets: 503\n+ tx retries: 1\n+ tx failed: 0\n+ rx drop misc: 0\n+ signal: -63 [-86, -63, -100, -100] dBm\n+ signal avg: -64 [-79, -64, -100, -100] dBm\n+ tx bitrate: 702.0 MBit/s VHT-MCS 8 80MHz VHT-NSS 2\n+ tx duration: 11494 us\n+ rx bitrate: 24.0 MBit/s\n+ rx duration: 0 us\n+ airtime weight: 256\n+ authorized: yes\n+ authenticated: yes\n+ associated: yes\n+ preamble: long\n+ WMM/WME: yes\n+ MFP: no\n+ TDLS peer: no\n+ DTIM period: 2\n+ beacon interval:100\n+ short slot time:yes\n+ connected time: 4257 seconds\n+ associated at [boottime]: 42.228s\n+ associated at: 1645652326500 ms\n+ current time: 1645656582641 ms\n+Station 5c:f7:e6:1c:36:f7 (on wlan1)\n+ inactive time: 6530 ms\n+ rx bytes: 74003941\n+ rx packets: 75242\n+ tx bytes: 31834401\n+ tx packets: 46661\n+ tx retries: 1625\n+ tx failed: 359\n+ rx drop misc: 7\n+ signal: -83 [-86, -86, -100, -100] dBm\n+ signal avg: -85 [-90, -89, -100, -100] dBm\n+ tx bitrate: 150.0 MBit/s MCS 7 40MHz short GI\n+ tx duration: 6054270 us\n+ rx bitrate: 24.0 MBit/s\n+ rx duration: 0 us\n+ airtime weight: 256\n+ authorized: yes\n+ authenticated: yes\n+ associated: yes\n+ preamble: long\n+ WMM/WME: yes\n+ MFP: no\n+ TDLS peer: no\n+ DTIM period: 2\n+ beacon interval:100\n+ short slot time:yes\n+ connected time: 4238 seconds\n+ associated at [boottime]: 60.927s\n+ associated at: 1645652345197 ms\n+ current time: 1645656582642 ms\n+Station 54:88:0e:ab:fb:81 (on wlan1)\n+ inactive time: 490 ms\n+ rx bytes: 745497\n+ rx packets: 6919\n+ tx bytes: 127474\n+ tx packets: 520\n+ tx retries: 0\n+ tx failed: 0\n+ rx drop misc: 2\n+ signal: -59 [-68, -59, -100, -100] dBm\n+ signal avg: -58 [-67, -58, -100, -100] dBm\n+ tx bitrate: 144.4 MBit/s MCS 15 short GI\n+ tx duration: 18010 us\n+ rx bitrate: 144.4 MBit/s MCS 15 short GI\n+ rx duration: 0 us\n+ airtime weight: 256\n+ authorized: yes\n+ authenticated: yes\n+ associated: yes\n+ preamble: long\n+ WMM/WME: yes\n+ MFP: no\n+ TDLS peer: no\n+ DTIM period: 2\n+ beacon interval:100\n+ short slot time:yes\n+ connected time: 4140 seconds\n+ associated at [boottime]: 158.256s\n+ associated at: 1645652442527 ms\n+ current time: 1645656582646 ms\";\n+\n+ let ret = extract_wifi_station_data(str);\n+ println!(\"{:?}\", ret);\n+\n+ let old_str = \"Station <mac removed> (on wlan1)\n+ inactive time: 10 ms\n+ rx bytes: 141627376\n+ rx packets: 329289\n+ tx bytes: 1106901\n+ tx packets: 6172\n+ tx retries: 0\n+ tx failed: 0\n+ rx drop misc: 322643\n+ signal: -73 dBm\n+ signal avg: -73 dBm\n+ tx bitrate: 6.0 MBit/s 40MHz\n+ rx bitrate: 54.0 MBit/s\n+ rx duration: 0 us\n+ authorized: yes\n+ authenticated: yes\n+ associated: yes\n+ preamble: short\n+ WMM/WME: yes\n+ MFP: no\n+ TDLS peer: no\n+ DTIM period: 2\n+ beacon interval:100\n+ short preamble: yes\n+ short slot time:yes\n+ connected time: 26651 seconds\";\n+\n+ let ret = extract_wifi_station_data(old_str);\n+ println!(\"\\n\\n{:?}\", ret);\n+}\n+\n+#[test]\n+fn test_extract_wifi_names() {\n+ let line1 = \"Inter-| sta-| Quality | Discarded packets | Missed | WE\";\n+ let line2 =\n+ \" face | tus | link level noise | nwid crypt frag retry misc | beacon | 22\";\n+ let line3 = \"wlan1: 0000 0 0 0 0 0 0 0 0 0\";\n+ let line4 = \"wlan0: 0000 0 0 0 0 0 0 0 0 0\";\n+\n+ let vec_lines = vec![line1, line2, line3, line4];\n+ let mut ret = Vec::new();\n+\n+ for line in vec_lines {\n+ if line.contains(':') {\n+ let name: Vec<&str> = line.split(':').collect();\n+ let name = name[0];\n+ ret.push(name.to_string());\n+ }\n+ }\n+\n+ println!(\"{:?}\", ret);\n+}\n" }, { "change_type": "MODIFY", "old_path": "scripts/openwrt_upload.sh", "new_path": "scripts/openwrt_upload.sh", "diff": "@@ -3,7 +3,7 @@ set -eux\nexport TARGET=ipq40xx\nexport TRIPLE=armv7-unknown-linux-musleabihf\nexport ROUTER_IP=192.168.10.1\n-bash scripts/openwrt_build_$TARGET.sh --features development\n+bash scripts/openwrt_build_$TARGET.sh --features rita_bin/development\nset +e\nssh root@$ROUTER_IP killall -9 rita\nset -e\n" }, { "change_type": "MODIFY", "old_path": "settings/src/client.rs", "new_path": "settings/src/client.rs", "diff": "@@ -139,7 +139,11 @@ impl Default for ExitClientSettings {\nimpl ExitClientSettings {\npub fn get_current_exit(&self) -> Option<&ExitServer> {\n+ if self.exits.contains_key(self.current_exit.as_ref()?) {\nSome(&self.exits[self.current_exit.as_ref()?])\n+ } else {\n+ None\n+ }\n}\n}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Added Wifi info to HardwareInfo For every wifi device in /proc/net/wireless, we add the survey dump and station dump to the hardware info struct which will then be send to display on op tools
20,255
11.03.2022 12:29:35
28,800
57f8d8c0ee6a2b9eed98e699bc8282e281affd2c
Added Serde Default to wifiDevice field to prevent deserialization error on optools
[ { "change_type": "MODIFY", "old_path": "althea_types/src/interop.rs", "new_path": "althea_types/src/interop.rs", "diff": "@@ -574,6 +574,7 @@ pub struct HardwareInfo {\n/// Vector of eth data i.e. whether a link is up and if so what the link speed is\npub ethernet_stats: Option<Vec<EthernetStats>>,\n// Vector of wifi devices on router with staion and survey data for each\n+ #[serde(default)]\npub wifi_devices: Vec<WifiDevice>,\n}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Added Serde Default to wifiDevice field to prevent deserialization error on optools
20,247
16.03.2022 14:04:36
25,200
d1c8ae7b56d66d957816be37de904927fc9ab00c
Restrict mr8300 to wifi channels 36 & 149
[ { "change_type": "MODIFY", "old_path": "rita_client/src/dashboard/wifi.rs", "new_path": "rita_client/src/dashboard/wifi.rs", "diff": "@@ -29,8 +29,9 @@ pub const ALLOWED_FIVE_80_IPQ40XX: [u16; 2] = [36, 149];\n/// list of nonoverlapping 80mhz channels for the TPLink-a6v3/wr-2100/e5600\npub const ALLOWED_FIVE_80_MT7621: [u16; 1] = [36];\n/// NOTE: linksys_mr8300: The first 5 GHz radio (IPQ4019) is limited to ch. 64 and below. The second 5 GHz radio (QCA9888), is limited to ch. 100 and above.\n-pub const ALLOWED_FIVE_80_LOW: [u16; 2] = [36, 52];\n-pub const ALLOWED_FIVE_80_HIGH: [u16; 4] = [100, 116, 132, 149];\n+/// But experience suggests it's only channels 36 and 149 that work with 80mhz channel widths. Maybe there's a different way to declare the channels that will work?\n+pub const ALLOWED_FIVE_80_LOW: [u16; 1] = [36];\n+pub const ALLOWED_FIVE_80_HIGH: [u16; 1] = [149];\npub const ALLOWED_FIVE_40_LOW: [u16; 4] = [36, 44, 52, 60];\npub const ALLOWED_FIVE_40_HIGH: [u16; 8] = [100, 108, 116, 124, 132, 140, 149, 157];\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Restrict mr8300 to wifi channels 36 & 149
20,247
16.03.2022 22:07:41
25,200
28251144e75c1b00130c3f9b061cdc1957b87712
Bump to Beta 19 RC 3
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -2551,7 +2551,7 @@ dependencies = [\n[[package]]\nname = \"rita_bin\"\n-version = \"0.19.2\"\n+version = \"0.19.3\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n@@ -2584,7 +2584,7 @@ dependencies = [\n[[package]]\nname = \"rita_client\"\n-version = \"0.19.2\"\n+version = \"0.19.3\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n@@ -2619,7 +2619,7 @@ dependencies = [\n[[package]]\nname = \"rita_common\"\n-version = \"0.19.2\"\n+version = \"0.19.3\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-service\",\n@@ -2657,7 +2657,7 @@ dependencies = [\n[[package]]\nname = \"rita_exit\"\n-version = \"0.19.2\"\n+version = \"0.19.3\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n" }, { "change_type": "MODIFY", "old_path": "rita_bin/Cargo.toml", "new_path": "rita_bin/Cargo.toml", "diff": "[package]\nname = \"rita_bin\"\n-version = \"0.19.2\"\n+version = \"0.19.3\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\nbuild = \"build.rs\"\n" }, { "change_type": "MODIFY", "old_path": "rita_client/Cargo.toml", "new_path": "rita_client/Cargo.toml", "diff": "[package]\nname = \"rita_client\"\n-version = \"0.19.2\"\n+version = \"0.19.3\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" }, { "change_type": "MODIFY", "old_path": "rita_common/Cargo.toml", "new_path": "rita_common/Cargo.toml", "diff": "[package]\nname = \"rita_common\"\n-version = \"0.19.2\"\n+version = \"0.19.3\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/dashboard/own_info.rs", "new_path": "rita_common/src/dashboard/own_info.rs", "diff": "@@ -6,7 +6,7 @@ use actix_web_async::HttpResponse;\nuse clarity::Address;\nuse num256::{Int256, Uint256};\n-pub static READABLE_VERSION: &str = \"Beta 19 RC2\";\n+pub static READABLE_VERSION: &str = \"Beta 19 RC3\";\n#[derive(Serialize)]\npub struct OwnInfo {\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/Cargo.toml", "new_path": "rita_exit/Cargo.toml", "diff": "[package]\nname = \"rita_exit\"\n-version = \"0.19.2\"\n+version = \"0.19.3\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Bump to Beta 19 RC 3
20,253
08.03.2022 11:11:06
28,800
d8ba7757fb1ba7d1123f101f8e0eee9b2bf2e548
Adding sequence number to contact info to enable editing from ops tools This sequence number is keeping track of the most recently updated version of a router's user contact info. Editing it either from the router or from ops tools will increment it and ops tools will display the most recent edit.
[ { "change_type": "MODIFY", "old_path": "althea_types/src/contact_info.rs", "new_path": "althea_types/src/contact_info.rs", "diff": "@@ -17,21 +17,32 @@ pub struct ContactDetails {\nimpl From<ContactType> for ContactDetails {\nfn from(val: ContactType) -> Self {\nmatch val {\n- ContactType::Phone { number } => ContactDetails {\n+ ContactType::Phone {\n+ number,\n+ sequence_number: _,\n+ } => ContactDetails {\nphone: Some(number.to_string()),\nemail: None,\n},\n- ContactType::Email { email } => ContactDetails {\n+ ContactType::Email {\n+ email,\n+ sequence_number: _,\n+ } => ContactDetails {\nphone: None,\nemail: Some(email.to_string()),\n},\n- ContactType::Both { email, number } => ContactDetails {\n+ ContactType::Both {\n+ email,\n+ number,\n+ sequence_number: _,\n+ } => ContactDetails {\nphone: Some(number.to_string()),\nemail: Some(email.to_string()),\n},\nContactType::Bad {\ninvalid_email,\ninvalid_number,\n+ sequence_number: _,\n} => ContactDetails {\nphone: invalid_number,\nemail: invalid_email,\n@@ -41,12 +52,13 @@ impl From<ContactType> for ContactDetails {\n}\nimpl ContactType {\n- pub fn convert(val: ContactDetails) -> Option<Self> {\n+ pub fn convert(val: ContactDetails, seq: Option<u32>) -> Option<Self> {\nlet same = ExitRegistrationDetails {\nphone: val.phone,\nemail: val.email,\nphone_code: None,\nemail_code: None,\n+ sequence_number: seq,\n};\nContactStorage::convert(same).map(|val| val.into())\n}\n@@ -71,19 +83,27 @@ impl From<Option<ContactType>> for ContactDetails {\npub enum ContactType {\nPhone {\nnumber: PhoneNumber,\n+ #[serde(default)]\n+ sequence_number: Option<u32>,\n},\nEmail {\nemail: EmailAddress,\n+ #[serde(default)]\n+ sequence_number: Option<u32>,\n},\nBoth {\nnumber: PhoneNumber,\nemail: EmailAddress,\n+ #[serde(default)]\n+ sequence_number: Option<u32>,\n},\n/// During migration we may encounter invalid values we don't want\n/// to lose this info so we store it in this variant.\nBad {\ninvalid_number: Option<String>,\ninvalid_email: Option<String>,\n+ #[serde(default)]\n+ sequence_number: Option<u32>,\n},\n}\n@@ -95,37 +115,58 @@ pub struct ContactStorage {\nemail: Option<EmailAddress>,\ninvalid_number: Option<String>,\ninvalid_email: Option<String>,\n+ #[serde(default)]\n+ sequence_number: u32,\n+}\n+\n+pub fn get_sequence_num(cs: ContactStorage) -> u32 {\n+ cs.sequence_number\n}\nimpl From<ContactType> for ContactStorage {\nfn from(val: ContactType) -> Self {\nmatch val {\n- ContactType::Both { number, email } => ContactStorage {\n+ ContactType::Both {\n+ number,\n+ email,\n+ sequence_number,\n+ } => ContactStorage {\nnumber: Some(number),\nemail: Some(email),\ninvalid_number: None,\ninvalid_email: None,\n+ sequence_number: sequence_number.unwrap_or(0),\n},\n- ContactType::Phone { number } => ContactStorage {\n+ ContactType::Phone {\n+ number,\n+ sequence_number,\n+ } => ContactStorage {\nnumber: Some(number),\nemail: None,\ninvalid_email: None,\ninvalid_number: None,\n+ sequence_number: sequence_number.unwrap_or(0),\n},\n- ContactType::Email { email } => ContactStorage {\n+ ContactType::Email {\n+ email,\n+ sequence_number,\n+ } => ContactStorage {\nnumber: None,\nemail: Some(email),\ninvalid_email: None,\ninvalid_number: None,\n+ sequence_number: sequence_number.unwrap_or(0),\n},\nContactType::Bad {\ninvalid_email: val_e,\ninvalid_number: val_p,\n+ sequence_number,\n} => ContactStorage {\nnumber: None,\nemail: None,\ninvalid_email: val_e,\ninvalid_number: val_p,\n+ sequence_number: sequence_number.unwrap_or(0),\n},\n}\n}\n@@ -139,57 +180,75 @@ impl From<ContactStorage> for ContactType {\nemail: Some(email),\ninvalid_email: _,\ninvalid_number: _,\n+ sequence_number,\n} => ContactType::Both {\nnumber: phone,\nemail,\n+ sequence_number: Some(sequence_number),\n},\nContactStorage {\nnumber: Some(phone),\nemail: None,\ninvalid_email: _,\ninvalid_number: _,\n- } => ContactType::Phone { number: phone },\n+ sequence_number,\n+ } => ContactType::Phone {\n+ number: phone,\n+ sequence_number: Some(sequence_number),\n+ },\nContactStorage {\nnumber: None,\nemail: Some(email),\ninvalid_email: _,\ninvalid_number: _,\n- } => ContactType::Email { email },\n+ sequence_number,\n+ } => ContactType::Email {\n+ email,\n+ sequence_number: Some(sequence_number),\n+ },\nContactStorage {\nnumber: None,\nemail: None,\ninvalid_email: Some(val),\ninvalid_number: None,\n+ sequence_number,\n} => ContactType::Bad {\ninvalid_email: Some(val),\ninvalid_number: None,\n+ sequence_number: Some(sequence_number),\n},\nContactStorage {\nnumber: None,\nemail: None,\ninvalid_email: None,\ninvalid_number: Some(val),\n+ sequence_number,\n} => ContactType::Bad {\ninvalid_email: None,\ninvalid_number: Some(val),\n+ sequence_number: Some(sequence_number),\n},\nContactStorage {\nnumber: None,\nemail: None,\ninvalid_email: Some(val_e),\ninvalid_number: Some(val_p),\n+ sequence_number,\n} => ContactType::Bad {\ninvalid_email: Some(val_e),\ninvalid_number: Some(val_p),\n+ sequence_number: Some(sequence_number),\n},\nContactStorage {\nnumber: None,\nemail: None,\ninvalid_email: None,\ninvalid_number: None,\n+ sequence_number,\n} => ContactType::Bad {\ninvalid_email: None,\ninvalid_number: None,\n+ sequence_number: Some(sequence_number),\n},\n}\n}\n@@ -204,30 +263,35 @@ impl ContactStorage {\nemail: Some(email),\nphone_code: _,\nemail_code: _,\n+ sequence_number,\n} => match (phone.parse(), email.parse()) {\n(Ok(validated_phone), Ok(validated_email)) => Some(ContactStorage {\nnumber: Some(validated_phone),\nemail: Some(validated_email),\ninvalid_email: None,\ninvalid_number: None,\n+ sequence_number: sequence_number.unwrap_or(0),\n}),\n(Err(_e), Ok(validated_email)) => Some(ContactStorage {\nemail: Some(validated_email),\nnumber: None,\ninvalid_email: None,\ninvalid_number: None,\n+ sequence_number: sequence_number.unwrap_or(0),\n}),\n(Ok(validated_phone), Err(_e)) => Some(ContactStorage {\nnumber: Some(validated_phone),\nemail: None,\ninvalid_email: None,\ninvalid_number: None,\n+ sequence_number: sequence_number.unwrap_or(0),\n}),\n(Err(_ea), Err(_eb)) => Some(ContactStorage {\nnumber: None,\nemail: None,\ninvalid_email: Some(email),\ninvalid_number: Some(phone),\n+ sequence_number: sequence_number.unwrap_or(0),\n}),\n},\nExitRegistrationDetails {\n@@ -235,18 +299,21 @@ impl ContactStorage {\nemail: None,\nphone_code: _,\nemail_code: _,\n+ sequence_number,\n} => match phone.parse() {\nOk(validated_phone) => Some(ContactStorage {\nnumber: Some(validated_phone),\nemail: None,\ninvalid_email: None,\ninvalid_number: None,\n+ sequence_number: sequence_number.unwrap_or(0),\n}),\nErr(_e) => Some(ContactStorage {\nnumber: None,\nemail: None,\ninvalid_number: Some(phone),\ninvalid_email: None,\n+ sequence_number: sequence_number.unwrap_or(0),\n}),\n},\nExitRegistrationDetails {\n@@ -254,18 +321,21 @@ impl ContactStorage {\nemail: Some(email),\nphone_code: _,\nemail_code: _,\n+ sequence_number,\n} => match email.parse() {\nOk(validated_email) => Some(ContactStorage {\nemail: Some(validated_email),\nnumber: None,\ninvalid_email: None,\ninvalid_number: None,\n+ sequence_number: sequence_number.unwrap_or(0),\n}),\nErr(_e) => Some(ContactStorage {\nemail: None,\nnumber: None,\ninvalid_email: Some(email),\ninvalid_number: None,\n+ sequence_number: sequence_number.unwrap_or(0),\n}),\n},\nExitRegistrationDetails {\n@@ -273,7 +343,14 @@ impl ContactStorage {\nemail: None,\nphone_code: _,\nemail_code: _,\n- } => None,\n+ sequence_number,\n+ } => Some(ContactStorage {\n+ email: None,\n+ number: None,\n+ invalid_email: None,\n+ invalid_number: None,\n+ sequence_number: sequence_number.unwrap_or(0),\n+ }),\n}\n}\n}\n@@ -281,32 +358,47 @@ impl ContactStorage {\nimpl From<ContactType> for ExitRegistrationDetails {\nfn from(ct: ContactType) -> Self {\nmatch ct {\n- ContactType::Both { number, email } => ExitRegistrationDetails {\n+ ContactType::Both {\n+ number,\n+ email,\n+ sequence_number,\n+ } => ExitRegistrationDetails {\nphone: Some(number.to_string()),\nemail: Some(email.to_string()),\nemail_code: None,\nphone_code: None,\n+ sequence_number,\n},\n- ContactType::Email { email } => ExitRegistrationDetails {\n+ ContactType::Email {\n+ email,\n+ sequence_number,\n+ } => ExitRegistrationDetails {\nphone: None,\nemail: Some(email.to_string()),\nemail_code: None,\nphone_code: None,\n+ sequence_number,\n},\n- ContactType::Phone { number } => ExitRegistrationDetails {\n+ ContactType::Phone {\n+ number,\n+ sequence_number,\n+ } => ExitRegistrationDetails {\nphone: Some(number.to_string()),\nemail: None,\nemail_code: None,\nphone_code: None,\n+ sequence_number,\n},\nContactType::Bad {\ninvalid_email,\ninvalid_number,\n+ sequence_number,\n} => ExitRegistrationDetails {\nphone: invalid_number,\nemail: invalid_email,\nemail_code: None,\nphone_code: None,\n+ sequence_number,\n},\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "althea_types/src/interop.rs", "new_path": "althea_types/src/interop.rs", "diff": "@@ -141,6 +141,8 @@ pub struct ExitRegistrationDetails {\npub phone: Option<String>,\n#[serde(skip_serializing_if = \"Option::is_none\", default)]\npub phone_code: Option<String>,\n+ #[serde(skip_serializing_if = \"Option::is_none\", default)]\n+ pub sequence_number: Option<u32>,\n}\n/// This is the state an exit can be in\n@@ -454,6 +456,8 @@ pub struct OperatorUpdateMessage {\n/// settings for the device bandwidth shaper\n#[serde(default = \"default_shaper_settings\")]\npub shaper_settings: ShaperSettings,\n+ /// Updated contact info from ops tools\n+ pub contact_info: Option<ContactType>,\n}\n/// Settings for the bandwidth shaper\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/dashboard/contact_info.rs", "new_path": "rita_client/src/dashboard/contact_info.rs", "diff": "@@ -14,10 +14,17 @@ fn clean_quotes(val: &str) -> String {\nval.trim().trim_matches('\"').trim_matches('\\\\').to_string()\n}\n+fn add_to_sequence(sequence: Option<u32>) -> u32 {\n+ match sequence {\n+ Some(seq) => seq + 1,\n+ None => 1,\n+ }\n+}\n+\npub async fn set_phone_number(req: String) -> HttpResponse {\nlet clean_string = clean_quotes(&req);\ntrace!(\"Got number {:?}\", clean_string);\n- let number: PhoneNumber = match clean_string.parse() {\n+ let phone_number: PhoneNumber = match clean_string.parse() {\nOk(p) => p,\nErr(e) => {\ninfo!(\"Failed to parse phonenumber with {:?}\", e);\n@@ -29,14 +36,42 @@ pub async fn set_phone_number(req: String) -> HttpResponse {\n// merge the new value into the existing struct, for the various possibilities\nlet res = match option_convert(rita_client.exit_client.contact_info.clone()) {\n- Some(ContactType::Phone { .. }) => Some(ContactType::Phone { number }),\n- Some(ContactType::Email { email }) => Some(ContactType::Both { number, email }),\n+ Some(ContactType::Phone {\n+ number: _,\n+ sequence_number,\n+ }) => Some(ContactType::Phone {\n+ number: phone_number,\n+ sequence_number: Some(add_to_sequence(sequence_number)),\n+ }),\n+ Some(ContactType::Email {\n+ email,\n+ sequence_number,\n+ }) => Some(ContactType::Both {\n+ number: phone_number,\n+ email,\n+ sequence_number: Some(add_to_sequence(sequence_number)),\n+ }),\nSome(ContactType::Both {\nnumber: _number,\nemail,\n- }) => Some(ContactType::Both { number, email }),\n- Some(ContactType::Bad { .. }) => Some(ContactType::Phone { number }),\n- None => Some(ContactType::Phone { number }),\n+ sequence_number,\n+ }) => Some(ContactType::Both {\n+ number: phone_number,\n+ email,\n+ sequence_number: Some(add_to_sequence(sequence_number)),\n+ }),\n+ Some(ContactType::Bad {\n+ invalid_number: _,\n+ invalid_email: _,\n+ sequence_number,\n+ }) => Some(ContactType::Phone {\n+ number: phone_number,\n+ sequence_number: Some(add_to_sequence(sequence_number)),\n+ }),\n+ None => Some(ContactType::Phone {\n+ number: phone_number,\n+ sequence_number: Some(0),\n+ }),\n};\nrita_client.exit_client.contact_info = option_convert(res);\n@@ -54,10 +89,14 @@ pub async fn get_phone_number(_req: HttpRequest) -> HttpResponse {\nlet rita_client = settings::get_rita_client();\nlet exit_client = rita_client.exit_client;\nmatch &option_convert(exit_client.contact_info) {\n- Some(ContactType::Phone { number }) => HttpResponse::Ok().json(number.to_string()),\n+ Some(ContactType::Phone {\n+ number,\n+ sequence_number: _,\n+ }) => HttpResponse::Ok().json(number.to_string()),\nSome(ContactType::Both {\nemail: _email,\nnumber,\n+ sequence_number: _,\n}) => HttpResponse::Ok().json(number.to_string()),\n_ => HttpResponse::Ok().finish(),\n}\n@@ -78,14 +117,42 @@ pub async fn set_email(req: String) -> HttpResponse {\n// merge the new value into the existing struct, for the various possibilities\nlet res = match option_convert(rita_client.exit_client.contact_info.clone()) {\n- Some(ContactType::Phone { number }) => Some(ContactType::Both { number, email }),\n- Some(ContactType::Email { .. }) => Some(ContactType::Email { email }),\n+ Some(ContactType::Phone {\n+ number,\n+ sequence_number,\n+ }) => Some(ContactType::Both {\n+ number,\n+ email,\n+ sequence_number: Some(add_to_sequence(sequence_number)),\n+ }),\n+ Some(ContactType::Email {\n+ email,\n+ sequence_number,\n+ }) => Some(ContactType::Email {\n+ email,\n+ sequence_number: Some(add_to_sequence(sequence_number)),\n+ }),\nSome(ContactType::Both {\nnumber,\nemail: _email,\n- }) => Some(ContactType::Both { number, email }),\n- Some(ContactType::Bad { .. }) => Some(ContactType::Email { email }),\n- None => Some(ContactType::Email { email }),\n+ sequence_number,\n+ }) => Some(ContactType::Both {\n+ number,\n+ email,\n+ sequence_number: Some(add_to_sequence(sequence_number)),\n+ }),\n+ Some(ContactType::Bad {\n+ invalid_number: _,\n+ invalid_email: _,\n+ sequence_number,\n+ }) => Some(ContactType::Email {\n+ email,\n+ sequence_number: Some(add_to_sequence(sequence_number)),\n+ }),\n+ None => Some(ContactType::Email {\n+ email,\n+ sequence_number: Some(0),\n+ }),\n};\nrita_client.exit_client.contact_info = option_convert(res);\n@@ -102,10 +169,14 @@ pub async fn get_email(_req: HttpRequest) -> HttpResponse {\nlet rita_client = settings::get_rita_client();\nlet exit_client = rita_client.exit_client;\nmatch &option_convert(exit_client.contact_info) {\n- Some(ContactType::Email { email }) => HttpResponse::Ok().json(email.to_string()),\n+ Some(ContactType::Email {\n+ email,\n+ sequence_number: _,\n+ }) => HttpResponse::Ok().json(email.to_string()),\nSome(ContactType::Both {\nnumber: _number,\nemail,\n+ sequence_number: _,\n}) => HttpResponse::Ok().json(email.to_string()),\n_ => HttpResponse::Ok().finish(),\n}\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/dashboard/installation_details.rs", "new_path": "rita_client/src/dashboard/installation_details.rs", "diff": "@@ -37,15 +37,23 @@ pub async fn set_installation_details(req: Json<InstallationDetailsPost>) -> Htt\n(Ok(p), Ok(e)) => ContactType::Both {\nnumber: p,\nemail: e,\n+ // initialize sequence with 0\n+ sequence_number: Some(0),\n},\n(_, _) => return HttpResponse::BadRequest().finish(),\n},\n(None, Some(email)) => match email.parse() {\n- Ok(e) => ContactType::Email { email: e },\n+ Ok(e) => ContactType::Email {\n+ email: e,\n+ sequence_number: Some(0),\n+ },\nErr(_e) => return HttpResponse::BadRequest().finish(),\n},\n(Some(phone), None) => match phone.parse() {\n- Ok(p) => ContactType::Phone { number: p },\n+ Ok(p) => ContactType::Phone {\n+ number: p,\n+ sequence_number: Some(0),\n+ },\nErr(_e) => return HttpResponse::BadRequest().finish(),\n},\n};\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/exit_manager/mod.rs", "new_path": "rita_client/src/exit_manager/mod.rs", "diff": "@@ -399,6 +399,7 @@ pub async fn exit_setup_request(exit: String, code: Option<String>) -> Result<()\nemail_code: None,\nphone: None,\nphone_code: None,\n+ sequence_number: None,\n}\n} else {\nreturn Err(RitaClientError::MiscStringError(\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/operator_update/mod.rs", "new_path": "rita_client/src/operator_update/mod.rs", "diff": "@@ -7,6 +7,7 @@ use crate::rita_loop::is_gateway_client;\nuse crate::rita_loop::CLIENT_LOOP_TIMEOUT;\nuse crate::set_router_update_instruction;\nuse althea_kernel_interface::opkg_feeds::CUSTOMFEEDS;\n+use althea_types::get_sequence_num;\nuse rita_common::rita_loop::is_gateway;\nuse rita_common::tunnel_manager::neighbor_status::get_neighbor_status;\nuse rita_common::tunnel_manager::shaping::flag_reset_shaper;\n@@ -209,6 +210,39 @@ async fn checkin() {\nlet mut rita_client = settings::get_rita_client();\n+ // the current sequence number to check the update against\n+ let current_sequence = match rita_client.exit_client.contact_info.clone() {\n+ Some(storage) => get_sequence_num(storage),\n+ None => 0,\n+ };\n+ if let Some(info) = new_settings.contact_info {\n+ // the incoming sequence number\n+ let seq = match info {\n+ althea_types::ContactType::Phone {\n+ number: _,\n+ sequence_number,\n+ } => sequence_number,\n+ althea_types::ContactType::Email {\n+ email: _,\n+ sequence_number,\n+ } => sequence_number,\n+ althea_types::ContactType::Both {\n+ number: _,\n+ email: _,\n+ sequence_number,\n+ } => sequence_number,\n+ althea_types::ContactType::Bad {\n+ invalid_number: _,\n+ invalid_email: _,\n+ sequence_number,\n+ } => sequence_number,\n+ };\n+ if seq.unwrap_or(0) > current_sequence {\n+ rita_client.exit_client.contact_info = option_convert(Some(info));\n+ }\n+ // else the existing config is more recent, so do not update\n+ };\n+\nlet mut network = rita_client.network;\ntrace!(\"Updating from operator settings\");\nlet mut payment = rita_client.payment;\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Adding sequence number to contact info to enable editing from ops tools This sequence number is keeping track of the most recently updated version of a router's user contact info. Editing it either from the router or from ops tools will increment it and ops tools will display the most recent edit.
20,253
17.03.2022 11:05:08
25,200
41c5cfa03fd068fe1d228f3a782c71a66d4e0a78
Cleaning up router checkin fn by breaking into smaller fns
[ { "change_type": "MODIFY", "old_path": "rita_client/src/operator_update/mod.rs", "new_path": "rita_client/src/operator_update/mod.rs", "diff": "@@ -8,10 +8,15 @@ use crate::rita_loop::CLIENT_LOOP_TIMEOUT;\nuse crate::set_router_update_instruction;\nuse althea_kernel_interface::opkg_feeds::CUSTOMFEEDS;\nuse althea_types::get_sequence_num;\n+use althea_types::ContactStorage;\n+use althea_types::ContactType;\nuse rita_common::rita_loop::is_gateway;\nuse rita_common::tunnel_manager::neighbor_status::get_neighbor_status;\nuse rita_common::tunnel_manager::shaping::flag_reset_shaper;\nuse rita_common::utils::option_convert;\n+use settings::client::RitaClientSettings;\n+use settings::network::NetworkSettings;\n+use settings::payment::PaymentSettings;\nuse updater::update_rita;\nuse althea_kernel_interface::hardware_info::get_hardware_info;\n@@ -210,74 +215,41 @@ async fn checkin() {\nlet mut rita_client = settings::get_rita_client();\n- // the current sequence number to check the update against\n- let current_sequence = match rita_client.exit_client.contact_info.clone() {\n- Some(storage) => get_sequence_num(storage),\n- None => 0,\n- };\n- if let Some(info) = new_settings.contact_info {\n- // the incoming sequence number\n- let seq = match info {\n- althea_types::ContactType::Phone {\n- number: _,\n- sequence_number,\n- } => sequence_number,\n- althea_types::ContactType::Email {\n- email: _,\n- sequence_number,\n- } => sequence_number,\n- althea_types::ContactType::Both {\n- number: _,\n- email: _,\n- sequence_number,\n- } => sequence_number,\n- althea_types::ContactType::Bad {\n- invalid_number: _,\n- invalid_email: _,\n- sequence_number,\n- } => sequence_number,\n- };\n- if seq.unwrap_or(0) > current_sequence {\n- rita_client.exit_client.contact_info = option_convert(Some(info));\n+ let update = check_contacts_update(\n+ rita_client.exit_client.contact_info.clone(),\n+ new_settings.contact_info.clone(),\n+ );\n+ if update {\n+ rita_client.exit_client.contact_info = option_convert(new_settings.contact_info.clone());\n}\n- // else the existing config is more recent, so do not update\n- };\n- let mut network = rita_client.network;\n+ let network = rita_client.network.clone();\ntrace!(\"Updating from operator settings\");\n- let mut payment = rita_client.payment;\n- if use_operator_price {\n- // This will be true on devices that have integrated switches\n- // and a wan port configured. Mostly not a problem since we stopped\n- // shipping wan ports by default\n- if is_gateway {\n- payment.local_fee = new_settings.gateway;\n- } else {\n- payment.local_fee = new_settings.relay;\n- }\n- payment.light_client_fee = new_settings.phone_relay;\n- } else {\n- info!(\"User has disabled the OperatorUpdate!\");\n- }\n- payment.max_fee = new_settings.max;\n- payment.balance_warning_level = new_settings.warning.into();\n- if let Some(new_chain) = new_settings.system_chain {\n- if payment.system_chain != new_chain {\n- set_system_blockchain(new_chain, &mut payment);\n- }\n- }\n- if let Some(new_chain) = new_settings.withdraw_chain {\n- payment.withdraw_chain = new_chain;\n- }\n+ let payment = update_payment_settings(\n+ rita_client.payment,\n+ use_operator_price,\n+ is_gateway,\n+ new_settings.clone(),\n+ );\nrita_client.payment = payment;\ntrace!(\"Done with payment\");\n+\nlet mut operator = rita_client.operator;\nlet new_operator_fee = Uint256::from(new_settings.operator_fee);\noperator.operator_fee = new_operator_fee;\nrita_client.operator = operator;\n- merge_settings_safely(new_settings.merge_json);\n+ merge_settings_safely(new_settings.merge_json.clone());\n//Every tick, update the local router update instructions\n- set_router_update_instruction(new_settings.local_update_instruction);\n+ set_router_update_instruction(new_settings.local_update_instruction.clone());\n+ perform_operator_update(new_settings, rita_client, network)\n+}\n+\n+/// checks the operatoraction and performs it, if any.\n+fn perform_operator_update(\n+ new_settings: OperatorUpdateMessage,\n+ mut rita_client: RitaClientSettings,\n+ mut network: NetworkSettings,\n+) {\nmatch new_settings.operator_action {\nSome(OperatorAction::ResetShaper) => flag_reset_shaper(),\nSome(OperatorAction::Reboot) => {\n@@ -321,6 +293,78 @@ async fn checkin() {\ntrace!(\"Successfully completed OperatorUpdate\");\n}\n+/// Creates a payment settings from OperatorUpdateMessage to be returned and applied\n+fn update_payment_settings(\n+ mut payment: PaymentSettings,\n+ use_operator_price: bool,\n+ is_gateway: bool,\n+ new_settings: OperatorUpdateMessage,\n+) -> PaymentSettings {\n+ if use_operator_price {\n+ // This will be true on devices that have integrated switches\n+ // and a wan port configured. Mostly not a problem since we stopped\n+ // shipping wan ports by default\n+ if is_gateway {\n+ payment.local_fee = new_settings.gateway;\n+ } else {\n+ payment.local_fee = new_settings.relay;\n+ }\n+ payment.light_client_fee = new_settings.phone_relay;\n+ } else {\n+ info!(\"User has disabled the OperatorUpdate!\");\n+ }\n+ payment.max_fee = new_settings.max;\n+ payment.balance_warning_level = new_settings.warning.into();\n+ if let Some(new_chain) = new_settings.system_chain {\n+ if payment.system_chain != new_chain {\n+ set_system_blockchain(new_chain, &mut payment);\n+ }\n+ }\n+ if let Some(new_chain) = new_settings.withdraw_chain {\n+ payment.withdraw_chain = new_chain;\n+ }\n+ payment\n+}\n+\n+/// Returns true if the contact info sent through OperatorUpdateMessage have been more\n+/// recently updated than the router's current contact info\n+fn check_contacts_update(current: Option<ContactStorage>, incoming: Option<ContactType>) -> bool {\n+ // the current sequence number to check the update against\n+ let current_sequence = match current {\n+ Some(storage) => get_sequence_num(storage),\n+ None => 0,\n+ };\n+ if let Some(info) = incoming {\n+ // the incoming sequence number\n+ let seq = match info {\n+ althea_types::ContactType::Phone {\n+ number: _,\n+ sequence_number,\n+ } => sequence_number,\n+ althea_types::ContactType::Email {\n+ email: _,\n+ sequence_number,\n+ } => sequence_number,\n+ althea_types::ContactType::Both {\n+ number: _,\n+ email: _,\n+ sequence_number,\n+ } => sequence_number,\n+ althea_types::ContactType::Bad {\n+ invalid_number: _,\n+ invalid_email: _,\n+ sequence_number,\n+ } => sequence_number,\n+ };\n+ if seq.unwrap_or(0) > current_sequence {\n+ return true;\n+ }\n+ // else the existing config is more recent, so do not update\n+ return false;\n+ }\n+ false\n+}\n+\n/// Allows for online updating of the release feed, note that this not run\n/// on every device startup meaning just editing it the config is not sufficient\nfn handle_release_feed_update(val: Option<String>) {\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Cleaning up router checkin fn by breaking into smaller fns
20,243
02.03.2022 08:24:42
28,800
ff2a4deffcdf36d0f1116b802f60ca359becbf80
Creating stripped binary by adding strip to Cargo.toml Simple addition to Cargo.toml to strip unnecessary information like debuginfo from binaries to make it smaller.
[ { "change_type": "MODIFY", "old_path": "rita_bin/Cargo.toml", "new_path": "rita_bin/Cargo.toml", "diff": "@@ -5,6 +5,9 @@ edition = \"2018\"\nlicense = \"Apache-2.0\"\nbuild = \"build.rs\"\n+[profile.release]\n+strip = \"true\"\n+\n[[bin]]\nname = \"rita_exit\"\npath = \"src/exit.rs\"\n@@ -60,3 +63,4 @@ dev_env = []\ndevelopment = [\"rita_common/dash_debug\",\"rita_client/operator_debug\"]\n# Op tools dev environement\noptools_dev_env = [\"rita_client/dev_env\"]\n+\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Creating stripped binary by adding strip to Cargo.toml Simple addition to Cargo.toml to strip unnecessary information like debuginfo from binaries to make it smaller.
20,243
22.03.2022 13:47:37
25,200
0acd852b703b8b939478475008997bbbb3dc8cb0
Changed alias for exits to resolve serde issue Apparently, serde doesn't override a value and will instead create duplicate key values when you alias something. In order, to fix this the alias was changed to be renamed.
[ { "change_type": "MODIFY", "old_path": "settings/src/client.rs", "new_path": "settings/src/client.rs", "diff": "@@ -106,7 +106,7 @@ fn default_balance_notification() -> bool {\n#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]\npub struct ExitClientSettings {\n/// This stores a mapping between an identifier (any string) to exits\n- #[serde(alias = \"new_exits\", default)]\n+ #[serde(rename = \"new_exits\", default)]\npub exits: HashMap<String, ExitServer>,\n/// This stores the current exit identifier\npub current_exit: Option<String>,\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Changed alias for exits to resolve serde issue Apparently, serde doesn't override a value and will instead create duplicate key values when you alias something. In order, to fix this the alias was changed to be renamed.
20,244
23.03.2022 16:03:54
14,400
768b57a04da9b3aeeebb56eeef5fe6874b438556
Only use bracket format on ipv6 manual peers Previously the actix http library handled brackets around ipv4 addresses, the latest version no longer handles this transparently and we now have to check our address formatting depending on if we have an ipv4 or v6 address to send a http hello to.
[ { "change_type": "MODIFY", "old_path": "rita_common/src/hello_handler/mod.rs", "new_path": "rita_common/src/hello_handler/mod.rs", "diff": "@@ -26,11 +26,20 @@ pub struct Hello {\npub async fn handle_hello(msg: Hello) {\ntrace!(\"Sending Hello {:?}\", msg);\n- let endpoint = format!(\n+ // ipv6 addresses need the [] bracket format, ipv4 address literals do not\n+ let endpoint = if msg.to.contact_socket.is_ipv4() {\n+ format!(\n+ \"http://{}:{}/hello\",\n+ msg.to.contact_socket.ip(),\n+ msg.to.contact_socket.port()\n+ )\n+ } else {\n+ format!(\n\"http://[{}]:{}/hello\",\nmsg.to.contact_socket.ip(),\nmsg.to.contact_socket.port()\n- );\n+ )\n+ };\nlet client = awc::Client::default();\ninfo!(\"Sending hello request to manual peer: {}\", endpoint);\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Only use bracket format on ipv6 manual peers Previously the actix http library handled brackets around ipv4 addresses, the latest version no longer handles this transparently and we now have to check our address formatting depending on if we have an ipv4 or v6 address to send a http hello to.
20,244
23.03.2022 16:09:48
14,400
c816e94538abb4f2f79f6cb44be2e4b92813ba49
Provide helper functions for last tunnel manager GC This is a trivial re-phrasing of the same functionality that is slightly cleaner in terms of making sure the lock does not get held by accident.
[ { "change_type": "MODIFY", "old_path": "rita_common/src/tunnel_manager/gc.rs", "new_path": "rita_common/src/tunnel_manager/gc.rs", "diff": "@@ -18,6 +18,17 @@ lazy_static! {\nstatic ref LAST_GC: Arc<RwLock<Instant>> = Arc::new(RwLock::new(Instant::now()));\n}\n+/// gets the last GC instant\n+fn get_last_gc() -> Instant {\n+ *LAST_GC.read().unwrap()\n+}\n+\n+/// sets the last GC time to the current instant\n+fn set_last_gc() {\n+ let mut last_gc = LAST_GC.write().unwrap();\n+ *last_gc = Instant::now();\n+}\n+\n/// A message type for deleting all tunnels we haven't heard from for more than the duration.\npub struct TriggerGc {\n/// if we do not receive a hello within this many seconds we attempt to gc the tunnel\n@@ -35,8 +46,7 @@ pub struct TriggerGc {\npub fn tm_trigger_gc(msg: TriggerGc) -> Result<(), RitaCommonError> {\nlet tunnel_manager = &mut *TUNNEL_MANAGER.write().unwrap();\n- let mut last_gc = LAST_GC.write().unwrap();\n- let time_since = Instant::now().checked_duration_since(*last_gc);\n+ let time_since = Instant::now().checked_duration_since(get_last_gc());\nmatch time_since {\nSome(time) => {\nif time < GC_FREQUENCY {\n@@ -45,8 +55,7 @@ pub fn tm_trigger_gc(msg: TriggerGc) -> Result<(), RitaCommonError> {\n}\nNone => return Ok(()),\n}\n- *last_gc = Instant::now();\n- drop(last_gc);\n+ set_last_gc();\nlet interfaces = into_interfaces_hashmap(&msg.babel_interfaces);\ntrace!(\"Starting tunnel gc {:?}\", interfaces);\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Provide helper functions for last tunnel manager GC This is a trivial re-phrasing of the same functionality that is slightly cleaner in terms of making sure the lock does not get held by accident.
20,244
23.03.2022 16:11:01
14,400
0857ae1b8e44f7da11956a75aedbbf612187dc4a
Add some function comments to PeerListener My goal here to help the reader easy understand both the http and udp peer discovery flow.
[ { "change_type": "MODIFY", "old_path": "rita_common/src/peer_listener/mod.rs", "new_path": "rita_common/src/peer_listener/mod.rs", "diff": "@@ -89,6 +89,7 @@ impl PeerListener {\n}\n}\n+/// Creates a listen interface on all interfaces in the peer_interfaces hashmap.\nfn listen_to_available_ifaces(peer_listener: &mut PeerListener) {\nlet interfaces = settings::get_rita_common().network.peer_interfaces;\nlet iface_list = interfaces;\n@@ -106,6 +107,8 @@ fn listen_to_available_ifaces(peer_listener: &mut PeerListener) {\n}\n}\n+/// Ticks the peer listener module sending ImHere messages and receiving Hello messages from all\n+/// peers over UDP\npub fn peerlistener_tick() {\ntrace!(\"Starting PeerListener tick!\");\n@@ -198,6 +201,7 @@ impl ListenInterface {\n}\n}\n+/// send UDP ImHere messages over IPV6 link local\nfn send_im_here(interfaces: &mut HashMap<String, ListenInterface>) {\ntrace!(\"About to send ImHere\");\nfor obj in interfaces.iter_mut() {\n@@ -218,6 +222,7 @@ fn send_im_here(interfaces: &mut HashMap<String, ListenInterface>) {\n}\n}\n+/// receive UDP ImHere messages over IPV6 link local\nfn receive_im_here(\ninterfaces: &mut HashMap<String, ListenInterface>,\n) -> (HashMap<IpAddr, Peer>, HashMap<SocketAddr, String>) {\n@@ -279,6 +284,7 @@ fn receive_im_here(\n(output, interface_map)\n}\n+/// Send UDP hello message over IPV6\npub fn send_hello(msg: &Hello, socket: &UdpSocket, send_addr: SocketAddr, sender_wgport: u16) {\ntrace!(\"Sending a Hello message\");\n@@ -294,6 +300,7 @@ pub fn send_hello(msg: &Hello, socket: &UdpSocket, send_addr: SocketAddr, sender\n}\n}\n+/// receive UDP hello messages over IPV6 link local ports\npub fn receive_hello(writer: &mut PeerListener) {\ntrace!(\"Dequeing Hello\");\nfor obj in writer.interfaces.iter_mut() {\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Add some function comments to PeerListener My goal here to help the reader easy understand both the http and udp peer discovery flow.
20,244
29.03.2022 16:39:33
14,400
1740a2e8aa06f68c6d0bf86ec219a2430171648c
Strip flag needs to be in top level workspace This binary strip flag was not effective since profile settings must be performed at the top level of the workspace.
[ { "change_type": "MODIFY", "old_path": "Cargo.toml", "new_path": "Cargo.toml", "diff": "@@ -12,3 +12,4 @@ opt-level = \"z\"\nlto = true\ncodegen-units = 1\nincremental = false\n+strip = true\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "rita_bin/Cargo.toml", "new_path": "rita_bin/Cargo.toml", "diff": "@@ -5,9 +5,6 @@ edition = \"2018\"\nlicense = \"Apache-2.0\"\nbuild = \"build.rs\"\n-[profile.release]\n-strip = \"true\"\n-\n[[bin]]\nname = \"rita_exit\"\npath = \"src/exit.rs\"\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Strip flag needs to be in top level workspace This binary strip flag was not effective since profile settings must be performed at the top level of the workspace.
20,253
30.03.2022 10:14:57
25,200
1d94dfad1aa81bf65933b3f26b3c25aca4353201
disables hardware info collection when logging disabled If the user has disabled logging but left operator configured on the router it no longer sends hardware info with checkin so as to not reveal info about connected devices(wifi info, which was recently added to hardware info).
[ { "change_type": "MODIFY", "old_path": "rita_client/src/operator_update/mod.rs", "new_path": "rita_client/src/operator_update/mod.rs", "diff": "@@ -167,12 +167,16 @@ async fn checkin() {\nneighbor_info.push(status);\n}\n- let hardware_info = match get_hardware_info(rita_client.network.device) {\n+ // disable hardware info sending if logging is disabled\n+ let hardware_info = match logging_enabled {\n+ true => match get_hardware_info(rita_client.network.device) {\nOk(info) => Some(info),\nErr(e) => {\nerror!(\"Failed to get hardware info with {:?}\", e);\nNone\n}\n+ },\n+ false => None,\n};\nlet client = awc::Client::default();\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
disables hardware info collection when logging disabled If the user has disabled logging but left operator configured on the router it no longer sends hardware info with checkin so as to not reveal info about connected devices(wifi info, which was recently added to hardware info).
20,244
30.03.2022 17:07:57
14,400
e02b0079c688ca6ef4d2903156099b5e3112c1d0
Log some hardware info Currently this hardware info is being sent to operator tools but once it's there we can only visualize so much of it to help with debugging, this provides more historical data for us to use via logging visualizations.
[ { "change_type": "MODIFY", "old_path": "rita_client/src/operator_update/mod.rs", "new_path": "rita_client/src/operator_update/mod.rs", "diff": "@@ -10,6 +10,7 @@ use althea_kernel_interface::opkg_feeds::CUSTOMFEEDS;\nuse althea_types::get_sequence_num;\nuse althea_types::ContactStorage;\nuse althea_types::ContactType;\n+use althea_types::HardwareInfo;\nuse rita_common::rita_loop::is_gateway;\nuse rita_common::tunnel_manager::neighbor_status::get_neighbor_status;\nuse rita_common::tunnel_manager::shaping::flag_reset_shaper;\n@@ -179,6 +180,8 @@ async fn checkin() {\nfalse => None,\n};\n+ hardware_info_logs(&hardware_info);\n+\nlet client = awc::Client::default();\nlet response = client\n.post(url)\n@@ -248,6 +251,34 @@ async fn checkin() {\nperform_operator_update(new_settings, rita_client, network)\n}\n+/// logs some hardware info that may help debug this router\n+fn hardware_info_logs(info: &Option<HardwareInfo>) {\n+ if let Some(info) = info {\n+ info!(\n+ \"HardwareInfo: Allocated memory {}/{}\",\n+ info.allocated_memory, info.system_memory\n+ );\n+ info!(\n+ \"HardwareInfo: 15 minute load average {}\",\n+ info.load_avg_fifteen_minute\n+ );\n+ info!(\"HardwareInfo: logical cores {}\", info.logical_processors);\n+ info!(\"HardwareInfo: model {}\", info.model);\n+ info!(\"HardwareInfo: uptime {}\", info.system_uptime.as_secs());\n+ let mut total_wifi_clients = 0;\n+ for wifi in info.wifi_devices.iter() {\n+ for _ in wifi.station_data.iter() {\n+ total_wifi_clients += 1;\n+ }\n+ }\n+ info!(\"HardwareInfo: total wifi clients {}\", total_wifi_clients);\n+ info!(\n+ \"HardwareInfo: Kernel version {}\",\n+ info.system_kernel_version,\n+ );\n+ }\n+}\n+\n/// checks the operatoraction and performs it, if any.\nfn perform_operator_update(\nnew_settings: OperatorUpdateMessage,\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Log some hardware info Currently this hardware info is being sent to operator tools but once it's there we can only visualize so much of it to help with debugging, this provides more historical data for us to use via logging visualizations.
20,244
31.03.2022 14:58:45
14,400
c33c93a3e973d3f3791d4a3c65ccea740ced193d
Disable tests that rely on live ETH or XDAI nodes Due to an issue with our ETH cluster we currently can't serve these requests causing errors in our integration tests here. This is hindering progress so we should simply run these tests manually.
[ { "change_type": "MODIFY", "old_path": "auto_bridge/src/lib.rs", "new_path": "auto_bridge/src/lib.rs", "diff": "@@ -792,6 +792,7 @@ mod tests {\n}\n#[test]\n+ #[ignore]\nfn test_check_withdrawals() {\nlet runner = actix::System::new();\n@@ -842,6 +843,7 @@ mod tests {\n}\n#[test]\n+ #[ignore]\nfn test_looping_logic() {\nlet runner = actix::System::new();\nrunner.block_on(async move {\n@@ -884,6 +886,7 @@ mod tests {\n/// This tests that the function 'get_payload_for_funds_unlock' is working correctly and generating the correct bytes to use.\n/// To test this, we look at a successful transaction on etherscan.io, and compare the raw input to that generated by this function.\n#[test]\n+ #[ignore]\nfn test_withdraw_encoding() {\nlet dest_address = \"0xffcbadeb2a7cc87563e22a8fb4ee120eb73b2d82\";\nlet dest_address = dest_address.parse().unwrap();\n@@ -891,7 +894,7 @@ mod tests {\nlet own_address = \"0x5e53002339223011ba4bc1e5faf61fb42544e2c9\";\nlet own_address = own_address.parse().unwrap();\n- let xdai_full_node_url = \"https://dai.altheamesh.com\";\n+ let xdai_full_node_url = \"https://dai.althea.net\";\nlet xdai_web3 = Web3::new(xdai_full_node_url, TIMEOUT);\nlet helper_on_xdai = default_bridge_addresses().helper_on_xdai;\n@@ -934,8 +937,8 @@ mod tests {\nfn test_check_relayed_message() {\nlet runner = actix::System::new();\nrunner.block_on(async move {\n- let xdai_full_node_url = \"https://eth.altheamesh.com\";\n- let eth_web3 = Web3::new(xdai_full_node_url, TIMEOUT);\n+ let eth_full_node_url = \"https://eth.althea.net\";\n+ let eth_web3 = Web3::new(eth_full_node_url, TIMEOUT);\nlet own_address = \"0xB5E7AcD8f1D5F8f8EA2DEf72C34Fe4B02c759329\";\nlet own_address = own_address.parse().unwrap();\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/token_bridge/mod.rs", "new_path": "rita_common/src/token_bridge/mod.rs", "diff": "@@ -760,6 +760,7 @@ mod tests {\n/// This function not currently in use and we instead use check_relayed_message because of simplicity, but simulate_signature_submission() is also functional and\n/// checks the same thing as check_relayed_message() does.\n#[test]\n+ #[ignore]\nfn test_simulate_unlock_funds() {\nlet pk = PrivateKey::from_str(&format!(\n\"983aa7cb3e22b5aa8425facb9703a{}e04bd829e675b{}e5df\",\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Disable tests that rely on live ETH or XDAI nodes Due to an issue with our ETH cluster we currently can't serve these requests causing errors in our integration tests here. This is hindering progress so we should simply run these tests manually.
20,255
31.03.2022 10:40:02
25,200
19b520e6a8ce4e75a0e9776fb563ee5db7fe4bae
Send assigned ipv6 subnet from exit to clients
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -328,6 +328,7 @@ dependencies = [\n\"base64 0.13.0\",\n\"clarity\",\n\"hex\",\n+ \"ipnetwork 0.18.0\",\n\"lettre\",\n\"num256\",\n\"phonenumber\",\n" }, { "change_type": "MODIFY", "old_path": "althea_types/Cargo.toml", "new_path": "althea_types/Cargo.toml", "diff": "@@ -19,6 +19,7 @@ clarity = \"0.5\"\narrayvec = {version= \"0.7\", features = [\"serde\"]}\nphonenumber = \"0.3\"\nlettre = {version = \"0.9\", features = [\"serde\"]}\n+ipnetwork = \"0.18\"\n[dev-dependencies]\nrand = \"0.8\"\n" }, { "change_type": "MODIFY", "old_path": "althea_types/src/interop.rs", "new_path": "althea_types/src/interop.rs", "diff": "@@ -4,6 +4,7 @@ use arrayvec::ArrayString;\nuse babel_monitor::Neighbor as NeighborLegacy;\nuse babel_monitor::Route as RouteLegacy;\nuse clarity::Address;\n+use ipnetwork::IpNetwork;\nuse num256::Uint256;\nuse std::collections::hash_map::DefaultHasher;\nuse std::fmt;\n@@ -277,6 +278,7 @@ pub struct ExitDetails {\n#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Hash, Clone, Copy)]\npub struct ExitClientDetails {\npub client_internal_ip: IpAddr,\n+ pub internet_ipv6_subnet: IpNetwork,\n}\n/// This is all the data we need to give a neighbor to open a wg connection\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/email.rs", "new_path": "rita_exit/src/database/email.rs", "diff": "@@ -91,8 +91,15 @@ pub fn handle_email_registration(\nOk(ip) => ip,\nErr(e) => return Err(RitaExitError::AddrParseError(e)),\n};\n+ let client_internet_ipv6_subnet = match their_record.internet_ipv6.parse() {\n+ Ok(sub) => sub,\n+ Err(e) => return Err(RitaExitError::IpNetworkError(e)),\n+ };\nOk(ExitState::Registered {\n- our_details: ExitClientDetails { client_internal_ip },\n+ our_details: ExitClientDetails {\n+ client_internal_ip,\n+ internet_ipv6_subnet: client_internet_ipv6_subnet,\n+ },\ngeneral_details: get_exit_info(),\nmessage: \"Registration OK\".to_string(),\n})\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/mod.rs", "new_path": "rita_exit/src/database/mod.rs", "diff": "@@ -157,8 +157,15 @@ pub async fn signup_client(client: ExitClientIdentity) -> Result<ExitState, Rita\nOk(ip) => ip,\nErr(e) => return Err(RitaExitError::AddrParseError(e)),\n};\n+ let client_internet_ipv6_subnet = match their_record.internet_ipv6.parse() {\n+ Ok(sub) => sub,\n+ Err(e) => return Err(RitaExitError::IpNetworkError(e)),\n+ };\nOk(ExitState::Registered {\n- our_details: ExitClientDetails { client_internal_ip },\n+ our_details: ExitClientDetails {\n+ client_internal_ip,\n+ internet_ipv6_subnet: client_internet_ipv6_subnet,\n+ },\ngeneral_details: get_exit_info(),\nmessage: \"Registration OK\".to_string(),\n})\n@@ -192,6 +199,7 @@ pub fn client_status(\n}\nlet current_ip = their_record.internal_ip.parse()?;\n+ let current_internet_ipv6 = their_record.internet_ipv6.parse()?;\nlet exit_network = &*EXIT_NETWORK_SETTINGS;\nlet current_subnet =\n@@ -209,6 +217,7 @@ pub fn client_status(\nOk(ExitState::Registered {\nour_details: ExitClientDetails {\nclient_internal_ip: current_ip,\n+ internet_ipv6_subnet: current_internet_ipv6,\n},\ngeneral_details: get_exit_info(),\nmessage: \"Registration OK\".to_string(),\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/sms.rs", "new_path": "rita_exit/src/database/sms.rs", "diff": "@@ -120,6 +120,7 @@ pub async fn handle_sms_registration(\nOk(ExitState::Registered {\nour_details: ExitClientDetails {\nclient_internal_ip: their_record.internal_ip.parse()?,\n+ internet_ipv6_subnet: their_record.internet_ipv6.parse()?,\n},\ngeneral_details: get_exit_info(),\nmessage: \"Registration OK\".to_string(),\n@@ -167,6 +168,7 @@ pub async fn handle_sms_registration(\nOk(ExitState::Registered {\nour_details: ExitClientDetails {\nclient_internal_ip: their_record.internal_ip.parse()?,\n+ internet_ipv6_subnet: their_record.internet_ipv6.parse()?,\n},\ngeneral_details: get_exit_info(),\nmessage: \"Registration OK\".to_string(),\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Send assigned ipv6 subnet from exit to clients
20,244
11.04.2022 09:06:26
14,400
16f1da2568a0448723eb5dc7caadaa021fadbcb8
Re-enable deregistration Reviewing exit logs from the last month this is seems safe to enable.
[ { "change_type": "MODIFY", "old_path": "rita_exit/src/database/mod.rs", "new_path": "rita_exit/src/database/mod.rs", "diff": "@@ -224,11 +224,7 @@ pub fn client_status(\n})\n} else {\nerror!(\"De-registering client! {:?}\", client);\n- Err(RitaExitError::MiscStringError(\n- \"Refusing to de-register clients right now!\".to_string(),\n- ))\n- // TODO restore this functionality once it's confirmed to be safe\n- // Ok(ExitState::New)\n+ Ok(ExitState::New)\n}\n}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Re-enable deregistration Reviewing exit logs from the last month this is seems safe to enable.
20,244
13.04.2022 20:39:27
14,400
174ba51d8da7726c2459a4b7b8580e71559a3b20
Better doc comments for ExitServer
[ { "change_type": "MODIFY", "old_path": "settings/src/client.rs", "new_path": "settings/src/client.rs", "diff": "@@ -27,31 +27,35 @@ pub fn default_config_path() -> String {\nformat!(\"/etc/{}.toml\", APP_NAME)\n}\n-/// This struct is used by rita to store exit specific information\n-/// There is one instance per exit\n+/// This struct represents an exit server cluster, meaning\n+/// an arbitrary number of actual machines may be represented here\n+/// all exits in a cluster share a wireguard and eth private key used for their\n+/// wg_exit connections and are found via searching the routing table for\n+/// ip's within the provided subnet.\n#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]\npub struct ExitServer {\n- // Subnet of exits in cluster\n+ /// Subnet of exits in cluster\npub subnet: IpNetwork,\n- // Field added for serde config writing\n- pub id: Option<Identity>,\n-\n- //field added for serde config writing\n- pub subnet_len: u8,\n-\n- // eth address of Selected exit\n+ /// eth address of this exit cluster\npub eth_address: Address,\n- //wg public key of selected exit\n+ /// wg public key used for wg_exit by this cluster\n+ /// each exit has a distinct wg key used for peer\n+ /// to peer tunnels and to identify it in logs\npub wg_public_key: WgKey,\n- /// The port over which we will reach the exit apis on over the mesh\n+ /// The power we reach out to to hit the register endpoint\n+ /// also used for all other exit lifecycle management api calls\n#[serde(default)]\npub registration_port: u16,\n+\n+ /// the exit description, a short string blurb that is displayed\n+ /// directly to the user\n+ ///\n#[serde(default)]\npub description: String,\n- /// The state and data about the exit\n+ /// The registration state and other data about the exit\n#[serde(default, flatten)]\npub info: ExitState,\n}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Better doc comments for ExitServer
20,244
13.04.2022 23:01:55
14,400
61f00a4b22f7fa4207087125e01605220e949f73
Allow for optional ipv6 assigments to clients We currently do not actually use any of these assignments client side so making it optional is easier. On the exit side I suspect issues actually handing out these IPs to existing registrations will be encountered.
[ { "change_type": "MODIFY", "old_path": "althea_types/src/interop.rs", "new_path": "althea_types/src/interop.rs", "diff": "@@ -278,7 +278,7 @@ pub struct ExitDetails {\n#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Hash, Clone, Copy)]\npub struct ExitClientDetails {\npub client_internal_ip: IpAddr,\n- pub internet_ipv6_subnet: IpNetwork,\n+ pub internet_ipv6_subnet: Option<IpNetwork>,\n}\n/// This is all the data we need to give a neighbor to open a wg connection\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/email.rs", "new_path": "rita_exit/src/database/email.rs", "diff": "@@ -98,7 +98,7 @@ pub fn handle_email_registration(\nOk(ExitState::Registered {\nour_details: ExitClientDetails {\nclient_internal_ip,\n- internet_ipv6_subnet: client_internet_ipv6_subnet,\n+ internet_ipv6_subnet: Some(client_internet_ipv6_subnet),\n},\ngeneral_details: get_exit_info(),\nmessage: \"Registration OK\".to_string(),\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/mod.rs", "new_path": "rita_exit/src/database/mod.rs", "diff": "@@ -164,7 +164,7 @@ pub async fn signup_client(client: ExitClientIdentity) -> Result<ExitState, Rita\nOk(ExitState::Registered {\nour_details: ExitClientDetails {\nclient_internal_ip,\n- internet_ipv6_subnet: client_internet_ipv6_subnet,\n+ internet_ipv6_subnet: Some(client_internet_ipv6_subnet),\n},\ngeneral_details: get_exit_info(),\nmessage: \"Registration OK\".to_string(),\n@@ -217,7 +217,7 @@ pub fn client_status(\nOk(ExitState::Registered {\nour_details: ExitClientDetails {\nclient_internal_ip: current_ip,\n- internet_ipv6_subnet: current_internet_ipv6,\n+ internet_ipv6_subnet: Some(current_internet_ipv6),\n},\ngeneral_details: get_exit_info(),\nmessage: \"Registration OK\".to_string(),\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/sms.rs", "new_path": "rita_exit/src/database/sms.rs", "diff": "@@ -120,7 +120,7 @@ pub async fn handle_sms_registration(\nOk(ExitState::Registered {\nour_details: ExitClientDetails {\nclient_internal_ip: their_record.internal_ip.parse()?,\n- internet_ipv6_subnet: their_record.internet_ipv6.parse()?,\n+ internet_ipv6_subnet: Some(their_record.internet_ipv6.parse()?),\n},\ngeneral_details: get_exit_info(),\nmessage: \"Registration OK\".to_string(),\n@@ -168,7 +168,7 @@ pub async fn handle_sms_registration(\nOk(ExitState::Registered {\nour_details: ExitClientDetails {\nclient_internal_ip: their_record.internal_ip.parse()?,\n- internet_ipv6_subnet: their_record.internet_ipv6.parse()?,\n+ internet_ipv6_subnet: Some(their_record.internet_ipv6.parse()?),\n},\ngeneral_details: get_exit_info(),\nmessage: \"Registration OK\".to_string(),\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Allow for optional ipv6 assigments to clients We currently do not actually use any of these assignments client side so making it optional is easier. On the exit side I suspect issues actually handing out these IPs to existing registrations will be encountered.
20,244
13.04.2022 23:08:26
14,400
eb533af5d687a64736714e7504e8be83d23ecf9e
Bump for Beta 19 RC5
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -2646,7 +2646,7 @@ dependencies = [\n[[package]]\nname = \"rita_bin\"\n-version = \"0.19.4\"\n+version = \"0.19.5\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n@@ -2679,7 +2679,7 @@ dependencies = [\n[[package]]\nname = \"rita_client\"\n-version = \"0.19.4\"\n+version = \"0.19.5\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n@@ -2714,7 +2714,7 @@ dependencies = [\n[[package]]\nname = \"rita_common\"\n-version = \"0.19.4\"\n+version = \"0.19.5\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-service\",\n@@ -2752,7 +2752,7 @@ dependencies = [\n[[package]]\nname = \"rita_exit\"\n-version = \"0.19.4\"\n+version = \"0.19.5\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n" }, { "change_type": "MODIFY", "old_path": "Cargo.toml", "new_path": "Cargo.toml", "diff": "@@ -8,8 +8,4 @@ edition = \"2018\"\nmembers = [\"althea_kernel_interface\", \"settings\", \"clu\", \"exit_db\", \"antenna_forwarding_client\", \"antenna_forwarding_protocol\", \"auto_bridge\",\"rita_common\",\"rita_exit\",\"rita_client\", \"rita_bin\"]\n[profile.release]\n-opt-level = \"z\"\n-lto = true\n-codegen-units = 1\n-incremental = false\n-strip = true\n\\ No newline at end of file\n+opt-level = 2\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "rita_bin/Cargo.toml", "new_path": "rita_bin/Cargo.toml", "diff": "[package]\nname = \"rita_bin\"\n-version = \"0.19.4\"\n+version = \"0.19.5\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\nbuild = \"build.rs\"\n" }, { "change_type": "MODIFY", "old_path": "rita_client/Cargo.toml", "new_path": "rita_client/Cargo.toml", "diff": "[package]\nname = \"rita_client\"\n-version = \"0.19.4\"\n+version = \"0.19.5\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/lib.rs", "new_path": "rita_client/src/lib.rs", "diff": "@@ -86,7 +86,7 @@ About:\n/// two minutes\npub fn wait_for_settings(settings_file: &str) -> RitaClientSettings {\nlet start = Instant::now();\n- let timeout = Duration::from_secs(120);\n+ let timeout = Duration::from_secs(5);\nlet mut res = RitaClientSettings::new(settings_file);\nwhile (Instant::now() - start) < timeout {\nif let Ok(val) = res {\n" }, { "change_type": "MODIFY", "old_path": "rita_common/Cargo.toml", "new_path": "rita_common/Cargo.toml", "diff": "[package]\nname = \"rita_common\"\n-version = \"0.19.4\"\n+version = \"0.19.5\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/dashboard/own_info.rs", "new_path": "rita_common/src/dashboard/own_info.rs", "diff": "@@ -6,7 +6,7 @@ use actix_web_async::HttpResponse;\nuse clarity::Address;\nuse num256::{Int256, Uint256};\n-pub static READABLE_VERSION: &str = \"Beta 19 RC4\";\n+pub static READABLE_VERSION: &str = \"Beta 19 RC5\";\n#[derive(Serialize)]\npub struct OwnInfo {\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/Cargo.toml", "new_path": "rita_exit/Cargo.toml", "diff": "[package]\nname = \"rita_exit\"\n-version = \"0.19.4\"\n+version = \"0.19.5\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Bump for Beta 19 RC5
20,244
25.04.2022 11:55:05
14,400
0d3f62ece286879405f27d3879ac89b47f6283e3
Reduce logging in forwarding loop
[ { "change_type": "MODIFY", "old_path": "antenna_forwarding_protocol/src/lib.rs", "new_path": "antenna_forwarding_protocol/src/lib.rs", "diff": "@@ -182,7 +182,7 @@ pub fn process_streams<S: ::std::hash::BuildHasher>(\nmatch read_till_block(&mut antenna_stream.stream) {\nOk(bytes) => {\nif !bytes.is_empty() {\n- info!(\n+ trace!(\n\"Got {} bytes for stream id {} from antenna/client\",\nbytes.len(),\nstream_id\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Reduce logging in forwarding loop
20,253
25.04.2022 12:19:24
25,200
457724b9c0f0034c389d34f0cecee646c9a34ff2
Expanding feature rita_client/dev_env for ops tools Part of an update to ops tools dev env to add a rita tower instance, this feature now points the dev tower to the correct heartbeat server key and sends it dummy exit info
[ { "change_type": "MODIFY", "old_path": "rita_client/src/heartbeat/mod.rs", "new_path": "rita_client/src/heartbeat/mod.rs", "diff": "@@ -64,13 +64,13 @@ pub struct HeartbeatCache {\nexit_neighbor_rita: RitaNeighbor,\n}\n-#[cfg(not(feature = \"operator_debug\"))]\n+#[cfg(not(any(feature = \"operator_debug\", feature = \"dev_env\")))]\nlazy_static! {\npub static ref HEARTBEAT_SERVER_KEY: WgKey = \"hizclQFo/ArWY+/9+AJ0LBY2dTiQK4smy5icM7GA5ng=\"\n.parse()\n.unwrap();\n}\n-#[cfg(feature = \"operator_debug\")]\n+#[cfg(any(feature = \"operator_debug\", feature = \"dev_env\"))]\nlazy_static! {\npub static ref HEARTBEAT_SERVER_KEY: WgKey = \"RECW5xQfDzo3bzaZtzepM/+qWRuFTohChKKzUqGA0n4=\"\n.parse()\n@@ -140,8 +140,13 @@ fn send_udp_heartbeat() {\n// Check for the basics first, before doing any of the hard futures work\nlet mut our_id: Identity = if settings::get_rita_client().get_identity().is_some() {\n+ trace!(\n+ \"Got identity: {} \",\n+ settings::get_rita_client().get_identity().unwrap()\n+ );\nsettings::get_rita_client().get_identity().unwrap()\n} else {\n+ trace!(\"Could not get identity!\");\nreturn;\n};\nlet mut selected_exit_details: ExitDetails = dummy_selected_exit_details();\n@@ -156,8 +161,12 @@ fn send_udp_heartbeat() {\nSome(details) => {\nour_id = id;\nselected_exit_details = details.clone();\n+ trace!(\"got exit details for id: {}\", id);\n+ }\n+ None => {\n+ trace!(\"got no exit details!\");\n+ return;\n}\n- None => return,\n}\n} else {\nreturn;\n@@ -180,7 +189,8 @@ fn send_udp_heartbeat() {\nmatch dns_request {\nOk(dnsres) => {\nlet dnsresult = VecDeque::from_iter(dnsres);\n- let selected_exit_route = if cfg!(feature = \"operator_debug\") {\n+ let selected_exit_route =\n+ if cfg!(feature = \"operator_debug\") || cfg!(feature = \"dev_env\") {\nOk(dummy_route())\n} else {\nget_selected_exit_route(&network_info.babel_routes)\n@@ -188,7 +198,8 @@ fn send_udp_heartbeat() {\nmatch selected_exit_route {\nOk(route) => {\n- let neigh_option = if cfg!(feature = \"operator_debug\") {\n+ let neigh_option =\n+ if cfg!(feature = \"operator_debug\") || cfg!(feature = \"dev_env\") {\nSome((dummy_neigh_babel(), dummy_neigh_tunnel()))\n} else {\nlet neigh_option1 =\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Expanding feature rita_client/dev_env for ops tools Part of an update to ops tools dev env to add a rita tower instance, this feature now points the dev tower to the correct heartbeat server key and sends it dummy exit info
20,243
27.04.2022 10:23:13
25,200
d156b01278cd72967e978d331c6c0205af107988
Added simple check to prevent payments from non updated nodes The code simply adds to the blockchain oracle struct a instant and a function that returns true if the blockchain oracle is outdated. The function will be modified to prevent further potential payment issues in the future.
[ { "change_type": "MODIFY", "old_path": "integration-tests/rita.sh", "new_path": "integration-tests/rita.sh", "diff": "@@ -84,7 +84,7 @@ if [ ! -z \"${COMPAT_LAYOUT-}\" ] ; then\nelse\npushd ..\nRUSTFLAGS=\"-C target-cpu=native\"\n- cargo build --all --release\n+ cargo build --all --release --features \"rita_bin/development\"\npopd\nfi\n" }, { "change_type": "MODIFY", "old_path": "rita_bin/Cargo.toml", "new_path": "rita_bin/Cargo.toml", "diff": "@@ -56,7 +56,7 @@ dash_debug = []\n# changes operator urls\noperator_debug = []\ndev_env = []\n-development = [\"rita_common/dash_debug\",\"rita_client/operator_debug\"]\n+development = [\"rita_common/dash_debug\",\"rita_client/operator_debug\",\"rita_common/integration_test\"]\n# Op tools dev environement\noptools_dev_env = [\"rita_client/dev_env\"]\n" }, { "change_type": "MODIFY", "old_path": "rita_common/Cargo.toml", "new_path": "rita_common/Cargo.toml", "diff": "@@ -44,3 +44,4 @@ features = [\"std\"]\n[features]\n# disables cors for dash debugging\ndash_debug = []\n+integration_test = []\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/blockchain_oracle/mod.rs", "new_path": "rita_common/src/blockchain_oracle/mod.rs", "diff": "@@ -15,6 +15,7 @@ use web30::client::Web3;\nuse std::sync::Arc;\nuse std::sync::RwLock;\nuse std::time::Duration;\n+use std::time::Instant;\n/// This is the value pay_threshold is multiplied by to determine the close threshold\n/// the close pay_threshold is when one router will pay another, the close_threshold is when\n@@ -89,6 +90,7 @@ pub struct BlockchainOracle {\n/// The last seen block, if this goes backwards we will\n/// ignore the update, none if not yet set\npub last_seen_block: Option<Uint256>,\n+ pub last_updated: Option<Instant>,\n}\n/// This struct contains important information to determine when a router should be paying and when it should be enforcing on\n@@ -135,6 +137,7 @@ impl BlockchainOracle {\ngas_info: GasInfo::default(),\nbalance: None,\nlast_seen_block: None,\n+ last_updated: None,\n}\n}\n}\n@@ -184,6 +187,10 @@ pub fn get_oracle_last_seen_block() -> Option<Uint256> {\nORACLE.read().unwrap().last_seen_block.clone()\n}\n+pub fn get_oracle_last_updated() -> Option<Instant> {\n+ ORACLE.read().unwrap().last_updated\n+}\n+\n// Oracle setters\npub fn set_oracle_gas_info(info: GasInfo) {\nORACLE.write().unwrap().gas_info = info;\n@@ -203,6 +210,10 @@ fn set_oracle_last_seen_block(block: Uint256) {\nORACLE.write().unwrap().last_seen_block = Some(block)\n}\n+pub fn set_oracle_last_updated(update: Instant) {\n+ ORACLE.write().unwrap().last_updated = Some(update)\n+}\n+\npub async fn update() {\nlet payment_settings = settings::get_rita_common().payment;\nlet our_address = payment_settings.eth_address.expect(\"No address!\");\n@@ -214,6 +225,29 @@ pub async fn update() {\nupdate_blockchain_info(our_address, web3, full_node).await;\n}\n+/// The current amount of time before we consider that the blockchain oracle\n+/// is too outdated and that we could have issues with payments.\n+const OUTDATED_TIME: Duration = Duration::new(300, 0);\n+/// This function is used to detect possible payment issues since we want to prevent\n+/// node failures in the future. Currently, it only checks to make sure the blockchain\n+/// oracle is semi-recent.\n+pub fn potential_payment_issues_detected() -> bool {\n+ // disable this feature if we're in development mode\n+ if cfg!(feature = \"integration_test\") {\n+ return false;\n+ }\n+\n+ match ORACLE.read().unwrap().last_updated {\n+ Some(time) => {\n+ if time.elapsed() > OUTDATED_TIME {\n+ return true;\n+ }\n+ }\n+ None => return true,\n+ }\n+ false\n+}\n+\nasync fn update_blockchain_info(our_address: Address, web3: Web3, full_node: String) {\n// all web30 functions check if the node is syncing, but sometimes the nodes lie about\n// syncing, this block checks the actual block number we've last seen and if we get a lower\n@@ -231,6 +265,7 @@ async fn update_blockchain_info(our_address: Address, web3: Web3, full_node: Str\n}\n}\nset_oracle_last_seen_block(latest_block);\n+ set_oracle_last_updated(Instant::now());\n}\nErr(e) => {\nwarn!(\"Failed to get latest block number with {:?}\", e);\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/debt_keeper/mod.rs", "new_path": "rita_common/src/debt_keeper/mod.rs", "diff": "//! of the excess complexity you see, managing an incoming payments pool versus a incoming debts pool\nuse crate::blockchain_oracle::get_oracle_close_thresh;\nuse crate::blockchain_oracle::get_oracle_pay_thresh;\n+use crate::blockchain_oracle::potential_payment_issues_detected;\nuse crate::payment_controller::queue_payment;\nuse crate::payment_validator::PAYMENT_SEND_TIMEOUT;\nuse crate::simulated_txfee_manager::add_tx_to_total;\n@@ -253,7 +254,14 @@ pub fn send_debt_update() -> Result<(), RitaCommonError> {\naction: TunnelAction::PaidOnTime,\n});\n}\n- DebtAction::MakePayment { to, amount } => queue_payment(PaymentTx {\n+ DebtAction::MakePayment { to, amount } => {\n+ if potential_payment_issues_detected() {\n+ warn!(\"Potential payment issue detected\");\n+ return Err(RitaCommonError::MiscStringError(\n+ \"Potential payment issue detected\".to_string(),\n+ ));\n+ }\n+ queue_payment(PaymentTx {\nto,\nfrom: match settings::get_rita_common().get_identity() {\nSome(id) => id,\n@@ -265,7 +273,8 @@ pub fn send_debt_update() -> Result<(), RitaCommonError> {\n},\namount,\ntxid: None, // not yet published\n- }),\n+ });\n+ }\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/tunnel_manager/mod.rs", "new_path": "rita_common/src/tunnel_manager/mod.rs", "diff": "@@ -10,6 +10,7 @@ pub mod id_callback;\npub mod neighbor_status;\npub mod shaping;\n+use crate::blockchain_oracle::potential_payment_issues_detected;\nuse crate::peer_listener::Peer;\nuse crate::RitaCommonError;\nuse crate::FAST_LOOP_TIMEOUT;\n@@ -633,6 +634,10 @@ fn tunnel_state_change(msg: TunnelChange, tunnels: &mut HashMap<Identity, Vec<Tu\n// this is done outside of the match to make the borrow checker happy\nif tunnel_bw_limits_need_change {\n+ if potential_payment_issues_detected() {\n+ warn!(\"Potential payment issue detected\");\n+ return;\n+ }\nlet res = tunnel_bw_limit_update(tunnels);\n// if this fails consistently it could be a wallet draining attack\n// TODO check for that case\n@@ -656,6 +661,7 @@ fn tunnel_bw_limit_update(tunnels: &HashMap<Identity, Vec<Tunnel>>) -> Result<()\n}\n}\n}\n+\nlet payment = settings::get_rita_common().payment;\nlet bw_per_iface = if limited_interfaces > 0 {\npayment.free_tier_throughput / u32::from(limited_interfaces)\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/network_endpoints/mod.rs", "new_path": "rita_exit/src/network_endpoints/mod.rs", "diff": "@@ -19,6 +19,7 @@ use althea_types::{\nEncryptedExitClientIdentity, EncryptedExitState, ExitClientIdentity, ExitState,\n};\nuse num256::Int256;\n+use rita_common::blockchain_oracle::potential_payment_issues_detected;\nuse rita_common::debt_keeper::get_debts_list;\nuse rita_common::payment_validator::calculate_unverified_payments;\nuse sodiumoxide::crypto::box_;\n@@ -242,6 +243,13 @@ pub async fn get_client_debt(client: Json<Identity>) -> HttpResponse {\nlet neg_one = Int256::from(neg_one);\nlet zero: Int256 = 0u8.into();\n+ // if we detect payment issues and development mode is not enabled, return zero\n+ // to prevent overpayment\n+ if potential_payment_issues_detected() {\n+ warn!(\"Potential payment issue detected\");\n+ return HttpResponse::Ok().json(zero);\n+ }\n+\n// these are payments to us, remember debt is positive when we owe and negative when we are owed\n// this value is being presented to the client router who's debt is positive (they owe the exit) so we\n// want to make it negative\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Added simple check to prevent payments from non updated nodes The code simply adds to the blockchain oracle struct a instant and a function that returns true if the blockchain oracle is outdated. The function will be modified to prevent further potential payment issues in the future.
20,244
29.04.2022 11:19:13
14,400
b308ca9137fee0945d5a3c40e614fb80879bf91d
Make postgres initdb locale independent A container rebuild for the integration tests seems to require this flag, probably an update to the way locales are handled.
[ { "change_type": "MODIFY", "old_path": "integration-tests/integration-test-script/world.py", "new_path": "integration-tests/integration-test-script/world.py", "diff": "@@ -109,7 +109,7 @@ class World:\nEXIT_NAMESPACE, POSTGRES_USER, POSTGRES_BIN, POSTGRES_DATABASE, POSTGRES_CONFIG), False)\ntime.sleep(30)\nelse:\n- exec_no_exit(\"sudo ip netns exec {} sudo -u {} PGDATA=/var/lib/postgresql/data {}\".format(\n+ exec_no_exit(\"sudo ip netns exec {} sudo -u {} PGDATA=/var/lib/postgresql/data {} --no-locale\".format(\nEXIT_NAMESPACE, POSTGRES_USER, INITDB_BIN), True)\nexec_or_exit(\"sudo ip netns exec {} sudo -u {} PGDATA=/var/lib/postgresql/data {}\".format(\nEXIT_NAMESPACE, POSTGRES_USER, POSTGRES_BIN), False)\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Make postgres initdb locale independent A container rebuild for the integration tests seems to require this flag, probably an update to the way locales are handled.
20,244
29.04.2022 16:45:56
14,400
e8b88de89c7bdfd83d41adb857f17361d16b81a0
Bump for Beta 19RC6
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -2646,7 +2646,7 @@ dependencies = [\n[[package]]\nname = \"rita_bin\"\n-version = \"0.19.5\"\n+version = \"0.19.6\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n@@ -2679,7 +2679,7 @@ dependencies = [\n[[package]]\nname = \"rita_client\"\n-version = \"0.19.5\"\n+version = \"0.19.6\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n@@ -2714,7 +2714,7 @@ dependencies = [\n[[package]]\nname = \"rita_common\"\n-version = \"0.19.5\"\n+version = \"0.19.6\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-service\",\n@@ -2752,7 +2752,7 @@ dependencies = [\n[[package]]\nname = \"rita_exit\"\n-version = \"0.19.5\"\n+version = \"0.19.6\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n" }, { "change_type": "MODIFY", "old_path": "rita_bin/Cargo.toml", "new_path": "rita_bin/Cargo.toml", "diff": "[package]\nname = \"rita_bin\"\n-version = \"0.19.5\"\n+version = \"0.19.6\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\nbuild = \"build.rs\"\n" }, { "change_type": "MODIFY", "old_path": "rita_client/Cargo.toml", "new_path": "rita_client/Cargo.toml", "diff": "[package]\nname = \"rita_client\"\n-version = \"0.19.5\"\n+version = \"0.19.6\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" }, { "change_type": "MODIFY", "old_path": "rita_common/Cargo.toml", "new_path": "rita_common/Cargo.toml", "diff": "[package]\nname = \"rita_common\"\n-version = \"0.19.5\"\n+version = \"0.19.6\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/dashboard/own_info.rs", "new_path": "rita_common/src/dashboard/own_info.rs", "diff": "@@ -6,7 +6,7 @@ use actix_web_async::HttpResponse;\nuse clarity::Address;\nuse num256::{Int256, Uint256};\n-pub static READABLE_VERSION: &str = \"Beta 19 RC5\";\n+pub static READABLE_VERSION: &str = \"Beta 19 RC6\";\n#[derive(Serialize)]\npub struct OwnInfo {\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/Cargo.toml", "new_path": "rita_exit/Cargo.toml", "diff": "[package]\nname = \"rita_exit\"\n-version = \"0.19.5\"\n+version = \"0.19.6\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Bump for Beta 19RC6
20,255
02.05.2022 13:28:26
25,200
f41afa05469b4be6185d8f64228170d5baa5080c
Changed position of funciton that calls local exit ip initiaztion Previously the function initialize_selected_exit_list was called in a position that was unreachable. This moves it to the front of the exit_manager_tick loop
[ { "change_type": "MODIFY", "old_path": "rita_client/src/dashboard/exits.rs", "new_path": "rita_client/src/dashboard/exits.rs", "diff": "@@ -65,6 +65,7 @@ pub fn dashboard_get_exit_info() -> Result<Vec<ExitInfo>, RitaClientError> {\nfor exit in exit_client.exits.clone().into_iter() {\nlet selected = is_selected(&exit.1, current_exit);\n+ info!(\"Trying to get exit: {}\", exit.0.clone());\nlet route_ip = match get_selected_exit(exit.0.clone()) {\nSome(a) => a,\nNone => {\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/exit_manager/mod.rs", "new_path": "rita_client/src/exit_manager/mod.rs", "diff": "@@ -577,6 +577,11 @@ fn correct_default_route(input: Option<DefaultRoute>) -> bool {\nfn initialize_selected_exit_list(exit: String, server: ExitServer) {\nlet list = &mut EXIT_MANAGER.write().unwrap().selected_exit_list;\n+ info!(\n+ \"Setting initialized IP for exit {} with ip: {}\",\n+ exit,\n+ server.subnet.ip()\n+ );\nlist.entry(exit).or_insert_with(|| SelectedExit {\nselected_id: Some(server.subnet.ip()),\nselected_id_degradation: None,\n@@ -598,6 +603,11 @@ pub async fn exit_manager_tick() {\nlet last_exit = get_selected_exit(current_exit.clone());\nlet mut exits = rita_client.exit_client.exits;\n+ // Initialize all exits ip addrs in local lazy static if they havent been set already\n+ for (k, s) in exits.clone() {\n+ initialize_selected_exit_list(k, s);\n+ }\n+\nlet exit_ser_ref = exits.get_mut(&current_exit);\n// code that connects to the current exit server\n@@ -737,7 +747,6 @@ pub async fn exit_manager_tick() {\nlet servers = { settings::get_rita_client().exit_client.exits };\nfor (k, s) in servers {\n- initialize_selected_exit_list(k.clone(), s.clone());\nmatch s.info {\nExitState::Denied { .. } | ExitState::Disabled | ExitState::GotInfo { .. } => {}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Changed position of funciton that calls local exit ip initiaztion Previously the function initialize_selected_exit_list was called in a position that was unreachable. This moves it to the front of the exit_manager_tick loop
20,244
03.05.2022 07:09:35
14,400
74161503fc0ffc7c868b15e2ed2c42891e6b6306
Bump for Beta 19 RC7
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -2646,7 +2646,7 @@ dependencies = [\n[[package]]\nname = \"rita_bin\"\n-version = \"0.19.6\"\n+version = \"0.19.7\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n@@ -2679,7 +2679,7 @@ dependencies = [\n[[package]]\nname = \"rita_client\"\n-version = \"0.19.6\"\n+version = \"0.19.7\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n@@ -2714,7 +2714,7 @@ dependencies = [\n[[package]]\nname = \"rita_common\"\n-version = \"0.19.6\"\n+version = \"0.19.7\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-service\",\n@@ -2752,7 +2752,7 @@ dependencies = [\n[[package]]\nname = \"rita_exit\"\n-version = \"0.19.6\"\n+version = \"0.19.7\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n" }, { "change_type": "MODIFY", "old_path": "rita_bin/Cargo.toml", "new_path": "rita_bin/Cargo.toml", "diff": "[package]\nname = \"rita_bin\"\n-version = \"0.19.6\"\n+version = \"0.19.7\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\nbuild = \"build.rs\"\n" }, { "change_type": "MODIFY", "old_path": "rita_client/Cargo.toml", "new_path": "rita_client/Cargo.toml", "diff": "[package]\nname = \"rita_client\"\n-version = \"0.19.6\"\n+version = \"0.19.7\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" }, { "change_type": "MODIFY", "old_path": "rita_common/Cargo.toml", "new_path": "rita_common/Cargo.toml", "diff": "[package]\nname = \"rita_common\"\n-version = \"0.19.6\"\n+version = \"0.19.7\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/dashboard/own_info.rs", "new_path": "rita_common/src/dashboard/own_info.rs", "diff": "@@ -6,7 +6,7 @@ use actix_web_async::HttpResponse;\nuse clarity::Address;\nuse num256::{Int256, Uint256};\n-pub static READABLE_VERSION: &str = \"Beta 19 RC6\";\n+pub static READABLE_VERSION: &str = \"Beta 19 RC7\";\n#[derive(Serialize)]\npub struct OwnInfo {\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/Cargo.toml", "new_path": "rita_exit/Cargo.toml", "diff": "[package]\nname = \"rita_exit\"\n-version = \"0.19.6\"\n+version = \"0.19.7\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Bump for Beta 19 RC7
20,244
07.05.2022 08:20:11
14,400
7d616205df858f6ce709f6cd6acc3e2b61b84564
Prevent interactive prompts from integration test
[ { "change_type": "MODIFY", "old_path": "integration-tests/container/Dockerfile", "new_path": "integration-tests/container/Dockerfile", "diff": "FROM postgres\nRUN echo \"deb http://deb.debian.org/debian/ unstable main\" > /etc/apt/sources.list.d/unstable.list\nRUN printf 'Package: *\\nPin: release a=unstable\\nPin-Priority: 90\\n' > /etc/apt/preferences.d/limit-unstable\n+ENV DEBIAN_FRONTEND=noninteractive\nRUN apt-get update && apt-get install -y sudo iputils-ping iproute2 jq vim netcat default-libmysqlclient-dev libsqlite3-dev postgresql-client-11 postgresql-server-dev-11 libpq-dev python3-pip bridge-utils wireguard linux-source curl git libssl-dev pkg-config build-essential ipset python3-setuptools python3-wheel dh-autoreconf procps\nRUN apt-get install -y -t unstable iperf3\nRUN curl https://sh.rustup.rs -sSf | sh -s -- -y\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Prevent interactive prompts from integration test
20,244
07.05.2022 08:31:32
14,400
2f9ea7487ffcc6908454c0b47a4828e497c187e1
Actually run cross tests in test.sh The --all argument was ommitted here, resulting in us not actually running the tests.
[ { "change_type": "MODIFY", "old_path": "scripts/test.sh", "new_path": "scripts/test.sh", "diff": "@@ -10,7 +10,7 @@ cargo clippy --all --all-targets --all-features -- -D warnings\ncargo fmt --all -- --check\n# test rita only on many architectures\n-CROSS_TEST_ARGS=\"--verbose -- --test-threads=1\"\n+CROSS_TEST_ARGS=\"--verbose --all -- --test-threads=1\"\ncross test --target x86_64-unknown-linux-musl $CROSS_TEST_ARGS\ncross test --target mips-unknown-linux-gnu $CROSS_TEST_ARGS\ncross test --target mipsel-unknown-linux-gnu $CROSS_TEST_ARGS\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Actually run cross tests in test.sh The --all argument was ommitted here, resulting in us not actually running the tests.
20,253
02.05.2022 10:45:37
25,200
a7c329f0bd42a73ae5225875704100547b1f7bb5
Adds a toggle for wifi encryption Users can switch between a set list of encryption modes from the router dashboard
[ { "change_type": "MODIFY", "old_path": "rita_client/src/dashboard/mod.rs", "new_path": "rita_client/src/dashboard/mod.rs", "diff": "@@ -143,6 +143,10 @@ pub fn start_client_dashboard(rita_dashboard_port: u16) {\n\"/wifi_settings/get_channels/{radio}\",\nweb::get().to(get_allowed_wifi_channels),\n)\n+ .route(\n+ \"/wifi_settings/get_encryption/{radio}\",\n+ web::get().to(get_allowed_encryption_modes),\n+ )\n.route(\"/wifi_settings\", web::get().to(get_wifi_config))\n.route(\"/withdraw/{address}/{amount}\", web::post().to(withdraw))\n.route(\"/withdraw_all/{address}\", web::post().to(withdraw_all))\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/dashboard/wifi.rs", "new_path": "rita_client/src/dashboard/wifi.rs", "diff": "@@ -224,6 +224,32 @@ fn set_channel(wifi_channel: &WifiChannel) -> Result<(), RitaClientError> {\nOk(())\n}\n+#[derive(Serialize, Deserialize, Clone, Debug)]\n+pub struct WifiSecurity {\n+ pub radio: String,\n+ pub encryption: String,\n+}\n+\n+/// Changes the wifi encryption mode from a given dropdown menu\n+fn set_security(wifi_security: &WifiSecurity) -> Result<(), RitaClientError> {\n+ // check that the given string is one of the approved strings for encryption mode\n+ if wifi_security.encryption == \"sae\"\n+ || wifi_security.encryption == \"sae-mixed\"\n+ || wifi_security.encryption == \"psk2+tkip+ccmp\"\n+ || wifi_security.encryption == \"psk-mixed+tkip+ccmp\"\n+ {\n+ KI.set_uci_var(\n+ &format!(\"wireless.{}.encryption\", wifi_security.radio),\n+ &wifi_security.encryption,\n+ )?;\n+ Ok(())\n+ } else {\n+ Err(RitaClientError::MiscStringError(\n+ \"Could not set wifi encryption; invalid encryption mode\".to_string(),\n+ ))\n+ }\n+}\n+\n#[derive(Clone, Debug)]\npub struct WifiDisabledReturn {\npub needs_reboot: bool,\n@@ -270,6 +296,7 @@ pub enum WifiToken {\nWifiSsid(WifiSsid),\nWifiPass(WifiPass),\nWifiDisabled(WifiDisabled),\n+ WifiSecurity(WifiSecurity),\n}\n/// an endpoint that takes a series of wifi tokens in json format and applies them all at once\n@@ -317,6 +344,13 @@ pub async fn set_wifi_multi(wifi_changes: Json<Vec<WifiToken>>) -> HttpResponse\nneeds_reboot = true;\n}\n}\n+ WifiToken::WifiSecurity(val) => {\n+ if let Err(e) = set_security(val) {\n+ return HttpResponse::build(StatusCode::BAD_REQUEST).json(ErrorJsonResponse {\n+ error: format!(\"Failed to set encryption: {}\", e),\n+ });\n+ }\n+ }\n};\n}\n@@ -443,6 +477,13 @@ fn validate_channel(\n}\n}\n+// returns allowed wifi encryption values\n+pub async fn get_allowed_encryption_modes(radio: Path<String>) -> HttpResponse {\n+ debug!(\"/wifi_settings/get_encryption hit with {:?}\", radio);\n+ HttpResponse::Ok().json([\"sae\", \"sae-mixed\", \"psk2+tkip+ccmp\", \"psk-mixed+tkip+ccmp\"])\n+ // TODO: restrict list based on device compatibility. This is currently just the full list of used values\n+}\n+\n// returns what channels are allowed for the provided radio value\npub async fn get_allowed_wifi_channels(radio: Path<String>) -> HttpResponse {\ndebug!(\"/wifi_settings/get_channels hit with {:?}\", radio);\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Adds a toggle for wifi encryption Users can switch between a set list of encryption modes from the router dashboard
20,255
05.05.2022 14:21:44
25,200
01bb6663ef5f01c99a8e0708d7b0083a6c90fef0
Fix the router dashboard password not being set on the frontend Two issues were fixed in this commit 1.) router_dashboard_password being saved to rita settings after hitting the /router/password endpoint 2.) Sending a 403 Forbidden to the frontend when not authenticated so that we get the login popup
[ { "change_type": "MODIFY", "old_path": "rita_client/src/dashboard/auth.rs", "new_path": "rita_client/src/dashboard/auth.rs", "diff": "use actix_web_async::{http::StatusCode, web::Json, HttpResponse};\nuse clarity::utils::bytes_to_hex_str;\nuse rita_common::{RitaCommonError, KI};\n+use settings::set_rita_client;\nuse sha3::{Digest, Sha3_512};\n#[derive(Serialize, Deserialize, Default, Clone, Debug)]\n@@ -20,6 +21,7 @@ pub async fn set_pass(router_pass: Json<RouterPassword>) -> HttpResponse {\nlet mut rita_client = settings::get_rita_client();\nrita_client.network.rita_dashboard_password = Some(hashed_pass);\n+ set_rita_client(rita_client);\nif let Err(e) = settings::write_config() {\nreturn HttpResponse::build(StatusCode::INTERNAL_SERVER_ERROR)\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/dashboard/mod.rs", "new_path": "rita_client/src/dashboard/mod.rs", "diff": "@@ -69,8 +69,8 @@ pub fn start_client_dashboard(rita_dashboard_port: u16) {\nrunner.block_on(async move {\nlet _res = HttpServer::new(|| {\nApp::new()\n- .wrap(middleware::HeadersMiddlewareFactory)\n.wrap(middleware::AuthMiddlewareFactory)\n+ .wrap(middleware::HeadersMiddlewareFactory)\n.route(\"/backup_created\", web::get().to(get_backup_created))\n.route(\n\"/backup_created/{status}\",\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/middleware.rs", "new_path": "rita_common/src/middleware.rs", "diff": "//! as necessary and convert it into a response, modify it as necessary and then return that\n//! response\n+use actix_web_async::body::BoxBody;\nuse actix_web_async::dev::{Service, Transform};\nuse actix_web_async::http::header::{\nHeader, ACCESS_CONTROL_ALLOW_HEADERS, ACCESS_CONTROL_ALLOW_ORIGIN,\n};\nuse actix_web_async::http::{header, Method, StatusCode};\n-use actix_web_httpauth_async::extractors::basic::Config;\n-use actix_web_httpauth_async::extractors::AuthenticationError;\n+use actix_web_async::HttpResponse;\nuse actix_web_async::{dev::ServiceRequest, dev::ServiceResponse, Error};\n+use actix_web_httpauth_async::extractors::basic::Config;\n+use actix_web_httpauth_async::extractors::AuthenticationError;\nuse actix_web_httpauth_async::headers::authorization::{Authorization, Basic};\nuse futures::future::{ok, LocalBoxFuture, Ready};\nuse futures::FutureExt;\n@@ -72,6 +74,8 @@ where\nNone => url_no_port,\n};\n+ info!(\"our req is {:?} and origin is {:?}\", req, origin);\n+\nlet req_method = req.method().clone();\nlet fut = self.service.call(req);\n@@ -109,11 +113,11 @@ where\npub struct AuthMiddlewareFactory;\n-impl<S, B> Transform<S, ServiceRequest> for AuthMiddlewareFactory\n+impl<S> Transform<S, ServiceRequest> for AuthMiddlewareFactory\nwhere\n- S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error> + 'static,\n+ S: Service<ServiceRequest, Response = ServiceResponse<BoxBody>, Error = Error> + 'static,\n{\n- type Response = ServiceResponse<B>;\n+ type Response = ServiceResponse<BoxBody>;\ntype Error = Error;\ntype InitError = ();\ntype Transform = AuthMiddleware<S>;\n@@ -128,11 +132,11 @@ pub struct AuthMiddleware<S> {\nservice: S,\n}\n-impl<S, B> Service<ServiceRequest> for AuthMiddleware<S>\n+impl<S> Service<ServiceRequest> for AuthMiddleware<S>\nwhere\n- S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error> + 'static,\n+ S: Service<ServiceRequest, Response = ServiceResponse<BoxBody>, Error = Error> + 'static,\n{\n- type Response = ServiceResponse<B>;\n+ type Response = ServiceResponse<BoxBody>;\ntype Error = Error;\ntype Future = LocalBoxFuture<'static, Result<Self::Response, Self::Error>>;\n@@ -140,6 +144,7 @@ where\nfn call(&self, req: ServiceRequest) -> Self::Future {\nlet password = settings::get_rita_client().network.rita_dashboard_password;\n+ info!(\"Password set is {:?}\", password);\nlet req_path = req.path().to_string();\n@@ -158,8 +163,13 @@ where\nlet auth = match auth {\nOk(auth) => auth,\nErr(_) => {\n- let config = Config::default();\n- return Err(AuthenticationError::from(config.realm(\"Admin\")).into());\n+ let resp = fut.await?;\n+ let requ = resp.request().clone();\n+ let http_resp: HttpResponse<BoxBody> = HttpResponse::Forbidden()\n+ .finish()\n+ .set_body(actix_web_async::body::BoxBody::new(\"Unauthorized\"));\n+ let resp = ServiceResponse::new(requ, http_resp);\n+ return Ok(resp);\n}\n};\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Fix the router dashboard password not being set on the frontend Two issues were fixed in this commit 1.) router_dashboard_password being saved to rita settings after hitting the /router/password endpoint 2.) Sending a 403 Forbidden to the frontend when not authenticated so that we get the login popup
20,244
07.05.2022 08:34:44
14,400
079e5811895128b2aa6abff73449c1f66703e072
Bump for Beta 19 RC8
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -2646,7 +2646,7 @@ dependencies = [\n[[package]]\nname = \"rita_bin\"\n-version = \"0.19.7\"\n+version = \"0.19.8\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n@@ -2679,7 +2679,7 @@ dependencies = [\n[[package]]\nname = \"rita_client\"\n-version = \"0.19.7\"\n+version = \"0.19.8\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n@@ -2714,7 +2714,7 @@ dependencies = [\n[[package]]\nname = \"rita_common\"\n-version = \"0.19.7\"\n+version = \"0.19.8\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-service\",\n@@ -2752,7 +2752,7 @@ dependencies = [\n[[package]]\nname = \"rita_exit\"\n-version = \"0.19.7\"\n+version = \"0.19.8\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n" }, { "change_type": "MODIFY", "old_path": "rita_bin/Cargo.toml", "new_path": "rita_bin/Cargo.toml", "diff": "[package]\nname = \"rita_bin\"\n-version = \"0.19.7\"\n+version = \"0.19.8\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\nbuild = \"build.rs\"\n" }, { "change_type": "MODIFY", "old_path": "rita_client/Cargo.toml", "new_path": "rita_client/Cargo.toml", "diff": "[package]\nname = \"rita_client\"\n-version = \"0.19.7\"\n+version = \"0.19.8\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" }, { "change_type": "MODIFY", "old_path": "rita_common/Cargo.toml", "new_path": "rita_common/Cargo.toml", "diff": "[package]\nname = \"rita_common\"\n-version = \"0.19.7\"\n+version = \"0.19.8\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/dashboard/own_info.rs", "new_path": "rita_common/src/dashboard/own_info.rs", "diff": "@@ -6,7 +6,7 @@ use actix_web_async::HttpResponse;\nuse clarity::Address;\nuse num256::{Int256, Uint256};\n-pub static READABLE_VERSION: &str = \"Beta 19 RC7\";\n+pub static READABLE_VERSION: &str = \"Beta 19 RC8\";\n#[derive(Serialize)]\npub struct OwnInfo {\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/Cargo.toml", "new_path": "rita_exit/Cargo.toml", "diff": "[package]\nname = \"rita_exit\"\n-version = \"0.19.7\"\n+version = \"0.19.8\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Bump for Beta 19 RC8
20,244
09.05.2022 16:30:46
14,400
fbffcf991fae3025cb0c1ec1cab26a4b7a538664
Simplify operator update lazy statics
[ { "change_type": "MODIFY", "old_path": "rita_client/src/operator_update/mod.rs", "new_path": "rita_client/src/operator_update/mod.rs", "diff": "@@ -73,35 +73,18 @@ impl UptimeStruct {\n}\nlazy_static! {\n- pub static ref RITA_UPTIME: Instant = Instant::now();\n- pub static ref TIME_PASSED: Arc<RwLock<UptimeStruct>> =\n- Arc::new(RwLock::new(UptimeStruct::new()));\n- static ref OPERATOR_UPDATE: Arc<RwLock<OperatorUpdate>> =\n- Arc::new(RwLock::new(OperatorUpdate::default()));\n+ /// stores the startup time for Rita, used to compute uptime\n+ static ref RITA_UPTIME: Instant = Instant::now();\n+ /// a timer of when we last ran an operator update, used to\n+ /// keep from running updates too often\n+ static ref OPERATOR_UPDATE: Arc<RwLock<Instant>> =\n+ Arc::new(RwLock::new(Instant::now()));\n}\n/// Perform operator updates every UPDATE_FREQUENCY seconds,\n/// even if we are called more often than that\nconst UPDATE_FREQUENCY: Duration = Duration::from_secs(60);\n-pub struct OperatorUpdate {\n- last_update: Instant,\n-}\n-\n-impl OperatorUpdate {\n- pub fn new() -> Self {\n- OperatorUpdate {\n- last_update: Instant::now(),\n- }\n- }\n-}\n-\n-impl Default for OperatorUpdate {\n- fn default() -> OperatorUpdate {\n- OperatorUpdate::new()\n- }\n-}\n-\n/// How long we wait for a response from the server\n/// this value must be less than or equal to the CLIENT_LOOP_SPEED\n/// in the rita_client loop\n@@ -111,10 +94,10 @@ pub struct Update;\npub async fn operator_update() {\nlet operator_update = &mut *OPERATOR_UPDATE.write().unwrap();\n- let time_elapsed = Instant::now().checked_duration_since(operator_update.last_update);\n+ let time_elapsed = Instant::now().checked_duration_since(*operator_update);\nif time_elapsed.is_some() && time_elapsed.unwrap() > UPDATE_FREQUENCY {\ncheckin().await;\n- operator_update.last_update = Instant::now();\n+ *operator_update = Instant::now();\n}\n}\n@@ -197,7 +180,7 @@ async fn checkin() {\nbilling_details,\nhardware_info,\nuser_bandwidth_limit,\n- rita_uptime: TIME_PASSED.write().unwrap().time_elapsed(&RITA_UPTIME),\n+ rita_uptime: RITA_UPTIME.elapsed(),\n})\n.await;\n@@ -510,11 +493,3 @@ mod tests {\n}\n}\n}\n-\n-#[test]\n-fn test_rita_uptime() {\n- // exact key match should fail\n- let uptime = TIME_PASSED.read().unwrap();\n- let time = uptime.prev_time;\n- println!(\"Time: {}\", time.as_secs());\n-}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Simplify operator update lazy statics
20,253
09.05.2022 10:38:03
25,200
d5e15425dbb83b8e109c5ff6287c37a975142b2a
Putting wifi encryption strings into enum
[ { "change_type": "MODIFY", "old_path": "rita_client/src/dashboard/wifi.rs", "new_path": "rita_client/src/dashboard/wifi.rs", "diff": "use ::actix_web_async::http::StatusCode;\nuse ::actix_web_async::web::Path;\nuse ::actix_web_async::{web::Json, HttpRequest, HttpResponse};\n+use althea_types::FromStr;\nuse rita_common::dashboard::nickname::maybe_set_nickname;\nuse rita_common::{RitaCommonError, KI};\nuse serde_json::Value;\n@@ -75,6 +76,41 @@ static FORBIDDEN_CHARS: &str = \"'/\\\"\\\\\";\nstatic MINIMUM_PASS_CHARS: usize = 8;\n+pub enum EncryptionModes {\n+ //\"sae\", \"sae-mixed\", \"psk2+tkip+ccmp\", \"psk-mixed+tkip+ccmp\"\n+ Sae,\n+ SaeMixed,\n+ Psk2TkipCcmp,\n+ Psk2MixedTkipCcmp,\n+}\n+\n+impl ToString for EncryptionModes {\n+ fn to_string(&self) -> String {\n+ match self {\n+ EncryptionModes::Sae => \"sae\".to_string(),\n+ EncryptionModes::SaeMixed => \"sae-mixed\".to_string(),\n+ EncryptionModes::Psk2TkipCcmp => \"psk2+tkip+ccmp\".to_string(),\n+ EncryptionModes::Psk2MixedTkipCcmp => \"psk-mixed+tkip+ccmp\".to_string(),\n+ }\n+ }\n+}\n+impl FromStr for EncryptionModes {\n+ type Err = RitaClientError;\n+\n+ fn from_str(s: &str) -> Result<Self, Self::Err> {\n+ match s {\n+ \"sae\" => Ok(EncryptionModes::Sae),\n+ \"sae-mixed\" => Ok(EncryptionModes::SaeMixed),\n+ \"psk2+tkip+ccmp\" => Ok(EncryptionModes::Psk2TkipCcmp),\n+ \"psk-mixed+tkip+ccmp\" => Ok(EncryptionModes::Psk2MixedTkipCcmp),\n+ _ => {\n+ let e = RitaClientError::MiscStringError(\"Invalid encryption mode!\".to_string());\n+ Err(e)\n+ }\n+ }\n+ }\n+}\n+\n/// A helper error type for displaying UCI config value validation problems human-readably.\n#[derive(Debug, Serialize)]\npub enum ValidationError {\n@@ -233,15 +269,12 @@ pub struct WifiSecurity {\n/// Changes the wifi encryption mode from a given dropdown menu\nfn set_security(wifi_security: &WifiSecurity) -> Result<(), RitaClientError> {\n// check that the given string is one of the approved strings for encryption mode\n- if wifi_security.encryption == \"sae\"\n- || wifi_security.encryption == \"sae-mixed\"\n- || wifi_security.encryption == \"psk2+tkip+ccmp\"\n- || wifi_security.encryption == \"psk-mixed+tkip+ccmp\"\n- {\n+ if EncryptionModes::from_str(&wifi_security.encryption).is_ok() {\nKI.set_uci_var(\n&format!(\"wireless.{}.encryption\", wifi_security.radio),\n&wifi_security.encryption,\n)?;\n+\nOk(())\n} else {\nErr(RitaClientError::MiscStringError(\n@@ -480,7 +513,12 @@ fn validate_channel(\n// returns allowed wifi encryption values\npub async fn get_allowed_encryption_modes(radio: Path<String>) -> HttpResponse {\ndebug!(\"/wifi_settings/get_encryption hit with {:?}\", radio);\n- HttpResponse::Ok().json([\"sae\", \"sae-mixed\", \"psk2+tkip+ccmp\", \"psk-mixed+tkip+ccmp\"])\n+ HttpResponse::Ok().json([\n+ EncryptionModes::Sae.to_string(),\n+ EncryptionModes::SaeMixed.to_string(),\n+ EncryptionModes::Psk2TkipCcmp.to_string(),\n+ EncryptionModes::Psk2MixedTkipCcmp.to_string(),\n+ ])\n// TODO: restrict list based on device compatibility. This is currently just the full list of used values\n}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Putting wifi encryption strings into enum
20,244
09.05.2022 17:06:26
14,400
daac559c6d7297872262858dc11c197263fcb339
Bump for Beta 19 RC9
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -2646,7 +2646,7 @@ dependencies = [\n[[package]]\nname = \"rita_bin\"\n-version = \"0.19.8\"\n+version = \"0.19.9\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n@@ -2679,7 +2679,7 @@ dependencies = [\n[[package]]\nname = \"rita_client\"\n-version = \"0.19.8\"\n+version = \"0.19.9\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n@@ -2714,7 +2714,7 @@ dependencies = [\n[[package]]\nname = \"rita_common\"\n-version = \"0.19.8\"\n+version = \"0.19.9\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-service\",\n" }, { "change_type": "MODIFY", "old_path": "rita_bin/Cargo.toml", "new_path": "rita_bin/Cargo.toml", "diff": "[package]\nname = \"rita_bin\"\n-version = \"0.19.8\"\n+version = \"0.19.9\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\nbuild = \"build.rs\"\n" }, { "change_type": "MODIFY", "old_path": "rita_client/Cargo.toml", "new_path": "rita_client/Cargo.toml", "diff": "[package]\nname = \"rita_client\"\n-version = \"0.19.8\"\n+version = \"0.19.9\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" }, { "change_type": "MODIFY", "old_path": "rita_common/Cargo.toml", "new_path": "rita_common/Cargo.toml", "diff": "[package]\nname = \"rita_common\"\n-version = \"0.19.8\"\n+version = \"0.19.9\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/dashboard/own_info.rs", "new_path": "rita_common/src/dashboard/own_info.rs", "diff": "@@ -6,7 +6,7 @@ use actix_web_async::HttpResponse;\nuse clarity::Address;\nuse num256::{Int256, Uint256};\n-pub static READABLE_VERSION: &str = \"Beta 19 RC8\";\n+pub static READABLE_VERSION: &str = \"Beta 19 RC9\";\n#[derive(Serialize)]\npub struct OwnInfo {\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Bump for Beta 19 RC9
20,244
10.05.2022 08:44:48
14,400
7ca6393deb0703d46b80d11393959be9bbb27ca3
Reduce middleware logging This would increase log volume by a huge amount for no good reason now that basic testing is done.
[ { "change_type": "MODIFY", "old_path": "rita_common/src/middleware.rs", "new_path": "rita_common/src/middleware.rs", "diff": "@@ -74,7 +74,7 @@ where\nNone => url_no_port,\n};\n- info!(\"our req is {:?} and origin is {:?}\", req, origin);\n+ trace!(\"our req is {:?} and origin is {:?}\", req, origin);\nlet req_method = req.method().clone();\n@@ -144,7 +144,7 @@ where\nfn call(&self, req: ServiceRequest) -> Self::Future {\nlet password = settings::get_rita_client().network.rita_dashboard_password;\n- info!(\"Password set is {:?}\", password);\n+ trace!(\"Password set is {:?}\", password);\nlet req_path = req.path().to_string();\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Reduce middleware logging This would increase log volume by a huge amount for no good reason now that basic testing is done.
20,253
11.05.2022 17:32:32
25,200
0807fe4c294d5c13e4e87936fdf40773d60b85b3
Removing installation details on ops checkin Installation details are stored in ops tools and are unneeded on the router side. Checking in to ops will now set installation details to None if successful
[ { "change_type": "MODIFY", "old_path": "rita_client/src/operator_update/mod.rs", "new_path": "rita_client/src/operator_update/mod.rs", "diff": "@@ -222,6 +222,7 @@ async fn checkin() {\nlet mut operator = rita_client.operator;\nlet new_operator_fee = Uint256::from(new_settings.operator_fee);\noperator.operator_fee = new_operator_fee;\n+ operator.installation_details = None;\nrita_client.operator = operator;\nmerge_settings_safely(new_settings.merge_json.clone());\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Removing installation details on ops checkin Installation details are stored in ops tools and are unneeded on the router side. Checking in to ops will now set installation details to None if successful
20,255
18.05.2022 09:43:53
25,200
a41787b36bde8f6f5b719de0b58debb29584a848
Fixing bug in is_router_storage_small() functionality
[ { "change_type": "MODIFY", "old_path": "rita_common/src/rita_loop/write_to_disk.rs", "new_path": "rita_common/src/rita_loop/write_to_disk.rs", "diff": "@@ -99,18 +99,21 @@ pub fn save_to_disk_loop(mut old_settings: SettingsOnDisk, file_path: &str) {\n/// running out of write endurance and\n/// the hard drive failing\npub fn is_router_storage_small(router_model: &str) -> bool {\n- router_model\n- .to_lowercase()\n- .matches(\n\"linksys_e5600|\ntplink_archer-a6-v3|\ncudy_wr2100|\nmikrotik_hap-ac2|\nmikrotik_routerboard-750gr3|\nmikrotik_routerboard-760igs|\n- netgear_ex6100v2\",\n- )\n+ netgear_ex6100v2\"\n+ .matches(&router_model.to_lowercase())\n.into_iter()\n.count()\n!= 0\n}\n+\n+#[test]\n+fn test_is_router_storage_small() {\n+ let router = \"linksys_e5600\";\n+ assert!(is_router_storage_small(router));\n+}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Fixing bug in is_router_storage_small() functionality
20,255
18.05.2022 09:46:19
25,200
7188e990860323f69a3d120d7967802e06195327
Removed todo!() condition causing a panic on exit instances during Ctrl-C handling
[ { "change_type": "MODIFY", "old_path": "rita_common/src/usage_tracker/mod.rs", "new_path": "rita_common/src/usage_tracker/mod.rs", "diff": "@@ -428,13 +428,11 @@ pub fn save_usage_on_shutdown() {\nlet history = &mut USAGE_TRACKER.write().unwrap();\nlet router_model = settings::get_rita_common().network.device;\n- match router_model {\n- Some(router_model_unwrapped) => {\n- is_router_storage_small(&router_model_unwrapped);\n+ if let Some(router_model_unwrapped) = router_model {\n+ if !is_router_storage_small(&router_model_unwrapped) {\nlet res = history.save(75);\ninfo!(\"Shutdown: saving usage data: {:?}\", res);\n}\n- None => todo!(),\n}\nhistory.last_save_hour = current_hour;\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Removed todo!() condition causing a panic on exit instances during Ctrl-C handling
20,255
18.05.2022 09:53:53
25,200
a17329ccbf77a6c5f3c7c5c69511d0c1aa283e8d
Modified crossbuilders dockerfile to build on Debian and fixed build_exit.sh
[ { "change_type": "MODIFY", "old_path": "cross-builders/exit/Dockerfile", "new_path": "cross-builders/exit/Dockerfile", "diff": "-FROM rustembedded/cross:x86_64-unknown-linux-gnu-0.2.0\n+FROM debian:11.3\nRUN apt-get update && apt-get install clang-6.0 libclang-6.0-dev llvm-dev libssl-dev postgresql-server-dev-all -y\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "scripts/build_exit.sh", "new_path": "scripts/build_exit.sh", "diff": "-#!/bin/bash\n-# Usage: ./linux_build_static [--debug] [--release]\n-#\n-# This script builds a static Linux binaries.\n-#\n-# Options:\n-# --debug (optional) Use debug profile\n-# --release (optional) Use release profile (default)\n-# --features (optional) List of features to build\n-#\n-# Note: You may need to disable or modify selinux, or add $USER to docker group\n-# to be able to use `docker`.\n-set -eux\n-\n-DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" >/dev/null && pwd )\"\n-\n-# Parse command line arguments\n-source $DIR/build_common.sh\n-\n-RUST_TOOLCHAIN=\"stable\"\n-CARGO_ROOT=\"$HOME/.cargo\"\n-CARGO_GIT=\"$CARGO_ROOT/.git\"\n-CARGO_REGISTRY=\"$CARGO_ROOT/registry\"\n-\n-docker pull ekidd/rust-musl-builder\n-RUST_MUSL_BUILDER=\"docker run --rm -it -v \"$(pwd)\":/home/rust/src -v $CARGO_GIT:/home/rust/.cargo/git -v $CARGO_REGISTRY:/home/rust/.cargo/registry ekidd/rust-musl-builder\"\n-$RUST_MUSL_BUILDER sudo chown -R rust:rust /home/rust/.cargo/git /home/rust/.cargo/registry\n-\n-$RUST_MUSL_BUILDER cargo build --all ${PROFILE} ${FEATURES}\n+# #!/bin/bash\n+\n+cd cross-builders/exit\n+docker build -t cross-with-clang-ssl .\n+cp Cross.toml ../..\n+cd ../..\n+cross build --release --target x86_64-unknown-linux-gnu -p rita_bin --bin rita_exit\n+rm Cross.toml\n\\ No newline at end of file\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Modified crossbuilders dockerfile to build on Debian and fixed build_exit.sh
20,255
17.05.2022 13:44:44
25,200
c0737b7cf4ce8094dc44862ff422f4fef7ffcd30
Fixed bug with exit subnet reclaiming for client that disconnect
[ { "change_type": "MODIFY", "old_path": "rita_exit/src/database/database_tools.rs", "new_path": "rita_exit/src/database/database_tools.rs", "diff": "@@ -301,7 +301,7 @@ pub fn delete_client(client: ExitClient, connection: &PgConnection) -> Result<()\ninfo!(\"Reclaimed index is: {:?}\", index);\n- let filtered_list = assigned_ips.filter(subnet.eq(sub.to_string()));\n+ let filtered_list = assigned_ips.filter(subnet.eq(exit_sub.to_string()));\nlet res = filtered_list.load::<models::AssignedIps>(connection);\nmatch res {\n@@ -330,7 +330,7 @@ pub fn delete_client(client: ExitClient, connection: &PgConnection) -> Result<()\n\"We are updating database with reclaim string: {:?}\",\navail_ips\n);\n- diesel::update(assigned_ips.find(sub.to_string()))\n+ diesel::update(assigned_ips.find(exit_sub.to_string()))\n.set(available_subnets.eq(avail_ips))\n.execute(connection)?;\n}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Fixed bug with exit subnet reclaiming for client that disconnect
20,255
18.05.2022 10:01:08
25,200
c2d8f703972a5f6bc998ba7de7fcce3b57c3a848
Added diesel migration instructions for prod databases to ipv6
[ { "change_type": "ADD", "old_path": null, "new_path": "exit_db/2022-05-18-184145_ipv6_migration/down.sql", "diff": "+-- This file should undo anything in `up.sql`\n+ALTER TABLE clients\n+ DROP COLUMN internet_ipv6\n+;\n+DROP TABLE assigned_ips;\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "exit_db/2022-05-18-184145_ipv6_migration/up.sql", "diff": "+-- Your SQL goes here\n+ALTER TABLE clients\n+ ADD COLUMN internet_ipv6 varchar(132) NOT NULL DEFAULT ''\n+;\n+CREATE TABLE assigned_ips\n+(\n+ subnet varchar(132) CONSTRAINT secondkey PRIMARY KEY,\n+ available_subnets varchar(512) NOT NULL,\n+ iterative_index bigint DEFAULT 0 NOT NULL\n+);\n\\ No newline at end of file\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Added diesel migration instructions for prod databases to ipv6
20,255
19.05.2022 14:00:25
25,200
6731ab29725b30cf4e34fb3228e892be2f308b6c
Modified RitaExit to tackle certain edge cases in regard to ipv6 support: 1.) handle multiple ipv6 subnets for clients rather than just 1 per exit cluster 2.) Handle when exit instances dont have ipv6
[ { "change_type": "MODIFY", "old_path": "rita_exit/src/database/database_tools.rs", "new_path": "rita_exit/src/database/database_tools.rs", "diff": "@@ -274,7 +274,7 @@ pub fn client_conflict(\n/// Delete a client from the Clients database. Retrieve the reclaimed subnet index and add it to\n/// available_subnets in assigned_ips database\npub fn delete_client(client: ExitClient, connection: &PgConnection) -> Result<(), RitaExitError> {\n- use self::schema::assigned_ips::dsl::{assigned_ips, available_subnets, subnet};\n+ use self::schema::assigned_ips::dsl::{assigned_ips, subnet};\nuse self::schema::clients::dsl::*;\ninfo!(\"Deleting clients {:?} in database\", client);\n@@ -285,24 +285,50 @@ pub fn delete_client(client: ExitClient, connection: &PgConnection) -> Result<()\nlet filtered_list = clients\n.select(internet_ipv6)\n.filter(mesh_ip.eq(&mesh_ip_string));\n- let mut sub = filtered_list.load::<String>(connection)?;\n- if let Some(sub) = sub.pop() {\n- let rita_exit = settings::get_rita_exit();\n- let exit_settings = rita_exit.exit_network;\n- let exit_sub = exit_settings.subnet;\n- // This is a valid subnet in database so this unwrap should not panic\n- let sub: IpNetwork = sub.parse().expect(\"Unable to parse subnet in database\");\n- let index = match generate_index_from_subnet(exit_sub, sub) {\n+ let mut client_sub = filtered_list.load::<String>(connection)?;\n+\n+ let filtered_list = assigned_ips.select(subnet);\n+ let exit_sub = filtered_list.load::<String>(connection)?;\n+\n+ if let Some(client_sub) = client_sub.pop() {\n+ if !client_sub.is_empty() {\n+ let client_sub: Vec<&str> = client_sub.split(',').collect();\n+ reclaim_all_ip_subnets(client_sub, exit_sub, connection)?;\n+ }\n+ }\n+\n+ delete(statement).execute(connection)?;\n+ Ok(())\n+}\n+\n+/// Given a vector of client subnet and exit subnets, reclaim all client subnets into the given exit subnets\n+/// This relies on the fact that there are no overlapping subnets\n+/// For example, if client has Ip addrs : \"fbad::1000/64,feee::1000/64\"\n+/// The exit subnets in the cluster are fbad::/40, feee::/40, fd00::/40\n+/// Then fbad::/40 would gain the subnet fbad::1000/64 and feee::/40 would gain the subnet feee::1000/64 as available subnets\n+/// when the client get deleted from the database. View the unit test below for more examples\n+fn reclaim_all_ip_subnets(\n+ client_sub: Vec<&str>,\n+ exit_sub: Vec<String>,\n+ conn: &PgConnection,\n+) -> Result<(), RitaExitError> {\n+ use self::schema::assigned_ips::dsl::{assigned_ips, available_subnets, subnet};\n+\n+ for client_ip in client_sub {\n+ for exit_ip in &exit_sub {\n+ let c_net: IpNetwork = client_ip.parse().expect(\"Unable to parse client subnet\");\n+ let e_net: IpNetwork = exit_ip.parse().expect(\"Unable to parse exit subnet\");\n+ if e_net.contains(c_net.ip()) {\n+ let index = match generate_index_from_subnet(e_net, c_net) {\nOk(a) => a,\nErr(e) => {\nreturn Err(e);\n}\n};\n-\ninfo!(\"Reclaimed index is: {:?}\", index);\n- let filtered_list = assigned_ips.filter(subnet.eq(exit_sub.to_string()));\n- let res = filtered_list.load::<models::AssignedIps>(connection);\n+ let filtered_list = assigned_ips.filter(subnet.eq(exit_ip));\n+ let res = filtered_list.load::<models::AssignedIps>(conn);\nmatch res {\nOk(mut a) => {\n@@ -330,9 +356,9 @@ pub fn delete_client(client: ExitClient, connection: &PgConnection) -> Result<()\n\"We are updating database with reclaim string: {:?}\",\navail_ips\n);\n- diesel::update(assigned_ips.find(exit_sub.to_string()))\n+ diesel::update(assigned_ips.find(exit_ip))\n.set(available_subnets.eq(avail_ips))\n- .execute(connection)?;\n+ .execute(conn)?;\n}\nErr(e) => {\nerror!(\n@@ -341,9 +367,13 @@ pub fn delete_client(client: ExitClient, connection: &PgConnection) -> Result<()\n);\n}\n}\n+\n+ // After we reclaim an index, we break from the loop. The prevents duplicate reclaiming when two instances have the same subnet\n+ break;\n+ }\n+ }\n}\n- delete(statement).execute(connection)?;\nOk(())\n}\n@@ -409,10 +439,17 @@ pub fn create_or_update_user_record(\nlet subnet = exit_settings.subnet;\n// If subnet isnt already present in database, create it\n- let subnet_entry = initialize_subnet_datastore(subnet, conn)?;\n+ let mut subnet_entry = None;\n+ if let Some(subnet) = subnet {\n+ subnet_entry = Some(initialize_subnet_datastore(subnet, conn)?);\ninfo!(\"Subnet Database entry: {:?}\", subnet_entry);\n+ }\nif let Some(val) = get_client(client, conn)? {\n+ // Give ipv6 if not present\n+ if let Some(subnet) = subnet {\n+ assign_ip_to_client(val.mesh_ip.clone(), subnet, conn)?;\n+ }\nupdate_client(client, &val, conn)?;\nOk(val)\n} else {\n@@ -423,7 +460,11 @@ pub fn create_or_update_user_record(\nlet new_ip = get_next_client_ip(conn)?;\n- let internet_ip = get_client_subnet(subnet, subnet_entry, conn)?;\n+ let internet_ip = if let (Some(subnet), Some(subnet_entry)) = (subnet, subnet_entry) {\n+ Some(get_client_subnet(subnet, subnet_entry, conn)?)\n+ } else {\n+ None\n+ };\nlet c = client_to_new_db_client(client, new_ip, user_country, internet_ip);\n@@ -653,7 +694,7 @@ fn generate_index_from_subnet(exit_sub: IpNetwork, sub: IpNetwork) -> Result<u64\n/// for ipv6 support. Existing clients in the previous schema will not have an ipv6 addr assigned, so every client is\n/// given one on startup\npub fn initialize_exisitng_clients_ipv6() -> Result<(), RitaExitError> {\n- use self::schema::clients::dsl::{clients, internet_ipv6, mesh_ip};\n+ use self::schema::clients::dsl::{clients, mesh_ip};\nlet conn = get_database_connection()?;\n// initialize the assigned_ips database\n@@ -661,6 +702,7 @@ pub fn initialize_exisitng_clients_ipv6() -> Result<(), RitaExitError> {\nlet exit_settings = rita_exit.exit_network;\nlet subnet = exit_settings.subnet;\n+ if let Some(subnet) = subnet {\n// If subnet isnt already present in database, create it\nlet subnet_entry = initialize_subnet_datastore(subnet, &conn)?;\ninfo!(\"Subnet Database entry: {:?}\", subnet_entry);\n@@ -672,25 +714,103 @@ pub fn initialize_exisitng_clients_ipv6() -> Result<(), RitaExitError> {\nlet ip_list = filtered_list.load::<String>(&conn)?;\nfor ip in ip_list {\n- let filtered_list = clients.select(internet_ipv6).filter(mesh_ip.eq(&ip));\n- let mut sub = filtered_list.load::<String>(&conn)?;\n+ assign_ip_to_client(ip, subnet, &conn)?;\n+ }\n+ }\n- if sub.len() > 1 {\n- error!(\"More than one ipv6 for a given client\");\n+ Ok(())\n}\n- let ipv6 = sub.pop();\n- if ipv6.is_none() || ipv6.clone().unwrap().is_empty() {\n- let subnet_entry = initialize_subnet_datastore(subnet, &conn)?;\n- let internet_ip = get_client_subnet(subnet, subnet_entry.clone(), &conn)?;\n- info!(\"Initializing ipv6 addrs for existing clients, IP: {}, is given ip {:?}, subnet entry is {:?}\", ip, internet_ip.clone(), subnet_entry.clone());\n- diesel::update(clients.find(ip))\n+/// This function updates the clients database with an added entry in the internet ipv6 field\n+/// that stores client ipv6 addrs. ipv6 addrs are stored in the form of \"fd00:1330/64,fde0::1100/40\" etc\n+/// with a comma being the delimiter\n+fn assign_ip_to_client(\n+ client_mesh_ip: String,\n+ exit_sub: IpNetwork,\n+ conn: &PgConnection,\n+) -> Result<IpNetwork, RitaExitError> {\n+ // check if ipv6 list already has an ip in its subnet\n+ use self::schema::clients::dsl::{clients, internet_ipv6, mesh_ip};\n+\n+ let filtered_list = clients\n+ .select(internet_ipv6)\n+ .filter(mesh_ip.eq(&client_mesh_ip));\n+ let mut sub = filtered_list.load::<String>(conn)?;\n+\n+ let client_ipv6_list = sub.pop();\n+\n+ if let Some(mut list_str) = client_ipv6_list {\n+ if !list_str.is_empty() {\n+ let list: Vec<&str> = list_str.split(',').collect();\n+ for ipv6_str in list {\n+ let ipv6_sub: IpNetwork =\n+ ipv6_str.parse().expect(\"Unable to parse ipnetwork subnet\");\n+ // Since there are no overlapping subnets, If the ip is in the subnet, so is the ip subnet\n+ if exit_sub.contains(ipv6_sub.ip()) {\n+ return Ok(ipv6_sub);\n+ }\n+ }\n+ // If code hasnt returned yet, we need to add the ip to the list\n+ let subnet_entry = initialize_subnet_datastore(exit_sub, conn)?;\n+ let internet_ip = get_client_subnet(exit_sub, subnet_entry.clone(), conn)?;\n+ let mut new_str = \",\".to_owned();\n+ new_str.push_str(&internet_ip.to_string());\n+ list_str.push_str(&new_str);\n+ info!(\"Initializing ipv6 addrs for existing clients, IP: {}, is given ip {:?}, subnet entry is {:?}\", client_mesh_ip, list_str.clone(), subnet_entry);\n+ diesel::update(clients.find(client_mesh_ip))\n+ .set(internet_ipv6.eq(list_str))\n+ .execute(conn)?;\n+ Ok(internet_ip)\n+ } else {\n+ // List is empty\n+ let subnet_entry = initialize_subnet_datastore(exit_sub, conn)?;\n+ let internet_ip = get_client_subnet(exit_sub, subnet_entry.clone(), conn)?;\n+ info!(\"Initializing ipv6 addrs for existing clients, IP: {}, is given ip {:?}, subnet entry is {:?}\", client_mesh_ip, internet_ip.clone(), subnet_entry);\n+ diesel::update(clients.find(client_mesh_ip))\n.set(internet_ipv6.eq(internet_ip.to_string()))\n- .execute(&conn)?;\n+ .execute(conn)?;\n+ Ok(internet_ip)\n+ }\n+ } else {\n+ // The client doesnt not have an appropriate ipv6 addr for our subnet, assign it one\n+ let subnet_entry = initialize_subnet_datastore(exit_sub, conn)?;\n+ let internet_ip = get_client_subnet(exit_sub, subnet_entry.clone(), conn)?;\n+ info!(\"Initializing ipv6 addrs for existing clients, IP: {}, is given ip {:?}, subnet entry is {:?}\", client_mesh_ip, internet_ip.clone(), subnet_entry);\n+ diesel::update(clients.find(client_mesh_ip))\n+ .set(internet_ipv6.eq(internet_ip.to_string()))\n+ .execute(conn)?;\n+ Ok(internet_ip)\n}\n}\n- Ok(())\n+/// Given a database client entry, get ipnetwork string (\"fd00::1337,f100:1400\") find the correct ipv6 address to send back to client corresponding to our exit instance\n+pub fn get_client_ipv6(their_record: &models::Client) -> Result<Option<IpNetwork>, RitaExitError> {\n+ let client_subs = &their_record.internet_ipv6;\n+ let client_mesh_ip = &their_record.mesh_ip;\n+\n+ let rita_exit = settings::get_rita_exit();\n+ let exit_settings = rita_exit.exit_network;\n+ let exit_sub = exit_settings.subnet;\n+\n+ if let Some(exit_sub) = exit_sub {\n+ if !client_subs.is_empty() {\n+ let c_sub: Vec<&str> = client_subs.split(',').collect();\n+ for sub in c_sub {\n+ let c_net: IpNetwork = sub.parse().expect(\"Unable to parse client subnet\");\n+ if exit_sub.contains(c_net.ip()) {\n+ return Ok(Some(c_net));\n+ }\n+ }\n+ }\n+\n+ // If no ip has been returned, an ip has not been setup, so we assign an ip in the database\n+ let conn = get_database_connection()?;\n+ let ip_net = assign_ip_to_client(client_mesh_ip.to_string(), exit_sub, &conn)?;\n+ Ok(Some(ip_net))\n+ } else {\n+ // This exit doesnt support ipv6\n+ Ok(None)\n+ }\n}\n#[cfg(test)]\n@@ -835,4 +955,149 @@ mod tests {\nlet sub: IpNetwork = \"2602:FBAD:0:32::/64\".parse().unwrap();\nassert_eq!(generate_index_from_subnet(exit_sub, sub).unwrap(), 50);\n}\n+\n+ #[test]\n+ fn test_assignment_ipv6_to_client_logic() {\n+ // TEST CASE 1\n+ // let client_ipv6_list = Some(\"fbad::1330/64,fedd::1000/64\".to_string());\n+ // let exit_sub: IpNetwork = \"fbad::1330/40\".parse().unwrap();\n+\n+ // TEST CASE 2\n+ let client_ipv6_list = Some(\"fbad::1330/64,fedd::1000/64\".to_string());\n+ let exit_sub: IpNetwork = \"feee::1330/40\".parse().unwrap();\n+\n+ // TEST CASE 3\n+ // let client_ipv6_list = Some(\"\".to_string());\n+ // let exit_sub: IpNetwork = \"fbad::1330/40\".parse().unwrap();\n+\n+ // TEST CASE 4\n+ // let client_ipv6_list: Option<String> = None;\n+ // let exit_sub: IpNetwork = \"fbad::1330/40\".parse().unwrap();\n+\n+ if let Some(mut list_str) = client_ipv6_list {\n+ if !list_str.is_empty() {\n+ let list: Vec<&str> = list_str.split(',').collect();\n+ println!(\"List looks like: {:?}\", list);\n+ for ipv6_str in list {\n+ let ipv6_sub: IpNetwork =\n+ ipv6_str.parse().expect(\"Unable to parse ipnetwork subnet\");\n+ // Since there are no overlapping subnets, If the ip is in the subnet, so is the ip subnet\n+ if exit_sub.contains(ipv6_sub.ip()) {\n+ println!(\"Hit Test case 1\");\n+ return;\n+ }\n+ }\n+ // If code hasnt returned yet, we need to add the ip to the list\n+ let internet_ip: IpNetwork = \"feee::1000/64\".parse().unwrap();\n+ let mut new_str = \",\".to_owned();\n+ new_str.push_str(&internet_ip.to_string());\n+ list_str.push_str(&new_str);\n+ println!(\"list_str looks like: {:?}\", list_str);\n+ println!(\"hit test case 2\");\n+ } else {\n+ // List is empty\n+ println!(\"Hit Test case 3\");\n+ }\n+ } else {\n+ // The client doesnt not have an appropriate ipv6 addr for our subnet, assign it one\n+ println!(\"hit Test case 4\");\n+ }\n+ }\n+\n+ #[test]\n+ fn test_get_client_ipv6() {\n+ let client_subs = \"fbad::1000/64\";\n+ let exit_sub: Option<IpNetwork> = Some(\"fbad::1000/40\".parse().unwrap());\n+ assert_eq!(\n+ get_client_ipv6_helper(client_subs.to_string(), exit_sub),\n+ Some(client_subs.parse().unwrap())\n+ );\n+\n+ let client_subs = \"\";\n+ let exit_sub: Option<IpNetwork> = Some(\"fbad::1000/40\".parse().unwrap());\n+ assert_eq!(\n+ get_client_ipv6_helper(client_subs.to_string(), exit_sub),\n+ Some(\"fbad::1000/64\".parse().unwrap())\n+ );\n+\n+ let client_subs = \"feee::1000/64\";\n+ let exit_sub: Option<IpNetwork> = Some(\"fbad::1000/40\".parse().unwrap());\n+ assert_eq!(\n+ get_client_ipv6_helper(client_subs.to_string(), exit_sub),\n+ Some(\"fbad::1000/64\".parse().unwrap())\n+ );\n+\n+ let client_subs = \"feee::1000/64,fbad::1000/64\";\n+ let exit_sub: Option<IpNetwork> = Some(\"fbad::1000/40\".parse().unwrap());\n+ assert_eq!(\n+ get_client_ipv6_helper(client_subs.to_string(), exit_sub),\n+ Some(\"fbad::1000/64\".parse().unwrap())\n+ );\n+ }\n+\n+ fn get_client_ipv6_helper(\n+ client_subs: String,\n+ exit_sub: Option<IpNetwork>,\n+ ) -> Option<IpNetwork> {\n+ if let Some(exit_sub) = exit_sub {\n+ if !client_subs.is_empty() {\n+ let c_sub: Vec<&str> = client_subs.split(',').collect();\n+ for sub in c_sub {\n+ let c_net: IpNetwork = sub.parse().expect(\"Unable to parse client subnet\");\n+ if exit_sub.contains(c_net.ip()) {\n+ return Some(c_net);\n+ }\n+ }\n+ }\n+ // If no ip has been returned, an ip has not been setup, so we assign an ip in the database\n+ let ip_net: IpNetwork = \"fbad::1000/64\".parse().unwrap();\n+ Some(ip_net)\n+ } else {\n+ // This exit doesnt support ipv6\n+ None\n+ }\n+ }\n+\n+ #[test]\n+ fn test_reclaim_all_subnets() {\n+ //Case 1: no ipv6 instances, should panic\n+ // let client_sub = vec![\"\"];\n+ // let exit_sub = vec![\"\".to_string()];\n+ // reclaim_all_subnets_helper(client_sub, exit_sub);\n+\n+ //Case 2: One ipv6 instance\n+ let client_sub = vec![\"fbad::1000/64\"];\n+ let exit_sub = vec![\"fbad::1000/40\".to_string()];\n+ reclaim_all_subnets_helper(client_sub, exit_sub);\n+\n+ //Case 3: Two ipv6 instances, same subnet (invalid case, there shouldnt be two client subs for 1 exit sub)\n+ let client_sub = vec![\"fbad::1000/64\", \"fbad::eeee/64\"];\n+ let exit_sub = vec![\"fbad::1000/40\".to_string()];\n+ reclaim_all_subnets_helper(client_sub, exit_sub);\n+\n+ //Case 3: Two ipv6 instances, same subnet (invalid case, no overlapping subnets)\n+ let client_sub = vec![\"fbad::1000/64\"];\n+ let exit_sub = vec![\"fbad::1000/40\".to_string(), \"fbad::1000/50\".to_string()];\n+ reclaim_all_subnets_helper(client_sub, exit_sub);\n+\n+ //Case 4: Two ipv6 instances, different subnet\n+ let client_sub = vec![\"fbad::1000/64\", \"feee::eeee/64\"];\n+ let exit_sub = vec![\"fbad::1000/40\".to_string(), \"feee::1000/40\".to_string()];\n+ reclaim_all_subnets_helper(client_sub, exit_sub);\n+ }\n+\n+ fn reclaim_all_subnets_helper(client_sub: Vec<&str>, exit_sub: Vec<String>) {\n+ for client_ip in client_sub {\n+ for exit_ip in &exit_sub {\n+ let c_net: IpNetwork = client_ip.parse().expect(\"Unable to parse client subnet\");\n+ let e_net: IpNetwork = exit_ip.parse().expect(\"Unable to parse exit subnet\");\n+ if e_net.contains(c_net.ip()) {\n+ println!(\"reclaiming client {:?} to exit sub {:?}\", c_net, e_net);\n+\n+ // After we reclaim an index, we break from the loop. The prevents duplicate reclaiming when two instances have the same subnet\n+ break;\n+ }\n+ }\n+ }\n+ }\n}\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/email.rs", "new_path": "rita_exit/src/database/email.rs", "diff": "@@ -3,6 +3,7 @@ use crate::database::database_tools::verify_client;\nuse crate::database::get_exit_info;\nuse crate::database::secs_since_unix_epoch;\nuse crate::database::struct_tools::verif_done;\n+use crate::get_client_ipv6;\nuse crate::RitaExitError;\nuse althea_types::{ExitClientDetails, ExitClientIdentity, ExitState};\n@@ -91,14 +92,14 @@ pub fn handle_email_registration(\nOk(ip) => ip,\nErr(e) => return Err(RitaExitError::AddrParseError(e)),\n};\n- let client_internet_ipv6_subnet = match their_record.internet_ipv6.parse() {\n+ let client_internet_ipv6_subnet = match get_client_ipv6(&their_record) {\nOk(sub) => sub,\n- Err(e) => return Err(RitaExitError::IpNetworkError(e)),\n+ Err(e) => return Err(e),\n};\nOk(ExitState::Registered {\nour_details: ExitClientDetails {\nclient_internal_ip,\n- internet_ipv6_subnet: Some(client_internet_ipv6_subnet),\n+ internet_ipv6_subnet: client_internet_ipv6_subnet,\n},\ngeneral_details: get_exit_info(),\nmessage: \"Registration OK\".to_string(),\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/mod.rs", "new_path": "rita_exit/src/database/mod.rs", "diff": "@@ -22,6 +22,7 @@ use crate::database::struct_tools::display_hashset;\nuse crate::database::struct_tools::to_exit_client;\nuse crate::database::struct_tools::to_identity;\nuse crate::database::struct_tools::verif_done;\n+use crate::get_client_ipv6;\nuse crate::rita_loop::EXIT_LOOP_TIMEOUT;\nuse crate::RitaExitError;\n@@ -157,14 +158,14 @@ pub async fn signup_client(client: ExitClientIdentity) -> Result<ExitState, Rita\nOk(ip) => ip,\nErr(e) => return Err(RitaExitError::AddrParseError(e)),\n};\n- let client_internet_ipv6_subnet = match their_record.internet_ipv6.parse() {\n+ let client_internet_ipv6_subnet = match get_client_ipv6(&their_record) {\nOk(sub) => sub,\n- Err(e) => return Err(RitaExitError::IpNetworkError(e)),\n+ Err(e) => return Err(e),\n};\nOk(ExitState::Registered {\nour_details: ExitClientDetails {\nclient_internal_ip,\n- internet_ipv6_subnet: Some(client_internet_ipv6_subnet),\n+ internet_ipv6_subnet: client_internet_ipv6_subnet,\n},\ngeneral_details: get_exit_info(),\nmessage: \"Registration OK\".to_string(),\n@@ -199,7 +200,7 @@ pub fn client_status(\n}\nlet current_ip = their_record.internal_ip.parse()?;\n- let current_internet_ipv6 = their_record.internet_ipv6.parse()?;\n+ let current_internet_ipv6 = get_client_ipv6(&their_record)?;\nlet exit_network = &*EXIT_NETWORK_SETTINGS;\nlet current_subnet =\n@@ -217,7 +218,7 @@ pub fn client_status(\nOk(ExitState::Registered {\nour_details: ExitClientDetails {\nclient_internal_ip: current_ip,\n- internet_ipv6_subnet: Some(current_internet_ipv6),\n+ internet_ipv6_subnet: current_internet_ipv6,\n},\ngeneral_details: get_exit_info(),\nmessage: \"Registration OK\".to_string(),\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/sms.rs", "new_path": "rita_exit/src/database/sms.rs", "diff": "@@ -3,6 +3,7 @@ use crate::database::database_tools::verify_client;\nuse crate::database::get_database_connection;\nuse crate::database::get_exit_info;\nuse crate::database::struct_tools::texts_sent;\n+use crate::get_client_ipv6;\nuse crate::RitaExitError;\nuse althea_types::{ExitClientDetails, ExitClientIdentity, ExitState};\n@@ -120,7 +121,7 @@ pub async fn handle_sms_registration(\nOk(ExitState::Registered {\nour_details: ExitClientDetails {\nclient_internal_ip: their_record.internal_ip.parse()?,\n- internet_ipv6_subnet: Some(their_record.internet_ipv6.parse()?),\n+ internet_ipv6_subnet: get_client_ipv6(&their_record)?,\n},\ngeneral_details: get_exit_info(),\nmessage: \"Registration OK\".to_string(),\n@@ -168,7 +169,7 @@ pub async fn handle_sms_registration(\nOk(ExitState::Registered {\nour_details: ExitClientDetails {\nclient_internal_ip: their_record.internal_ip.parse()?,\n- internet_ipv6_subnet: Some(their_record.internet_ipv6.parse()?),\n+ internet_ipv6_subnet: get_client_ipv6(&their_record)?,\n},\ngeneral_details: get_exit_info(),\nmessage: \"Registration OK\".to_string(),\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/struct_tools.rs", "new_path": "rita_exit/src/database/struct_tools.rs", "diff": "@@ -66,7 +66,7 @@ pub fn client_to_new_db_client(\nclient: &ExitClientIdentity,\nnew_ip: IpAddr,\ncountry: String,\n- internet_ip: IpNetwork,\n+ internet_ip: Option<IpNetwork>,\n) -> models::Client {\nlet mut rng = rand::thread_rng();\nlet rand_code: u64 = rng.gen_range(0..999_999);\n@@ -77,7 +77,13 @@ pub fn client_to_new_db_client(\neth_address: client.global.eth_address.to_string().to_lowercase(),\nnickname: client.global.nickname.unwrap_or_default().to_string(),\ninternal_ip: new_ip.to_string(),\n- internet_ipv6: internet_ip.to_string(),\n+ internet_ipv6: {\n+ if let Some(ip_net) = internet_ip {\n+ ip_net.to_string()\n+ } else {\n+ \"\".to_string()\n+ }\n+ },\nemail: client.reg_details.email.clone().unwrap_or_default(),\nphone: client.reg_details.phone.clone().unwrap_or_default(),\ncountry,\n" }, { "change_type": "MODIFY", "old_path": "settings/src/exit.rs", "new_path": "settings/src/exit.rs", "diff": "@@ -28,7 +28,7 @@ pub struct ExitNetworkSettings {\n/// The netmask, in bits to mask out, for the exit tunnel\npub netmask: u8,\n/// The subnet we use to assign to client routers for ipv6\n- pub subnet: IpNetwork,\n+ pub subnet: Option<IpNetwork>,\n/// Time in seconds before user is dropped from the db due to inactivity\n/// 0 means disabled\npub entry_timeout: u32,\n@@ -56,7 +56,7 @@ impl ExitNetworkSettings {\nown_internal_ip: \"172.16.255.254\".parse().unwrap(),\nexit_start_ip: \"172.16.0.0\".parse().unwrap(),\nnetmask: 12,\n- subnet: IpNetwork::V6(\"ff01::0/128\".parse().unwrap()),\n+ subnet: Some(IpNetwork::V6(\"ff01::0/128\".parse().unwrap())),\nentry_timeout: 0,\ngeoip_api_user: None,\ngeoip_api_key: None,\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Modified RitaExit to tackle certain edge cases in regard to ipv6 support: 1.) handle multiple ipv6 subnets for clients rather than just 1 per exit cluster 2.) Handle when exit instances dont have ipv6
20,243
23.05.2022 14:41:46
25,200
bbd7351a2df6bb26a2469a2cf20d4ddcdc551735
Change to neighborstatus back to original Previous change was unnecessary to neighbor status here.
[ { "change_type": "MODIFY", "old_path": "althea_types/src/interop.rs", "new_path": "althea_types/src/interop.rs", "diff": "@@ -706,8 +706,6 @@ pub struct NeighborStatus {\n/// If this user is currently being enforced upon\n#[serde(default)]\npub enforced: bool,\n- #[serde(default)]\n- pub neighbor_name: String,\n}\n/// Heartbeat sent to the operator server to help monitor\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/tunnel_manager/neighbor_status.rs", "new_path": "rita_common/src/tunnel_manager/neighbor_status.rs", "diff": "@@ -49,7 +49,6 @@ pub fn update_neighbor_status() {\nid: *id,\nshaper_speed: lowest_shaper_speed,\nenforced,\n- neighbor_name: \"\".to_string(),\n},\n);\n}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Change to neighborstatus back to original Previous change was unnecessary to neighbor status here.
20,244
24.05.2022 06:56:57
14,400
00d460751ac433a343b4b2b8315cc3c3b5273644
Update exit builder script Debian builds where not compatible with centos, so this patch successfully gets us building with cross gnu
[ { "change_type": "MODIFY", "old_path": "cross-builders/exit/Dockerfile", "new_path": "cross-builders/exit/Dockerfile", "diff": "-FROM debian:11.3\n-RUN apt-get update && apt-get install clang-6.0 libclang-6.0-dev llvm-dev libssl-dev postgresql-server-dev-all -y\n\\ No newline at end of file\n+FROM rustembedded/cross:x86_64-unknown-linux-gnu-0.2.1\n+RUN apt-get update && apt-get install libssl-dev postgresql-server-dev-all -y\n\\ No newline at end of file\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Update exit builder script Debian builds where not compatible with centos, so this patch successfully gets us building with cross gnu
20,244
24.05.2022 07:28:52
14,400
7e60cf04e3b36faf8b5fcaf45e37d449850fbb22
Cleanup migrations Previously the ipv6 migration had been incorrectly folded into the initial setup migration. This resulted in a conflict when correcting the migration folder structure. This patch resolves the issue by reverting the changes to the 2019 migration and moving the new 2022 ipv6 migration to the correct location.
[ { "change_type": "MODIFY", "old_path": "exit_db/migrations/2019-02-22-214628_rita-setup/down.sql", "new_path": "exit_db/migrations/2019-02-22-214628_rita-setup/down.sql", "diff": "-- This file should undo anything in `up.sql`\nDROP TABLE clients;\n\\ No newline at end of file\n-DROP TABLE assigned_ips;\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "exit_db/migrations/2019-02-22-214628_rita-setup/up.sql", "new_path": "exit_db/migrations/2019-02-22-214628_rita-setup/up.sql", "diff": "@@ -5,7 +5,6 @@ CREATE TABLE clients\nwg_port integer NOT NULL,\neth_address varchar(64) NOT NULL,\ninternal_ip varchar(42) NOT NULL,\n- internet_ipv6 varchar(132) NOT NULL,\nnickname varchar(32) NOT NULL,\nemail varchar(512) NOT NULL,\nphone varchar(32) NOT NULL,\n@@ -17,10 +16,3 @@ CREATE TABLE clients\nlast_seen bigint DEFAULT 0 NOT NULL,\nlast_balance_warning_time bigint DEFAULT 0 NOT NULL\n);\n\\ No newline at end of file\n-\n-CREATE TABLE assigned_ips\n-(\n- subnet varchar(132) CONSTRAINT secondkey PRIMARY KEY,\n- available_subnets varchar(512) NOT NULL,\n- iterative_index bigint DEFAULT 0 NOT NULL\n-);\n\\ No newline at end of file\n" }, { "change_type": "RENAME", "old_path": "exit_db/2022-05-18-184145_ipv6_migration/down.sql", "new_path": "exit_db/migrations/2022-05-18-184145_ipv6_migration/down.sql", "diff": "" }, { "change_type": "RENAME", "old_path": "exit_db/2022-05-18-184145_ipv6_migration/up.sql", "new_path": "exit_db/migrations/2022-05-18-184145_ipv6_migration/up.sql", "diff": "" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Cleanup migrations Previously the ipv6 migration had been incorrectly folded into the initial setup migration. This resulted in a conflict when correcting the migration folder structure. This patch resolves the issue by reverting the changes to the 2019 migration and moving the new 2022 ipv6 migration to the correct location.
20,244
25.05.2022 09:00:59
14,400
17a0246137fd66eae2bfc1f0abea80f7fd00bf53
Do not panic when enforcement fails
[ { "change_type": "MODIFY", "old_path": "rita_exit/src/database/mod.rs", "new_path": "rita_exit/src/database/mod.rs", "diff": "@@ -464,7 +464,7 @@ pub fn enforce_exit_clients(\nKI.set_class_limit(\"wg_exit\", 10_000_000, 10_000_000, ip)\n};\nif res.is_err() {\n- panic!(\"Failed to limit {} with {:?}\", ip, res);\n+ error!(\"Failed to limit {} with {:?}\", ip, res);\n}\n}\n_ => warn!(\"Can't parse Ipv4Addr to create limit!\"),\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Do not panic when enforcement fails
20,244
25.05.2022 15:23:01
14,400
461b514a7f5b2f3f7c4625b6e50d0a2c846a8b4c
Remove WyreReservationRequest It's only used downstream so it should be defined downstream
[ { "change_type": "MODIFY", "old_path": "althea_types/src/user_info.rs", "new_path": "althea_types/src/user_info.rs", "diff": "@@ -80,38 +80,6 @@ pub struct WyreReservationRequestCarrier {\npub billing_details: BillingDetails,\n}\n-/// The exact struct for sending to this endpoint\n-///https://docs.sendwyre.com/docs/wallet-order-reservations\n-#[derive(Debug, Clone, Serialize, Deserialize)]\n-pub struct WyreReservationRequest {\n- pub amount: f32,\n- #[serde(rename = \"sourceCurrency\")]\n- pub source_currency: String,\n- #[serde(rename = \"destCurrency\")]\n- pub dest_currency: String,\n- pub dest: String,\n- #[serde(rename = \"firstName\")]\n- pub first_name: String,\n- #[serde(rename = \"lastName\")]\n- pub last_name: String,\n- pub city: String,\n- pub state: String,\n- pub country: String,\n- pub phone: Option<String>,\n- pub email: Option<String>,\n- pub street1: String,\n- #[serde(rename = \"postalCode\")]\n- pub postal_code: String,\n- #[serde(rename = \"lockFields\")]\n- pub lock_fields: Vec<String>,\n- #[serde(rename = \"redirectUrl\")]\n- pub redirect_url: String,\n- #[serde(rename = \"failureRedirectUrl\")]\n- pub failure_redirect_url: String,\n- #[serde(rename = \"referrerAccountId\")]\n- pub referrer_account_id: String,\n-}\n-\n#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct WyreReservationResponse {\npub url: String,\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Remove WyreReservationRequest It's only used downstream so it should be defined downstream
20,255
24.05.2022 12:13:37
25,200
8cc0fb72b81f1077c13e1e6694d5e4d037d70006
Fixed clippy lint: holding rwlock across async/await calls
[ { "change_type": "MODIFY", "old_path": "rita_client/src/operator_fee_manager/mod.rs", "new_path": "rita_client/src/operator_fee_manager/mod.rs", "diff": "@@ -40,6 +40,7 @@ pub fn get_operator_fee_debt() -> Uint256 {\nstate.operator_debt.clone()\n}\n+#[derive(Clone)]\nstruct OperatorFeeManager {\n/// the operator fee is denominated in wei per second, so every time this routine runs\n/// we take the number of seconds since the last time it ran and multiply that by the\n@@ -60,6 +61,14 @@ impl OperatorFeeManager {\n}\n}\n+fn get_operator_fee_data() -> OperatorFeeManager {\n+ OPERATOR_FEE_DATA.write().unwrap().clone()\n+}\n+\n+fn set_operator_fee_data(set: OperatorFeeManager) {\n+ *OPERATOR_FEE_DATA.write().unwrap() = set;\n+}\n+\n/// Very basic loop for async operator payments\npub async fn tick_operator_payments() {\n// get variables\n@@ -83,12 +92,13 @@ pub async fn tick_operator_payments() {\n};\nlet operator_fee = operator_settings.operator_fee.clone();\n- let mut state = OPERATOR_FEE_DATA.write().unwrap();\n+ let mut state = get_operator_fee_data();\n// accumulate, if we don't pay this will count up, if we do pay we will pay the full amount\nlet last_updated = state.last_updated.elapsed().as_secs();\nstate.operator_debt += Uint256::from(last_updated) * operator_fee;\nstate.last_updated = Instant::now();\n+ set_operator_fee_data(state.clone());\n// reassign to an immutable variable to prevent mistakes\nlet amount_to_pay = state.operator_debt.clone();\n@@ -147,6 +157,7 @@ pub async fn tick_operator_payments() {\n});\nadd_tx_to_total(amount_to_pay.clone());\nstate.operator_debt -= amount_to_pay;\n+ set_operator_fee_data(state);\n}\nErr(e) => {\nwarn!(\"Failed to pay the operator! {:?}\", e);\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/operator_update/mod.rs", "new_path": "rita_client/src/operator_update/mod.rs", "diff": "@@ -86,12 +86,21 @@ pub const OPERATOR_UPDATE_TIMEOUT: Duration = CLIENT_LOOP_TIMEOUT;\npub struct Update;\n+fn get_operator_update() -> Instant {\n+ *OPERATOR_UPDATE.write().unwrap()\n+}\n+\n+fn set_operator_update(set: Instant) {\n+ *OPERATOR_UPDATE.write().unwrap() = set;\n+}\n+\npub async fn operator_update() {\n- let operator_update = &mut *OPERATOR_UPDATE.write().unwrap();\n- let time_elapsed = Instant::now().checked_duration_since(*operator_update);\n+ let operator_update = get_operator_update();\n+ let time_elapsed = Instant::now().checked_duration_since(operator_update);\nif time_elapsed.is_some() && time_elapsed.unwrap() > UPDATE_FREQUENCY {\ncheckin().await;\n- *operator_update = Instant::now();\n+ let operator_update = Instant::now();\n+ set_operator_update(operator_update);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/traffic_watcher/mod.rs", "new_path": "rita_client/src/traffic_watcher/mod.rs", "diff": "@@ -82,15 +82,18 @@ pub struct QueryExitDebts {\npub async fn query_exit_debts(msg: QueryExitDebts) {\ntrace!(\"About to query the exit for client debts\");\n+ let local_debt: Option<Int256>;\n+ {\nlet writer = &mut *TRAFFIC_WATCHER.write().unwrap();\n// we could exit the function if this fails, but doing so would remove the chance\n// that we can get debts from the exit and continue anyways\n- let local_debt =\n+ local_debt =\nmatch local_traffic_calculation(writer, &msg.exit_id, msg.exit_price, msg.routes) {\nOk(val) => Some(Int256::from(val)),\nErr(_e) => None,\n};\n+ }\nlet gateway_exit_client = is_gateway_client();\nlet start = Instant::now();\nlet exit_addr = msg.exit_internal_addr;\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/dashboard/wallet.rs", "new_path": "rita_common/src/dashboard/wallet.rs", "diff": "@@ -99,18 +99,25 @@ fn queue_eth_compatible_withdraw(address: Address, amount: Uint256) -> HttpRespo\nHttpResponse::build(StatusCode::OK).json(\"Withdraw queued\")\n}\n+fn get_withdraw_queue() -> Option<(Address, Uint256)> {\n+ WITHDRAW_QUEUE.write().unwrap().clone()\n+}\n+\n+fn set_withraw_queue(set: Option<(Address, Uint256)>) {\n+ *WITHDRAW_QUEUE.write().unwrap() = set;\n+}\n+\n/// Withdraw for eth compatible chains, pulls from the queued withdraw\n/// and executes it\npub async fn eth_compatible_withdraw() {\nlet full_node = get_web3_server();\nlet web3 = Web3::new(&full_node, WITHDRAW_TIMEOUT);\nlet payment_settings = settings::get_rita_common().payment;\n- let mut writer = WITHDRAW_QUEUE.write().unwrap();\n- if let Some((dest, amount)) = &*writer {\n+ if let Some((dest, amount)) = get_withdraw_queue() {\nlet transaction_status = web3\n.send_transaction(\n- *dest,\n+ dest,\nVec::new(),\namount.clone(),\npayment_settings.eth_address.unwrap(),\n@@ -125,7 +132,7 @@ pub async fn eth_compatible_withdraw() {\nerror!(\"Withdraw failed with {:?} retrying later!\", e);\n} else {\ninfo!(\"Successful withdraw of {} to {}\", amount, dest);\n- *writer = None;\n+ set_withraw_queue(None);\n}\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/payment_controller/mod.rs", "new_path": "rita_common/src/payment_controller/mod.rs", "diff": "@@ -101,14 +101,18 @@ impl Error for PaymentControllerError {}\n/// This function is called by the async loop in order to perform payment\n/// controller actions\npub async fn tick_payment_controller() {\n+ let outgoing_payments: Vec<PaymentTx>;\n+ let resend_queue: Vec<ResendInfo>;\n+\n+ {\nlet mut data = PAYMENT_DATA.write().unwrap();\n// we fully empty both queues every run, and replace them with empty\n// vectors this helps deal with logic issues around outgoing payments\n// needing to queue retries which would cause a deadlock if we needed\n// a write lock to iterate.\n- let outgoing_payments = data.outgoing_queue.clone();\n- let resend_queue = data.resend_queue.clone();\n+ outgoing_payments = data.outgoing_queue.clone();\n+ resend_queue = data.resend_queue.clone();\ninfo!(\n\"Ticking payment controller with {} payments and {} resends\",\n@@ -118,7 +122,7 @@ pub async fn tick_payment_controller() {\ndata.outgoing_queue = Vec::new();\ndata.resend_queue = Vec::new();\n- drop(data);\n+ }\n// this creates a series of futures that we can use to perform\n// retires in parallel, this is helpful because retries may take\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/payment_validator/mod.rs", "new_path": "rita_common/src/payment_validator/mod.rs", "diff": "@@ -184,15 +184,17 @@ pub async fn validate() {\nlet our_address = settings::get_rita_common().payment.eth_address.unwrap();\nlet mut to_delete = Vec::new();\n+ let unvalidated_transactions: HashSet<ToValidate>;\n+ {\nlet history = HISTORY.read().unwrap();\n- let unvalidated_transactions = history.unvalidated_transactions.clone();\n+ unvalidated_transactions = history.unvalidated_transactions.clone();\ninfo!(\n\"Attempting to validate {} transactions {}\",\nhistory.unvalidated_transactions.len(),\nprint_txids(&history.unvalidated_transactions)\n);\n- drop(history);\n+ }\nlet mut futs = Vec::new();\nfor item in unvalidated_transactions {\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/peer_listener/mod.rs", "new_path": "rita_common/src/peer_listener/mod.rs", "diff": "@@ -26,6 +26,7 @@ lazy_static! {\n#[derive(Debug)]\npub struct PeerListener {\n+ pub contacting_neighbors: bool,\npub interfaces: HashMap<String, ListenInterface>,\npub peers: HashMap<IpAddr, Peer>,\n@@ -82,6 +83,7 @@ impl Default for PeerListener {\nimpl PeerListener {\npub fn new() -> Result<PeerListener, RitaCommonError> {\nOk(PeerListener {\n+ contacting_neighbors: false,\ninterfaces: HashMap::new(),\npeers: HashMap::new(),\ninterface_map: HashMap::new(),\n@@ -113,10 +115,12 @@ pub fn peerlistener_tick() {\ntrace!(\"Starting PeerListener tick!\");\nlet mut writer = PEER_LISTENER.write().unwrap();\n+ if !writer.contacting_neighbors {\nsend_im_here(&mut writer.interfaces);\nlet (a, b) = receive_im_here(&mut writer.interfaces);\n{\n+ // Reset hashmaps only when not contacting peers\n(*writer).peers = a;\n(*writer).interface_map = b;\n}\n@@ -124,6 +128,7 @@ pub fn peerlistener_tick() {\nlisten_to_available_ifaces(&mut writer);\n}\n+}\n#[allow(dead_code)]\npub fn unlisten_interface(interface: String) {\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/token_bridge/mod.rs", "new_path": "rita_common/src/token_bridge/mod.rs", "diff": "@@ -197,18 +197,23 @@ async fn xdai_bridge(bridge: TokenBridgeCore) {\n}\n};\n+ let max_gas_price: Uint256;\n+ {\n// Add gas price entry to lazy static\nlet writer = &mut *GAS_PRICES.write().unwrap();\nupdate_gas_price_store(eth_gas_price.clone(), writer);\n// Get max acceptable gas price (within 20%)\n- let max_gas_price = match get_acceptable_gas_price(eth_gas_price.clone(), writer) {\n+ max_gas_price = match get_acceptable_gas_price(eth_gas_price.clone(), writer) {\nOk(a) => a,\nErr(_) => {\n- error!(\"Not enough entries in gas price datastore, or error in datastore entry logic\");\n+ error!(\n+ \"Not enough entries in gas price datastore, or error in datastore entry logic\"\n+ );\nreturn;\n}\n};\n+ }\n// the amount of Eth to retain in WEI. This is the cost of our transfer from the\n// xdai chain to the destination address.\n@@ -224,13 +229,14 @@ async fn xdai_bridge(bridge: TokenBridgeCore) {\n// initiate withdrawals if any, scope bridge write\n{\n- let mut writer = BRIDGE.write().unwrap();\n+ let mut writer = get_bridge_state();\nif writer.withdraw_in_progress {\nlet withdraw_details = match &writer.withdraw_details {\nSome(a) => a.clone(),\nNone => {\nerror!(\"No withdraw information present\");\nwriter.withdraw_in_progress = false;\n+ set_bridge_state(writer.clone());\nreturn;\n}\n};\n@@ -249,6 +255,7 @@ async fn xdai_bridge(bridge: TokenBridgeCore) {\n//reset the withdraw lock\nwriter.withdraw_in_progress = false;\nwriter.withdraw_details = None;\n+ set_bridge_state(writer);\n}\n}\n@@ -478,6 +485,14 @@ pub fn setup_withdraw(msg: Withdraw) -> Result<(), RitaCommonError> {\nOk(())\n}\n+fn get_bridge_state() -> TokenBridgeState {\n+ BRIDGE.write().unwrap().clone()\n+}\n+\n+fn set_bridge_state(set: TokenBridgeState) {\n+ *BRIDGE.write().unwrap() = set;\n+}\n+\n/// This function initiates the withdrawal by calling the relayTokens function when there is no\n/// other withdrawal currently in progress. It receives the information from the lazy static varaible,\n/// which was setup by the function setup_withdrawal, and runs every loop to see if this lazy static has\n@@ -494,9 +509,10 @@ pub async fn withdraw(msg: Withdraw) -> Result<(), RitaCommonError> {\nif let SystemChain::Xdai = system_chain {\n//check if a wtihdrawal is in progress, if not set bool to true\n- let mut writer = BRIDGE.write().unwrap();\n+ let mut writer = get_bridge_state();\nif !writer.withdraw_in_progress {\nwriter.withdraw_in_progress = true;\n+ set_bridge_state(writer.clone());\nlet _res =\nencode_relaytokens(token_bridge, to, amount.clone(), Duration::from_secs(600))\n.await;\n@@ -504,6 +520,7 @@ pub async fn withdraw(msg: Withdraw) -> Result<(), RitaCommonError> {\ndetailed_state_change(DetailedBridgeState::XdaiToDai { amount });\n// Reset the lock\nwriter.withdraw_in_progress = false;\n+ set_bridge_state(writer);\nOk(())\n} else {\nErr(RitaCommonError::MiscStringError(\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/tunnel_manager/contact_peers.rs", "new_path": "rita_common/src/tunnel_manager/contact_peers.rs", "diff": "use crate::hello_handler::handle_hello;\nuse crate::hello_handler::Hello;\nuse crate::peer_listener::Hello as NewHello;\n-use crate::peer_listener::PeerListener;\nuse crate::peer_listener::PEER_LISTENER;\nuse crate::peer_listener::{send_hello, Peer};\nuse crate::rita_loop::is_gateway;\n@@ -67,17 +66,14 @@ pub async fn tm_neighbor_inquiry_hostname(their_hostname: String) -> Result<(),\n/// Contacts one neighbor with our LocalIdentity to get their LocalIdentity and wireguard tunnel\n/// interface name. Sends a Hello over udp, or http if its a manual peer\n-pub async fn tm_neighbor_inquiry(\n- peer: &Peer,\n- is_manual_peer: bool,\n- peer_listener: &mut PeerListener,\n-) -> Result<(), RitaCommonError> {\n+pub async fn tm_neighbor_inquiry(peer: &Peer, is_manual_peer: bool) -> Result<(), RitaCommonError> {\ntrace!(\"TunnelManager neigh inquiry for {:?}\", peer);\nlet our_port = tm_get_port();\nif is_manual_peer {\ncontact_manual_peer(peer, our_port).await\n} else {\n+ let peer_listener = &mut *PEER_LISTENER.write().unwrap();\nlet iface_name = match peer_listener.interface_map.get(&peer.contact_socket) {\nSome(a) => a,\nNone => {\n@@ -94,10 +90,17 @@ pub async fn tm_neighbor_inquiry(\n))\n}\n};\n- contact_neighbor(peer, our_port, udp_socket, peer.contact_socket).await\n+\n+ contact_neighbor(peer, our_port, udp_socket, peer.contact_socket)\n}\n}\n+/// This sets a lock on th Peer Listener lazy static to prevent the peer listner tick from overwriting\n+/// hashmap data (which contact_peers uses) with new data until the peer contacting process has been complete\n+fn set_contacting_neighbors(set: bool) {\n+ PEER_LISTENER.write().unwrap().contacting_neighbors = set;\n+}\n+\n/// takes a list of peers to contact and dispatches UDP hello messages to peers discovered via IPv6 link local\n/// multicast peer discovery, also sends http hello messages to manual peers, only resolves manual peers with\n/// hostnames if the devices is detected to be a gateway.\n@@ -107,14 +110,14 @@ pub async fn tm_contact_peers(peers: HashMap<IpAddr, Peer>) {\nlet is_gateway = is_gateway();\nlet rita_hello_port = network_settings.rita_hello_port;\ndrop(network_settings);\n- // Hold a lock on shared state until we finish sending all messages. This prevents a race condition\n- // where the hashmaps get cleared out during subsequent ticks\n+\ninfo!(\"TunnelManager contacting peers\");\n- let writer = &mut *PEER_LISTENER.write().unwrap();\n+ // Hashmaps will not get overwritten while this bool is set\n+ set_contacting_neighbors(true);\nfor (_, peer) in peers.iter() {\ninfo!(\"contacting peer found by UDP {:?}\", peer);\n- let res = tm_neighbor_inquiry(peer, false, writer).await;\n+ let res = tm_neighbor_inquiry(peer, false).await;\nif res.is_err() {\nwarn!(\"Neighbor inqury for {:?} failed! with {:?}\", peer, res);\n}\n@@ -130,7 +133,7 @@ pub async fn tm_contact_peers(peers: HashMap<IpAddr, Peer>) {\nifidx: 0,\ncontact_socket: socket,\n};\n- let res = tm_neighbor_inquiry(&man_peer, true, writer).await;\n+ let res = tm_neighbor_inquiry(&man_peer, true).await;\nif res.is_err() {\nwarn!(\n\"Neighbor inqury for {:?} failed with: {:?}\",\n@@ -155,11 +158,14 @@ pub async fn tm_contact_peers(peers: HashMap<IpAddr, Peer>) {\n}\n}\n}\n+\n+ // Hashmaps can now get overwritten\n+ set_contacting_neighbors(false);\n}\n/// Sets out to contacts a local mesh neighbor, takes a speculative port (only assigned if the neighbor\n/// responds successfully). This function is used for mesh peers\n-async fn contact_neighbor(\n+fn contact_neighbor(\npeer: &Peer,\nour_port: u16,\nsocket: &UdpSocket,\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Fixed clippy lint: holding rwlock across async/await calls
20,255
25.05.2022 13:28:22
25,200
95e69de966f296c4d0495e0c55c517396f34b7cc
Added a magic phone number in config that allows exit registration without authentication Currently operators enter their phone number when trying to signup users to get an auth code Adding this magic nubmer in the config allows operators to directly register without using their details and makes the process of registration faster
[ { "change_type": "MODIFY", "old_path": "rita_exit/src/database/sms.rs", "new_path": "rita_exit/src/database/sms.rs", "diff": "@@ -9,6 +9,7 @@ use crate::RitaExitError;\nuse althea_types::{ExitClientDetails, ExitClientIdentity, ExitState};\nuse phonenumber::PhoneNumber;\nuse settings::exit::ExitVerifSettings;\n+use settings::get_rita_exit;\nuse std::time::Duration;\n#[derive(Serialize)]\n@@ -101,8 +102,18 @@ pub async fn handle_sms_registration(\n\"Handling phone registration for {}\",\nclient.global.wg_public_key\n);\n+\n+ // Get magic phone number\n+ let magic_phone_number = get_rita_exit().exit_network.magic_phone_number;\n+\nlet text_num = texts_sent(&their_record);\nlet sent_more_than_allowed_texts = text_num > 10;\n+ info!(\n+ \"Magic number is : {:?} and client nubmer is {:?}\",\n+ magic_phone_number,\n+ client.reg_details.phone.clone()\n+ );\n+\nmatch (\nclient.reg_details.phone.clone(),\nclient.reg_details.phone_code.clone(),\n@@ -110,7 +121,9 @@ pub async fn handle_sms_registration(\n) {\n// all texts exhausted, but they can still submit the correct code\n(Some(number), Some(code), true) => {\n- let result = check_text(number, code, api_key).await?;\n+ let result = (magic_phone_number.is_some()\n+ && magic_phone_number.unwrap() == number.clone())\n+ || check_text(number.clone(), code, api_key).await?;\nlet conn = get_database_connection()?;\nif result {\nverify_client(&client, true, &conn)?;\n@@ -156,7 +169,9 @@ pub async fn handle_sms_registration(\n}\n// user has attempts remaining and is submitting a code\n(Some(number), Some(code), false) => {\n- let result = check_text(number, code, api_key).await?;\n+ let result = (magic_phone_number.is_some()\n+ && magic_phone_number.unwrap() == number.clone())\n+ || check_text(number, code, api_key).await?;\nlet conn = get_database_connection()?;\ntrace!(\"Check text returned {}\", result);\n" }, { "change_type": "MODIFY", "old_path": "settings/src/exit.rs", "new_path": "settings/src/exit.rs", "diff": "@@ -42,6 +42,8 @@ pub struct ExitNetworkSettings {\npub wg_private_key: WgKey,\n/// path for the exit tunnel keyfile must be distinct from the common tunnel path!\npub wg_private_key_path: String,\n+ /// Magic phone number operators enter in order to register to exit without auth\n+ pub magic_phone_number: Option<String>,\n}\nimpl ExitNetworkSettings {\n@@ -64,6 +66,7 @@ impl ExitNetworkSettings {\nwg_private_key: WgKey::from_str(\"mFFBLqQYrycxfHo10P9l8I2G7zbw8tia4WkGGgjGCn8=\")\n.unwrap(),\nwg_private_key_path: String::new(),\n+ magic_phone_number: None,\n}\n}\n}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Added a magic phone number in config that allows exit registration without authentication Currently operators enter their phone number when trying to signup users to get an auth code Adding this magic nubmer in the config allows operators to directly register without using their details and makes the process of registration faster
20,244
27.05.2022 17:41:01
14,400
e7a0e4adde501f0ccaf29682e8d664385568682e
Add mtu functions for kernel interface These functions allow modification of interface MTU values.
[ { "change_type": "MODIFY", "old_path": "althea_kernel_interface/src/interface_tools.rs", "new_path": "althea_kernel_interface/src/interface_tools.rs", "diff": "+use crate::file_io::get_lines;\nuse crate::KernelInterface;\nuse crate::KernelInterfaceError as Error;\nuse regex::Regex;\n@@ -124,6 +125,32 @@ impl dyn KernelInterface {\nOk(())\n}\n}\n+\n+ /// Gets the mtu from an interface\n+ pub fn get_mtu(&self, if_name: &str) -> Result<usize, Error> {\n+ let lines = get_lines(&format!(\"/sys/class/net/{}/mtu\", if_name))?;\n+ if let Some(mtu) = lines.get(0) {\n+ Ok(mtu.parse()?)\n+ } else {\n+ Err(Error::NoInterfaceError(if_name.to_string()))\n+ }\n+ }\n+\n+ /// Sets the mtu of an interface\n+ pub fn set_mtu(&self, if_name: &str, mtu: usize) -> Result<(), Error> {\n+ let output = self.run_command(\n+ \"ip\",\n+ &[\"link\", \"set\", \"dev\", if_name, \"mtu\", &mtu.to_string()],\n+ )?;\n+ if !output.stderr.is_empty() {\n+ return Err(Error::RuntimeError(format!(\n+ \"received error setting interface mtu: {}\",\n+ String::from_utf8(output.stderr)?\n+ )));\n+ } else {\n+ Ok(())\n+ }\n+ }\n}\n#[test]\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Add mtu functions for kernel interface These functions allow modification of interface MTU values.
20,244
27.05.2022 18:12:13
14,400
295c9463fbb1fea83b893e1d33c030c3302faa20
Bump for Beta19 RC10
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -2646,7 +2646,7 @@ dependencies = [\n[[package]]\nname = \"rita_bin\"\n-version = \"0.19.9\"\n+version = \"0.19.10\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n@@ -2679,7 +2679,7 @@ dependencies = [\n[[package]]\nname = \"rita_client\"\n-version = \"0.19.9\"\n+version = \"0.19.10\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n@@ -2714,7 +2714,7 @@ dependencies = [\n[[package]]\nname = \"rita_common\"\n-version = \"0.19.9\"\n+version = \"0.19.10\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-service\",\n@@ -2752,7 +2752,7 @@ dependencies = [\n[[package]]\nname = \"rita_exit\"\n-version = \"0.19.8\"\n+version = \"0.19.10\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n" }, { "change_type": "MODIFY", "old_path": "rita_bin/Cargo.toml", "new_path": "rita_bin/Cargo.toml", "diff": "[package]\nname = \"rita_bin\"\n-version = \"0.19.9\"\n+version = \"0.19.10\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\nbuild = \"build.rs\"\n" }, { "change_type": "MODIFY", "old_path": "rita_client/Cargo.toml", "new_path": "rita_client/Cargo.toml", "diff": "[package]\nname = \"rita_client\"\n-version = \"0.19.9\"\n+version = \"0.19.10\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" }, { "change_type": "MODIFY", "old_path": "rita_common/Cargo.toml", "new_path": "rita_common/Cargo.toml", "diff": "[package]\nname = \"rita_common\"\n-version = \"0.19.9\"\n+version = \"0.19.10\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/dashboard/own_info.rs", "new_path": "rita_common/src/dashboard/own_info.rs", "diff": "@@ -6,7 +6,7 @@ use actix_web_async::HttpResponse;\nuse clarity::Address;\nuse num256::{Int256, Uint256};\n-pub static READABLE_VERSION: &str = \"Beta 19 RC9\";\n+pub static READABLE_VERSION: &str = \"Beta 19 RC10\";\n#[derive(Serialize)]\npub struct OwnInfo {\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/Cargo.toml", "new_path": "rita_exit/Cargo.toml", "diff": "[package]\nname = \"rita_exit\"\n-version = \"0.19.8\"\n+version = \"0.19.10\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Bump for Beta19 RC10
20,244
07.06.2022 07:32:34
14,400
db0c0e1eb3b56674032a4add847a1d4e162a03e7
Don't use sftp for uploads The latest openssh version uses sftp by default for uploads, dropbear on openwrt does not yet support this behavior, adding this flag ops out of the new sftp flow.
[ { "change_type": "MODIFY", "old_path": "scripts/openwrt_upload.sh", "new_path": "scripts/openwrt_upload.sh", "diff": "@@ -7,5 +7,5 @@ bash scripts/openwrt_build_$TARGET.sh --features rita_bin/development\nset +e\nssh root@$ROUTER_IP killall -9 rita\nset -e\n-scp target/$TRIPLE/release/rita root@$ROUTER_IP:/tmp/rita\n+scp -O target/$TRIPLE/release/rita root@$ROUTER_IP:/tmp/rita\nssh root@$ROUTER_IP NO_REMOTE_LOG=TRUE RUST_BACKTRACE=FULL RUST_LOG=TRACE /tmp/rita --config=/etc/rita.toml --platform=linux &> out.log\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Don't use sftp for uploads The latest openssh version uses sftp by default for uploads, dropbear on openwrt does not yet support this behavior, adding this flag ops out of the new sftp flow.
20,244
09.06.2022 14:52:33
14,400
b735f7dfbac685ed5eba560126319c44781fd6b9
Update jemallocator crate
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -1573,9 +1573,9 @@ checksum = \"1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35\"\n[[package]]\nname = \"jemalloc-sys\"\n-version = \"0.3.2\"\n+version = \"0.5.0+5.3.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"0d3b9f3f5c9b31aa0f5ed3260385ac205db665baa41d49bb8338008ae94ede45\"\n+checksum = \"f655c3ecfa6b0d03634595b4b54551d4bd5ac208b9e0124873949a7ab168f70b\"\ndependencies = [\n\"cc\",\n\"fs_extra\",\n@@ -1584,9 +1584,9 @@ dependencies = [\n[[package]]\nname = \"jemallocator\"\n-version = \"0.3.2\"\n+version = \"0.5.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"43ae63fcfc45e99ab3d1b29a46782ad679e98436c3169d15a167a1108a724b69\"\n+checksum = \"16c2514137880c52b0b4822b563fadd38257c1f380858addb74a400889696ea6\"\ndependencies = [\n\"jemalloc-sys\",\n\"libc\",\n" }, { "change_type": "MODIFY", "old_path": "rita_bin/Cargo.toml", "new_path": "rita_bin/Cargo.toml", "diff": "@@ -39,7 +39,7 @@ rita_client = { path = \"../rita_client\", default-features = false }\nrita_exit = { path = \"../rita_exit\", default-features = false }\nflate2 = { version = \"1.0\", features = [\"rust_backend\"], default-features = false }\nreqwest = { version = \"0.11\", features = [\"blocking\", \"json\"] }\n-jemallocator = {version = \"0.3\", optional = true}\n+jemallocator = {version = \"0.5\", optional = true}\n# we don't call or us OpenSSL directly in this codebase, but by adding\n# this dependency with this feature we can enforce that openssl is compiled\n# in 'vendored' mode all the way down the tree. What this means is that we use\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Update jemallocator crate
20,244
09.06.2022 15:00:36
14,400
4e724faf0629a436cb3243a18de7c9d64e425778
Add psdk2+ccmp mode to wifi security Some routers have this mode set, so we need to support it.
[ { "change_type": "MODIFY", "old_path": "rita_client/src/dashboard/wifi.rs", "new_path": "rita_client/src/dashboard/wifi.rs", "diff": "@@ -128,7 +128,7 @@ impl FromStr for EncryptionModes {\n\"none\" | \"NONE\" => Ok(EncryptionModes::None),\n\"sae\" | \"WPA3\" => Ok(EncryptionModes::Sae),\n\"sae-mixed\" | \"WPA2+WPA3\" => Ok(EncryptionModes::SaeMixed),\n- \"psk2+tkip+ccmp\" | \"WPA2\" => Ok(EncryptionModes::Psk2TkipCcmp),\n+ \"psk2+tkip+ccmp\" | \"psk2+ccmp\" | \"WPA2\" => Ok(EncryptionModes::Psk2TkipCcmp),\n\"psk-mixed+tkip+ccmp\" | \"WPA+WPA2\" => Ok(EncryptionModes::Psk2MixedTkipCcmp),\n_ => {\nlet e = RitaClientError::MiscStringError(\"Invalid encryption mode!\".to_string());\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Add psdk2+ccmp mode to wifi security Some routers have this mode set, so we need to support it.
20,255
02.06.2022 13:36:08
25,200
23dd3ba49bb5f1fed8bceb6256c6dfecacf179d7
Making client subnet a config configurable field instead of a hardcoded field This is the subnet size a client router receives from the exit. The default is set to /56 when this field is None in the config
[ { "change_type": "MODIFY", "old_path": "rita_exit/src/database/database_tools.rs", "new_path": "rita_exit/src/database/database_tools.rs", "diff": "@@ -19,8 +19,8 @@ use std::convert::TryInto;\nuse std::net::IpAddr;\nuse std::net::Ipv4Addr;\n-// Subnet size assigned to each client\n-const CLIENT_SUBNET_SIZE: u8 = 64;\n+// Default Subnet size assigned to each client\n+const DEFAULT_CLIENT_SUBNET_SIZE: u8 = 56;\n/// Takes a list of clients and returns a sorted list of ip addresses spefically v4 since it\n/// can implement comparison operators\n@@ -595,7 +595,14 @@ pub fn get_client_subnet(\n}\n// Once we get the index, generate the subnet\n- match generate_iterative_client_subnet(sub, index.unwrap(), CLIENT_SUBNET_SIZE.into()) {\n+ match generate_iterative_client_subnet(\n+ sub,\n+ index.unwrap(),\n+ settings::get_rita_exit()\n+ .get_client_subnet_size()\n+ .unwrap_or(DEFAULT_CLIENT_SUBNET_SIZE)\n+ .into(),\n+ ) {\nOk(addr) => {\n// increment iterative index\nif used_iterative_index {\n" }, { "change_type": "MODIFY", "old_path": "settings/src/exit.rs", "new_path": "settings/src/exit.rs", "diff": "@@ -29,6 +29,8 @@ pub struct ExitNetworkSettings {\npub netmask: u8,\n/// The subnet we use to assign to client routers for ipv6\npub subnet: Option<IpNetwork>,\n+ /// The specified client subnet, else use /56\n+ pub client_subnet_size: Option<u8>,\n/// Time in seconds before user is dropped from the db due to inactivity\n/// 0 means disabled\npub entry_timeout: u32,\n@@ -59,6 +61,7 @@ impl ExitNetworkSettings {\nexit_start_ip: \"172.16.0.0\".parse().unwrap(),\nnetmask: 12,\nsubnet: Some(IpNetwork::V6(\"ff01::0/128\".parse().unwrap())),\n+ client_subnet_size: None,\nentry_timeout: 0,\ngeoip_api_user: None,\ngeoip_api_key: None,\n@@ -225,6 +228,10 @@ impl RitaExitSettingsStruct {\n))\n}\n+ pub fn get_client_subnet_size(&self) -> Option<u8> {\n+ self.exit_network.client_subnet_size\n+ }\n+\npub fn get_all(&self) -> Result<serde_json::Value, SettingsError> {\nOk(serde_json::to_value(self.clone())?)\n}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Making client subnet a config configurable field instead of a hardcoded field This is the subnet size a client router receives from the exit. The default is set to /56 when this field is None in the config
20,255
06.06.2022 11:24:45
25,200
8b1746375c87ec8c349915f66942f42a3a902ea0
Adding case to fuzzy_traffic_match CI test to account for 0 traffic
[ { "change_type": "MODIFY", "old_path": "integration-tests/integration-test-script/utils.py", "new_path": "integration-tests/integration-test-script/utils.py", "diff": "@@ -361,10 +361,10 @@ def fuzzy_traffic_match(numA, numB):\n# signs must not match\nif numA > 0 and numB > 0 or numA < 0 and numB < 0:\nreturn False\n- if numA > 0:\n+ if numA >= 0:\npos = numA\nneg = numB\n- if numB > 0:\n+ if numB >= 0:\npos = numB\nneg = numA\npos_abs = abs(pos)\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Adding case to fuzzy_traffic_match CI test to account for 0 traffic
20,244
15.06.2022 09:09:14
14,400
49a765160f430d011ef8401acacd3b5ad49fa1a1
Bump for Beta 19 RC11
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -2619,7 +2619,7 @@ dependencies = [\n[[package]]\nname = \"rita_bin\"\n-version = \"0.19.10\"\n+version = \"0.19.11\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n@@ -2652,7 +2652,7 @@ dependencies = [\n[[package]]\nname = \"rita_client\"\n-version = \"0.19.10\"\n+version = \"0.19.11\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n@@ -2687,7 +2687,7 @@ dependencies = [\n[[package]]\nname = \"rita_common\"\n-version = \"0.19.10\"\n+version = \"0.19.11\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-service\",\n@@ -2725,7 +2725,7 @@ dependencies = [\n[[package]]\nname = \"rita_exit\"\n-version = \"0.19.10\"\n+version = \"0.19.11\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n" }, { "change_type": "MODIFY", "old_path": "rita_bin/Cargo.toml", "new_path": "rita_bin/Cargo.toml", "diff": "[package]\nname = \"rita_bin\"\n-version = \"0.19.10\"\n+version = \"0.19.11\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\nbuild = \"build.rs\"\n" }, { "change_type": "MODIFY", "old_path": "rita_client/Cargo.toml", "new_path": "rita_client/Cargo.toml", "diff": "[package]\nname = \"rita_client\"\n-version = \"0.19.10\"\n+version = \"0.19.11\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" }, { "change_type": "MODIFY", "old_path": "rita_common/Cargo.toml", "new_path": "rita_common/Cargo.toml", "diff": "[package]\nname = \"rita_common\"\n-version = \"0.19.10\"\n+version = \"0.19.11\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/dashboard/own_info.rs", "new_path": "rita_common/src/dashboard/own_info.rs", "diff": "@@ -6,7 +6,7 @@ use actix_web_async::HttpResponse;\nuse clarity::Address;\nuse num256::{Int256, Uint256};\n-pub static READABLE_VERSION: &str = \"Beta 19 RC10\";\n+pub static READABLE_VERSION: &str = \"Beta 19 RC11\";\n#[derive(Serialize)]\npub struct OwnInfo {\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/Cargo.toml", "new_path": "rita_exit/Cargo.toml", "diff": "[package]\nname = \"rita_exit\"\n-version = \"0.19.10\"\n+version = \"0.19.11\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Bump for Beta 19 RC11
20,253
15.06.2022 10:49:18
25,200
883ea69a502081fec52f6e6939aa2056363a8b91
Adds multi port toggling Interfaces endpoint now accepts an array so that a user may change and send multiple port reassignments at once from the dashboard adds multiset_interfaces to handle the incoming Vecs of changes now reboots within multiset_interfaces instead of at the end of ethernet_transform_mode
[ { "change_type": "MODIFY", "old_path": "docs/api/router-dashboard.md", "new_path": "docs/api/router-dashboard.md", "diff": "@@ -874,9 +874,9 @@ Format:\n## /interfaces\n-Calling HTTP `POST` request on this endpoint with a json object specifying an interface and a mode\n-will transform that interface to the specified mode. The provided interface must be available from\n-the `GET` version of this same endpoint.\n+Calling HTTP `POST` request on this endpoint with a json object specifying a list of the router's interfaces\n+and one of their corresponding modes will transform each interface to its specified mode. The provided interface\n+must be available from the `GET` version of this same endpoint.\n- URL: `<rita ip>:<rita_dashboard_port>/interfaces`\n- Method: `POST`\n@@ -888,7 +888,7 @@ the `GET` version of this same endpoint.\n- Error Response: `500 Server Error`\n- Sample Call\n-`curl 127.0.0.1:<rita_dashboard_port>/interfaces -H 'Content-Type: application/json' -i -d '{\"interface\":\"wlan0\", \"mode\":\"LAN\"}'`\n+`curl 127.0.0.1:<rita_dashboard_port>/interfaces -H 'Content-Type: application/json' -i -d '{\"interfaces\":[\"eth0.4\",\"eth1\",\"eth0.3\"],\"modes\":[\"LTE\",\"Phone\",\"Lan\"]}'`\nFormat:\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/dashboard/interfaces.rs", "new_path": "rita_client/src/dashboard/interfaces.rs", "diff": "@@ -10,9 +10,9 @@ use std::net::Ipv4Addr;\nuse crate::RitaClientError;\n#[derive(Serialize, Deserialize, Clone, Debug)]\n-pub struct InterfaceToSet {\n- pub interface: String,\n- pub mode: InterfaceMode,\n+pub struct InterfacesToSet {\n+ pub interfaces: Vec<String>,\n+ pub modes: Vec<InterfaceMode>,\n}\n#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Copy)]\n@@ -156,13 +156,13 @@ pub fn ethernet2mode(ifname: &str, setting_name: &str) -> Result<InterfaceMode,\n})\n}\n-fn set_interface_mode(iface_name: &str, mode: InterfaceMode) -> Result<(), RitaClientError> {\n- trace!(\"InterfaceToSet received\");\n+/// Set mode for an individual interface\n+fn set_interface_mode(iface_name: String, mode: InterfaceMode) -> Result<(), RitaClientError> {\nlet iface_name = iface_name;\nlet target_mode = mode;\nlet interfaces = get_interfaces()?;\n- let current_mode = get_current_interface_mode(&interfaces, iface_name);\n- if !interfaces.contains_key(iface_name) {\n+ let current_mode = get_current_interface_mode(&interfaces, &iface_name);\n+ if !interfaces.contains_key(&iface_name) {\nreturn Err(RitaClientError::InterfaceModeError(\n\"Attempted to configure non-existant or unavailable interface!\".to_string(),\n));\n@@ -179,12 +179,53 @@ fn set_interface_mode(iface_name: &str, mode: InterfaceMode) -> Result<(), RitaC\n}\n}\n}\n+ ethernet_transform_mode(&iface_name, current_mode, target_mode)\n+}\n- trace!(\"Transforming ethernet\");\n- ethernet_transform_mode(iface_name, current_mode, target_mode)\n+/// Handles the validation of new port settings from multi port toggle\n+fn multiset_interfaces(\n+ iface_name: Vec<String>,\n+ mode: Vec<InterfaceMode>,\n+) -> Result<(), RitaClientError> {\n+ trace!(\"InterfaceToSet received\");\n+ if iface_name.len() != mode.len() {\n+ return Err(RitaClientError::MiscStringError(\n+ \"Extra mode or iface found!\".to_string(),\n+ ));\n+ }\n+ // for each interface sent through, we set its interface mode\n+ let mut target_modes = mode.clone();\n+\n+ // do not allow multiple WANs- this is checked for before we run through the setter so we do\n+ // not waste time on obviously incorrect configs\n+ let mut wan_count = 0;\n+ for m in mode {\n+ if matches!(m, InterfaceMode::Wan) || matches!(m, InterfaceMode::StaticWan { .. }) {\n+ wan_count += 1;\n+ }\n+ }\n+ if wan_count > 1 {\n+ return Err(RitaClientError::MiscStringError(\n+ \"Only one WAN interface allowed!\".to_string(),\n+ ));\n}\n-/// Transform a wired inteface from mode A to mode B\n+ for iface in iface_name {\n+ let mode = target_modes.remove(0);\n+\n+ let setter = set_interface_mode(iface.clone(), mode);\n+ if setter.is_err() {\n+ return Err(RitaClientError::InterfaceModeError(iface));\n+ }\n+ }\n+\n+ trace!(\"Successfully transformed ethernet mode, rebooting\");\n+ // reboot has been moved here to avoid doing it after every interface\n+ KI.run_command(\"reboot\", &[])?;\n+ Ok(())\n+}\n+\n+/// Transform a wired interface from mode A to mode B\npub fn ethernet_transform_mode(\nifname: &str,\na: InterfaceMode,\n@@ -393,12 +434,10 @@ pub fn ethernet_transform_mode(\nreturn Err(RitaCommonError::SettingsError(_e).into());\n}\n+ trace!(\"Transforming ethernet\");\n// We edited disk contents, force global sync\nKI.fs_sync()?;\n- trace!(\"Successsfully transformed ethernet mode, rebooting\");\n- KI.run_command(\"reboot\", &[])?;\n-\nOk(())\n}\n@@ -631,6 +670,7 @@ mod tests {\npub async fn get_interfaces_endpoint(_req: HttpRequest) -> HttpResponse {\ndebug!(\"get /interfaces hit\");\n+\nmatch get_interfaces() {\nOk(val) => HttpResponse::Ok().json(val),\nErr(e) => {\n@@ -640,11 +680,11 @@ pub async fn get_interfaces_endpoint(_req: HttpRequest) -> HttpResponse {\n}\n}\n-pub async fn set_interfaces_endpoint(interface: Json<InterfaceToSet>) -> HttpResponse {\n- let interface = interface.into_inner();\n+pub async fn set_interfaces_endpoint(interfaces: Json<InterfacesToSet>) -> HttpResponse {\n+ let interface = interfaces.into_inner();\ndebug!(\"set /interfaces hit\");\n- match set_interface_mode(&interface.interface, interface.mode) {\n+ match multiset_interfaces(interface.interfaces, interface.modes) {\nOk(_) => HttpResponse::Ok().into(),\nErr(e) => {\nerror!(\"Set interfaces failed with {:?}\", e);\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Adds multi port toggling Interfaces endpoint now accepts an array so that a user may change and send multiple port reassignments at once from the dashboard adds multiset_interfaces to handle the incoming Vecs of changes now reboots within multiset_interfaces instead of at the end of ethernet_transform_mode
20,247
15.06.2022 13:08:41
25,200
556fff579ca768e0d36c1051cd72bcb627d691de
Save org address changes immediately With write optimization, there's now a greater likelihood that setting an org address will be followed by the router being turned off before the settings file is saved. This ensures that the settings file is saved immediately.
[ { "change_type": "MODIFY", "old_path": "rita_client/src/dashboard/operator.rs", "new_path": "rita_client/src/dashboard/operator.rs", "diff": "@@ -92,6 +92,11 @@ pub async fn change_operator(path: Path<Address>) -> HttpResponse {\nrita_client.operator = operator;\nsettings::set_rita_client(rita_client);\n+ // save immediately\n+ if let Err(_e) = settings::write_config() {\n+ return HttpResponse::InternalServerError().finish();\n+ }\n+\nHttpResponse::Ok().finish()\n}\n@@ -102,6 +107,12 @@ pub async fn remove_operator(_path: Path<Address>) -> HttpResponse {\nrita_client.operator = operator;\nsettings::set_rita_client(rita_client);\n+\n+ // save immediately\n+ if let Err(_e) = settings::write_config() {\n+ return HttpResponse::InternalServerError().finish();\n+ }\n+\nHttpResponse::Ok().finish()\n}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Save org address changes immediately With write optimization, there's now a greater likelihood that setting an org address will be followed by the router being turned off before the settings file is saved. This ensures that the settings file is saved immediately.
20,244
16.06.2022 15:28:40
14,400
48eafe8658715a05bf539df216021255c1e826f7
Add support for tkip+aes wifi encryption
[ { "change_type": "MODIFY", "old_path": "rita_client/src/dashboard/wifi.rs", "new_path": "rita_client/src/dashboard/wifi.rs", "diff": "@@ -128,7 +128,9 @@ impl FromStr for EncryptionModes {\n\"none\" | \"NONE\" => Ok(EncryptionModes::None),\n\"sae\" | \"WPA3\" => Ok(EncryptionModes::Sae),\n\"sae-mixed\" | \"WPA2+WPA3\" => Ok(EncryptionModes::SaeMixed),\n- \"psk2+tkip+ccmp\" | \"psk2+ccmp\" | \"WPA2\" => Ok(EncryptionModes::Psk2TkipCcmp),\n+ \"psk2+tkip+ccmp\" | \"psk2+ccmp\" | \"psk2+tkip+aes\" | \"WPA2\" => {\n+ Ok(EncryptionModes::Psk2TkipCcmp)\n+ }\n\"psk-mixed+tkip+ccmp\" | \"WPA+WPA2\" => Ok(EncryptionModes::Psk2MixedTkipCcmp),\n_ => {\nlet e = RitaClientError::MiscStringError(\"Invalid encryption mode!\".to_string());\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Add support for tkip+aes wifi encryption
20,255
13.06.2022 10:30:29
25,200
5f7d4144bedcae06da532f384f9ca55111dc00ec
Added client internet ipv6 subnet to allowed ips on the exit side
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -306,6 +306,7 @@ name = \"althea_kernel_interface\"\nversion = \"0.1.0\"\ndependencies = [\n\"althea_types\",\n+ \"ipnetwork 0.18.0\",\n\"itertools 0.10.3\",\n\"lazy_static\",\n\"log\",\n" }, { "change_type": "MODIFY", "old_path": "althea_kernel_interface/Cargo.toml", "new_path": "althea_kernel_interface/Cargo.toml", "diff": "@@ -14,6 +14,7 @@ log = \"0.4\"\nserde_derive = \"1.0\"\nserde = \"1.0\"\nalthea_types = { path = \"../althea_types\" }\n+ipnetwork = \"0.18\"\n[dependencies.regex]\nversion = \"1.4\"\n" }, { "change_type": "MODIFY", "old_path": "althea_kernel_interface/src/exit_server_tunnel.rs", "new_path": "althea_kernel_interface/src/exit_server_tunnel.rs", "diff": "use super::{KernelInterface, KernelInterfaceError};\nuse althea_types::WgKey;\n+use ipnetwork::IpNetwork;\nuse std::collections::HashSet;\nuse std::net::IpAddr;\nuse KernelInterfaceError as Error;\n@@ -7,6 +8,7 @@ use KernelInterfaceError as Error;\n#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]\npub struct ExitClient {\npub internal_ip: IpAddr,\n+ pub internet_ipv6_list: Option<IpNetwork>,\npub public_key: WgKey,\npub mesh_ip: IpAddr,\npub port: u16,\n@@ -33,12 +35,22 @@ impl dyn KernelInterface {\nlet mut client_pubkeys = HashSet::new();\nfor c in clients.iter() {\n+ // For the allowed IPs, we appends the clients internal ip as well\n+ // as the client ipv6 assigned list and add this to wireguards allowed ips\n+ // internet_ipv6_list is already in the form of \"<subnet1>,<subnet2>..\"\n+ let i_ipv6 = &c.internet_ipv6_list;\n+ let mut allowed_ips = c.internal_ip.to_string().to_owned();\n+ if let Some(ip6) = i_ipv6 {\n+ allowed_ips.push_str(\", \");\n+ allowed_ips.push_str(&ip6.to_string());\n+ }\n+\nargs.push(\"peer\".into());\nargs.push(format!(\"{}\", c.public_key));\nargs.push(\"endpoint\".into());\nargs.push(format!(\"[{}]:{}\", c.mesh_ip, c.port));\nargs.push(\"allowed-ips\".into());\n- args.push(format!(\"{}\", c.internal_ip));\n+ args.push(allowed_ips);\nclient_pubkeys.insert(c.public_key);\n}\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/struct_tools.rs", "new_path": "rita_exit/src/database/struct_tools.rs", "diff": "@@ -27,6 +27,12 @@ pub fn to_exit_client(client: Client) -> Result<ExitClient, RitaExitError> {\ninternal_ip: client.internal_ip.parse()?,\nport: client.wg_port as u16,\npublic_key: client.wg_pubkey.parse()?,\n+ internet_ipv6_list: {\n+ match client.internet_ipv6.parse() {\n+ Ok(a) => Some(a),\n+ Err(_) => None,\n+ }\n+ },\n})\n}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Added client internet ipv6 subnet to allowed ips on the exit side
20,255
13.06.2022 10:49:23
25,200
8e586715495b7f40624cd87b3496cda4f5c67240
Added link local ip addr to wg_exit and ip6tables to route ip6traffic between eth0 and wg_exit on the exit side
[ { "change_type": "MODIFY", "old_path": "althea_kernel_interface/src/exit_server_tunnel.rs", "new_path": "althea_kernel_interface/src/exit_server_tunnel.rs", "diff": "+use crate::open_tunnel::to_wg_local;\n+\nuse super::{KernelInterface, KernelInterfaceError};\nuse althea_types::WgKey;\n-use ipnetwork::IpNetwork;\nuse std::collections::HashSet;\nuse std::net::IpAddr;\nuse KernelInterfaceError as Error;\n-#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]\n+#[derive(Debug, Clone, Eq, PartialEq, Hash)]\npub struct ExitClient {\npub internal_ip: IpAddr,\n- pub internet_ipv6_list: Option<IpNetwork>,\n+ pub internet_ipv6_list: String,\npub public_key: WgKey,\npub mesh_ip: IpAddr,\npub port: u16,\n@@ -40,9 +41,9 @@ impl dyn KernelInterface {\n// internet_ipv6_list is already in the form of \"<subnet1>,<subnet2>..\"\nlet i_ipv6 = &c.internet_ipv6_list;\nlet mut allowed_ips = c.internal_ip.to_string().to_owned();\n- if let Some(ip6) = i_ipv6 {\n- allowed_ips.push_str(\", \");\n- allowed_ips.push_str(&ip6.to_string());\n+ if !i_ipv6.is_empty() {\n+ allowed_ips.push(',');\n+ allowed_ips.push_str(i_ipv6);\n}\nargs.push(\"peer\".into());\n@@ -89,7 +90,13 @@ impl dyn KernelInterface {\n}\n/// Performs the one time startup tasks for the rita_exit clients loop\n- pub fn one_time_exit_setup(&self, local_ip: &IpAddr, netmask: u8) -> Result<(), Error> {\n+ pub fn one_time_exit_setup(\n+ &self,\n+ local_ip: &IpAddr,\n+ netmask: u8,\n+ exit_mesh: IpAddr,\n+ external_nic: String,\n+ ) -> Result<(), Error> {\nlet _output = self.run_command(\n\"ip\",\n&[\n@@ -101,6 +108,59 @@ impl dyn KernelInterface {\n],\n)?;\n+ // Set up link local mesh ip in wg_exit as fe80 + rest of mesh ip of exit\n+ let local_link = to_wg_local(&exit_mesh);\n+\n+ let _output = self.run_command(\n+ \"ip\",\n+ &[\n+ \"address\",\n+ \"add\",\n+ &format!(\"{}/64\", local_link),\n+ \"dev\",\n+ \"wg_exit\",\n+ ],\n+ )?;\n+\n+ // Add iptable routes between wg_exit and eth0\n+ if self\n+ .add_iptables_rule(\n+ \"ip6tables\",\n+ &[\n+ \"-A\",\n+ \"FORWARD\",\n+ \"-i\",\n+ \"wg_exit\",\n+ \"-o\",\n+ &external_nic,\n+ \"-j\",\n+ \"ACCEPT\",\n+ ],\n+ )\n+ .is_err()\n+ {\n+ error!(\"IPV6 ERROR: uanble to set ip6table rules: wg_exit to ex_nic\");\n+ }\n+\n+ if self\n+ .add_iptables_rule(\n+ \"ip6tables\",\n+ &[\n+ \"-A\",\n+ \"FORWARD\",\n+ \"-i\",\n+ &external_nic,\n+ \"-o\",\n+ \"wg_exit\",\n+ \"-j\",\n+ \"ACCEPT\",\n+ ],\n+ )\n+ .is_err()\n+ {\n+ error!(\"IPV6 ERROR: uanble to set ip6table rules: ex_nic to wg_Exit\");\n+ }\n+\nlet output = self.run_command(\"ip\", &[\"link\", \"set\", \"dev\", \"wg_exit\", \"mtu\", \"1340\"])?;\nif !output.stderr.is_empty() {\nreturn Err(KernelInterfaceError::RuntimeError(format!(\n" }, { "change_type": "MODIFY", "old_path": "althea_kernel_interface/src/open_tunnel.rs", "new_path": "althea_kernel_interface/src/open_tunnel.rs", "diff": "@@ -3,7 +3,7 @@ use althea_types::WgKey;\nuse std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};\nuse std::path::Path;\n-fn to_wg_local(ip: &IpAddr) -> IpAddr {\n+pub fn to_wg_local(ip: &IpAddr) -> IpAddr {\nmatch *ip {\nIpAddr::V6(ip) => {\nlet seg = ip.segments();\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/struct_tools.rs", "new_path": "rita_exit/src/database/struct_tools.rs", "diff": "@@ -27,12 +27,7 @@ pub fn to_exit_client(client: Client) -> Result<ExitClient, RitaExitError> {\ninternal_ip: client.internal_ip.parse()?,\nport: client.wg_port as u16,\npublic_key: client.wg_pubkey.parse()?,\n- internet_ipv6_list: {\n- match client.internet_ipv6.parse() {\n- Ok(a) => Some(a),\n- Err(_) => None,\n- }\n- },\n+ internet_ipv6_list: client.internet_ipv6,\n})\n}\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/rita_loop/mod.rs", "new_path": "rita_exit/src/rita_loop/mod.rs", "diff": "@@ -229,6 +229,14 @@ fn setup_exit_wg_tunnel() {\n.own_internal_ip\n.into(),\nsettings::get_rita_exit().exit_network.netmask,\n+ settings::get_rita_exit()\n+ .network\n+ .mesh_ip\n+ .expect(\"Expected a mesh ip for this exit\"),\n+ settings::get_rita_exit()\n+ .network\n+ .external_nic\n+ .expect(\"Expected an external nic here\"),\n)\n.expect(\"Failed to setup wg_exit!\");\nKI.setup_nat(&settings::get_rita_exit().network.external_nic.unwrap())\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Added link local ip addr to wg_exit and ip6tables to route ip6traffic between eth0 and wg_exit on the exit side
20,255
16.06.2022 11:32:57
25,200
3b8f8d47217f8c26e26c6b8ef9936a7025e62c5e
Add ipv6 routes for every client subnet on the exit side
[ { "change_type": "MODIFY", "old_path": "althea_kernel_interface/src/exit_server_tunnel.rs", "new_path": "althea_kernel_interface/src/exit_server_tunnel.rs", "diff": "@@ -2,6 +2,7 @@ use crate::open_tunnel::to_wg_local;\nuse super::{KernelInterface, KernelInterfaceError};\nuse althea_types::WgKey;\n+use ipnetwork::IpNetwork;\nuse std::collections::HashSet;\nuse std::net::IpAddr;\nuse KernelInterfaceError as Error;\n@@ -89,6 +90,28 @@ impl dyn KernelInterface {\nOk(())\n}\n+ /// This function adds a route for each client subnet to the ipv6 routing table\n+ /// through wg_exit\n+ pub fn setup_client_routes(&self, client_ipv6_list: String, client_mesh: String) {\n+ if client_ipv6_list.is_empty() {\n+ return;\n+ }\n+\n+ let ipv6_list: Vec<&str> = client_ipv6_list.split(',').collect();\n+\n+ for ip in ipv6_list {\n+ // Verfiy its a valid subnet\n+ if let Ok(ip_net) = ip.parse::<IpNetwork>() {\n+ let _res = self.run_command(\n+ \"ip\",\n+ &[\"-6\", \"route\", \"add\", &ip_net.to_string(), \"dev\", \"wg_exit\"],\n+ );\n+ } else {\n+ error!(\"IPV6 Error: Invalid client database state. Client with mesh ip: {:?} has invalid database ipv6 list: {:?}\", client_mesh, client_ipv6_list);\n+ }\n+ }\n+ }\n+\n/// Performs the one time startup tasks for the rita_exit clients loop\npub fn one_time_exit_setup(\n&self,\n@@ -245,3 +268,21 @@ impl dyn KernelInterface {\nOk(())\n}\n}\n+\n+#[test]\n+fn test_iproute_parsing() {\n+ let str = \"fbad::/64,feee::/64\";\n+\n+ if str.is_empty() {\n+ return;\n+ }\n+\n+ let ipv6_list: Vec<&str> = str.split(',').collect();\n+\n+ for ip in ipv6_list {\n+ // Verfiy its a valid subnet\n+ if let Ok(ip_net) = ip.parse::<IpNetwork>() {\n+ println!(\"debugging: {:?}\", ip_net)\n+ }\n+ }\n+}\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/mod.rs", "new_path": "rita_exit/src/database/mod.rs", "diff": "@@ -363,6 +363,9 @@ pub fn setup_clients(\n(true, Err(e)) => warn!(\"Error converting {:?} to exit client {:?}\", c, e),\n(false, _) => trace!(\"{:?} is not verified, not adding to wg_exit\", c),\n}\n+\n+ // Setup or verify that an ipv6 route exists for each client\n+ KI.setup_client_routes(c.internet_ipv6.clone(), c.mesh_ip.clone())\n}\ntrace!(\"converted clients {:?}\", wg_clients);\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Add ipv6 routes for every client subnet on the exit side
20,255
05.06.2022 19:17:41
25,200
30e0244209401803f07ff1c176658be16a6f3535
Set the ipv6 address in router /etc/config/network When set under 'lan' in the network config, SLAAC take a subnet and assigns a /64 address to hosts that connect. Rita exit sends a /60, we assign the router this address in this commit and slaac does ip assignment
[ { "change_type": "MODIFY", "old_path": "althea_kernel_interface/src/ip_addr.rs", "new_path": "althea_kernel_interface/src/ip_addr.rs", "diff": "use crate::KernelInterface;\nuse crate::KernelInterfaceError as Error;\n+use ipnetwork::IpNetwork;\nuse std::net::Ipv4Addr;\nimpl dyn KernelInterface {\n@@ -44,6 +45,38 @@ impl dyn KernelInterface {\n}\n}\n+ /// After receiving an ipv6 addr from the exit, this function adds that ip\n+ /// to /etc/network/addr. SLAAC takes this ip and assigns a /64 to hosts that connect\n+ /// to the router\n+ pub fn setup_ipv6_slaac(&self, router_ipv6_str: IpNetwork) {\n+ let output = self\n+ .run_command(\"uci\", &[\"get\", \"network.lan.ip6addr\"])\n+ .unwrap();\n+\n+ match String::from_utf8(output.stdout) {\n+ Ok(a) => {\n+ if a.is_empty() || {\n+ router_ipv6_str\n+ != a.replace('\\n', \"\")\n+ .parse::<IpNetwork>()\n+ .expect(\"This should be a valid network\")\n+ } {\n+ let mut append_str = \"network.lan.ip6addr=\".to_owned();\n+ append_str.push_str(&router_ipv6_str.to_string());\n+ let res1 = self.run_command(\"uci\", &[\"set\", &append_str]);\n+ let res2 = self.run_command(\"uci\", &[\"commit\", \"network\"]);\n+ let res3 = self.run_command(\"/etc/init.d/network\", &[\"reload\"]);\n+\n+ match (res1.clone(), res2.clone(), res3.clone()) {\n+ (Ok(_), Ok(_), Ok(_)) => {},\n+ _ => error!(\"Unable to set ipv6 subnet correctly. Following are the results of command: {:?}, {:?}, {:?}\", res1, res2, res3),\n+ }\n+ }\n+ }\n+ Err(e) => error!(\"Error setting ipv6: {:?}\", e),\n+ }\n+ }\n+\n/// Adds an ipv4 address to a given interface, true is returned when\n/// the ip is added, false if it is already there and Error if the interface\n/// does not exist or some other error has occured\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/exit_manager/mod.rs", "new_path": "rita_client/src/exit_manager/mod.rs", "diff": "@@ -562,6 +562,7 @@ async fn exit_status_request(exit: String) -> Result<(), RitaClientError> {\n};\ncurrent_exit.info = exit_response.clone();\nsettings::set_rita_client(rita_client);\n+\ntrace!(\"Got exit status response {:?}\", exit_response);\nOk(())\n}\n@@ -782,4 +783,24 @@ pub async fn exit_manager_tick() {\n}\n}\n}\n+\n+ // This block runs after an exit manager tick (an exit is selected),\n+ // and looks at the ipv6 subnet assigned to our router in the ExitState struct\n+ // which should be present after requesting general status from a registered exit.\n+ // This subnet is then added the lan network interface on the router to be used by slaac\n+ trace!(\"Setting up ipv6 for slaac\");\n+ let rita_settings = settings::get_rita_client();\n+ let current_exit = rita_settings.exit_client.current_exit;\n+ if let Some(exit) = current_exit {\n+ let exit_ser = rita_settings.exit_client.exits.get(&exit);\n+ if let Some(exit_ser) = exit_ser {\n+ let exit_info = exit_ser.info.clone();\n+\n+ if let ExitState::Registered { our_details, .. } = exit_info {\n+ if let Some(ipv6_sub) = our_details.internet_ipv6_subnet {\n+ KI.setup_ipv6_slaac(ipv6_sub)\n+ }\n+ }\n+ }\n+ }\n}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Set the ipv6 address in router /etc/config/network When set under 'lan' in the network config, SLAAC take a subnet and assigns a /64 address to hosts that connect. Rita exit sends a /60, we assign the router this address in this commit and slaac does ip assignment
20,255
08.06.2022 13:14:05
25,200
950743c7077dc7b8526ed742dc9c759524748e7f
Adding ::/0 to wireguard allowed ips on client side
[ { "change_type": "MODIFY", "old_path": "althea_kernel_interface/src/exit_client_tunnel.rs", "new_path": "althea_kernel_interface/src/exit_client_tunnel.rs", "diff": "@@ -46,7 +46,7 @@ impl dyn KernelInterface {\n\"endpoint\",\n&format!(\"[{}]:{}\", args.endpoint.ip(), args.endpoint.port()),\n\"allowed-ips\",\n- \"0.0.0.0/0\",\n+ \"0.0.0.0/0, ::/0\",\n\"persistent-keepalive\",\n\"5\",\n],\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Adding ::/0 to wireguard allowed ips on client side
20,255
08.06.2022 14:22:48
25,200
7008177629341ff3d0bf7bf81d3cbfcff2d3aaee
Automatically copy an fe80 address to the wg_exit interface on the client side
[ { "change_type": "MODIFY", "old_path": "althea_kernel_interface/src/exit_client_tunnel.rs", "new_path": "althea_kernel_interface/src/exit_client_tunnel.rs", "diff": "use super::KernelInterface;\n-use crate::KernelInterfaceError as Error;\n+use crate::{open_tunnel::to_wg_local, KernelInterfaceError as Error};\nuse althea_types::WgKey;\nuse std::net::{IpAddr, Ipv4Addr, SocketAddr};\n@@ -31,7 +31,11 @@ pub struct ClientExitTunnelConfig {\n}\nimpl dyn KernelInterface {\n- pub fn set_client_exit_tunnel_config(&self, args: ClientExitTunnelConfig) -> Result<(), Error> {\n+ pub fn set_client_exit_tunnel_config(\n+ &self,\n+ args: ClientExitTunnelConfig,\n+ local_mesh: Option<IpAddr>,\n+ ) -> Result<(), Error> {\nself.run_command(\n\"wg\",\n&[\n@@ -127,6 +131,26 @@ impl dyn KernelInterface {\n}\n}\n+ // If wg_exit does not have a link local addr, set one up\n+ if self.get_link_local_device_ip(\"wg_exit\").is_err() {\n+ if let Some(mesh) = local_mesh {\n+ if let Err(e) = self.run_command(\n+ \"ip\",\n+ &[\n+ \"address\",\n+ \"add\",\n+ &format!(\"{}/64\", to_wg_local(&mesh)),\n+ \"dev\",\n+ \"wg_exit\",\n+ ],\n+ ) {\n+ error!(\"IPV6 ERROR: Unable to set link local for wg_exit: {:?}\", e);\n+ }\n+ } else {\n+ error!(\"IPV6 ERRROR: No mesh ip, unable to set link local for wg_exit\");\n+ }\n+ }\n+\nlet output = self.run_command(\"ip\", &[\"link\", \"set\", \"dev\", \"wg_exit\", \"mtu\", \"1340\"])?;\nif !output.stderr.is_empty() {\nreturn Err(Error::RuntimeError(format!(\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/exit_manager/mod.rs", "new_path": "rita_client/src/exit_manager/mod.rs", "diff": "@@ -135,6 +135,8 @@ fn linux_setup_exit_tunnel(\n) -> Result<(), RitaClientError> {\nlet mut rita_client = settings::get_rita_client();\nlet mut network = rita_client.network;\n+ let local_mesh_ip = network.mesh_ip;\n+\n// TODO this should be refactored to return a value\nKI.update_settings_route(&mut network.last_default_route);\n@@ -159,7 +161,7 @@ fn linux_setup_exit_tunnel(\nrita_client.network = network;\nsettings::set_rita_client(rita_client);\n- KI.set_client_exit_tunnel_config(args)?;\n+ KI.set_client_exit_tunnel_config(args, local_mesh_ip)?;\nKI.set_route_to_tunnel(&general_details.server_internal_ip)?;\nKI.create_client_nat_rules()?;\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Automatically copy an fe80 address to the wg_exit interface on the client side
20,255
08.06.2022 15:01:11
25,200
8fe198f73f3620e50334e7729ea4a83f6717eb8e
Added default ipv6 route on the client through wg_exit
[ { "change_type": "MODIFY", "old_path": "althea_kernel_interface/src/exit_client_tunnel.rs", "new_path": "althea_kernel_interface/src/exit_client_tunnel.rs", "diff": "@@ -200,6 +200,34 @@ impl dyn KernelInterface {\nOk(())\n}\n+ pub fn set_ipv6_route_to_tunnel(&self) -> Result<(), Error> {\n+\n+ // Remove current default route\n+ if let Err(e) = self.run_command(\"ip\", &[\"-6\", \"route\", \"del\", \"default\"]) {\n+ warn!(\"Failed to delete default ip6 route {:?}\", e);\n+ }\n+ // Set new default route\n+ let output = self.run_command(\n+ \"ip\",\n+ &[\n+ \"-6\",\n+ \"route\",\n+ \"add\",\n+ \"default\",\n+ \"dev\",\n+ \"wg_exit\",\n+ ],\n+ )?;\n+ if !output.stderr.is_empty() {\n+ error!(\"IPV6 ERROR: Unable to set ip -6 default route\");\n+ return Err(Error::RuntimeError(format!(\n+ \"received error setting ip -6 route: {}\",\n+ String::from_utf8(output.stderr)?\n+ )));\n+ }\n+ Ok(())\n+ }\n+\n/// Adds nat rules for lan client, these act within the structure\n/// of the openwrt rules which themselves create a few requirements\n/// (such as saying that zone-lan-forward shoul jump to the accept table)\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/exit_manager/mod.rs", "new_path": "rita_client/src/exit_manager/mod.rs", "diff": "@@ -146,7 +146,7 @@ fn linux_setup_exit_tunnel(\nlet args = ClientExitTunnelConfig {\nendpoint: SocketAddr::new(\n- get_selected_exit(exit).expect(\"There should be an exit ip here\"),\n+ get_selected_exit(exit.clone()).expect(\"There should be an exit ip here\"),\ngeneral_details.wg_exit_port,\n),\npubkey: current_exit.wg_public_key,\n@@ -163,6 +163,7 @@ fn linux_setup_exit_tunnel(\nKI.set_client_exit_tunnel_config(args, local_mesh_ip)?;\nKI.set_route_to_tunnel(&general_details.server_internal_ip)?;\n+ KI.set_ipv6_route_to_tunnel()?;\nKI.create_client_nat_rules()?;\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Added default ipv6 route on the client through wg_exit
20,255
13.06.2022 14:08:37
25,200
5510b41099b3ff104382b11d6b4caf9f2e43eb6b
Fixed CI division by zero edge case
[ { "change_type": "MODIFY", "old_path": "althea_kernel_interface/src/exit_client_tunnel.rs", "new_path": "althea_kernel_interface/src/exit_client_tunnel.rs", "diff": "@@ -201,23 +201,13 @@ impl dyn KernelInterface {\n}\npub fn set_ipv6_route_to_tunnel(&self) -> Result<(), Error> {\n-\n// Remove current default route\nif let Err(e) = self.run_command(\"ip\", &[\"-6\", \"route\", \"del\", \"default\"]) {\nwarn!(\"Failed to delete default ip6 route {:?}\", e);\n}\n// Set new default route\n- let output = self.run_command(\n- \"ip\",\n- &[\n- \"-6\",\n- \"route\",\n- \"add\",\n- \"default\",\n- \"dev\",\n- \"wg_exit\",\n- ],\n- )?;\n+ let output =\n+ self.run_command(\"ip\", &[\"-6\", \"route\", \"add\", \"default\", \"dev\", \"wg_exit\"])?;\nif !output.stderr.is_empty() {\nerror!(\"IPV6 ERROR: Unable to set ip -6 default route\");\nreturn Err(Error::RuntimeError(format!(\n" }, { "change_type": "MODIFY", "old_path": "integration-tests/integration-test-script/world.py", "new_path": "integration-tests/integration-test-script/world.py", "diff": "@@ -448,8 +448,12 @@ class World:\nnode.id, intended_debts[node][owed], owed.id))\ncontinue\nif not fuzzy_match(debts[node.id][owed.id], intended_debts[node][owed]):\n+ if debts[node.id][owed.id] != 0:\nprint(\"{} has a predicted debt of {} for {} but actual debt is {} {:.2%} accurate\".format(\nnode.id, intended_debts[node][owed], owed.id, debts[node.id][owed.id], intended_debts[node][owed]/debts[node.id][owed.id]))\n+ else:\n+ print(\"{} has a predicted debt of {} for {} but actual debt is {}\".format(\n+ node.id, intended_debts[node][owed], owed.id, debts[node.id][owed.id]))\n# exit(1)\ndef get_best_route(self, all_routes, from_node, target_node):\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Fixed CI division by zero edge case
20,244
23.06.2022 16:47:59
14,400
5c90639bf694f7a5411ad6de8c71147e1530e385
Use sys instead of regex for ifindex Previously we where getting the interface index using a regex. This is not at all needed as the info is easy to access in the linux /sys/ interface.
[ { "change_type": "MODIFY", "old_path": "althea_kernel_interface/src/interface_tools.rs", "new_path": "althea_kernel_interface/src/interface_tools.rs", "diff": "@@ -136,6 +136,16 @@ impl dyn KernelInterface {\n}\n}\n+ /// Gets the ifidx from an interface\n+ pub fn get_ifidx(&self, if_name: &str) -> Result<usize, Error> {\n+ let lines = get_lines(&format!(\"/sys/class/net/{}/ifindex\", if_name))?;\n+ if let Some(ifindex) = lines.get(0) {\n+ Ok(ifindex.parse()?)\n+ } else {\n+ Err(Error::NoInterfaceError(if_name.to_string()))\n+ }\n+ }\n+\n/// Sets the mtu of an interface\npub fn set_mtu(&self, if_name: &str, mtu: usize) -> Result<(), Error> {\nlet output = self.run_command(\n" }, { "change_type": "MODIFY", "old_path": "althea_kernel_interface/src/link_local_tools.rs", "new_path": "althea_kernel_interface/src/link_local_tools.rs", "diff": "@@ -120,24 +120,6 @@ impl dyn KernelInterface {\n))\n}\n}\n- /// Returns the ifidx of the provided interface\n- pub fn get_iface_index(&self, name: &str) -> Result<u32, KernelInterfaceError> {\n- let links = String::from_utf8(self.run_command(\"ip\", &[\"link\"])?.stdout)?;\n-\n- lazy_static! {\n- static ref RE: Regex =\n- Regex::new(r\"([0-9]+): (.*?)(:|@)\").expect(\"Unable to compile regular expression\");\n- }\n-\n- for caps in RE.captures_iter(&links) {\n- if name == &caps[2] {\n- return Ok(caps[1].parse()?);\n- }\n- }\n- Err(KernelInterfaceError::RuntimeError(\n- \"Interface not found\".to_string(),\n- ))\n- }\n}\n#[test]\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/peer_listener/mod.rs", "new_path": "rita_common/src/peer_listener/mod.rs", "diff": "@@ -171,7 +171,7 @@ impl ListenInterface {\nlet link_ip = KI.get_link_local_device_ip(ifname)?;\n// Lookup interface index\n- let iface_index = KI.get_iface_index(ifname).unwrap_or(0);\n+ let iface_index = KI.get_ifidx(ifname).unwrap_or(0) as u32;\n// Bond to multicast discovery address on each listen port\nlet multicast_socketaddr = SocketAddrV6::new(disc_ip, port, 0, iface_index);\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Use sys instead of regex for ifindex Previously we where getting the interface index using a regex. This is not at all needed as the info is easy to access in the linux /sys/ interface.
20,244
23.06.2022 18:55:41
14,400
28669b13c6416bf10028291fee7df99db7924e68
Make mtu setting DSA aware This patch makes mtu changes dsa aware by adding a function to use the iflink value to lookup the ifindex of the parent interface. If a parent interface exists it's mtu is also bumped as appropriate.
[ { "change_type": "MODIFY", "old_path": "althea_kernel_interface/src/interface_tools.rs", "new_path": "althea_kernel_interface/src/interface_tools.rs", "diff": "@@ -24,6 +24,16 @@ impl dyn KernelInterface {\nOk(vec)\n}\n+ pub fn ifindex_to_interface_name(&self, ifindex: usize) -> Result<String, Error> {\n+ for interface in self.get_interfaces()? {\n+ let found_ifindex = self.get_ifindex(&interface)?;\n+ if ifindex == found_ifindex {\n+ return Ok(interface);\n+ }\n+ }\n+ Err(Error::NoInterfaceError(ifindex.to_string()))\n+ }\n+\n/// Deletes an named interface\npub fn del_interface(&self, name: &str) -> Result<(), Error> {\nself.run_command(\"ip\", &[\"link\", \"del\", \"dev\", name])?;\n@@ -136,8 +146,8 @@ impl dyn KernelInterface {\n}\n}\n- /// Gets the ifidx from an interface\n- pub fn get_ifidx(&self, if_name: &str) -> Result<usize, Error> {\n+ /// Gets the ifindex from an interface\n+ pub fn get_ifindex(&self, if_name: &str) -> Result<usize, Error> {\nlet lines = get_lines(&format!(\"/sys/class/net/{}/ifindex\", if_name))?;\nif let Some(ifindex) = lines.get(0) {\nOk(ifindex.parse()?)\n@@ -146,8 +156,31 @@ impl dyn KernelInterface {\n}\n}\n- /// Sets the mtu of an interface\n+ /// Gets the iflink value from an interface. Physical interfaces have an ifindex and iflink that are\n+ /// identical but if you have a virtual (say DSA) interface then this will be the physical interface name\n+ pub fn get_iflink(&self, if_name: &str) -> Result<usize, Error> {\n+ let lines = get_lines(&format!(\"/sys/class/net/{}/iflink\", if_name))?;\n+ if let Some(iflink) = lines.get(0) {\n+ Ok(iflink.parse()?)\n+ } else {\n+ Err(Error::NoInterfaceError(if_name.to_string()))\n+ }\n+ }\n+\n+ /// Sets the mtu of an interface, if this interface is a DSA interface the\n+ /// parent interface will be located and it's mtu increased as appropriate\npub fn set_mtu(&self, if_name: &str, mtu: usize) -> Result<(), Error> {\n+ let ifindex = self.get_ifindex(if_name)?;\n+ let iflink = self.get_iflink(if_name)?;\n+ // dsa interface detected, this is an interface controlled by an internal switch\n+ // the parent interface (which has the ifindex value represented in iflink for the child interface)\n+ // needs to have whatever the mtu is, plus room for VLAN headers\n+ const DSA_VLAN_HEADER_SIZE: usize = 8;\n+ if ifindex != iflink {\n+ let parent_if_name = self.ifindex_to_interface_name(iflink)?;\n+ self.set_mtu(&parent_if_name, mtu + DSA_VLAN_HEADER_SIZE)?;\n+ }\n+\nlet output = self.run_command(\n\"ip\",\n&[\"link\", \"set\", \"dev\", if_name, \"mtu\", &mtu.to_string()],\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/peer_listener/mod.rs", "new_path": "rita_common/src/peer_listener/mod.rs", "diff": "@@ -171,7 +171,7 @@ impl ListenInterface {\nlet link_ip = KI.get_link_local_device_ip(ifname)?;\n// Lookup interface index\n- let iface_index = KI.get_ifidx(ifname).unwrap_or(0) as u32;\n+ let iface_index = KI.get_ifindex(ifname).unwrap_or(0) as u32;\n// Bond to multicast discovery address on each listen port\nlet multicast_socketaddr = SocketAddrV6::new(disc_ip, port, 0, iface_index);\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Make mtu setting DSA aware This patch makes mtu changes dsa aware by adding a function to use the iflink value to lookup the ifindex of the parent interface. If a parent interface exists it's mtu is also bumped as appropriate.
20,244
23.06.2022 19:19:34
14,400
275dfe57bc0bac13affa0aef867196167555f947
Use /sys/ for get_interfaces() This makes the get_interfaces() function in kernel inteface much easier by using native linux /sys/ properties rather than building a regex and parsing the output of 'ip'
[ { "change_type": "MODIFY", "old_path": "althea_kernel_interface/src/interface_tools.rs", "new_path": "althea_kernel_interface/src/interface_tools.rs", "diff": "@@ -2,22 +2,24 @@ use crate::file_io::get_lines;\nuse crate::KernelInterface;\nuse crate::KernelInterfaceError as Error;\nuse regex::Regex;\n+use std::fs::read_dir;\nuse std::net::IpAddr;\nuse std::str::from_utf8;\nimpl dyn KernelInterface {\n/// Returns all existing interfaces\npub fn get_interfaces(&self) -> Result<Vec<String>, Error> {\n- let links = String::from_utf8(self.run_command(\"ip\", &[\"link\"])?.stdout)?;\n+ let links = read_dir(\"/sys/class/net/\")?;\nlet mut vec = Vec::new();\n-\n- lazy_static! {\n- static ref RE: Regex =\n- Regex::new(r\"[0-9]+: (.*?)(:|@)\").expect(\"Unable to compile regular expression\");\n+ for dir in links {\n+ let dir = dir?;\n+ if dir.path().is_dir() {\n+ // this could fail if the interface contains any characters\n+ // not allowed in unicode. I don't think the kernel allows\n+ // this in the first place\n+ vec.push(dir.file_name().to_str().unwrap().to_string());\n}\n- for caps in RE.captures_iter(&links) {\n- vec.push(String::from(&caps[1]));\n}\ntrace!(\"interfaces: {:?}\", vec);\n@@ -196,42 +198,6 @@ impl dyn KernelInterface {\n}\n}\n-#[test]\n-fn test_get_interfaces_linux() {\n- use crate::KI;\n-\n- use std::os::unix::process::ExitStatusExt;\n- use std::process::ExitStatus;\n- use std::process::Output;\n-\n- KI.set_mock(Box::new(move |program, args| {\n- assert_eq!(program, \"ip\");\n- assert_eq!(args, &[\"link\"]);\n-\n- Ok(Output {\n- stdout: b\"\n- 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000\n- link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00\n-2: dummy: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000\n- link/ether 22:8a:b6:9e:2d:1e brd ff:ff:ff:ff:ff:ff\n-3: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000\n- link/none\n-2843: veth-1-6@if2842: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc netem state UP mode DEFAULT group default qlen 1000\n- link/ether 76:d1:f5:3d:32:53 brd ff:ff:ff:ff:ff:ff link-netnsid 1\"\n- .to_vec(),\n- stderr: b\"\".to_vec(),\n- status: ExitStatus::from_raw(0),\n- })\n- }));\n-\n- let interfaces = KI.get_interfaces().unwrap();\n-\n- assert_eq!(interfaces[0].to_string(), \"lo\");\n- assert_eq!(interfaces[1].to_string(), \"dummy\");\n- assert_eq!(interfaces[2].to_string(), \"wg0\");\n- assert_eq!(interfaces[3].to_string(), \"veth-1-6\");\n-}\n-\n#[test]\nfn test_get_wg_remote_ip() {\nuse crate::KI;\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Use /sys/ for get_interfaces() This makes the get_interfaces() function in kernel inteface much easier by using native linux /sys/ properties rather than building a regex and parsing the output of 'ip'
20,244
23.06.2022 19:53:54
14,400
5b85dd6640556cbbb6a95edea174dff2886035b3
Bump for Beta 20 rc1
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -2620,7 +2620,7 @@ dependencies = [\n[[package]]\nname = \"rita_bin\"\n-version = \"0.19.11\"\n+version = \"0.20.1\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n@@ -2653,7 +2653,7 @@ dependencies = [\n[[package]]\nname = \"rita_client\"\n-version = \"0.19.11\"\n+version = \"0.20.1\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n@@ -2688,7 +2688,7 @@ dependencies = [\n[[package]]\nname = \"rita_common\"\n-version = \"0.19.11\"\n+version = \"0.20.1\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-service\",\n@@ -2726,7 +2726,7 @@ dependencies = [\n[[package]]\nname = \"rita_exit\"\n-version = \"0.19.11\"\n+version = \"0.20.1\"\ndependencies = [\n\"actix 0.13.0\",\n\"actix-web\",\n" }, { "change_type": "MODIFY", "old_path": "rita_bin/Cargo.toml", "new_path": "rita_bin/Cargo.toml", "diff": "[package]\nname = \"rita_bin\"\n-version = \"0.19.11\"\n+version = \"0.20.1\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\nbuild = \"build.rs\"\n" }, { "change_type": "MODIFY", "old_path": "rita_client/Cargo.toml", "new_path": "rita_client/Cargo.toml", "diff": "[package]\nname = \"rita_client\"\n-version = \"0.19.11\"\n+version = \"0.20.1\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" }, { "change_type": "MODIFY", "old_path": "rita_common/Cargo.toml", "new_path": "rita_common/Cargo.toml", "diff": "[package]\nname = \"rita_common\"\n-version = \"0.19.11\"\n+version = \"0.20.1\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/dashboard/own_info.rs", "new_path": "rita_common/src/dashboard/own_info.rs", "diff": "@@ -6,7 +6,7 @@ use actix_web_async::HttpResponse;\nuse clarity::Address;\nuse num256::{Int256, Uint256};\n-pub static READABLE_VERSION: &str = \"Beta 19 RC11\";\n+pub static READABLE_VERSION: &str = \"Beta 20 RC1\";\n#[derive(Serialize)]\npub struct OwnInfo {\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/Cargo.toml", "new_path": "rita_exit/Cargo.toml", "diff": "[package]\nname = \"rita_exit\"\n-version = \"0.19.11\"\n+version = \"0.20.1\"\nedition = \"2018\"\nlicense = \"Apache-2.0\"\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Bump for Beta 20 rc1
20,244
23.06.2022 20:03:52
14,400
7275b5a22069d64c6e642f9d2c713df92bdbc4d5
Bump web30, ipnetwork and awc deps Plus transitive deps via cargo.lock
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -69,9 +69,9 @@ dependencies = [\n[[package]]\nname = \"actix-http\"\n-version = \"3.0.4\"\n+version = \"3.1.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"a5885cb81a0d4d0d322864bea1bb6c2a8144626b4fdc625d4c51eba197e7797a\"\n+checksum = \"bd2e9f6794b5826aff6df65e3a0d0127b271d1c03629c774238f3582e903d4e4\"\ndependencies = [\n\"actix-codec\",\n\"actix-rt\",\n@@ -95,13 +95,13 @@ dependencies = [\n\"itoa\",\n\"language-tags\",\n\"local-channel\",\n- \"log\",\n\"mime\",\n\"percent-encoding\",\n\"pin-project-lite\",\n\"rand 0.8.5\",\n- \"sha-1 0.10.0\",\n+ \"sha1\",\n\"smallvec\",\n+ \"tracing\",\n\"zstd\",\n]\n@@ -189,9 +189,9 @@ dependencies = [\n[[package]]\nname = \"actix-web\"\n-version = \"4.0.1\"\n+version = \"4.1.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"f4e5ebffd51d50df56a3ae0de0e59487340ca456f05dd0b90c0a7a6dd6a74d31\"\n+checksum = \"a27e8fe9ba4ae613c21f677c2cfaf0696c3744030c6f485b34634e502d6bb379\"\ndependencies = [\n\"actix-codec\",\n\"actix-http\",\n@@ -221,7 +221,7 @@ dependencies = [\n\"serde_urlencoded\",\n\"smallvec\",\n\"socket2\",\n- \"time 0.3.9\",\n+ \"time 0.3.11\",\n\"url\",\n]\n@@ -306,7 +306,7 @@ name = \"althea_kernel_interface\"\nversion = \"0.1.0\"\ndependencies = [\n\"althea_types\",\n- \"ipnetwork 0.18.0\",\n+ \"ipnetwork 0.19.0\",\n\"itertools 0.10.3\",\n\"lazy_static\",\n\"log\",\n@@ -329,7 +329,7 @@ dependencies = [\n\"base64 0.13.0\",\n\"clarity\",\n\"hex\",\n- \"ipnetwork 0.18.0\",\n+ \"ipnetwork 0.19.0\",\n\"lettre\",\n\"num256\",\n\"phonenumber\",\n@@ -484,7 +484,7 @@ version = \"0.1.0\"\ndependencies = [\n\"ascii\",\n\"env_logger\",\n- \"ipnetwork 0.18.0\",\n+ \"ipnetwork 0.19.0\",\n\"log\",\n\"serde 1.0.137\",\n\"serde_derive\",\n@@ -635,9 +635,9 @@ checksum = \"c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8\"\n[[package]]\nname = \"bytestring\"\n-version = \"1.0.0\"\n+version = \"1.1.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"90706ba19e97b90786e19dc0d5e2abd80008d99d4c0c5d1ad0b5e72cec7c494d\"\n+checksum = \"86b6a75fd3048808ef06af5cd79712be8111960adaf89d90250974b38fc3928a\"\ndependencies = [\n\"bytes\",\n]\n@@ -672,7 +672,7 @@ dependencies = [\n\"libc\",\n\"num-integer\",\n\"num-traits 0.2.15\",\n- \"time 0.1.43\",\n+ \"time 0.1.44\",\n\"winapi 0.3.9\",\n]\n@@ -771,7 +771,7 @@ source = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"94d4706de1b0fa5b132270cddffa8585166037822e260a944fe161acd137ca05\"\ndependencies = [\n\"percent-encoding\",\n- \"time 0.3.9\",\n+ \"time 0.3.11\",\n\"version_check 0.9.4\",\n]\n@@ -811,9 +811,9 @@ dependencies = [\n[[package]]\nname = \"crossbeam-channel\"\n-version = \"0.5.4\"\n+version = \"0.5.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53\"\n+checksum = \"4c02a4d71819009c192cf4872265391563fd6a84c81ff2c0f2a7026ca4c1d85c\"\ndependencies = [\n\"cfg-if\",\n\"crossbeam-utils\",\n@@ -821,12 +821,12 @@ dependencies = [\n[[package]]\nname = \"crossbeam-utils\"\n-version = \"0.8.8\"\n+version = \"0.8.10\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38\"\n+checksum = \"7d82ee10ce34d7bc12c2122495e7593a9c41347ecdd64185af4ecf72cb1a7f83\"\ndependencies = [\n\"cfg-if\",\n- \"lazy_static\",\n+ \"once_cell\",\n]\n[[package]]\n@@ -968,7 +968,7 @@ dependencies = [\n\"encoding\",\n\"lazy_static\",\n\"rand 0.4.6\",\n- \"time 0.1.43\",\n+ \"time 0.1.44\",\n\"version_check 0.1.5\",\n]\n@@ -1309,13 +1309,13 @@ dependencies = [\n[[package]]\nname = \"getrandom\"\n-version = \"0.2.6\"\n+version = \"0.2.7\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad\"\n+checksum = \"4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6\"\ndependencies = [\n\"cfg-if\",\n\"libc\",\n- \"wasi 0.10.2+wasi-snapshot-preview1\",\n+ \"wasi 0.11.0+wasi-snapshot-preview1\",\n]\n[[package]]\n@@ -1359,9 +1359,9 @@ dependencies = [\n[[package]]\nname = \"hashbrown\"\n-version = \"0.11.2\"\n+version = \"0.12.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e\"\n+checksum = \"db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3\"\n[[package]]\nname = \"hermit-abi\"\n@@ -1484,9 +1484,9 @@ dependencies = [\n[[package]]\nname = \"indexmap\"\n-version = \"1.8.2\"\n+version = \"1.9.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a\"\n+checksum = \"10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e\"\ndependencies = [\n\"autocfg 1.1.0\",\n\"hashbrown\",\n@@ -1539,9 +1539,9 @@ checksum = \"02c3eaab3ac0ede60ffa41add21970a7df7d91772c03383aac6c2c3d53cc716b\"\n[[package]]\nname = \"ipnetwork\"\n-version = \"0.18.0\"\n+version = \"0.19.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"4088d739b183546b239688ddbc79891831df421773df95e236daf7867866d355\"\n+checksum = \"1f84f1612606f3753f205a4e9a2efd6fe5b4c573a6269b2cc6c3003d44a0d127\"\ndependencies = [\n\"serde 1.0.137\",\n]\n@@ -1602,9 +1602,9 @@ dependencies = [\n[[package]]\nname = \"js-sys\"\n-version = \"0.3.57\"\n+version = \"0.3.58\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"671a26f820db17c2a2750743f1dd03bafd15b98c9f30c7c2628c024c05d73397\"\n+checksum = \"c3fac17f7123a73ca62df411b1bf727ccc805daa070338fda671c86dac1bdc27\"\ndependencies = [\n\"wasm-bindgen\",\n]\n@@ -1655,7 +1655,7 @@ dependencies = [\n\"email\",\n\"lettre\",\n\"mime\",\n- \"time 0.1.43\",\n+ \"time 0.1.44\",\n\"uuid\",\n]\n@@ -1777,9 +1777,9 @@ dependencies = [\n[[package]]\nname = \"mio\"\n-version = \"0.8.3\"\n+version = \"0.8.4\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"713d550d9b44d89174e066b7a6217ae06234c10cb47819a88290d2b353c31799\"\n+checksum = \"57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf\"\ndependencies = [\n\"libc\",\n\"log\",\n@@ -1872,10 +1872,10 @@ source = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606\"\ndependencies = [\n\"num-bigint 0.4.3\",\n- \"num-complex 0.4.1\",\n+ \"num-complex 0.4.2\",\n\"num-integer\",\n\"num-iter\",\n- \"num-rational 0.4.0\",\n+ \"num-rational 0.4.1\",\n\"num-traits 0.2.15\",\n]\n@@ -1936,9 +1936,9 @@ dependencies = [\n[[package]]\nname = \"num-complex\"\n-version = \"0.4.1\"\n+version = \"0.4.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"97fbc387afefefd5e9e39493299f3069e14a140dd34dc19b4c1c1a8fddb6a790\"\n+checksum = \"7ae39348c8bc5fbd7f40c727a9925f03517afd2ab27d46702108b6a7e5414c19\"\ndependencies = [\n\"num-traits 0.2.15\",\n]\n@@ -2001,9 +2001,9 @@ dependencies = [\n[[package]]\nname = \"num-rational\"\n-version = \"0.4.0\"\n+version = \"0.4.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a\"\n+checksum = \"0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0\"\ndependencies = [\n\"autocfg 1.1.0\",\n\"num-bigint 0.4.3\",\n@@ -2120,9 +2120,9 @@ checksum = \"ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf\"\n[[package]]\nname = \"openssl-src\"\n-version = \"111.20.0+1.1.1o\"\n+version = \"111.21.0+1.1.1p\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"92892c4f87d56e376e469ace79f1128fdaded07646ddf73aa0be4706ff712dec\"\n+checksum = \"6d0a8313729211913936f1b95ca47a5fc7f2e04cd658c115388287f8a8361008\"\ndependencies = [\n\"cc\",\n]\n@@ -2261,7 +2261,7 @@ checksum = \"54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d\"\ndependencies = [\n\"maplit\",\n\"pest\",\n- \"sha-1 0.8.2\",\n+ \"sha-1\",\n]\n[[package]]\n@@ -2319,9 +2319,9 @@ dependencies = [\n[[package]]\nname = \"proc-macro2\"\n-version = \"1.0.39\"\n+version = \"1.0.40\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f\"\n+checksum = \"dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7\"\ndependencies = [\n\"unicode-ident\",\n]\n@@ -2337,21 +2337,21 @@ dependencies = [\n[[package]]\nname = \"quote\"\n-version = \"1.0.18\"\n+version = \"1.0.20\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1\"\n+checksum = \"3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804\"\ndependencies = [\n\"proc-macro2\",\n]\n[[package]]\nname = \"r2d2\"\n-version = \"0.8.9\"\n+version = \"0.8.10\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"545c5bc2b880973c9c10e4067418407a0ccaa3091781d1671d46eb35107cb26f\"\n+checksum = \"51de85fb3fb6524929c8a2eb85e6b6d363de4e8c48f9e2c2eac4944abc181c93\"\ndependencies = [\n\"log\",\n- \"parking_lot 0.11.2\",\n+ \"parking_lot 0.12.1\",\n\"scheduled-thread-pool\",\n]\n@@ -2584,9 +2584,9 @@ dependencies = [\n[[package]]\nname = \"reqwest\"\n-version = \"0.11.10\"\n+version = \"0.11.11\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"46a1f7aa4f35e5e8b4160449f51afc758f0ce6454315a9fa7d0d113e958c41eb\"\n+checksum = \"b75aa69a3f06bbcc66ede33af2af253c6f7a86b1ca0033f60c580a27074fbf92\"\ndependencies = [\n\"base64 0.13.0\",\n\"bytes\",\n@@ -2611,6 +2611,7 @@ dependencies = [\n\"serde_urlencoded\",\n\"tokio\",\n\"tokio-native-tls\",\n+ \"tower-service\",\n\"url\",\n\"wasm-bindgen\",\n\"wasm-bindgen-futures\",\n@@ -2668,7 +2669,7 @@ dependencies = [\n\"clu\",\n\"compressed_log\",\n\"hex-literal\",\n- \"ipnetwork 0.18.0\",\n+ \"ipnetwork 0.19.0\",\n\"lazy_static\",\n\"lettre\",\n\"lettre_email\",\n@@ -2709,7 +2710,7 @@ dependencies = [\n\"flate2\",\n\"futures 0.3.21\",\n\"hex-literal\",\n- \"ipnetwork 0.18.0\",\n+ \"ipnetwork 0.19.0\",\n\"lazy_static\",\n\"log\",\n\"num-traits 0.2.15\",\n@@ -2741,7 +2742,7 @@ dependencies = [\n\"exit_db\",\n\"handlebars\",\n\"ipaddress\",\n- \"ipnetwork 0.18.0\",\n+ \"ipnetwork 0.19.0\",\n\"lazy_static\",\n\"lettre\",\n\"lettre_email\",\n@@ -2869,9 +2870,9 @@ dependencies = [\n[[package]]\nname = \"semver\"\n-version = \"1.0.9\"\n+version = \"1.0.10\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"8cb243bdfdb5936c8dc3c45762a19d12ab4550cdc753bc247637d4ec35a040fd\"\n+checksum = \"a41d061efea015927ac527063765e73601444cdc344ba855bc7bd44578b25e1c\"\n[[package]]\nname = \"serde\"\n@@ -2975,7 +2976,7 @@ dependencies = [\n\"auto-bridge\",\n\"clarity\",\n\"config\",\n- \"ipnetwork 0.18.0\",\n+ \"ipnetwork 0.19.0\",\n\"lazy_static\",\n\"log\",\n\"num256\",\n@@ -3000,10 +3001,10 @@ dependencies = [\n]\n[[package]]\n-name = \"sha-1\"\n-version = \"0.10.0\"\n+name = \"sha1\"\n+version = \"0.10.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f\"\n+checksum = \"c77f4e7f65455545c2153c1253d25056825e77ee2533f0e41deb65a93a34852f\"\ndependencies = [\n\"cfg-if\",\n\"cpufeatures\",\n@@ -3095,9 +3096,9 @@ checksum = \"6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601\"\n[[package]]\nname = \"syn\"\n-version = \"1.0.96\"\n+version = \"1.0.98\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf\"\n+checksum = \"c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd\"\ndependencies = [\n\"proc-macro2\",\n\"quote\",\n@@ -3158,19 +3159,20 @@ dependencies = [\n[[package]]\nname = \"time\"\n-version = \"0.1.43\"\n+version = \"0.1.44\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438\"\n+checksum = \"6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255\"\ndependencies = [\n\"libc\",\n+ \"wasi 0.10.0+wasi-snapshot-preview1\",\n\"winapi 0.3.9\",\n]\n[[package]]\nname = \"time\"\n-version = \"0.3.9\"\n+version = \"0.3.11\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"c2702e08a7a860f005826c6815dcac101b19b5eb330c27fe4a5928fec1d20ddd\"\n+checksum = \"72c91f41dcb2f096c05f0873d667dceec1087ce5bcf984ec8ffb19acddbb3217\"\ndependencies = [\n\"itoa\",\n\"libc\",\n@@ -3291,9 +3293,9 @@ dependencies = [\n[[package]]\nname = \"tower-service\"\n-version = \"0.3.1\"\n+version = \"0.3.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6\"\n+checksum = \"b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52\"\n[[package]]\nname = \"tracing\"\n@@ -3360,9 +3362,9 @@ checksum = \"099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992\"\n[[package]]\nname = \"unicode-ident\"\n-version = \"1.0.0\"\n+version = \"1.0.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee\"\n+checksum = \"5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c\"\n[[package]]\nname = \"unicode-normalization\"\n@@ -3441,9 +3443,9 @@ dependencies = [\n[[package]]\nname = \"wasi\"\n-version = \"0.10.2+wasi-snapshot-preview1\"\n+version = \"0.10.0+wasi-snapshot-preview1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6\"\n+checksum = \"1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f\"\n[[package]]\nname = \"wasi\"\n@@ -3453,9 +3455,9 @@ checksum = \"9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423\"\n[[package]]\nname = \"wasm-bindgen\"\n-version = \"0.2.80\"\n+version = \"0.2.81\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad\"\n+checksum = \"7c53b543413a17a202f4be280a7e5c62a1c69345f5de525ee64f8cfdbc954994\"\ndependencies = [\n\"cfg-if\",\n\"wasm-bindgen-macro\",\n@@ -3463,9 +3465,9 @@ dependencies = [\n[[package]]\nname = \"wasm-bindgen-backend\"\n-version = \"0.2.80\"\n+version = \"0.2.81\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4\"\n+checksum = \"5491a68ab4500fa6b4d726bd67408630c3dbe9c4fe7bda16d5c82a1fd8c7340a\"\ndependencies = [\n\"bumpalo\",\n\"lazy_static\",\n@@ -3478,9 +3480,9 @@ dependencies = [\n[[package]]\nname = \"wasm-bindgen-futures\"\n-version = \"0.4.30\"\n+version = \"0.4.31\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"6f741de44b75e14c35df886aff5f1eb73aa114fa5d4d00dcd37b5e01259bf3b2\"\n+checksum = \"de9a9cec1733468a8c657e57fa2413d2ae2c0129b95e87c5b72b8ace4d13f31f\"\ndependencies = [\n\"cfg-if\",\n\"js-sys\",\n@@ -3490,9 +3492,9 @@ dependencies = [\n[[package]]\nname = \"wasm-bindgen-macro\"\n-version = \"0.2.80\"\n+version = \"0.2.81\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5\"\n+checksum = \"c441e177922bc58f1e12c022624b6216378e5febc2f0533e41ba443d505b80aa\"\ndependencies = [\n\"quote\",\n\"wasm-bindgen-macro-support\",\n@@ -3500,9 +3502,9 @@ dependencies = [\n[[package]]\nname = \"wasm-bindgen-macro-support\"\n-version = \"0.2.80\"\n+version = \"0.2.81\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b\"\n+checksum = \"7d94ac45fcf608c1f45ef53e748d35660f168490c10b23704c7779ab8f5c3048\"\ndependencies = [\n\"proc-macro2\",\n\"quote\",\n@@ -3513,15 +3515,15 @@ dependencies = [\n[[package]]\nname = \"wasm-bindgen-shared\"\n-version = \"0.2.80\"\n+version = \"0.2.81\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744\"\n+checksum = \"6a89911bd99e5f3659ec4acf9c4d93b0a90fe4a2a11f15328472058edc5261be\"\n[[package]]\nname = \"web-sys\"\n-version = \"0.3.57\"\n+version = \"0.3.58\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"7b17e741662c70c8bd24ac5c5b18de314a2c26c32bf8346ee1e6f53de919c283\"\n+checksum = \"2fed94beee57daf8dd7d51f2b15dc2bcde92d7a72304cdf662a4371008b71b90\"\ndependencies = [\n\"js-sys\",\n\"wasm-bindgen\",\n@@ -3529,9 +3531,9 @@ dependencies = [\n[[package]]\nname = \"web30\"\n-version = \"0.18.12\"\n+version = \"0.19.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"f702c1d71d9487900e63732c1454062025e456ab6e41c77267a2dec5f4120b2f\"\n+checksum = \"463b0185237bb5c10abf6ce7a5923b03503aea0bb2ff5d9ad930d790e69c0cb0\"\ndependencies = [\n\"awc\",\n\"clarity\",\n@@ -3655,18 +3657,18 @@ dependencies = [\n[[package]]\nname = \"zstd\"\n-version = \"0.10.2+zstd.1.5.2\"\n+version = \"0.11.2+zstd.1.5.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"5f4a6bd64f22b5e3e94b4e238669ff9f10815c27a5180108b849d24174a83847\"\n+checksum = \"20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4\"\ndependencies = [\n\"zstd-safe\",\n]\n[[package]]\nname = \"zstd-safe\"\n-version = \"4.1.6+zstd.1.5.2\"\n+version = \"5.0.2+zstd.1.5.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"94b61c51bb270702d6167b8ce67340d2754b088d0c091b06e593aa772c3ee9bb\"\n+checksum = \"1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db\"\ndependencies = [\n\"libc\",\n\"zstd-sys\",\n@@ -3674,9 +3676,9 @@ dependencies = [\n[[package]]\nname = \"zstd-sys\"\n-version = \"1.6.3+zstd.1.5.2\"\n+version = \"2.0.1+zstd.1.5.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"fc49afa5c8d634e75761feda8c592051e7eeb4683ba827211eb0d731d3402ea8\"\n+checksum = \"9fd07cbbc53846d9145dbffdf6dd09a7a0aa52be46741825f5c97bdd4f73f12b\"\ndependencies = [\n\"cc\",\n\"libc\",\n" }, { "change_type": "MODIFY", "old_path": "althea_kernel_interface/Cargo.toml", "new_path": "althea_kernel_interface/Cargo.toml", "diff": "@@ -14,7 +14,7 @@ log = \"0.4\"\nserde_derive = \"1.0\"\nserde = \"1.0\"\nalthea_types = { path = \"../althea_types\" }\n-ipnetwork = \"0.18\"\n+ipnetwork = \"0.19\"\n[dependencies.regex]\nversion = \"1.4\"\n" }, { "change_type": "MODIFY", "old_path": "althea_types/Cargo.toml", "new_path": "althea_types/Cargo.toml", "diff": "@@ -19,7 +19,7 @@ clarity = \"0.5\"\narrayvec = {version= \"0.7\", features = [\"serde\"]}\nphonenumber = \"0.3\"\nlettre = {version = \"0.9\", features = [\"serde\"]}\n-ipnetwork = \"0.18\"\n+ipnetwork = \"0.19\"\n[dev-dependencies]\nrand = \"0.8\"\n" }, { "change_type": "MODIFY", "old_path": "auto_bridge/Cargo.toml", "new_path": "auto_bridge/Cargo.toml", "diff": "@@ -5,7 +5,7 @@ authors = [\"Jehan <jehan.tremback@gmail.com>, Justin <justin@althea.net>\"]\nedition = \"2018\"\n[dependencies]\n-web30 = \"0.18\"\n+web30 = \"0.19\"\nnum256 = \"0.3\"\nclarity = \"0.5\"\nrand = \"0.8\"\n" }, { "change_type": "MODIFY", "old_path": "auto_bridge/src/lib.rs", "new_path": "auto_bridge/src/lib.rs", "diff": "@@ -104,7 +104,7 @@ impl TokenBridge {\nlet own_address = self.own_address;\nlet tokens_bought = match web3\n- .get_uniswap_price(\n+ .get_uniswap_v3_price(\nown_address,\n*DAI_CONTRACT_ON_ETH,\n*WETH_CONTRACT_ADDRESS,\n@@ -128,7 +128,7 @@ impl TokenBridge {\nlet own_address = self.own_address;\nlet tokens_bought = match web3\n- .get_uniswap_price(\n+ .get_uniswap_v3_price(\nown_address,\n*WETH_CONTRACT_ADDRESS,\n*DAI_CONTRACT_ON_ETH,\n@@ -168,7 +168,7 @@ impl TokenBridge {\n// initiate swap with no sqrtPriceLimit\nlet tokens = match web3\n- .swap_uniswap_eth_in(\n+ .swap_uniswap_v3_eth_in(\nsecret,\n*DAI_CONTRACT_ON_ETH,\nNone,\n" }, { "change_type": "MODIFY", "old_path": "babel_monitor/Cargo.toml", "new_path": "babel_monitor/Cargo.toml", "diff": "@@ -7,7 +7,7 @@ edition = \"2018\"\n[dependencies]\nascii = \"1.0\"\nenv_logger = \"0.9\"\n-ipnetwork = \"0.18\"\n+ipnetwork = \"0.19\"\nlog = \"0.4\"\nserde = \"1.0\"\nserde_derive = \"1.0\"\n" }, { "change_type": "MODIFY", "old_path": "rita_client/Cargo.toml", "new_path": "rita_client/Cargo.toml", "diff": "@@ -28,9 +28,9 @@ babel_monitor = { path = \"../babel_monitor\" }\narrayvec = {version= \"0.7\", features = [\"serde\"]}\nsodiumoxide = \"0.2\"\nclu = { path = \"../clu\" }\n-web30 = \"0.18\"\n-awc = \"3.0.0-beta.21\"\n-ipnetwork = \"0.18\"\n+web30 = \"0.19\"\n+awc = \"3.0.0\"\n+ipnetwork = \"0.19\"\nactix-async = {package=\"actix\", version = \"0.13\"}\nactix-web-async = { package=\"actix-web\", version = \"4.0.1\", default_features = false, features= [\"openssl\"]}\nactix-web-httpauth-async = { package=\"actix-web-httpauth\", version = \"0.6.0\"}\n" }, { "change_type": "MODIFY", "old_path": "rita_common/Cargo.toml", "new_path": "rita_common/Cargo.toml", "diff": "@@ -6,7 +6,7 @@ license = \"Apache-2.0\"\n[dependencies]\nrand = \"0.8.0\"\n-ipnetwork = \"0.18\"\n+ipnetwork = \"0.19\"\nserde_derive = \"1.0\"\nhex-literal = \"0.3\"\ndocopt = \"1.1\"\n@@ -34,7 +34,7 @@ actix-web-httpauth-async = { package=\"actix-web-httpauth\", version = \"0.6.0\"}\nactix-web-async = { package=\"actix-web\", version = \"4.0.1\", default_features = false, features= [\"openssl\"]}\nawc = {version = \"3.0.0-beta.21\", default-features = false, features=[\"openssl\", \"compress-gzip\", \"compress-zstd\"]}\nactix-service = \"2.0.2\"\n-web30 = \"0.18\"\n+web30 = \"0.19\"\nalthea_types = { path = \"../althea_types\" }\n[dependencies.regex]\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/Cargo.toml", "new_path": "rita_exit/Cargo.toml", "diff": "@@ -20,7 +20,7 @@ awc = \"3.0.0-beta.21\"\nhandlebars = \"4.0\"\nrand = \"0.8.0\"\nlazy_static = \"1.4\"\n-ipnetwork = \"0.18\"\n+ipnetwork = \"0.19\"\nclarity = \"0.5\"\nserde = \"1.0\"\nserde_derive = \"1.0\"\n" }, { "change_type": "MODIFY", "old_path": "settings/Cargo.toml", "new_path": "settings/Cargo.toml", "diff": "@@ -20,4 +20,4 @@ lazy_static = \"1.4\"\nclarity = \"0.5\"\narrayvec = {version= \"0.7\", features = [\"serde\"]}\nphonenumber = \"0.3\"\n-ipnetwork = \"0.18\"\n+ipnetwork = \"0.19\"\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Bump web30, ipnetwork and awc deps Plus transitive deps via cargo.lock
20,244
24.06.2022 18:20:20
14,400
0645d39feb252c7b5d6371c97b469f79d12fadc5
Do not suppport tkip wifi security This patch modifies the way we handle /etc/config/wireless to be compatible with reading tkip based modes and all documented mode strings, but only writing the most basic format for CCMP (aes) enabled encryption. This is more secure and also more widely supported.
[ { "change_type": "MODIFY", "old_path": "rita_client/src/dashboard/wifi.rs", "new_path": "rita_client/src/dashboard/wifi.rs", "diff": "@@ -102,8 +102,8 @@ impl EncryptionModes {\nEncryptionModes::None => \"none\".to_string(),\nEncryptionModes::Sae => \"sae\".to_string(),\nEncryptionModes::SaeMixed => \"sae-mixed\".to_string(),\n- EncryptionModes::Psk2TkipCcmp => \"psk2+tkip+ccmp\".to_string(),\n- EncryptionModes::Psk2MixedTkipCcmp => \"psk-mixed+tkip+ccmp\".to_string(),\n+ EncryptionModes::Psk2TkipCcmp => \"psk2\".to_string(),\n+ EncryptionModes::Psk2MixedTkipCcmp => \"psk-mixed\".to_string(),\n}\n}\n}\n@@ -128,10 +128,15 @@ impl FromStr for EncryptionModes {\n\"none\" | \"NONE\" => Ok(EncryptionModes::None),\n\"sae\" | \"WPA3\" => Ok(EncryptionModes::Sae),\n\"sae-mixed\" | \"WPA2+WPA3\" => Ok(EncryptionModes::SaeMixed),\n- \"psk2+tkip+ccmp\" | \"psk2+ccmp\" | \"psk2+tkip+aes\" | \"WPA2\" => {\n- Ok(EncryptionModes::Psk2TkipCcmp)\n- }\n- \"psk-mixed+tkip+ccmp\" | \"WPA+WPA2\" => Ok(EncryptionModes::Psk2MixedTkipCcmp),\n+ \"psk2+tkip+ccmp\" | \"psk2+tkip+aes\" | \"psk2+tkip\" | \"psk2+ccmp\" | \"psk2+aes\"\n+ | \"psk2\" | \"WPA2\" => Ok(EncryptionModes::Psk2TkipCcmp),\n+ \"psk-mixed+tkip+ccmp\"\n+ | \"psk-mixed+tkip+aes\"\n+ | \"psk-mixed+tkip\"\n+ | \"psk-mixed+ccmp\"\n+ | \"psk-mixed+aes\"\n+ | \"psk-mixed\"\n+ | \"WPA+WPA2\" => Ok(EncryptionModes::Psk2MixedTkipCcmp),\n_ => {\nlet e = RitaClientError::MiscStringError(\"Invalid encryption mode!\".to_string());\nErr(e)\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Do not suppport tkip wifi security This patch modifies the way we handle /etc/config/wireless to be compatible with reading tkip based modes and all documented mode strings, but only writing the most basic format for CCMP (aes) enabled encryption. This is more secure and also more widely supported.
20,255
23.06.2022 12:43:13
25,200
511041bde1a8b735180f982359d33139eedb6cdd
Add a loop in rita client to truncate babeld logs Some routers had an issue with updates, the babeld logs filling up the /tmp folder are the culprit. This ensures that log file doesnt get too large and sends these over to graylog, while truncating the babeld.log file
[ { "change_type": "MODIFY", "old_path": "rita_client/src/rita_loop/mod.rs", "new_path": "rita_client/src/rita_loop/mod.rs", "diff": "@@ -24,10 +24,18 @@ use rita_common::rita_loop::set_gateway;\nuse rita_common::tunnel_manager::tm_get_neighbors;\nuse rita_common::tunnel_manager::tm_get_tunnels;\nuse settings::client::RitaClientSettings;\n+use std::fs::File;\n+use std::fs::OpenOptions;\n+use std::io::Read;\n+use std::io::Seek;\n+use std::path::Path;\nuse std::sync::atomic::{AtomicBool, Ordering};\nuse std::thread;\nuse std::time::{Duration, Instant};\n+/// The maximum size in bytes an babel log is allowed to be, 5MB\n+const MAX_LOG_SIZE: u64 = 5 * 1000 * 1000;\n+\nlazy_static! {\n/// see the comment on check_for_gateway_client_billing_corner_case()\n/// to identify why this variable is needed. In short it identifies\n@@ -81,6 +89,8 @@ pub fn start_rita_loop() {\nrunner.block_on(async move {\nmanage_gateway();\n+ manage_babeld_logs();\n+\nlet exit_dest_price = get_exit_dest_price();\nlet tunnels = tm_get_tunnels().unwrap();\n@@ -264,3 +274,63 @@ fn manage_gateway() {\n}\n}\n}\n+\n+/// This function truncates babeld.log and sends them over to graylog to prevent memory getting full\n+fn manage_babeld_logs() {\n+ info!(\"Running babel log truncation loop\");\n+\n+ let log_file = \"/tmp/log/babeld.log\";\n+ let path = Path::new(log_file);\n+ let mut file = match File::open(path) {\n+ Ok(a) => a,\n+ Err(e) => {\n+ error!(\"Unable to truncate babel logs: {:?}\", e);\n+ return;\n+ }\n+ };\n+\n+ // Read file and log data\n+ let mut buf = String::new();\n+ match file.read_to_string(&mut buf) {\n+ Ok(_) => {\n+ for line in buf.lines() {\n+ info!(\"{} {}\", log_file, line);\n+ }\n+ }\n+ Err(e) => {\n+ error!(\"Unable to truncate babel logs: {:?}\", e);\n+ return;\n+ }\n+ }\n+\n+ // truncating babeld logs\n+ if let Ok(metadata) = file.metadata() {\n+ // length of the file\n+ if metadata.len() > MAX_LOG_SIZE {\n+ info!(\n+ \"File {} has exceeded {} bytes, truncating\",\n+ log_file, MAX_LOG_SIZE\n+ );\n+ // our current file handle does not have write permissions, so we open a new\n+ // one in 'truncate' mode which means it clears out the entire file on open\n+ let mut options = OpenOptions::new();\n+ let path = Path::new(log_file);\n+ match options.write(true).truncate(true).open(path) {\n+ Ok(_) => {\n+ // now that the file has been truncated we need to take our read only file\n+ // handle and rewind it's internal pointer to the start otherwise we'll be\n+ // trying to read at an offset longer than the file\n+ match file.rewind() {\n+ Ok(_) => info!(\"Log truncate {} successful!\", log_file),\n+ Err(e) => {\n+ error!(\"Failed to truncate {} with {:?}\", log_file, e)\n+ }\n+ }\n+ }\n+ Err(e) => error!(\"Failed to truncate {} logs with {:?}\", log_file, e),\n+ }\n+ }\n+ } else {\n+ warn!(\"Failed to get metadata for log file {}\", log_file)\n+ }\n+}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Add a loop in rita client to truncate babeld logs Some routers had an issue with updates, the babeld logs filling up the /tmp folder are the culprit. This ensures that log file doesnt get too large and sends these over to graylog, while truncating the babeld.log file
20,255
24.06.2022 10:28:00
25,200
ef500b57458262f9e9b7d9c8acb555f2f86b97bb
Restart babeld on startup Right now when Rita restarts babel also needs to be restarted, because Rita inserts tunnels into the babel routing table as interfaces when Rita is restarted those tunnels are torn down and re-created without notifying babel resulting in complete network failure.
[ { "change_type": "ADD", "old_path": null, "new_path": "althea_kernel_interface/src/babel.rs", "diff": "+use crate::KernelInterface;\n+\n+impl dyn KernelInterface {\n+ pub fn restart_babel(&self) {\n+ let _res = self.run_command(\"/etc/init.d/babeld\", &[\"restart\"]);\n+ }\n+}\n" }, { "change_type": "MODIFY", "old_path": "althea_kernel_interface/src/lib.rs", "new_path": "althea_kernel_interface/src/lib.rs", "diff": "@@ -22,6 +22,7 @@ use std::{\nuse std::str;\n+mod babel;\npub mod bridge_tools;\nmod check_cron;\nmod counter;\n" }, { "change_type": "MODIFY", "old_path": "rita_bin/src/client.rs", "new_path": "rita_bin/src/client.rs", "diff": "@@ -60,6 +60,12 @@ fn main() {\n})\n.expect(\"Error setting Ctrl-C handler\");\n+ // Because Rita clears and sets up new Wireguard Tunnels on every restart Babel, which was attached and listening to\n+ // the old tunnels is now in an incorrect state. We must either restart babel or empty it's interfaces list so that the newly\n+ // created wireguard tunnels can be re-added by this instance of Rita. Due to errors in babel (see git history there)\n+ // restarting is the way to go as removing dead interfaces often does not work\n+ KI.restart_babel();\n+\nlet args: Args = Docopt::new(get_client_usage(\nenv!(\"CARGO_PKG_VERSION\"),\nenv!(\"GIT_HASH\"),\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/operator_update/updater.rs", "new_path": "rita_client/src/operator_update/updater.rs", "diff": "@@ -32,9 +32,6 @@ pub fn update_system(instruction: UpdateType) -> Result<(), KernelInterfaceError\n// Restart rita after opkg\nlet args = vec![\"restart\"];\n- if let Err(e) = KI.run_command(\"/etc/init.d/babeld\", &args) {\n- error!(\"Unable to restart babel after opkg update: {}\", e);\n- }\nif let Err(e) = KI.run_command(\"/etc/init.d/rita\", &args) {\nerror!(\"Unable to restart rita after opkg update: {}\", e)\n}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Restart babeld on startup Right now when Rita restarts babel also needs to be restarted, because Rita inserts tunnels into the babel routing table as interfaces when Rita is restarted those tunnels are torn down and re-created without notifying babel resulting in complete network failure.
20,255
27.06.2022 11:19:29
25,200
b3f18b338dc9ae77b63e6edf672d1ec8ba85dc77
Update rita tower after an opkg update
[ { "change_type": "MODIFY", "old_path": "rita_client/src/operator_update/updater.rs", "new_path": "rita_client/src/operator_update/updater.rs", "diff": "@@ -35,6 +35,10 @@ pub fn update_system(instruction: UpdateType) -> Result<(), KernelInterfaceError\nif let Err(e) = KI.run_command(\"/etc/init.d/rita\", &args) {\nerror!(\"Unable to restart rita after opkg update: {}\", e)\n}\n+ if let Err(e) = KI.run_command(\"/etc/init.d/rita_tower\", &args) {\n+ error!(\"Unable to restart rita tower after opkg update: {}\", e)\n+ }\n+\nOk(())\n}\n}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Update rita tower after an opkg update
20,244
11.07.2022 15:53:05
14,400
c2dfae54b9e1c0c8670274895a73267aa39ef7cb
Fix new clippy nits
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -3532,9 +3532,9 @@ dependencies = [\n[[package]]\nname = \"web30\"\n-version = \"0.19.1\"\n+version = \"0.19.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"463b0185237bb5c10abf6ce7a5923b03503aea0bb2ff5d9ad930d790e69c0cb0\"\n+checksum = \"c2a1cd88f65c3315ffda8722ee2de20ae5e9c607ebd009377fbfd2ea68375af3\"\ndependencies = [\n\"awc\",\n\"clarity\",\n" }, { "change_type": "MODIFY", "old_path": "althea_kernel_interface/src/file_io.rs", "new_path": "althea_kernel_interface/src/file_io.rs", "diff": "use crate::KernelInterfaceError as Error;\n+use std::fmt::Write as _;\nuse std::fs::File;\nuse std::io::BufRead;\nuse std::io::BufReader;\n@@ -21,10 +22,10 @@ pub fn get_lines(filename: &str) -> Result<Vec<String>, Error> {\npub fn write_out(filename: &str, content: Vec<String>) -> Result<(), Error> {\n// overwrite the old version\nlet mut file = File::create(filename)?;\n- let mut final_ouput = String::new();\n+ let mut final_output = String::new();\nfor item in content {\n- final_ouput += &format!(\"{}\\n\", item);\n+ writeln!(final_output, \"{}\", item).unwrap();\n}\n- file.write_all(final_ouput.as_bytes())?;\n+ file.write_all(final_output.as_bytes())?;\nOk(())\n}\n" }, { "change_type": "MODIFY", "old_path": "althea_kernel_interface/src/ip_route.rs", "new_path": "althea_kernel_interface/src/ip_route.rs", "diff": "use crate::KernelInterface;\nuse crate::KernelInterfaceError as Error;\nuse althea_types::FromStr;\n+use std::fmt::Write as _;\nuse std::net::IpAddr;\n/// Stores a default route of the format\n@@ -178,11 +179,11 @@ impl ToString for IpRoute {\nformat!(\"{}/{} \", dst, subnet)\n};\nif let Some(via) = via {\n- out += &format!(\"via {} \", via)\n+ write!(out, \"via {} \", via).unwrap();\n}\n- out += &format!(\"dev {} proto static \", nic);\n+ write!(out, \"dev {} proto static \", nic).unwrap();\nif let Some(src) = src {\n- out += &format!(\"src {} \", src)\n+ write!(out, \"src {} \", src).unwrap();\n}\nout\n}\n" }, { "change_type": "MODIFY", "old_path": "babel_monitor/src/lib.rs", "new_path": "babel_monitor/src/lib.rs", "diff": "@@ -348,7 +348,7 @@ pub fn run_command(stream: &mut TcpStream, cmd: &str) -> Result<String, BabelMon\nreturn Err(CommandFailed(cmd, format!(\"{:?}\", out)));\n}\n- let _res = out.unwrap();\n+ out.unwrap();\ninfo!(\"Command write succeeded, returning output\");\nread_babel(stream, String::new(), 0)\n}\n" }, { "change_type": "MODIFY", "old_path": "exit_db/src/models.rs", "new_path": "exit_db/src/models.rs", "diff": "+#![allow(clippy::extra_unused_lifetimes)]\nuse crate::schema::assigned_ips;\nuse crate::schema::clients;\n-#[derive(Queryable, Serialize, Deserialize, Debug, Insertable, Clone, AsChangeset, Default)]\n+#[derive(Queryable, Serialize, Deserialize, Debug, Insertable, Clone, Default)]\n#[table_name = \"clients\"]\npub struct Client {\npub mesh_ip: String,\n@@ -28,7 +29,7 @@ pub struct Client {\n/// The iterative index stores the index at which we assign a subnet to a client\n/// For example, if our exit subnet is fd00::1000/120 and our client subnets are /124, index 0 represents\n/// fd00::1000/124 index 1 represents fd00::1010/124, 2 is fd00::1120/124 etc...\n-#[derive(Queryable, Serialize, Deserialize, Debug, Insertable, Clone, AsChangeset, Default)]\n+#[derive(Queryable, Serialize, Deserialize, Debug, Insertable, Clone, Default)]\n#[table_name = \"assigned_ips\"]\npub struct AssignedIps {\npub subnet: String,\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/payment_validator/mod.rs", "new_path": "rita_common/src/payment_validator/mod.rs", "diff": "@@ -18,6 +18,7 @@ use futures::future::join_all;\nuse num256::Uint256;\nuse std::collections::HashSet;\nuse std::fmt;\n+use std::fmt::Write as _;\nuse std::sync::Arc;\nuse std::sync::RwLock;\nuse std::time::{Duration, Instant};\n@@ -451,7 +452,7 @@ fn payment_is_old(chain_height: Uint256, tx_height: Option<Uint256>) -> bool {\nfn print_txids(list: &HashSet<ToValidate>) -> String {\nlet mut output = String::new();\nfor item in list.iter() {\n- output += &format!(\"{} ,\", item);\n+ write!(output, \"{} ,\", item).unwrap();\n}\noutput\n}\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/peer_listener/message.rs", "new_path": "rita_common/src/peer_listener/message.rs", "diff": "@@ -458,7 +458,7 @@ fn test_deserialize_with_wrong_serialization() {\nresult[3] += 1;\n//decode should not work\n- let _decode = match PeerMessage::decode(&result) {\n+ match PeerMessage::decode(&result) {\nOk(_) => panic!(\"Expected error\"),\nErr(MessageError::DeserializationError) => (),\nErr(_) => panic!(\"Wrong Error\"),\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/geoip.rs", "new_path": "rita_exit/src/database/geoip.rs", "diff": "@@ -136,13 +136,6 @@ struct CountryDetails {\niso_code: String,\n}\n-pub fn get_country_async(ip: IpAddr) -> Result<String, RitaExitError> {\n- match get_country(ip) {\n- Ok(res) => Ok(res),\n- Err(e) => Err(e),\n- }\n-}\n-\n/// get ISO country code from ip, consults a in memory cache\npub fn get_country(ip: IpAddr) -> Result<String, RitaExitError> {\ntrace!(\"get GeoIP country for {}\", ip.to_string());\n@@ -229,15 +222,6 @@ pub fn get_country(ip: IpAddr) -> Result<String, RitaExitError> {\n/// Returns true or false if an ip is confirmed to be inside or outside the region and error\n/// if an api error is encountered trying to figure that out.\npub fn verify_ip(request_ip: IpAddr) -> Result<bool, RitaExitError> {\n- match verify_ip_sync(request_ip) {\n- Ok(item) => Ok(item),\n- Err(e) => Err(e),\n- }\n-}\n-\n-/// Returns true or false if an ip is confirmed to be inside or outside the region and error\n-/// if an api error is encountered trying to figure that out.\n-pub fn verify_ip_sync(request_ip: IpAddr) -> Result<bool, RitaExitError> {\n// in this case we have a gateway directly attached to the exit, so our\n// peer address for them will be an fe80 linklocal ip address. When we\n// detect this we know that they are in the allowed countries list because\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/mod.rs", "new_path": "rita_exit/src/database/mod.rs", "diff": "@@ -12,11 +12,10 @@ use crate::database::database_tools::update_client;\nuse crate::database::database_tools::verify_client;\nuse crate::database::database_tools::verify_db_client;\nuse crate::database::email::handle_email_registration;\n-use crate::database::geoip::get_country_async;\n+use crate::database::geoip::get_country;\nuse crate::database::geoip::get_gateway_ip_bulk;\nuse crate::database::geoip::get_gateway_ip_single;\nuse crate::database::geoip::verify_ip;\n-use crate::database::geoip::verify_ip_sync;\nuse crate::database::sms::handle_sms_registration;\nuse crate::database::struct_tools::display_hashset;\nuse crate::database::struct_tools::to_exit_client;\n@@ -104,7 +103,7 @@ pub async fn signup_client(client: ExitClientIdentity) -> Result<ExitState, Rita\nlet verify_status = verify_ip(gateway_ip)?;\ninfo!(\"verified the ip country {:?}\", client);\n- let user_country = get_country_async(gateway_ip)?;\n+ let user_country = get_country(gateway_ip)?;\ninfo!(\"got the country {:?}\", client);\nlet conn = get_database_connection()?;\n@@ -253,7 +252,7 @@ pub fn validate_clients_region(\nOk(val) => val,\n};\nfor item in list.iter() {\n- let res = verify_ip_sync(item.gateway_ip);\n+ let res = verify_ip(item.gateway_ip);\nmatch res {\nOk(true) => trace!(\"{:?} is from an allowed ip\", item),\nOk(false) => {\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/sms.rs", "new_path": "rita_exit/src/database/sms.rs", "diff": "@@ -157,7 +157,7 @@ pub async fn handle_sms_registration(\n}),\n// user has attempts remaining and is requesting the code be resent\n(Some(number), None, false) => {\n- let _res = send_text(number, api_key).await?;\n+ send_text(number, api_key).await?;\nlet conn = get_database_connection()?;\ntext_sent(&client, &conn, text_num)?;\nOk(ExitState::Pending {\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/struct_tools.rs", "new_path": "rita_exit/src/database/struct_tools.rs", "diff": "@@ -7,6 +7,7 @@ use exit_db::models::Client;\nuse ipnetwork::IpNetwork;\nuse rand::Rng;\nuse std::collections::HashSet;\n+use std::fmt::Write as _;\nuse std::net::IpAddr;\nuse crate::RitaExitError;\n@@ -58,7 +59,7 @@ pub fn texts_sent(client: &models::Client) -> i32 {\npub fn display_hashset(input: &HashSet<String>) -> String {\nlet mut out = String::new();\nfor item in input.iter() {\n- out += &format!(\"{}, \", item);\n+ write!(out, \"{}, \", item).unwrap();\n}\nout\n}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Fix new clippy nits
20,244
11.07.2022 17:14:57
14,400
66d5104fa241dfec0fbc244e1a72416985b23f10
Minor token bridge cleanup
[ { "change_type": "MODIFY", "old_path": "auto_bridge/src/lib.rs", "new_path": "auto_bridge/src/lib.rs", "diff": "@@ -100,10 +100,10 @@ impl TokenBridge {\n/// takes in 'amount' of dai and returns correspoding amount of eth\npub async fn dai_to_eth_price(&self, amount: Uint256) -> Result<Uint256, TokenBridgeError> {\n- let web3 = self.eth_web3.clone();\nlet own_address = self.own_address;\n- let tokens_bought = match web3\n+ let tokens_bought = match self\n+ .eth_web3\n.get_uniswap_v3_price(\nown_address,\n*DAI_CONTRACT_ON_ETH,\n@@ -124,10 +124,10 @@ impl TokenBridge {\n/// takes in 'amount' of eth, and returns corresponding amount of dai\npub async fn eth_to_dai_price(&self, amount: Uint256) -> Result<Uint256, TokenBridgeError> {\n- let web3 = self.eth_web3.clone();\nlet own_address = self.own_address;\n- let tokens_bought = match web3\n+ let tokens_bought = match self\n+ .eth_web3\n.get_uniswap_v3_price(\nown_address,\n*WETH_CONTRACT_ADDRESS,\n@@ -157,9 +157,8 @@ impl TokenBridge {\ntimeout: Duration,\n) -> Result<Uint256, TokenBridgeError> {\nlet secret = self.eth_privatekey;\n- let web3 = self.eth_web3.clone();\n- let block = web3.eth_get_latest_block().await?;\n+ let block = self.eth_web3.eth_get_latest_block().await?;\nlet expected_dai = self.eth_to_dai_price(eth_amount.clone()).await?;\n// Equivalent to `amount * (1 - 0.025)` without using decimals\n@@ -167,7 +166,8 @@ impl TokenBridge {\nlet deadline = block.timestamp + timeout.as_secs().into();\n// initiate swap with no sqrtPriceLimit\n- let tokens = match web3\n+ let tokens = match self\n+ .eth_web3\n.swap_uniswap_v3_eth_in(\nsecret,\n*DAI_CONTRACT_ON_ETH,\n@@ -195,14 +195,14 @@ impl TokenBridge {\ndai_amount: Uint256,\ntimeout: Duration,\n) -> Result<Uint256, TokenBridgeError> {\n- let eth_web3 = self.eth_web3.clone();\nlet own_address = self.own_address;\nlet secret = self.eth_privatekey;\n// You basically just send it some dai to the bridge address and they show\n// up in the same address on the xdai side we have no idea when this has succeeded\n// since the events are not indexed\n- let tx_hash = eth_web3\n+ let tx_hash = self\n+ .eth_web3\n.send_transaction(\n*DAI_CONTRACT_ON_ETH,\nencode_call(\n@@ -217,7 +217,7 @@ impl TokenBridge {\n)\n.await?;\n- eth_web3\n+ self.eth_web3\n.wait_for_transaction(tx_hash, timeout, None)\n.await?;\n@@ -225,9 +225,11 @@ impl TokenBridge {\n}\npub async fn get_dai_balance(&self, address: Address) -> Result<Uint256, TokenBridgeError> {\n- let web3 = self.eth_web3.clone();\nlet dai_address = *DAI_CONTRACT_ON_ETH;\n- Ok(web3.get_erc20_balance(dai_address, address).await?)\n+ Ok(self\n+ .eth_web3\n+ .get_erc20_balance(dai_address, address)\n+ .await?)\n}\n/// input is the packed signatures output from get_relay_message_hash\n" }, { "change_type": "MODIFY", "old_path": "rita_common/src/token_bridge/mod.rs", "new_path": "rita_common/src/token_bridge/mod.rs", "diff": "@@ -31,6 +31,7 @@ use auto_bridge::{check_withdrawals, encode_relaytokens, get_relay_message_hash}\nuse auto_bridge::{TokenBridge as TokenBridgeCore, TokenBridgeError};\nuse clarity::utils::display_uint256_as_address;\nuse clarity::Address;\n+use futures::future::join3;\nuse num256::Uint256;\nuse num_traits::identities::Zero;\nuse rand::{thread_rng, Rng};\n@@ -174,14 +175,20 @@ async fn transfer_dai(\n/// on the xdai blockchain to find any withdrawals related to us, and if so we unlock these funds.\n/// We then rescue any stuck dai and send any eth that we have over to the xdai chain.\nasync fn xdai_bridge(bridge: TokenBridgeCore) {\n- let eth_gas_price = match bridge.eth_web3.eth_gas_price().await {\n+ let (eth_gas_price, wei_per_dollar, our_eth_balance) = join3(\n+ bridge.eth_web3.eth_gas_price(),\n+ bridge.dai_to_eth_price(eth_to_wei(1u8.into())),\n+ bridge.eth_web3.eth_get_balance(bridge.own_address),\n+ )\n+ .await;\n+ let eth_gas_price = match eth_gas_price {\nOk(val) => val,\nErr(e) => {\nwarn!(\"Failed to get eth gas price with {}\", e);\nreturn;\n}\n};\n- let wei_per_dollar = match bridge.dai_to_eth_price(eth_to_wei(1u8.into())).await {\n+ let wei_per_dollar = match wei_per_dollar {\nOk(val) => val,\nErr(e) => {\nwarn!(\"Failed to get eth price with {}\", e);\n@@ -189,7 +196,7 @@ async fn xdai_bridge(bridge: TokenBridgeCore) {\n}\n};\nlet wei_per_cent = wei_per_dollar.clone() / 100u32.into();\n- let our_eth_balance = match bridge.eth_web3.eth_get_balance(bridge.own_address).await {\n+ let our_eth_balance = match our_eth_balance {\nOk(val) => val,\nErr(e) => {\nwarn!(\"Failed to get eth balance {}\", e);\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Minor token bridge cleanup
20,255
14.07.2022 14:52:34
25,200
d02f9e491a0b273934eb5c6893154aa059a8bc7b
Add cargo audit to github CI
[ { "change_type": "MODIFY", "old_path": ".github/workflows/rust.yml", "new_path": ".github/workflows/rust.yml", "diff": "@@ -40,6 +40,14 @@ jobs:\n- uses: Swatinem/rust-cache@v1\n- name: Check for Clippy lints\nrun: rustup component add clippy && cargo clippy --all --all-targets --all-features -- -D warnings\n+ audit:\n+ needs: check\n+ runs-on: ubuntu-latest\n+ steps:\n+ - uses: actions/checkout@v2\n+ - uses: Swatinem/rust-cache@v1\n+ - name: Run Cargo Audit\n+ run: cargo install cargo-audit && cargo audit\ncross-mips:\nneeds: test\nruns-on: ubuntu-latest\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Add cargo audit to github CI
20,255
15.07.2022 13:20:00
25,200
be46fe4b128c38bba69f793c50d13683ed760ad2
Removed IPAddress dep from rita exit cargo audit shows this crate with security vulneribilites so it has been removed and replaced with other ip network functions
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -115,7 +115,7 @@ dependencies = [\n\"firestorm\",\n\"http\",\n\"log\",\n- \"regex 1.6.0\",\n+ \"regex\",\n\"serde 1.0.139\",\n]\n@@ -215,7 +215,7 @@ dependencies = [\n\"mime\",\n\"once_cell\",\n\"pin-project-lite\",\n- \"regex 1.6.0\",\n+ \"regex\",\n\"serde 1.0.139\",\n\"serde_json\",\n\"serde_urlencoded\",\n@@ -268,15 +268,6 @@ dependencies = [\n\"version_check 0.9.4\",\n]\n-[[package]]\n-name = \"aho-corasick\"\n-version = \"0.6.10\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5\"\n-dependencies = [\n- \"memchr\",\n-]\n-\n[[package]]\nname = \"aho-corasick\"\nversion = \"0.7.18\"\n@@ -311,7 +302,7 @@ dependencies = [\n\"lazy_static\",\n\"log\",\n\"oping\",\n- \"regex 1.6.0\",\n+ \"regex\",\n\"serde 1.0.139\",\n\"serde_derive\",\n]\n@@ -715,7 +706,7 @@ dependencies = [\n\"lazy_static\",\n\"log\",\n\"rand 0.8.5\",\n- \"regex 1.6.0\",\n+ \"regex\",\n\"serde 1.0.139\",\n\"serde_derive\",\n\"serde_json\",\n@@ -931,7 +922,7 @@ source = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"7f3f119846c823f9eafcf953a8f6ffb6ed69bf6240883261a7f13b634579a51f\"\ndependencies = [\n\"lazy_static\",\n- \"regex 1.6.0\",\n+ \"regex\",\n\"serde 1.0.139\",\n\"strsim\",\n]\n@@ -1054,7 +1045,7 @@ dependencies = [\n\"atty\",\n\"humantime\",\n\"log\",\n- \"regex 1.6.0\",\n+ \"regex\",\n\"termcolor\",\n]\n@@ -1501,20 +1492,6 @@ dependencies = [\n\"cfg-if\",\n]\n-[[package]]\n-name = \"ipaddress\"\n-version = \"0.1.2\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"c9e999e655a4d0ab9b8d21026760e5154d8adee48c9149c67f918f540f6a05f5\"\n-dependencies = [\n- \"lazy_static\",\n- \"libc\",\n- \"num 0.1.42\",\n- \"num-integer\",\n- \"num-traits 0.1.43\",\n- \"regex 0.2.11\",\n-]\n-\n[[package]]\nname = \"ipgen\"\nversion = \"1.0.1\"\n@@ -1837,20 +1814,6 @@ dependencies = [\n\"version_check 0.9.4\",\n]\n-[[package]]\n-name = \"num\"\n-version = \"0.1.42\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e\"\n-dependencies = [\n- \"num-bigint 0.1.44\",\n- \"num-complex 0.1.43\",\n- \"num-integer\",\n- \"num-iter\",\n- \"num-rational 0.1.42\",\n- \"num-traits 0.2.15\",\n-]\n-\n[[package]]\nname = \"num\"\nversion = \"0.2.1\"\n@@ -1879,18 +1842,6 @@ dependencies = [\n\"num-traits 0.2.15\",\n]\n-[[package]]\n-name = \"num-bigint\"\n-version = \"0.1.44\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"e63899ad0da84ce718c14936262a41cee2c79c981fc0a0e7c7beb47d5a07e8c1\"\n-dependencies = [\n- \"num-integer\",\n- \"num-traits 0.2.15\",\n- \"rand 0.4.6\",\n- \"rustc-serialize\",\n-]\n-\n[[package]]\nname = \"num-bigint\"\nversion = \"0.2.6\"\n@@ -1914,16 +1865,6 @@ dependencies = [\n\"serde 1.0.139\",\n]\n-[[package]]\n-name = \"num-complex\"\n-version = \"0.1.43\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"b288631d7878aaf59442cffd36910ea604ecd7745c36054328595114001c9656\"\n-dependencies = [\n- \"num-traits 0.2.15\",\n- \"rustc-serialize\",\n-]\n-\n[[package]]\nname = \"num-complex\"\nversion = \"0.2.4\"\n@@ -1975,18 +1916,6 @@ dependencies = [\n\"num-traits 0.2.15\",\n]\n-[[package]]\n-name = \"num-rational\"\n-version = \"0.1.42\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"ee314c74bd753fc86b4780aa9475da469155f3848473a261d2d18e35245a784e\"\n-dependencies = [\n- \"num-bigint 0.1.44\",\n- \"num-integer\",\n- \"num-traits 0.2.15\",\n- \"rustc-serialize\",\n-]\n-\n[[package]]\nname = \"num-rational\"\nversion = \"0.2.4\"\n@@ -2277,7 +2206,7 @@ dependencies = [\n\"lazy_static\",\n\"nom 5.1.2\",\n\"quick-xml\",\n- \"regex 1.6.0\",\n+ \"regex\",\n\"regex-cache\",\n\"serde 1.0.139\",\n\"serde_derive\",\n@@ -2522,28 +2451,15 @@ dependencies = [\n\"bitflags\",\n]\n-[[package]]\n-name = \"regex\"\n-version = \"0.2.11\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384\"\n-dependencies = [\n- \"aho-corasick 0.6.10\",\n- \"memchr\",\n- \"regex-syntax 0.5.6\",\n- \"thread_local\",\n- \"utf8-ranges\",\n-]\n-\n[[package]]\nname = \"regex\"\nversion = \"1.6.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b\"\ndependencies = [\n- \"aho-corasick 0.7.18\",\n+ \"aho-corasick\",\n\"memchr\",\n- \"regex-syntax 0.6.27\",\n+ \"regex-syntax\",\n]\n[[package]]\n@@ -2554,17 +2470,8 @@ checksum = \"2f7b62d69743b8b94f353b6b7c3deb4c5582828328bcb8d5fedf214373808793\"\ndependencies = [\n\"lru-cache\",\n\"oncemutex\",\n- \"regex 1.6.0\",\n- \"regex-syntax 0.6.27\",\n-]\n-\n-[[package]]\n-name = \"regex-syntax\"\n-version = \"0.5.6\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7\"\n-dependencies = [\n- \"ucd-util\",\n+ \"regex\",\n+ \"regex-syntax\",\n]\n[[package]]\n@@ -2717,7 +2624,7 @@ dependencies = [\n\"num-traits 0.2.15\",\n\"num256\",\n\"rand 0.8.5\",\n- \"regex 1.6.0\",\n+ \"regex\",\n\"serde 1.0.139\",\n\"serde_cbor\",\n\"serde_derive\",\n@@ -2742,7 +2649,6 @@ dependencies = [\n\"diesel\",\n\"exit_db\",\n\"handlebars\",\n- \"ipaddress\",\n\"ipnetwork 0.20.0\",\n\"lazy_static\",\n\"lettre\",\n@@ -2767,12 +2673,6 @@ version = \"0.13.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2\"\n-[[package]]\n-name = \"rustc-serialize\"\n-version = \"0.3.24\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda\"\n-\n[[package]]\nname = \"rustc_version\"\nversion = \"0.4.0\"\n@@ -2898,7 +2798,7 @@ checksum = \"6a3a4e0ea8a88553209f6cc6cfe8724ecad22e1acf372793c27d995290fe74f8\"\ndependencies = [\n\"lazy_static\",\n\"num-traits 0.1.43\",\n- \"regex 1.6.0\",\n+ \"regex\",\n\"serde 0.8.23\",\n]\n@@ -3149,15 +3049,6 @@ dependencies = [\n\"syn\",\n]\n-[[package]]\n-name = \"thread_local\"\n-version = \"0.3.6\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b\"\n-dependencies = [\n- \"lazy_static\",\n-]\n-\n[[package]]\nname = \"time\"\nversion = \"0.1.44\"\n@@ -3349,12 +3240,6 @@ version = \"0.1.4\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c\"\n-[[package]]\n-name = \"ucd-util\"\n-version = \"0.1.9\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"65bfcbf611b122f2c10eb1bb6172fbc4c2e25df9970330e4d75ce2b5201c9bfc\"\n-\n[[package]]\nname = \"unicode-bidi\"\nversion = \"0.3.8\"\n@@ -3388,12 +3273,6 @@ dependencies = [\n\"percent-encoding\",\n]\n-[[package]]\n-name = \"utf8-ranges\"\n-version = \"1.0.5\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"7fcfc827f90e53a02eaef5e535ee14266c1d569214c6aa70133a624d8a3164ba\"\n-\n[[package]]\nname = \"uuid\"\nversion = \"0.7.4\"\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/Cargo.toml", "new_path": "rita_exit/Cargo.toml", "diff": "@@ -35,5 +35,4 @@ reqwest = { version = \"0.11\", features = [\"blocking\", \"json\"] }\nexit_db = { path = \"../exit_db\" }\nactix-web-async = {package=\"actix-web\", version = \"4.0.1\", default_features = false, features= [\"openssl\"] }\ndiesel = { version = \"1.4\", features = [\"postgres\", \"r2d2\"] }\n-ipaddress = \"0.1.2\"\n[features]\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/database_tools.rs", "new_path": "rita_exit/src/database/database_tools.rs", "diff": "@@ -2,8 +2,7 @@ use crate::database::secs_since_unix_epoch;\nuse crate::database::struct_tools::client_to_new_db_client;\nuse crate::database::ONE_DAY;\nuse exit_db::models::AssignedIps;\n-use ipaddress::IPAddress;\n-use ipnetwork::IpNetwork;\n+use ipnetwork::{IpNetwork, Ipv6Network, NetworkSize};\nuse rita_common::utils::ip_increment::increment;\nuse crate::{RitaExitError, DB_POOL};\n@@ -16,8 +15,8 @@ use diesel::r2d2::PooledConnection;\nuse diesel::select;\nuse exit_db::{models, schema};\nuse std::convert::TryInto;\n-use std::net::IpAddr;\nuse std::net::Ipv4Addr;\n+use std::net::{IpAddr, Ipv6Addr};\n// Default Subnet size assigned to each client\nconst DEFAULT_CLIENT_SUBNET_SIZE: u8 = 56;\n@@ -600,8 +599,7 @@ pub fn get_client_subnet(\nindex.unwrap(),\nsettings::get_rita_exit()\n.get_client_subnet_size()\n- .unwrap_or(DEFAULT_CLIENT_SUBNET_SIZE)\n- .into(),\n+ .unwrap_or(DEFAULT_CLIENT_SUBNET_SIZE),\n) {\nOk(addr) => {\n// increment iterative index\n@@ -637,31 +635,47 @@ pub fn get_client_subnet(\nfn generate_iterative_client_subnet(\nexit_sub: IpNetwork,\nind: u64,\n- subprefix: usize,\n+ subprefix: u8,\n) -> Result<IpNetwork, RitaExitError> {\n- // Convert IpNetwork into IPAdress type\n- let network: IPAddress = IPAddress::parse(exit_sub.to_string())\n- .expect(\"Paniced while parsing the exit subnet: IpNetwork -> IPAddress\");\n- let mut net = network.network();\n- net.prefix = net.prefix.from(subprefix).unwrap();\n+ let net;\n+\n+ // Covert the subnet's ip address into a u128 integer to allow for easy iterative\n+ // addition operations. To this u128, we add (interative_index * client_subnet_size)\n+ // and convert this result into an ipv6 addr. This is the starting ip in the client subnet\n+ //\n+ // For example, if we have exit subnet: fbad::1000/120, client subnet size is 124, index is 1\n+ // we do (fbad::1000).to_int() + (16 * 1) = fbad::1010/124 is the client subnet\n+ let net_as_int: u128 = if let IpAddr::V6(addr) = exit_sub.network() {\n+ net = Ipv6Network::new(addr, subprefix).unwrap();\n+ addr.into()\n+ } else {\n+ return Err(RitaExitError::MiscStringError(\n+ \"Exit subnet expected to be ipv6!!\".to_string(),\n+ ));\n+ };\n- if subprefix < network.prefix.num {\n+ if subprefix < exit_sub.prefix() {\nreturn Err(RitaExitError::MiscStringError(\n\"Client subnet larger than exit subnet\".to_string(),\n));\n}\n- // This is the total number of client subnets available. We are checking that our iterative index\n+ // This bitshifting is the total number of client subnets available. We are checking that our iterative index\n// is lower than this number. For example, exit subnet: fd00:1000/120, client subnet /124, number of subnets will be\n// 2^(124 - 120) => 2^4 => 16\n- if ind < (1 << (subprefix - network.prefix.num)) {\n- net = net.from(&net.host_address, &net.prefix);\n- let size = net.size();\n- net.host_address += ind * size;\n- let ret = net\n- .to_string()\n- .parse()\n- .expect(\"Paniced while parsing exit subnet: IPAdress -> IpNetwork\");\n+ if ind < (1 << (subprefix - exit_sub.prefix())) {\n+ let ret = net_as_int + (ind as u128 * net.size());\n+ let v6addr = Ipv6Addr::from(ret);\n+ let ret = IpNetwork::from(match Ipv6Network::new(v6addr, subprefix) {\n+ Ok(a) => a,\n+ Err(e) => {\n+ return Err(RitaExitError::MiscStringError(format!(\n+ \"Unable to parse a valid client subnet: {:?}\",\n+ e\n+ )))\n+ }\n+ });\n+\nOk(ret)\n} else {\nerror!(\n@@ -677,24 +691,39 @@ fn generate_iterative_client_subnet(\n/// subnet within the larger subnet\n/// For exmaple fd00::1020/124 is the 3rd subnet in fd00::1000/120, so it generates the index '2'\nfn generate_index_from_subnet(exit_sub: IpNetwork, sub: IpNetwork) -> Result<u64, RitaExitError> {\n- let exit_sub_mig: IPAddress = IPAddress::parse(exit_sub.to_string())\n- .expect(\"Paniced while migrating IpNetwork -> IPAddress\");\n- let sub_mig: IPAddress =\n- IPAddress::parse(sub.to_string()).expect(\"Paniced while parsing IpNetwork -> IPAddress\");\n-\n- if exit_sub_mig.size() < sub_mig.size() {\n+ if exit_sub.size() < sub.size() {\nerror!(\"Invalid subnet sizes\");\nreturn Err(RitaExitError::MiscStringError(\n\"Invalid subnet sizes provided to generate_index_from_subnet\".to_string(),\n));\n}\n- let size = sub_mig.size();\n- let ret = (sub_mig.host_address - exit_sub_mig.host_address) / size;\n- Ok(ret\n- .to_string()\n- .parse::<u64>()\n- .expect(\"Unalbe to parse biguint into u64\"))\n+ let size: u128 = if let NetworkSize::V6(a) = sub.size() {\n+ a\n+ } else {\n+ return Err(RitaExitError::MiscStringError(\n+ \"Exit Subnet needs to be ipv6!!\".to_string(),\n+ ));\n+ };\n+ let exit_sub_int: u128 = if let IpAddr::V6(addr) = exit_sub.ip() {\n+ addr.into()\n+ } else {\n+ return Err(RitaExitError::MiscStringError(\n+ \"Exit Subnet needs to be ipv6!!\".to_string(),\n+ ));\n+ };\n+\n+ let sub_int: u128 = if let IpAddr::V6(addr) = sub.ip() {\n+ addr.into()\n+ } else {\n+ return Err(RitaExitError::MiscStringError(\n+ \"Exit Subnet needs to be ipv6!!\".to_string(),\n+ ));\n+ };\n+\n+ let ret: u128 = (sub_int - exit_sub_int) / size;\n+\n+ Ok(ret as u64)\n}\n/// This function run on startup initializes databases and other missing fields from the previous database schema\n@@ -824,50 +853,6 @@ pub fn get_client_ipv6(their_record: &models::Client) -> Result<Option<IpNetwork\nmod tests {\nuse super::*;\n- /// Test to strings conversions and parsing from IpNetwork -> IPAdress -> IpNetwork\n- #[test]\n- fn test_ipnetwork_tostring() {\n- let ip: IpNetwork = \"2602:FBAD::/40\".parse().unwrap();\n- let to_str = ip.to_string();\n- println!(\"network: {}\", to_str);\n-\n- let ip_ad: IPAddress = IPAddress::parse(to_str).unwrap();\n- println!(\"IPAdress network: {:?}\", ip_ad);\n-\n- let to_str = ip_ad.to_string();\n- println!(\"network: {}\", to_str);\n-\n- let ip: IpNetwork = to_str.parse().unwrap();\n- println!(\"IpNetwork network: {:?}\", ip);\n- }\n-\n- /// This checks the functionality of IPAddress 'subnet' function which divides a larger subnet\n- /// into individual smaller ones. Source code of this function is used\n- #[ignore]\n- #[test]\n- fn test_subnet_splitting() {\n- let ip = IPAddress::parse(\"2602:FBAD::/40\").unwrap();\n- println!(\"we got: {:?}\", ip);\n- let subnets = ip.subnet(42);\n- println!(\"subners: {:?}\", subnets);\n-\n- println!(\"Subnets custom: {:?}\", test_subnet_aggregate(ip, 42));\n- }\n-\n- #[allow(dead_code)]\n- fn test_subnet_aggregate(network: IPAddress, subprefix: usize) -> Vec<IPAddress> {\n- let mut ret = Vec::new();\n- let mut net = network.network();\n- for _ in 0..(1 << (subprefix - network.prefix.num)) {\n- ret.push(net.clone());\n- net = net.from(&net.host_address, &net.prefix);\n- let size = net.size();\n- net.host_address += size;\n- }\n-\n- ret\n- }\n-\n/// Test iterative subnet generation\n#[test]\nfn test_generate_iterative_subnet() {\n@@ -933,23 +918,13 @@ mod tests {\n#[test]\nfn test_subnet_to_index() {\n- let exit_sub: IpNetwork = \"fd00::1000/120\".parse().unwrap();\nlet sub: IpNetwork = \"fd00::1000/124\".parse().unwrap();\n- let exit_sub_mig: IPAddress = IPAddress::parse(exit_sub.to_string())\n- .expect(\"Paniced while migrating IpNetwork -> IPAddress\");\n- let sub_mig: IPAddress = IPAddress::parse(sub.to_string())\n- .expect(\"Paniced while parsing IpNetwork -> IPAddress\");\n-\n- let net = sub_mig.network();\n+ let net = sub.network();\nprintln!(\"net: {:?}\", net);\n- let size = net.size();\n+ let size = sub.size();\nprintln!(\"size: {:?}\", size);\n- let test = (sub_mig.host_address - exit_sub_mig.host_address) / size;\n- let a: u64 = test.to_string().parse().unwrap();\n- println!(\"Res: {:?}\", a);\n-\nlet exit_sub: IpNetwork = \"fd00::1000/120\".parse().unwrap();\nlet sub: IpNetwork = \"fd00::1060/124\".parse().unwrap();\nassert_eq!(generate_index_from_subnet(exit_sub, sub).unwrap(), 6);\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Removed IPAddress dep from rita exit cargo audit shows this crate with security vulneribilites so it has been removed and replaced with other ip network functions
20,255
19.07.2022 11:23:30
25,200
e267f7d86405b060aa6c628020b88d2cced5de12
Update lettre crate to 0.10 Cargo audit point out a vulnerability with version 0.9.4
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -79,7 +79,7 @@ dependencies = [\n\"actix-tls\",\n\"actix-utils\",\n\"ahash\",\n- \"base64 0.13.0\",\n+ \"base64\",\n\"bitflags\",\n\"brotli\",\n\"bytes\",\n@@ -98,7 +98,7 @@ dependencies = [\n\"mime\",\n\"percent-encoding\",\n\"pin-project-lite\",\n- \"rand 0.8.5\",\n+ \"rand\",\n\"sha1\",\n\"smallvec\",\n\"tracing\",\n@@ -234,7 +234,7 @@ dependencies = [\n\"actix-service\",\n\"actix-utils\",\n\"actix-web\",\n- \"base64 0.13.0\",\n+ \"base64\",\n\"futures-core\",\n\"futures-util\",\n\"pin-project-lite\",\n@@ -265,7 +265,7 @@ checksum = \"fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47\"\ndependencies = [\n\"getrandom\",\n\"once_cell\",\n- \"version_check 0.9.4\",\n+ \"version_check\",\n]\n[[package]]\n@@ -317,14 +317,14 @@ version = \"0.1.0\"\ndependencies = [\n\"arrayvec 0.7.2\",\n\"babel_monitor\",\n- \"base64 0.13.0\",\n+ \"base64\",\n\"clarity\",\n\"hex\",\n\"ipnetwork 0.20.0\",\n\"lettre\",\n\"num256\",\n\"phonenumber\",\n- \"rand 0.8.5\",\n+ \"rand\",\n\"serde 1.0.139\",\n\"serde_derive\",\n\"serde_json\",\n@@ -343,7 +343,7 @@ dependencies = [\n\"lazy_static\",\n\"log\",\n\"oping\",\n- \"rand 0.8.5\",\n+ \"rand\",\n\"serde 1.0.139\",\n\"serde_json\",\n\"sodiumoxide\",\n@@ -357,7 +357,7 @@ dependencies = [\n\"clarity\",\n\"lazy_static\",\n\"log\",\n- \"rand 0.8.5\",\n+ \"rand\",\n\"serde 1.0.139\",\n\"serde_derive\",\n\"serde_json\",\n@@ -385,12 +385,6 @@ version = \"1.0.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"bbf56136a5198c7b01a49e3afcbef6cf84597273d298f54432926024107b0109\"\n-[[package]]\n-name = \"ascii_utils\"\n-version = \"0.9.3\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"71938f30533e4d95a6d17aa530939da3842c2ab6f4f84b9dae68447e4129f74a\"\n-\n[[package]]\nname = \"atty\"\nversion = \"0.2.14\"\n@@ -412,22 +406,13 @@ dependencies = [\n\"log\",\n\"num 0.4.0\",\n\"num256\",\n- \"rand 0.8.5\",\n+ \"rand\",\n\"serde 1.0.139\",\n\"serde_derive\",\n\"tokio\",\n\"web30\",\n]\n-[[package]]\n-name = \"autocfg\"\n-version = \"0.1.8\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78\"\n-dependencies = [\n- \"autocfg 1.1.0\",\n-]\n-\n[[package]]\nname = \"autocfg\"\nversion = \"1.1.0\"\n@@ -447,7 +432,7 @@ dependencies = [\n\"actix-tls\",\n\"actix-utils\",\n\"ahash\",\n- \"base64 0.13.0\",\n+ \"base64\",\n\"bytes\",\n\"cfg-if\",\n\"cookie\",\n@@ -462,7 +447,7 @@ dependencies = [\n\"openssl\",\n\"percent-encoding\",\n\"pin-project-lite\",\n- \"rand 0.8.5\",\n+ \"rand\",\n\"serde 1.0.139\",\n\"serde_json\",\n\"serde_urlencoded\",\n@@ -489,26 +474,7 @@ checksum = \"b62ddb9cb1ec0a098ad4bbf9344d0713fa193ae1a80af55febcff2627b6a00c1\"\ndependencies = [\n\"getrandom\",\n\"instant\",\n- \"rand 0.8.5\",\n-]\n-\n-[[package]]\n-name = \"base64\"\n-version = \"0.9.3\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643\"\n-dependencies = [\n- \"byteorder\",\n- \"safemem\",\n-]\n-\n-[[package]]\n-name = \"base64\"\n-version = \"0.10.1\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e\"\n-dependencies = [\n- \"byteorder\",\n+ \"rand\",\n]\n[[package]]\n@@ -594,12 +560,6 @@ dependencies = [\n\"alloc-stdlib\",\n]\n-[[package]]\n-name = \"bufstream\"\n-version = \"0.1.4\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"40e38929add23cdf8a366df9b0e088953150724bcbe5fc330b0d8eb3b328eec8\"\n-\n[[package]]\nname = \"bumpalo\"\nversion = \"3.10.0\"\n@@ -620,9 +580,9 @@ checksum = \"14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610\"\n[[package]]\nname = \"bytes\"\n-version = \"1.1.0\"\n+version = \"1.2.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8\"\n+checksum = \"f0b3de4a0c5e67e16066a0715723abd91edc2f9001d09c46e1dca929351e130e\"\n[[package]]\nname = \"bytestring\"\n@@ -685,15 +645,6 @@ dependencies = [\n\"sha3\",\n]\n-[[package]]\n-name = \"cloudabi\"\n-version = \"0.0.3\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f\"\n-dependencies = [\n- \"bitflags\",\n-]\n-\n[[package]]\nname = \"clu\"\nversion = \"0.0.1\"\n@@ -705,7 +656,7 @@ dependencies = [\n\"ipgen\",\n\"lazy_static\",\n\"log\",\n- \"rand 0.8.5\",\n+ \"rand\",\n\"regex\",\n\"serde 1.0.139\",\n\"serde_derive\",\n@@ -763,7 +714,7 @@ checksum = \"94d4706de1b0fa5b132270cddffa8585166037822e260a944fe161acd137ca05\"\ndependencies = [\n\"percent-encoding\",\n\"time 0.3.11\",\n- \"version_check 0.9.4\",\n+ \"version_check\",\n]\n[[package]]\n@@ -822,9 +773,9 @@ dependencies = [\n[[package]]\nname = \"crypto-common\"\n-version = \"0.1.5\"\n+version = \"0.1.6\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"2ccfd8c0ee4cce11e45b3fd6f9d5e69e0cc62912aa6a0cb1bf4617b0eba5a12f\"\n+checksum = \"1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3\"\ndependencies = [\n\"generic-array 0.14.5\",\n\"typenum\",\n@@ -949,83 +900,20 @@ source = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be\"\n[[package]]\n-name = \"email\"\n-version = \"0.0.20\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"91549a51bb0241165f13d57fc4c72cef063b4088fb078b019ecbf464a45f22e4\"\n-dependencies = [\n- \"base64 0.9.3\",\n- \"chrono\",\n- \"encoding\",\n- \"lazy_static\",\n- \"rand 0.4.6\",\n- \"time 0.1.44\",\n- \"version_check 0.1.5\",\n-]\n-\n-[[package]]\n-name = \"encoding\"\n-version = \"0.2.33\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec\"\n-dependencies = [\n- \"encoding-index-japanese\",\n- \"encoding-index-korean\",\n- \"encoding-index-simpchinese\",\n- \"encoding-index-singlebyte\",\n- \"encoding-index-tradchinese\",\n-]\n-\n-[[package]]\n-name = \"encoding-index-japanese\"\n-version = \"1.20141219.5\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91\"\n-dependencies = [\n- \"encoding_index_tests\",\n-]\n-\n-[[package]]\n-name = \"encoding-index-korean\"\n-version = \"1.20141219.5\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81\"\n-dependencies = [\n- \"encoding_index_tests\",\n-]\n-\n-[[package]]\n-name = \"encoding-index-simpchinese\"\n-version = \"1.20141219.5\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"d87a7194909b9118fc707194baa434a4e3b0fb6a5a757c73c3adb07aa25031f7\"\n-dependencies = [\n- \"encoding_index_tests\",\n-]\n-\n-[[package]]\n-name = \"encoding-index-singlebyte\"\n-version = \"1.20141219.5\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a\"\n-dependencies = [\n- \"encoding_index_tests\",\n-]\n-\n-[[package]]\n-name = \"encoding-index-tradchinese\"\n-version = \"1.20141219.5\"\n+name = \"email-encoding\"\n+version = \"0.1.3\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18\"\n+checksum = \"34dd14c63662e0206599796cd5e1ad0268ab2b9d19b868d6050d688eba2bbf98\"\ndependencies = [\n- \"encoding_index_tests\",\n+ \"base64\",\n+ \"memchr\",\n]\n[[package]]\n-name = \"encoding_index_tests\"\n-version = \"0.1.4\"\n+name = \"email_address\"\n+version = \"0.2.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569\"\n+checksum = \"8684b7c9cb4857dfa1e5b9629ef584ba618c9b93bae60f58cb23f4f271d0468e\"\n[[package]]\nname = \"encoding_rs\"\n@@ -1077,15 +965,6 @@ version = \"0.1.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed\"\n-[[package]]\n-name = \"fast_chemail\"\n-version = \"0.9.6\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"495a39d30d624c2caabe6312bfead73e7717692b44e0b32df168c275a2e8e9e4\"\n-dependencies = [\n- \"ascii_utils\",\n-]\n-\n[[package]]\nname = \"fastrand\"\nversion = \"1.7.0\"\n@@ -1148,12 +1027,6 @@ version = \"1.2.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394\"\n-[[package]]\n-name = \"fuchsia-cprng\"\n-version = \"0.1.1\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba\"\n-\n[[package]]\nname = \"futures\"\nversion = \"0.1.31\"\n@@ -1273,7 +1146,7 @@ source = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803\"\ndependencies = [\n\"typenum\",\n- \"version_check 0.9.4\",\n+ \"version_check\",\n]\n[[package]]\n@@ -1336,9 +1209,9 @@ checksum = \"eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7\"\n[[package]]\nname = \"handlebars\"\n-version = \"4.3.1\"\n+version = \"4.3.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"b66d0c1b6e3abfd1e72818798925e16e02ed77e1b47f6c25a95a23b377ee4299\"\n+checksum = \"36641a8b9deb60e23fb9bb47ac631d664a780b088909b89179a4eab5618b076b\"\ndependencies = [\n\"log\",\n\"pest\",\n@@ -1350,9 +1223,9 @@ dependencies = [\n[[package]]\nname = \"hashbrown\"\n-version = \"0.12.2\"\n+version = \"0.12.3\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"607c8a29735385251a339424dd462993c0fed8fa09d378f259377df08c126022\"\n+checksum = \"8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888\"\n[[package]]\nname = \"hermit-abi\"\n@@ -1377,12 +1250,13 @@ checksum = \"7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0\"\n[[package]]\nname = \"hostname\"\n-version = \"0.1.5\"\n+version = \"0.3.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"21ceb46a83a85e824ef93669c8b390009623863b5c195d1ba747292c0c72f94e\"\n+checksum = \"3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867\"\ndependencies = [\n\"libc\",\n- \"winutil\",\n+ \"match_cfg\",\n+ \"winapi 0.3.9\",\n]\n[[package]]\n@@ -1479,7 +1353,7 @@ version = \"1.9.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e\"\ndependencies = [\n- \"autocfg 1.1.0\",\n+ \"autocfg\",\n\"hashbrown\",\n]\n@@ -1606,33 +1480,25 @@ checksum = \"e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646\"\n[[package]]\nname = \"lettre\"\n-version = \"0.9.6\"\n+version = \"0.10.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"86ed8677138975b573ab4949c35613931a4addeadd0a8a6aa0327e2a979660de\"\n+checksum = \"5677c78c7c7ede1dd68e8a7078012bc625449fb304e7b509b917eaaedfe6e849\"\ndependencies = [\n- \"base64 0.10.1\",\n- \"bufstream\",\n- \"fast_chemail\",\n+ \"base64\",\n+ \"email-encoding\",\n+ \"email_address\",\n+ \"fastrand\",\n+ \"futures-util\",\n\"hostname\",\n- \"log\",\n+ \"httpdate\",\n+ \"idna\",\n+ \"mime\",\n\"native-tls\",\n- \"nom 4.2.3\",\n+ \"nom 7.1.1\",\n+ \"once_cell\",\n+ \"quoted_printable\",\n\"serde 1.0.139\",\n- \"serde_derive\",\n- \"serde_json\",\n-]\n-\n-[[package]]\n-name = \"lettre_email\"\n-version = \"0.9.4\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"fd02480f8dcf48798e62113974d6ccca2129a51d241fa20f1ea349c8a42559d5\"\n-dependencies = [\n- \"base64 0.10.1\",\n- \"email\",\n- \"lettre\",\n- \"mime\",\n- \"time 0.1.44\",\n+ \"socket2\",\n\"uuid\",\n]\n@@ -1697,7 +1563,7 @@ version = \"0.4.7\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53\"\ndependencies = [\n- \"autocfg 1.1.0\",\n+ \"autocfg\",\n\"scopeguard\",\n]\n@@ -1725,6 +1591,12 @@ version = \"1.0.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d\"\n+[[package]]\n+name = \"match_cfg\"\n+version = \"0.1.0\"\n+source = \"registry+https://github.com/rust-lang/crates.io-index\"\n+checksum = \"ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4\"\n+\n[[package]]\nname = \"matches\"\nversion = \"0.1.9\"\n@@ -1743,6 +1615,12 @@ version = \"0.3.16\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d\"\n+[[package]]\n+name = \"minimal-lexical\"\n+version = \"0.2.1\"\n+source = \"registry+https://github.com/rust-lang/crates.io-index\"\n+checksum = \"68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a\"\n+\n[[package]]\nname = \"miniz_oxide\"\nversion = \"0.5.3\"\n@@ -1784,9 +1662,9 @@ dependencies = [\n[[package]]\nname = \"nix\"\n-version = \"0.24.1\"\n+version = \"0.24.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"8f17df307904acd05aa8e32e97bb20f2a0df1728bbc2d771ae8f9a90463441e9\"\n+checksum = \"195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc\"\ndependencies = [\n\"bitflags\",\n\"cfg-if\",\n@@ -1795,23 +1673,23 @@ dependencies = [\n[[package]]\nname = \"nom\"\n-version = \"4.2.3\"\n+version = \"5.1.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6\"\n+checksum = \"ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af\"\ndependencies = [\n+ \"lexical-core\",\n\"memchr\",\n- \"version_check 0.1.5\",\n+ \"version_check\",\n]\n[[package]]\nname = \"nom\"\n-version = \"5.1.2\"\n+version = \"7.1.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af\"\n+checksum = \"a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36\"\ndependencies = [\n- \"lexical-core\",\n\"memchr\",\n- \"version_check 0.9.4\",\n+ \"minimal-lexical\",\n]\n[[package]]\n@@ -1848,7 +1726,7 @@ version = \"0.2.6\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304\"\ndependencies = [\n- \"autocfg 1.1.0\",\n+ \"autocfg\",\n\"num-integer\",\n\"num-traits 0.2.15\",\n]\n@@ -1859,7 +1737,7 @@ version = \"0.4.3\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f\"\ndependencies = [\n- \"autocfg 1.1.0\",\n+ \"autocfg\",\n\"num-integer\",\n\"num-traits 0.2.15\",\n\"serde 1.0.139\",\n@@ -1871,7 +1749,7 @@ version = \"0.2.4\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95\"\ndependencies = [\n- \"autocfg 1.1.0\",\n+ \"autocfg\",\n\"num-traits 0.2.15\",\n]\n@@ -1901,7 +1779,7 @@ version = \"0.1.45\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9\"\ndependencies = [\n- \"autocfg 1.1.0\",\n+ \"autocfg\",\n\"num-traits 0.2.15\",\n]\n@@ -1911,7 +1789,7 @@ version = \"0.1.43\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252\"\ndependencies = [\n- \"autocfg 1.1.0\",\n+ \"autocfg\",\n\"num-integer\",\n\"num-traits 0.2.15\",\n]\n@@ -1922,7 +1800,7 @@ version = \"0.2.4\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef\"\ndependencies = [\n- \"autocfg 1.1.0\",\n+ \"autocfg\",\n\"num-bigint 0.2.6\",\n\"num-integer\",\n\"num-traits 0.2.15\",\n@@ -1934,7 +1812,7 @@ version = \"0.4.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0\"\ndependencies = [\n- \"autocfg 1.1.0\",\n+ \"autocfg\",\n\"num-bigint 0.4.3\",\n\"num-integer\",\n\"num-traits 0.2.15\",\n@@ -1955,7 +1833,7 @@ version = \"0.2.15\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd\"\ndependencies = [\n- \"autocfg 1.1.0\",\n+ \"autocfg\",\n]\n[[package]]\n@@ -2062,7 +1940,7 @@ version = \"0.9.75\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"e5f9bd0c2710541a3cda73d6f9ac4f1b240de4ae261065d309dbe73d9dceb42f\"\ndependencies = [\n- \"autocfg 1.1.0\",\n+ \"autocfg\",\n\"cc\",\n\"libc\",\n\"openssl-src\",\n@@ -2239,9 +2117,9 @@ checksum = \"eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872\"\n[[package]]\nname = \"pq-sys\"\n-version = \"0.4.6\"\n+version = \"0.4.7\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"6ac25eee5a0582f45a67e837e350d784e7003bd29a5f460796772061ca49ffda\"\n+checksum = \"3b845d6d8ec554f972a2c5298aad68953fd64e7441e846075450b44656a016d1\"\ndependencies = [\n\"vcpkg\",\n]\n@@ -2273,6 +2151,12 @@ dependencies = [\n\"proc-macro2\",\n]\n+[[package]]\n+name = \"quoted_printable\"\n+version = \"0.4.5\"\n+source = \"registry+https://github.com/rust-lang/crates.io-index\"\n+checksum = \"3fee2dce59f7a43418e3382c766554c614e06a552d53a8f07ef499ea4b332c0f\"\n+\n[[package]]\nname = \"r2d2\"\nversion = \"0.8.10\"\n@@ -2284,38 +2168,6 @@ dependencies = [\n\"scheduled-thread-pool\",\n]\n-[[package]]\n-name = \"rand\"\n-version = \"0.4.6\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293\"\n-dependencies = [\n- \"fuchsia-cprng\",\n- \"libc\",\n- \"rand_core 0.3.1\",\n- \"rdrand\",\n- \"winapi 0.3.9\",\n-]\n-\n-[[package]]\n-name = \"rand\"\n-version = \"0.6.5\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca\"\n-dependencies = [\n- \"autocfg 0.1.8\",\n- \"libc\",\n- \"rand_chacha 0.1.1\",\n- \"rand_core 0.4.2\",\n- \"rand_hc\",\n- \"rand_isaac\",\n- \"rand_jitter\",\n- \"rand_os\",\n- \"rand_pcg\",\n- \"rand_xorshift\",\n- \"winapi 0.3.9\",\n-]\n-\n[[package]]\nname = \"rand\"\nversion = \"0.8.5\"\n@@ -2323,18 +2175,8 @@ source = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404\"\ndependencies = [\n\"libc\",\n- \"rand_chacha 0.3.1\",\n- \"rand_core 0.6.3\",\n-]\n-\n-[[package]]\n-name = \"rand_chacha\"\n-version = \"0.1.1\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef\"\n-dependencies = [\n- \"autocfg 0.1.8\",\n- \"rand_core 0.3.1\",\n+ \"rand_chacha\",\n+ \"rand_core\",\n]\n[[package]]\n@@ -2344,24 +2186,9 @@ source = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88\"\ndependencies = [\n\"ppv-lite86\",\n- \"rand_core 0.6.3\",\n+ \"rand_core\",\n]\n-[[package]]\n-name = \"rand_core\"\n-version = \"0.3.1\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b\"\n-dependencies = [\n- \"rand_core 0.4.2\",\n-]\n-\n-[[package]]\n-name = \"rand_core\"\n-version = \"0.4.2\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc\"\n-\n[[package]]\nname = \"rand_core\"\nversion = \"0.6.3\"\n@@ -2371,77 +2198,6 @@ dependencies = [\n\"getrandom\",\n]\n-[[package]]\n-name = \"rand_hc\"\n-version = \"0.1.0\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4\"\n-dependencies = [\n- \"rand_core 0.3.1\",\n-]\n-\n-[[package]]\n-name = \"rand_isaac\"\n-version = \"0.1.1\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08\"\n-dependencies = [\n- \"rand_core 0.3.1\",\n-]\n-\n-[[package]]\n-name = \"rand_jitter\"\n-version = \"0.1.4\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b\"\n-dependencies = [\n- \"libc\",\n- \"rand_core 0.4.2\",\n- \"winapi 0.3.9\",\n-]\n-\n-[[package]]\n-name = \"rand_os\"\n-version = \"0.1.3\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071\"\n-dependencies = [\n- \"cloudabi\",\n- \"fuchsia-cprng\",\n- \"libc\",\n- \"rand_core 0.4.2\",\n- \"rdrand\",\n- \"winapi 0.3.9\",\n-]\n-\n-[[package]]\n-name = \"rand_pcg\"\n-version = \"0.1.2\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44\"\n-dependencies = [\n- \"autocfg 0.1.8\",\n- \"rand_core 0.4.2\",\n-]\n-\n-[[package]]\n-name = \"rand_xorshift\"\n-version = \"0.1.1\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c\"\n-dependencies = [\n- \"rand_core 0.3.1\",\n-]\n-\n-[[package]]\n-name = \"rdrand\"\n-version = \"0.4.0\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2\"\n-dependencies = [\n- \"rand_core 0.3.1\",\n-]\n-\n[[package]]\nname = \"redox_syscall\"\nversion = \"0.2.13\"\n@@ -2495,7 +2251,7 @@ version = \"0.11.11\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"b75aa69a3f06bbcc66ede33af2af253c6f7a86b1ca0033f60c580a27074fbf92\"\ndependencies = [\n- \"base64 0.13.0\",\n+ \"base64\",\n\"bytes\",\n\"encoding_rs\",\n\"futures-core\",\n@@ -2579,7 +2335,6 @@ dependencies = [\n\"ipnetwork 0.20.0\",\n\"lazy_static\",\n\"lettre\",\n- \"lettre_email\",\n\"log\",\n\"num-traits 0.2.15\",\n\"num256\",\n@@ -2623,7 +2378,7 @@ dependencies = [\n\"log\",\n\"num-traits 0.2.15\",\n\"num256\",\n- \"rand 0.8.5\",\n+ \"rand\",\n\"regex\",\n\"serde 1.0.139\",\n\"serde_cbor\",\n@@ -2652,12 +2407,11 @@ dependencies = [\n\"ipnetwork 0.20.0\",\n\"lazy_static\",\n\"lettre\",\n- \"lettre_email\",\n\"log\",\n\"num256\",\n\"phonenumber\",\n\"r2d2\",\n- \"rand 0.8.5\",\n+ \"rand\",\n\"reqwest\",\n\"rita_common\",\n\"serde 1.0.139\",\n@@ -2688,12 +2442,6 @@ version = \"1.0.10\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695\"\n-[[package]]\n-name = \"safemem\"\n-version = \"0.3.3\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072\"\n-\n[[package]]\nname = \"same-file\"\nversion = \"1.0.6\"\n@@ -2939,9 +2687,12 @@ checksum = \"f054c6c1a6e95179d6f23ed974060dcefb2d9388bb7256900badad682c499de4\"\n[[package]]\nname = \"slab\"\n-version = \"0.4.6\"\n+version = \"0.4.7\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32\"\n+checksum = \"4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef\"\n+dependencies = [\n+ \"autocfg\",\n+]\n[[package]]\nname = \"smallvec\"\n@@ -3095,10 +2846,11 @@ checksum = \"cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c\"\n[[package]]\nname = \"tokio\"\n-version = \"1.19.2\"\n+version = \"1.20.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"c51a52ed6686dd62c320f9b89299e9dfb46f730c7a48e635c19f21d116cb1439\"\n+checksum = \"57aec3cfa4c296db7255446efb4928a6be304b431a806216105542a67b6ca82e\"\ndependencies = [\n+ \"autocfg\",\n\"bytes\",\n\"libc\",\n\"memchr\",\n@@ -3248,9 +3000,9 @@ checksum = \"099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992\"\n[[package]]\nname = \"unicode-ident\"\n-version = \"1.0.1\"\n+version = \"1.0.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c\"\n+checksum = \"15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7\"\n[[package]]\nname = \"unicode-normalization\"\n@@ -3275,11 +3027,11 @@ dependencies = [\n[[package]]\nname = \"uuid\"\n-version = \"0.7.4\"\n+version = \"1.1.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a\"\n+checksum = \"dd6469f4314d5f1ffec476e05f17cc9a78bc7a27a6a857842170bdf8d6f98d2f\"\ndependencies = [\n- \"rand 0.6.5\",\n+ \"getrandom\",\n]\n[[package]]\n@@ -3288,12 +3040,6 @@ version = \"0.2.15\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426\"\n-[[package]]\n-name = \"version_check\"\n-version = \"0.1.5\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd\"\n-\n[[package]]\nname = \"version_check\"\nversion = \"0.9.4\"\n@@ -3517,15 +3263,6 @@ dependencies = [\n\"winapi 0.3.9\",\n]\n-[[package]]\n-name = \"winutil\"\n-version = \"0.1.1\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"7daf138b6b14196e3830a588acf1e86966c694d3e8fb026fb105b8b5dca07e6e\"\n-dependencies = [\n- \"winapi 0.3.9\",\n-]\n-\n[[package]]\nname = \"yaml-rust\"\nversion = \"0.4.5\"\n" }, { "change_type": "MODIFY", "old_path": "althea_types/Cargo.toml", "new_path": "althea_types/Cargo.toml", "diff": "@@ -18,7 +18,7 @@ sodiumoxide = \"0.2\"\nclarity = \"0.5\"\narrayvec = {version= \"0.7\", features = [\"serde\"]}\nphonenumber = \"0.3\"\n-lettre = {version = \"0.9\", features = [\"serde\"]}\n+lettre = {version = \"0.10\", features = [\"serde\"]}\nipnetwork = \"0.20\"\n[dev-dependencies]\n" }, { "change_type": "MODIFY", "old_path": "althea_types/src/contact_info.rs", "new_path": "althea_types/src/contact_info.rs", "diff": "//! to serialize enums with struct members. This file is all boilerplate conversion code for pretty small storage formats.\nuse crate::ExitRegistrationDetails;\n-use lettre::EmailAddress;\n+use lettre::Address as EmailAddress;\nuse phonenumber::PhoneNumber;\n/// Struct for submitting contact details to exits\n" }, { "change_type": "MODIFY", "old_path": "rita_client/Cargo.toml", "new_path": "rita_client/Cargo.toml", "diff": "@@ -21,8 +21,7 @@ althea_kernel_interface = { path = \"../althea_kernel_interface\" }\nantenna_forwarding_client = { path = \"../antenna_forwarding_client\" }\nsettings = { path = \"../settings\" }\nsha3 = \"0.10\"\n-lettre = \"0.9\"\n-lettre_email = \"0.9\"\n+lettre = \"0.10\"\nphonenumber = \"0.3\"\nbabel_monitor = { path = \"../babel_monitor\" }\narrayvec = {version= \"0.7\", features = [\"serde\"]}\n" }, { "change_type": "MODIFY", "old_path": "rita_client/src/dashboard/contact_info.rs", "new_path": "rita_client/src/dashboard/contact_info.rs", "diff": "@@ -7,7 +7,7 @@ use rita_common::utils::option_convert;\nuse actix_web_async::HttpRequest;\nuse actix_web_async::HttpResponse;\nuse althea_types::ContactType;\n-use lettre::EmailAddress;\n+use lettre::Address as EmailAddress;\nuse phonenumber::PhoneNumber;\nfn clean_quotes(val: &str) -> String {\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/Cargo.toml", "new_path": "rita_exit/Cargo.toml", "diff": "@@ -25,8 +25,7 @@ clarity = \"0.5\"\nserde = \"1.0\"\nserde_derive = \"1.0\"\nserde_json = \"1.0\"\n-lettre = \"0.9\"\n-lettre_email = \"0.9\"\n+lettre = { version = \"0.10\", features = [\"file-transport\"]}\nr2d2 = \"0.8\"\nphonenumber = \"0.3\"\narrayvec = {version= \"0.7\", features = [\"serde\"]}\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/database/email.rs", "new_path": "rita_exit/src/database/email.rs", "diff": "@@ -10,12 +10,12 @@ use althea_types::{ExitClientDetails, ExitClientIdentity, ExitState};\nuse diesel::prelude::PgConnection;\nuse exit_db::models;\nuse handlebars::Handlebars;\n-use lettre::file::FileTransport;\n-use lettre::smtp::authentication::{Credentials, Mechanism};\n-use lettre::smtp::extension::ClientId;\n-use lettre::smtp::ConnectionReuseParameters;\n-use lettre::{SmtpClient, Transport};\n-use lettre_email::EmailBuilder;\n+use lettre::transport::smtp::authentication::Credentials;\n+use lettre::transport::smtp::authentication::Mechanism;\n+use lettre::transport::smtp::extension::ClientId;\n+use lettre::transport::smtp::PoolConfig;\n+use lettre::FileTransport;\n+use lettre::{Message, SmtpTransport, Transport};\nuse serde_json::json;\nuse settings::exit::ExitVerifSettings;\n@@ -38,30 +38,27 @@ pub fn send_mail(client: &models::Client) -> Result<(), RitaExitError> {\nlet reg = Handlebars::new();\n- let email = EmailBuilder::new()\n- .to(client.email.clone())\n- .from(mailer.from_address)\n+ let email = Message::builder()\n+ .to(client.email.clone().parse().unwrap())\n+ .from(mailer.from_address.parse().unwrap())\n.subject(mailer.signup_subject)\n// TODO: maybe have a proper templating engine\n- .text(reg.render_template(\n+ .body(reg.render_template(\n&mailer.signup_body,\n&json!({\"email_code\": client.email_code.to_string()}),\n- )?)\n- .build()?;\n+ )?)?;\nif mailer.test {\n- let mut mailer = FileTransport::new(&mailer.test_dir);\n- mailer.send(email.into())?;\n+ let mailer = FileTransport::new(&mailer.test_dir);\n+ mailer.send(&email)?;\n} else {\n- // TODO add serde to lettre\n- let mut mailer = SmtpClient::new_simple(&mailer.smtp_url)?\n+ let mailer = SmtpTransport::relay(&mailer.smtp_url)?\n.hello_name(ClientId::Domain(mailer.smtp_domain))\n.credentials(Credentials::new(mailer.smtp_username, mailer.smtp_password))\n- .smtp_utf8(true)\n- .authentication_mechanism(Mechanism::Plain)\n- .connection_reuse(ConnectionReuseParameters::ReuseUnlimited)\n- .transport();\n- mailer.send(email.into())?;\n+ .authentication(vec![Mechanism::Plain])\n+ .pool_config(PoolConfig::new().max_size(20))\n+ .build();\n+ mailer.send(&email)?;\n}\nOk(())\n" }, { "change_type": "MODIFY", "old_path": "rita_exit/src/error.rs", "new_path": "rita_exit/src/error.rs", "diff": "@@ -19,9 +19,9 @@ pub enum RitaExitError {\nDieselError(diesel::result::Error),\nRitaCommonError(RitaCommonError),\nRenderError(RenderError),\n- EmailError(lettre_email::error::Error),\n- FileError(lettre::file::error::Error),\n- SmtpError(lettre::smtp::error::Error),\n+ EmailError(lettre::error::Error),\n+ FileError(lettre::transport::file::Error),\n+ SmtpError(lettre::transport::smtp::Error),\nIpNetworkError(IpNetworkError),\nPhoneParseError(phonenumber::ParseError),\nClarityError(clarity::error::Error),\n@@ -49,18 +49,18 @@ impl From<RenderError> for RitaExitError {\nRitaExitError::RenderError(error)\n}\n}\n-impl From<lettre_email::error::Error> for RitaExitError {\n- fn from(error: lettre_email::error::Error) -> Self {\n+impl From<lettre::error::Error> for RitaExitError {\n+ fn from(error: lettre::error::Error) -> Self {\nRitaExitError::EmailError(error)\n}\n}\n-impl From<lettre::file::error::Error> for RitaExitError {\n- fn from(error: lettre::file::error::Error) -> Self {\n+impl From<lettre::transport::file::Error> for RitaExitError {\n+ fn from(error: lettre::transport::file::Error) -> Self {\nRitaExitError::FileError(error)\n}\n}\n-impl From<lettre::smtp::error::Error> for RitaExitError {\n- fn from(error: lettre::smtp::error::Error) -> Self {\n+impl From<lettre::transport::smtp::Error> for RitaExitError {\n+ fn from(error: lettre::transport::smtp::Error) -> Self {\nRitaExitError::SmtpError(error)\n}\n}\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Update lettre crate to 0.10 Cargo audit point out a vulnerability with version 0.9.4
20,255
20.07.2022 10:12:47
25,200
ee4aed25baeabb2e849bbeaf99e0a281533fe30a
Use compressed log 0.5.1
[ { "change_type": "MODIFY", "old_path": "Cargo.lock", "new_path": "Cargo.lock", "diff": "@@ -116,7 +116,7 @@ dependencies = [\n\"http\",\n\"log\",\n\"regex\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n]\n[[package]]\n@@ -216,12 +216,12 @@ dependencies = [\n\"once_cell\",\n\"pin-project-lite\",\n\"regex\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde_json\",\n\"serde_urlencoded\",\n\"smallvec\",\n\"socket2\",\n- \"time 0.3.11\",\n+ \"time\",\n\"url\",\n]\n@@ -303,7 +303,7 @@ dependencies = [\n\"log\",\n\"oping\",\n\"regex\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde_derive\",\n]\n@@ -325,7 +325,7 @@ dependencies = [\n\"num256\",\n\"phonenumber\",\n\"rand\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde_derive\",\n\"serde_json\",\n\"sodiumoxide\",\n@@ -344,7 +344,7 @@ dependencies = [\n\"log\",\n\"oping\",\n\"rand\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde_json\",\n\"sodiumoxide\",\n]\n@@ -358,7 +358,7 @@ dependencies = [\n\"lazy_static\",\n\"log\",\n\"rand\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde_derive\",\n\"serde_json\",\n\"sodiumoxide\",\n@@ -376,7 +376,7 @@ version = \"0.7.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6\"\ndependencies = [\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n]\n[[package]]\n@@ -407,7 +407,7 @@ dependencies = [\n\"num 0.4.0\",\n\"num256\",\n\"rand\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde_derive\",\n\"tokio\",\n\"web30\",\n@@ -448,7 +448,7 @@ dependencies = [\n\"percent-encoding\",\n\"pin-project-lite\",\n\"rand\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde_json\",\n\"serde_urlencoded\",\n\"tokio\",\n@@ -462,7 +462,7 @@ dependencies = [\n\"env_logger\",\n\"ipnetwork 0.20.0\",\n\"log\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde_derive\",\n]\n@@ -489,7 +489,7 @@ version = \"1.3.3\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad\"\ndependencies = [\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n]\n[[package]]\n@@ -614,19 +614,6 @@ version = \"1.0.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd\"\n-[[package]]\n-name = \"chrono\"\n-version = \"0.4.19\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73\"\n-dependencies = [\n- \"libc\",\n- \"num-integer\",\n- \"num-traits 0.2.15\",\n- \"time 0.1.44\",\n- \"winapi 0.3.9\",\n-]\n-\n[[package]]\nname = \"clarity\"\nversion = \"0.5.1\"\n@@ -638,7 +625,7 @@ dependencies = [\n\"num-traits 0.2.15\",\n\"num256\",\n\"secp256k1\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde-rlp\",\n\"serde_bytes\",\n\"serde_derive\",\n@@ -658,7 +645,7 @@ dependencies = [\n\"log\",\n\"rand\",\n\"regex\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde_derive\",\n\"serde_json\",\n\"settings\",\n@@ -667,21 +654,21 @@ dependencies = [\n[[package]]\nname = \"compressed_log\"\n-version = \"0.5.0\"\n+version = \"0.5.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"0e8d927ae6eec4ece3a1b6cd1a148c29c8000cc2e973b30c37f2c13f695b2a33\"\n+checksum = \"e1e33c133da56e4aecd84f598f8e865c8d0ff0bb0d481d7026d5aee27a896901\"\ndependencies = [\n\"actix 0.12.0\",\n\"awc\",\n\"backoff\",\n- \"chrono\",\n\"flate2\",\n\"futures 0.3.21\",\n\"lazy_static\",\n\"log\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde_derive\",\n\"serde_json\",\n+ \"time\",\n]\n[[package]]\n@@ -693,7 +680,7 @@ dependencies = [\n\"lazy_static\",\n\"nom 5.1.2\",\n\"rust-ini\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde-hjson\",\n\"serde_json\",\n\"toml\",\n@@ -713,7 +700,7 @@ source = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"94d4706de1b0fa5b132270cddffa8585166037822e260a944fe161acd137ca05\"\ndependencies = [\n\"percent-encoding\",\n- \"time 0.3.11\",\n+ \"time\",\n\"version_check\",\n]\n@@ -874,7 +861,7 @@ checksum = \"7f3f119846c823f9eafcf953a8f6ffb6ed69bf6240883261a7f13b634579a51f\"\ndependencies = [\n\"lazy_static\",\n\"regex\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"strsim\",\n]\n@@ -954,7 +941,7 @@ dependencies = [\n\"althea_types\",\n\"diesel\",\n\"dotenv\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde_derive\",\n\"serde_json\",\n]\n@@ -1179,7 +1166,7 @@ checksum = \"4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6\"\ndependencies = [\n\"cfg-if\",\n\"libc\",\n- \"wasi 0.11.0+wasi-snapshot-preview1\",\n+ \"wasi\",\n]\n[[package]]\n@@ -1209,14 +1196,14 @@ checksum = \"eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7\"\n[[package]]\nname = \"handlebars\"\n-version = \"4.3.2\"\n+version = \"4.3.3\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"36641a8b9deb60e23fb9bb47ac631d664a780b088909b89179a4eab5618b076b\"\n+checksum = \"360d9740069b2f6cbb63ce2dbaa71a20d3185350cbb990d7bebeb9318415eb17\"\ndependencies = [\n\"log\",\n\"pest\",\n\"pest_derive\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde_json\",\n\"thiserror\",\n]\n@@ -1394,7 +1381,7 @@ version = \"0.20.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"bf466541e9d546596ee94f9f69590f89473455f88372423e0008fc1a7daf100e\"\ndependencies = [\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n]\n[[package]]\n@@ -1480,9 +1467,9 @@ checksum = \"e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646\"\n[[package]]\nname = \"lettre\"\n-version = \"0.10.0\"\n+version = \"0.10.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"5677c78c7c7ede1dd68e8a7078012bc625449fb304e7b509b917eaaedfe6e849\"\n+checksum = \"2eabca5e0b4d0e98e7f2243fb5b7520b6af2b65d8f87bcc86f2c75185a6ff243\"\ndependencies = [\n\"base64\",\n\"email-encoding\",\n@@ -1497,7 +1484,7 @@ dependencies = [\n\"nom 7.1.1\",\n\"once_cell\",\n\"quoted_printable\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"socket2\",\n\"uuid\",\n]\n@@ -1638,7 +1625,7 @@ checksum = \"57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf\"\ndependencies = [\n\"libc\",\n\"log\",\n- \"wasi 0.11.0+wasi-snapshot-preview1\",\n+ \"wasi\",\n\"windows-sys\",\n]\n@@ -1740,7 +1727,7 @@ dependencies = [\n\"autocfg\",\n\"num-integer\",\n\"num-traits 0.2.15\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n]\n[[package]]\n@@ -1846,7 +1833,7 @@ dependencies = [\n\"num 0.4.0\",\n\"num-derive\",\n\"num-traits 0.2.15\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde_derive\",\n]\n@@ -2086,7 +2073,7 @@ dependencies = [\n\"quick-xml\",\n\"regex\",\n\"regex-cache\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde_derive\",\n\"thiserror\",\n]\n@@ -2269,7 +2256,7 @@ dependencies = [\n\"native-tls\",\n\"percent-encoding\",\n\"pin-project-lite\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde_json\",\n\"serde_urlencoded\",\n\"tokio\",\n@@ -2310,7 +2297,7 @@ dependencies = [\n\"rita_client\",\n\"rita_common\",\n\"rita_exit\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde_json\",\n\"settings\",\n]\n@@ -2340,7 +2327,7 @@ dependencies = [\n\"num256\",\n\"phonenumber\",\n\"rita_common\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde_derive\",\n\"serde_json\",\n\"settings\",\n@@ -2380,7 +2367,7 @@ dependencies = [\n\"num256\",\n\"rand\",\n\"regex\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde_cbor\",\n\"serde_derive\",\n\"serde_json\",\n@@ -2414,7 +2401,7 @@ dependencies = [\n\"rand\",\n\"reqwest\",\n\"rita_common\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde_derive\",\n\"serde_json\",\n\"settings\",\n@@ -2531,9 +2518,9 @@ checksum = \"9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8\"\n[[package]]\nname = \"serde\"\n-version = \"1.0.139\"\n+version = \"1.0.140\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"0171ebb889e45aa68b44aee0859b3eede84c6f5f5c228e6f140c0b2a0a46cad6\"\n+checksum = \"fc855a42c7967b7c369eb5860f7164ef1f6f81c20c7cc1141f2a604e18723b03\"\ndependencies = [\n\"serde_derive\",\n]\n@@ -2559,7 +2546,7 @@ dependencies = [\n\"byteorder\",\n\"error\",\n\"num 0.2.1\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n]\n[[package]]\n@@ -2568,7 +2555,7 @@ version = \"0.11.6\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"212e73464ebcde48d723aa02eb270ba62eff38a9b732df31f33f1b4e145f3a54\"\ndependencies = [\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n]\n[[package]]\n@@ -2578,14 +2565,14 @@ source = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5\"\ndependencies = [\n\"half\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n]\n[[package]]\nname = \"serde_derive\"\n-version = \"1.0.139\"\n+version = \"1.0.140\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"dc1d3230c1de7932af58ad8ffbe1d784bd55efd5a9d84ac24f69c72d83543dfb\"\n+checksum = \"6f2122636b9fe3b81f1cb25099fcf2d3f542cdb1d45940d56c713158884a05da\"\ndependencies = [\n\"proc-macro2\",\n\"quote\",\n@@ -2600,7 +2587,7 @@ checksum = \"82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7\"\ndependencies = [\n\"itoa\",\n\"ryu\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n]\n[[package]]\n@@ -2612,7 +2599,7 @@ dependencies = [\n\"form_urlencoded\",\n\"itoa\",\n\"ryu\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n]\n[[package]]\n@@ -2631,7 +2618,7 @@ dependencies = [\n\"num256\",\n\"owning_ref\",\n\"phonenumber\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde_derive\",\n\"serde_json\",\n\"toml\",\n@@ -2719,7 +2706,7 @@ dependencies = [\n\"ed25519\",\n\"libc\",\n\"libsodium-sys\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n]\n[[package]]\n@@ -2800,17 +2787,6 @@ dependencies = [\n\"syn\",\n]\n-[[package]]\n-name = \"time\"\n-version = \"0.1.44\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255\"\n-dependencies = [\n- \"libc\",\n- \"wasi 0.10.0+wasi-snapshot-preview1\",\n- \"winapi 0.3.9\",\n-]\n-\n[[package]]\nname = \"time\"\nversion = \"0.3.11\"\n@@ -2932,7 +2908,7 @@ version = \"0.5.9\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7\"\ndependencies = [\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n]\n[[package]]\n@@ -3067,12 +3043,6 @@ dependencies = [\n\"try-lock\",\n]\n-[[package]]\n-name = \"wasi\"\n-version = \"0.10.0+wasi-snapshot-preview1\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f\"\n-\n[[package]]\nname = \"wasi\"\nversion = \"0.11.0+wasi-snapshot-preview1\"\n@@ -3168,7 +3138,7 @@ dependencies = [\n\"log\",\n\"num 0.4.0\",\n\"num256\",\n- \"serde 1.0.139\",\n+ \"serde 1.0.140\",\n\"serde_derive\",\n\"serde_json\",\n\"tokio\",\n" } ]
Rust
Apache License 2.0
althea-net/althea_rs
Use compressed log 0.5.1