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,244 | 11.05.2020 09:24:29 | 14,400 | 9c0e1fbed0e246f5fde30a5dde09d468c2fe8c06 | Improve logging in tunnel manager
Better and more readable logging of tunnel gc | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/tunnel_manager/mod.rs",
"new_path": "rita/src/rita_common/tunnel_manager/mod.rs",
"diff": "@@ -482,8 +482,8 @@ impl Handler<TriggerGC> for TunnelManager {\nfn handle(&mut self, msg: TriggerGC, _ctx: &mut Context<Self>) -> Self::Result {\nlet mut good: HashMap<Identity, Vec<Tunnel>> = HashMap::new();\nlet mut timed_out: HashMap<Identity, Vec<Tunnel>> = HashMap::new();\n- // Split entries into good and timed out rebuilding the double hashmap strucutre\n- // as you can tell this is enterly copy based and uses 2n ram to prevent borrow\n+ // Split entries into good and timed out rebuilding the double hashmap structure\n+ // as you can tell this is totally copy based and uses 2n ram to prevent borrow\n// checker issues, we should consider a method that does modify in place\nfor (identity, tunnels) in self.tunnels.iter() {\nfor tunnel in tunnels.iter() {\n@@ -503,7 +503,11 @@ impl Handler<TriggerGC> for TunnelManager {\n}\n}\n- info!(\"TriggerGC: removing tunnels: {:?}\", timed_out);\n+ for (id, tunnels) in timed_out.iter() {\n+ for tunnel in tunnels {\n+ info!(\"TriggerGC: removing tunnel: {} {}\", id, tunnel);\n+ }\n+ }\n// Please keep in mind it makes more sense to update the tunnel map *before* yielding the\n// actual interfaces and ports from timed_out.\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Improve logging in tunnel manager
Better and more readable logging of tunnel gc |
20,244 | 11.05.2020 09:25:04 | 14,400 | 9784eaa809d0e7f76fecaff6823d092bee98f0b1 | Fix comment typo in BabelMonitor | [
{
"change_type": "MODIFY",
"old_path": "babel_monitor/src/lib.rs",
"new_path": "babel_monitor/src/lib.rs",
"diff": "@@ -186,7 +186,7 @@ fn read_babel(\nreturn Box::new(read_babel(stream, full_message, depth));\n} else if let Err(NoTerminator(_)) = babel_data {\n// our buffer was not full but we also did not find a terminator,\n- // we must have caught babel while it was interupped (only really happens\n+ // we must have caught babel while it was interrupted (only really happens\n// in single cpu situations)\nthread::sleep(SLEEP_TIME);\ntrace!(\"we didn't get the whole message yet, trying again\");\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Fix comment typo in BabelMonitor |
20,244 | 11.05.2020 09:29:55 | 14,400 | 7501b3e05a01b50099b15e300d70b142d66ef081 | Clean up development features
This had some old stuff that needed work | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/dashboard/development.rs",
"new_path": "rita/src/rita_common/dashboard/development.rs",
"diff": "#[cfg(feature = \"development\")]\n-use crate::rita_common::rita_loop::Crash;\n+use crate::rita_common::rita_loop::fast_loop::Crash;\n#[cfg(feature = \"development\")]\n-use crate::rita_common::rita_loop::RitaLoop as RitaCommonLoop;\n+use crate::rita_common::rita_loop::fast_loop::RitaFastLoop as RitaCommonLoop;\n#[cfg(feature = \"development\")]\nuse crate::KI;\n#[cfg(feature = \"development\")]\nuse crate::SETTING;\n#[cfg(feature = \"development\")]\n-use actix::registry::SystemService;\n+use actix::SystemService;\nuse actix_web::{HttpRequest, HttpResponse, Result};\n#[cfg(feature = \"development\")]\n-use clu::{cleanup, linux_generate_mesh_ip};\n+use clu::{cleanup, generate_mesh_ip};\nuse failure::Error;\n#[cfg(feature = \"development\")]\nuse settings::RitaCommonSettings;\n@@ -66,7 +66,7 @@ pub fn wipe(_req: HttpRequest) -> Result<HttpResponse, Error> {\nnetwork_settings.wg_private_key = Some(keypair.private);\n// Generate new mesh IP\n- match linux_generate_mesh_ip() {\n+ match generate_mesh_ip() {\nOk(ip) => {\ntrace!(\"wipe: Generated new mesh IP\");\nnetwork_settings.mesh_ip = Some(ip);\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_exit/network_endpoints/mod.rs",
"new_path": "rita/src/rita_exit/network_endpoints/mod.rs",
"diff": "@@ -251,7 +251,7 @@ pub fn nuke_db(_req: HttpRequest) -> Result<HttpResponse, Error> {\n}\n#[cfg(feature = \"development\")]\n-pub fn nuke_db(_req: HttpRequest) -> Box<Future<Item = HttpResponse, Error = Error>> {\n+pub fn nuke_db(_req: HttpRequest) -> Box<dyn Future<Item = HttpResponse, Error = Error>> {\ntrace!(\"nuke_db: Truncating all data from the database\");\nDbClient::from_registry()\n.send(TruncateTables {})\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Clean up development features
This had some old stuff that needed work |
20,244 | 11.05.2020 17:06:24 | 14,400 | 0a52bc4caec482a8db8bbf4327dd48dadc6da241 | Add hardware info to OperatorCheckin
This lets us notify and otherwise act on system hardware info,
right now we're just sending it off to the operator tools but
I hope to do some really cool stuff with it soon. | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "althea_kernel_interface/src/hardware_info.rs",
"diff": "+use crate::file_io::get_lines;\n+use althea_types::HardwareInfo;\n+use failure::Error;\n+\n+/// Gets the load average and memory of the system from /proc should be plenty\n+/// efficient and safe to run. Requires the device name to be passed in because\n+/// it's stored in settings and I don't see why we should parse it here\n+/// things that might be interesting to add here are CPU arch and system temp sadly\n+/// both are rather large steps up complexity wise to parse due to the lack of consistent\n+/// formatting\n+pub fn get_hardware_info(device_name: Option<String>) -> Result<HardwareInfo, Error> {\n+ // cpu load average\n+ let load_average_error = Err(format_err!(\"Failed to get load average\"));\n+ let lines = get_lines(\"/proc/loadavg\")?;\n+ let load_avg = match lines.iter().next() {\n+ Some(line) => line,\n+ None => return load_average_error,\n+ };\n+ let mut load_avg = load_avg.split_whitespace();\n+ let one_minute_load_avg: f32 = match load_avg.next() {\n+ Some(val) => val.parse()?,\n+ None => return load_average_error,\n+ };\n+ let five_minute_load_avg: f32 = match load_avg.next() {\n+ Some(val) => val.parse()?,\n+ None => return load_average_error,\n+ };\n+ let fifteen_minute_load_avg: f32 = match load_avg.next() {\n+ Some(val) => val.parse()?,\n+ None => return load_average_error,\n+ };\n+\n+ // memory info\n+ let lines = get_lines(\"/proc/meminfo\")?;\n+ let mut lines = lines.iter();\n+ let memory_info_error = Err(format_err!(\"Failed to get memory info\"));\n+ let mem_total: u64 = match lines.next() {\n+ Some(line) => match line.split_whitespace().nth(1) {\n+ Some(val) => val.parse()?,\n+ None => return memory_info_error,\n+ },\n+ None => return memory_info_error,\n+ };\n+ let mem_free: u64 = match lines.next() {\n+ Some(line) => match line.split_whitespace().nth(1) {\n+ Some(val) => val.parse()?,\n+ None => return memory_info_error,\n+ },\n+ None => return memory_info_error,\n+ };\n+ let model = match device_name {\n+ Some(name) => name.to_string(),\n+ None => \"Unknown Device\".to_string(),\n+ };\n+\n+ Ok(HardwareInfo {\n+ load_avg_one_minute: one_minute_load_avg,\n+ load_avg_five_minute: five_minute_load_avg,\n+ load_avg_fifteen_minute: fifteen_minute_load_avg,\n+ system_memory: mem_total,\n+ allocated_memory: mem_free,\n+ model,\n+ })\n+}\n+\n+#[test]\n+fn test_read_hw_info() {\n+ let res = get_hardware_info(Some(\"test\".to_string()));\n+ let hw_info = res.unwrap();\n+ assert_eq!(hw_info.model, \"test\");\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "althea_kernel_interface/src/lib.rs",
"new_path": "althea_kernel_interface/src/lib.rs",
"diff": "@@ -24,6 +24,7 @@ mod exit_server_tunnel;\npub mod file_io;\nmod fs_sync;\nmod get_neighbors;\n+pub mod hardware_info;\nmod interface_tools;\nmod ip_addr;\nmod ip_route;\n"
},
{
"change_type": "MODIFY",
"old_path": "althea_types/src/interop.rs",
"new_path": "althea_types/src/interop.rs",
"diff": "@@ -478,6 +478,19 @@ pub struct OperatorCheckinMessage {\n/// regularly with the operator server but it contains non-fixed size data\n/// like strings\npub contact_details: Option<ContactDetails>,\n+ /// Info about the current state of this device, including it's model, CPU,\n+ /// memory, and hopefully some day more info like temperature\n+ pub hardware_info: Option<HardwareInfo>,\n+}\n+\n+#[derive(Debug, Clone, Serialize, Deserialize)]\n+pub struct HardwareInfo {\n+ pub load_avg_one_minute: f32,\n+ pub load_avg_five_minute: f32,\n+ pub load_avg_fifteen_minute: f32,\n+ pub system_memory: u64,\n+ pub allocated_memory: u64,\n+ pub model: String,\n}\n/// Struct for storing peer status data for reporting to the operator tools server\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/operator_update/mod.rs",
"new_path": "rita/src/rita_client/operator_update/mod.rs",
"diff": "@@ -10,6 +10,7 @@ use crate::SETTING;\nuse actix::{Actor, Arbiter, Context, Handler, Message, Supervised, SystemService};\nuse actix_web::Error;\nuse actix_web::{client, HttpMessage};\n+use althea_kernel_interface::hardware_info::get_hardware_info;\nuse althea_kernel_interface::opkg_feeds::get_release_feed;\nuse althea_kernel_interface::opkg_feeds::set_release_feed;\nuse althea_types::ContactDetails;\n@@ -128,6 +129,14 @@ fn checkin() {\n});\n}\n+ let hardware_info = match get_hardware_info({ SETTING.get_network().device.clone() }) {\n+ Ok(info) => Some(info),\n+ Err(e) => {\n+ error!(\"Failed to get hardware info with {:?}\", e);\n+ None\n+ }\n+ };\n+\nlet res = client::post(url)\n.header(\"User-Agent\", \"Actix-web\")\n.json(OperatorCheckinMessage {\n@@ -136,6 +145,7 @@ fn checkin() {\nsystem_chain,\nneighbor_info: Some(neighbor_info),\ncontact_details: Some(contact_details),\n+ hardware_info,\n})\n.unwrap()\n.send()\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Add hardware info to OperatorCheckin
This lets us notify and otherwise act on system hardware info,
right now we're just sending it off to the operator tools but
I hope to do some really cool stuff with it soon. |
20,244 | 11.05.2020 19:18:07 | 14,400 | 23778d23321bdea464c7871014c1251260fd68a2 | Add display currency symbol toggle to localization | [
{
"change_type": "MODIFY",
"old_path": "settings/src/localization.rs",
"new_path": "settings/src/localization.rs",
"diff": "@@ -6,15 +6,24 @@ fn default_wyre_account_id() -> String {\n\"AC_2J6LWQEGW8P\".to_string()\n}\n+fn default_display_currency_symbol() -> bool {\n+ true\n+}\n+\n#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]\npub struct LocalizationSettings {\n- // A flag indicating whether or not the dashboard should give users the option to purchase\n- // cryptocurrency through Wyre as part of the funding flow.\n+ /// A flag indicating whether or not the dashboard should give users the option to purchase\n+ /// cryptocurrency through Wyre as part of the funding flow.\n#[serde(default = \"default_wyre_enabled\")]\npub wyre_enabled: bool,\n- // Wyre account_id used to associate transactions with a specific Wyre account\n+ /// Wyre account_id used to associate transactions with a specific Wyre account\n#[serde(default = \"default_wyre_account_id\")]\npub wyre_account_id: String,\n+ /// If we should display the $ symbol or just the DAI star symbol next\n+ /// to the balance, designed to help manage how prominent we want the cryptocurrency\n+ /// aspect of Althea to be displayed to the user.\n+ #[serde(default = \"default_display_currency_symbol\")]\n+ pub display_currency_symbol: bool,\n}\nimpl Default for LocalizationSettings {\n@@ -22,6 +31,7 @@ impl Default for LocalizationSettings {\nLocalizationSettings {\nwyre_enabled: default_wyre_enabled(),\nwyre_account_id: default_wyre_account_id(),\n+ display_currency_symbol: default_display_currency_symbol(),\n}\n}\n}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Add display currency symbol toggle to localization |
20,244 | 11.05.2020 19:20:00 | 14,400 | cb266d92c042e1c0fdd15474f6bfc66a965817c4 | Bump for Beta 14 RC1 | [
{
"change_type": "MODIFY",
"old_path": "Cargo.lock",
"new_path": "Cargo.lock",
"diff": "@@ -2656,7 +2656,7 @@ dependencies = [\n[[package]]\nname = \"rita\"\n-version = \"0.5.46\"\n+version = \"0.5.47\"\ndependencies = [\n\"actix\",\n\"actix-web\",\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/Cargo.toml",
"new_path": "rita/Cargo.toml",
"diff": "[package]\nname = \"rita\"\n-version = \"0.5.46\"\n-authors = [\"Jehan <jehan.tremback@gmail.com>\", \"Ben <wangben3@gmail.com>\"]\n+version = \"0.5.47\"\n+authors = [\"Justin <justin@althea.net>\", \"Jehan <jehan.tremback@gmail.com>\", \"Ben <wangben3@gmail.com>\"]\nbuild = \"build.rs\"\nedition = \"2018\"\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/dashboard/own_info.rs",
"new_path": "rita/src/rita_common/dashboard/own_info.rs",
"diff": "@@ -6,7 +6,7 @@ use failure::Error;\nuse num256::{Int256, Uint256};\nuse settings::RitaCommonSettings;\n-pub static READABLE_VERSION: &str = \"Beta 13 RC7\";\n+pub static READABLE_VERSION: &str = \"Beta 14 RC1\";\n#[derive(Serialize)]\npub struct OwnInfo {\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Bump for Beta 14 RC1 |
20,244 | 11.05.2020 19:20:31 | 14,400 | a1072aa9a398791429e3513d2a4164000e069a1b | Fix logging message for hello handler | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/hello_handler/mod.rs",
"new_path": "rita/src/rita_common/hello_handler/mod.rs",
"diff": "@@ -27,7 +27,7 @@ impl Actor for HelloHandler {\nimpl Supervised for HelloHandler {}\nimpl SystemService for HelloHandler {\nfn service_started(&mut self, _ctx: &mut Context<Self>) {\n- info!(\"HTTP Client started\");\n+ info!(\"HelloHandler started\");\n}\n}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Fix logging message for hello handler |
20,244 | 12.05.2020 09:14:31 | 14,400 | 6d821ba0765d41628a97b6006097d44117167e81 | Jemalloc as a feature
Turns out this needs to be a feature otherwise OpenWRT will choke
on building it, even on x86 cross architecures. Need to do more
investigation to determine exactly why it dislikes the openwrt
build system but otherwise works with cross compilation | [
{
"change_type": "MODIFY",
"old_path": "rita/Cargo.toml",
"new_path": "rita/Cargo.toml",
"diff": "@@ -68,7 +68,7 @@ sodiumoxide = \"0.2\"\ncompressed_log = \"0.2\"\nflate2 = { version = \"1.0\", features = [\"rust_backend\"], default-features = false }\nreqwest = { version = \"0.10\", features = [\"blocking\", \"json\"] }\n-jemallocator = \"0.3\"\n+jemallocator = {version = \"0.3\", optional = true}\n[dependencies.regex]\nversion = \"1.3\"\n@@ -77,6 +77,7 @@ features = [\"std\"]\n[features]\n# Features for big iron devices with more ram\n-server = []\n+jemalloc = [\"jemallocator\"]\n+server = [\"jemalloc\"]\nlong_timeouts = []\ndevelopment = []\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/client.rs",
"new_path": "rita/src/client.rs",
"diff": "#![allow(clippy::pedantic)]\n#![forbid(unsafe_code)]\n+#[cfg(feature = \"jemalloc\")]\n+use jemallocator::Jemalloc;\n+#[cfg(feature = \"jemalloc\")]\n+#[global_allocator]\n+static GLOBAL: Jemalloc = Jemalloc;\n+\n#[macro_use]\nextern crate failure;\n#[macro_use]\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/exit.rs",
"new_path": "rita/src/exit.rs",
"diff": "#![allow(clippy::pedantic)]\n#![forbid(unsafe_code)]\n+#[cfg(feature = \"jemalloc\")]\nuse jemallocator::Jemalloc;\n+#[cfg(feature = \"jemalloc\")]\n#[global_allocator]\nstatic GLOBAL: Jemalloc = Jemalloc;\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Jemalloc as a feature
Turns out this needs to be a feature otherwise OpenWRT will choke
on building it, even on x86 cross architecures. Need to do more
investigation to determine exactly why it dislikes the openwrt
build system but otherwise works with cross compilation |
20,244 | 13.05.2020 10:30:10 | 14,400 | 0e11d0ba0987e11bbaa9f056ec30370e10b0fa6c | Add clippy to local test suite | [
{
"change_type": "MODIFY",
"old_path": "scripts/test.sh",
"new_path": "scripts/test.sh",
"diff": "@@ -3,6 +3,7 @@ set -eux\nNODES=${NODES:='None'}\nRUST_TEST_THREADS=1 cargo test --all\n+cargo clippy --all-targets --all-features -- -D warnings\ncross test --target x86_64-unknown-linux-musl --verbose -p rita --bin rita -- --test-threads=1\ncross test --target mips-unknown-linux-gnu --verbose -p rita --bin rita -- --test-threads=1\ncross test --target mipsel-unknown-linux-gnu --verbose -p rita --bin rita -- --test-threads=1\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Add clippy to local test suite |
20,244 | 13.05.2020 11:56:37 | 14,400 | 7c04642cecf42045cab2da64030a531b0845d55e | Update Clarity and other deps
Adds support for EIP55 compatible addresses, which are now the default
display type. This is backwards compatible because the parse() impl
over in Clarity is permissive. | [
{
"change_type": "MODIFY",
"old_path": "Cargo.lock",
"new_path": "Cargo.lock",
"diff": "@@ -91,7 +91,7 @@ dependencies = [\n\"percent-encoding 1.0.1\",\n\"rand 0.6.5\",\n\"regex\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"serde_json\",\n\"serde_urlencoded 0.5.5\",\n\"sha1\",\n@@ -137,9 +137,9 @@ version = \"0.5.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"b95aceadaf327f18f0df5962fedc1bde2f870566a0b9f65c89508a3b1f79334c\"\ndependencies = [\n- \"proc-macro2 1.0.9\",\n- \"quote 1.0.3\",\n- \"syn 1.0.17\",\n+ \"proc-macro2 1.0.12\",\n+ \"quote 1.0.5\",\n+ \"syn 1.0.21\",\n]\n[[package]]\n@@ -189,7 +189,7 @@ dependencies = [\n\"failure\",\n\"hex\",\n\"num256\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"serde_derive\",\n\"serde_json\",\n\"sodiumoxide\",\n@@ -209,7 +209,7 @@ dependencies = [\n\"log\",\n\"oping\",\n\"rand 0.7.3\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"serde_json\",\n\"sodiumoxide\",\n]\n@@ -224,7 +224,7 @@ dependencies = [\n\"lazy_static\",\n\"log\",\n\"rand 0.7.3\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"serde_derive\",\n\"serde_json\",\n\"sodiumoxide\",\n@@ -232,9 +232,9 @@ dependencies = [\n[[package]]\nname = \"arc-swap\"\n-version = \"0.4.5\"\n+version = \"0.4.6\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"d663a8e9a99154b5fb793032533f6328da35e23aac63d5c152279aa8ba356825\"\n+checksum = \"b585a98a234c46fc563103e9278c9391fde1f4e6850334da895d27edb9580f62\"\n[[package]]\nname = \"arrayvec\"\n@@ -251,7 +251,7 @@ version = \"0.5.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8\"\ndependencies = [\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n]\n[[package]]\n@@ -273,7 +273,7 @@ source = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"9c356497fd3417158bcb318266ac83c391219ca3a5fa659049f42e0041ab57d6\"\ndependencies = [\n\"extend\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"serde_json\",\n]\n@@ -327,7 +327,7 @@ dependencies = [\n\"futures 0.1.29\",\n\"ipnetwork 0.14.0\",\n\"log\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"serde_derive\",\n\"tokio 0.1.22\",\n]\n@@ -356,9 +356,9 @@ dependencies = [\n[[package]]\nname = \"backtrace-sys\"\n-version = \"0.1.34\"\n+version = \"0.1.37\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"ca797db0057bae1a7aa2eef3283a874695455cecf08a43bfb8507ee0ebc1ed69\"\n+checksum = \"18fbebbe1c9d1f383a9cc7e8ccdb471b91c8d024ee9c2ca5b5346121fe8b4399\"\ndependencies = [\n\"cc\",\n\"libc\",\n@@ -396,7 +396,7 @@ source = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"5753e2a71534719bf3f4e57006c3a4f0d2c672a4b676eec84161f763eca87dbf\"\ndependencies = [\n\"byteorder\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n]\n[[package]]\n@@ -503,9 +503,9 @@ dependencies = [\n[[package]]\nname = \"clarity\"\n-version = \"0.1.23\"\n+version = \"0.1.24\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"d1cb37bb4c73ac0c710e4f27cb8b378c4f369c4effb9792f9ecb4c57687aefad\"\n+checksum = \"4bef7646f692d63ad2dbf5da1581d98693a9bcc81b49918ba63ad7823acc1471\"\ndependencies = [\n\"bytecount\",\n\"failure\",\n@@ -514,7 +514,7 @@ dependencies = [\n\"num-traits 0.2.11\",\n\"num256\",\n\"secp256k1\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"serde-rlp\",\n\"serde_bytes\",\n\"serde_derive\",\n@@ -544,7 +544,7 @@ dependencies = [\n\"log\",\n\"rand 0.7.3\",\n\"regex\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"serde_derive\",\n\"serde_json\",\n\"settings\",\n@@ -576,7 +576,7 @@ dependencies = [\n\"flate2\",\n\"futures 0.1.29\",\n\"log\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"serde_derive\",\n\"serde_json\",\n]\n@@ -590,7 +590,7 @@ dependencies = [\n\"lazy_static\",\n\"nom 5.1.1\",\n\"rust-ini\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"serde-hjson\",\n\"serde_json\",\n\"toml\",\n@@ -700,9 +700,9 @@ dependencies = [\n[[package]]\nname = \"diesel\"\n-version = \"1.4.3\"\n+version = \"1.4.4\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"9d7cc03b910de9935007861dce440881f69102aaaedfd4bc5a6f40340ca5840c\"\n+checksum = \"33d7ca63eb2efea87a7f56a283acc49e2ce4b2bd54adf7465dc1d81fef13d8fc\"\ndependencies = [\n\"bitflags\",\n\"byteorder\",\n@@ -717,9 +717,9 @@ version = \"1.4.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"45f5098f628d02a7a0f68ddba586fb61e80edec3bdc1be3b921f4ceec60858d3\"\ndependencies = [\n- \"proc-macro2 1.0.9\",\n- \"quote 1.0.3\",\n- \"syn 1.0.17\",\n+ \"proc-macro2 1.0.12\",\n+ \"quote 1.0.5\",\n+ \"syn 1.0.21\",\n]\n[[package]]\n@@ -745,7 +745,7 @@ checksum = \"7f525a586d310c87df72ebcd98009e57f1cc030c8c268305287a476beb653969\"\ndependencies = [\n\"lazy_static\",\n\"regex\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"strsim\",\n]\n@@ -848,9 +848,9 @@ checksum = \"a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569\"\n[[package]]\nname = \"encoding_rs\"\n-version = \"0.8.22\"\n+version = \"0.8.23\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"cd8d03faa7fe0c1431609dfad7bbe827af30f82e1e2ae6f7ee4fca6bd764bc28\"\n+checksum = \"e8ac63f94732332f44fe654443c46f6375d1939684c17b0afb6cb56b0456e171\"\ndependencies = [\n\"cfg-if\",\n]\n@@ -895,7 +895,7 @@ dependencies = [\n\"diesel\",\n\"dotenv\",\n\"failure\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"serde_derive\",\n\"serde_json\",\n]\n@@ -907,16 +907,16 @@ source = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"fe9db393664b0e6c6230a14115e7e798f80b70f54038dc21165db24c6b7f28fc\"\ndependencies = [\n\"proc-macro-error\",\n- \"proc-macro2 1.0.9\",\n- \"quote 1.0.3\",\n- \"syn 1.0.17\",\n+ \"proc-macro2 1.0.12\",\n+ \"quote 1.0.5\",\n+ \"syn 1.0.21\",\n]\n[[package]]\nname = \"failure\"\n-version = \"0.1.7\"\n+version = \"0.1.8\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"b8529c2421efa3066a5cbd8063d2244603824daccb6936b079010bb2aa89464b\"\n+checksum = \"d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86\"\ndependencies = [\n\"backtrace\",\n\"failure_derive\",\n@@ -924,13 +924,13 @@ dependencies = [\n[[package]]\nname = \"failure_derive\"\n-version = \"0.1.7\"\n+version = \"0.1.8\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"030a733c8287d6213886dd487564ff5c8f6aae10278b3588ed177f9d18f8d231\"\n+checksum = \"aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4\"\ndependencies = [\n- \"proc-macro2 1.0.9\",\n- \"quote 1.0.3\",\n- \"syn 1.0.17\",\n+ \"proc-macro2 1.0.12\",\n+ \"quote 1.0.5\",\n+ \"syn 1.0.21\",\n\"synstructure\",\n]\n@@ -951,9 +951,9 @@ dependencies = [\n[[package]]\nname = \"filetime\"\n-version = \"0.2.8\"\n+version = \"0.2.10\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"1ff6d4dab0aa0c8e6346d46052e93b13a16cf847b54ed357087c35011048cc7d\"\n+checksum = \"affc17579b132fc2461adf7c575cc6e8b134ebca52c51f5411388965227dc695\"\ndependencies = [\n\"cfg-if\",\n\"libc\",\n@@ -1030,9 +1030,9 @@ checksum = \"1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef\"\n[[package]]\nname = \"futures\"\n-version = \"0.3.4\"\n+version = \"0.3.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"5c329ae8753502fb44ae4fc2b622fa2a94652c41e795143765ba0927f92ab780\"\n+checksum = \"1e05b85ec287aac0dc34db7d4a569323df697f9c55b99b15d6b4ef8cde49f613\"\ndependencies = [\n\"futures-channel\",\n\"futures-core\",\n@@ -1045,9 +1045,9 @@ dependencies = [\n[[package]]\nname = \"futures-channel\"\n-version = \"0.3.4\"\n+version = \"0.3.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"f0c77d04ce8edd9cb903932b608268b3fffec4163dc053b3b402bf47eac1f1a8\"\n+checksum = \"f366ad74c28cca6ba456d95e6422883cfb4b252a83bed929c83abfdbbf2967d5\"\ndependencies = [\n\"futures-core\",\n\"futures-sink\",\n@@ -1055,9 +1055,9 @@ dependencies = [\n[[package]]\nname = \"futures-core\"\n-version = \"0.3.4\"\n+version = \"0.3.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"f25592f769825e89b92358db00d26f965761e094951ac44d3663ef25b7ac464a\"\n+checksum = \"59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399\"\n[[package]]\nname = \"futures-cpupool\"\n@@ -1071,9 +1071,9 @@ dependencies = [\n[[package]]\nname = \"futures-executor\"\n-version = \"0.3.4\"\n+version = \"0.3.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"f674f3e1bcb15b37284a90cedf55afdba482ab061c407a9c0ebbd0f3109741ba\"\n+checksum = \"10d6bb888be1153d3abeb9006b11b02cf5e9b209fda28693c31ae1e4e012e314\"\ndependencies = [\n\"futures-core\",\n\"futures-task\",\n@@ -1082,33 +1082,36 @@ dependencies = [\n[[package]]\nname = \"futures-io\"\n-version = \"0.3.4\"\n+version = \"0.3.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"a638959aa96152c7a4cddf50fcb1e3fede0583b27157c26e67d6f99904090dc6\"\n+checksum = \"de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789\"\n[[package]]\nname = \"futures-macro\"\n-version = \"0.3.4\"\n+version = \"0.3.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"9a5081aa3de1f7542a794a397cde100ed903b0630152d0973479018fd85423a7\"\n+checksum = \"d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39\"\ndependencies = [\n\"proc-macro-hack\",\n- \"proc-macro2 1.0.9\",\n- \"quote 1.0.3\",\n- \"syn 1.0.17\",\n+ \"proc-macro2 1.0.12\",\n+ \"quote 1.0.5\",\n+ \"syn 1.0.21\",\n]\n[[package]]\nname = \"futures-sink\"\n-version = \"0.3.4\"\n+version = \"0.3.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"3466821b4bc114d95b087b850a724c6f83115e929bc88f1fa98a3304a944c8a6\"\n+checksum = \"3f2032893cb734c7a05d85ce0cc8b8c4075278e93b24b66f9de99d6eb0fa8acc\"\n[[package]]\nname = \"futures-task\"\n-version = \"0.3.4\"\n+version = \"0.3.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"7b0a34e53cf6cdcd0178aa573aed466b646eb3db769570841fda0c7ede375a27\"\n+checksum = \"bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626\"\n+dependencies = [\n+ \"once_cell\",\n+]\n[[package]]\nname = \"futures-timer\"\n@@ -1121,9 +1124,9 @@ dependencies = [\n[[package]]\nname = \"futures-util\"\n-version = \"0.3.4\"\n+version = \"0.3.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"22766cf25d64306bedf0384da004d05c9974ab104fcc4528f1236181c18004c5\"\n+checksum = \"8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6\"\ndependencies = [\n\"futures 0.1.29\",\n\"futures-channel\",\n@@ -1133,6 +1136,7 @@ dependencies = [\n\"futures-sink\",\n\"futures-task\",\n\"memchr\",\n+ \"pin-project\",\n\"pin-utils\",\n\"proc-macro-hack\",\n\"proc-macro-nested\",\n@@ -1207,9 +1211,9 @@ dependencies = [\n[[package]]\nname = \"h2\"\n-version = \"0.2.4\"\n+version = \"0.2.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"377038bf3c89d18d6ca1431e7a5027194fbd724ca10592b9487ede5e8e144f42\"\n+checksum = \"79b7246d7e4b979c03fa093da39cfb3617a96bbeee6310af63991668d7e843ff\"\ndependencies = [\n\"bytes 0.5.4\",\n\"fnv\",\n@@ -1220,7 +1224,7 @@ dependencies = [\n\"indexmap\",\n\"log\",\n\"slab\",\n- \"tokio 0.2.16\",\n+ \"tokio 0.2.20\",\n\"tokio-util\",\n]\n@@ -1235,7 +1239,7 @@ dependencies = [\n\"pest\",\n\"pest_derive\",\n\"quick-error\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"serde_json\",\n\"walkdir\",\n]\n@@ -1246,14 +1250,14 @@ version = \"0.5.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353\"\ndependencies = [\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n]\n[[package]]\nname = \"hermit-abi\"\n-version = \"0.1.8\"\n+version = \"0.1.12\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"1010591b26bbfe835e9faeabeb11866061cc7dcebffd56ad7d0942d0e61aefd8\"\n+checksum = \"61565ff7aaace3525556587bd2dc31d4a07071957be715e63ce7b1eccf51a8f4\"\ndependencies = [\n\"libc\",\n]\n@@ -1353,15 +1357,15 @@ dependencies = [\n[[package]]\nname = \"hyper\"\n-version = \"0.13.4\"\n+version = \"0.13.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"ed6081100e960d9d74734659ffc9cc91daf1c0fc7aceb8eaa94ee1a3f5046f2e\"\n+checksum = \"96816e1d921eca64d208a85aab4f7798455a8e34229ee5a88c935bdee1b78b14\"\ndependencies = [\n\"bytes 0.5.4\",\n\"futures-channel\",\n\"futures-core\",\n\"futures-util\",\n- \"h2 0.2.4\",\n+ \"h2 0.2.5\",\n\"http 0.2.1\",\n\"http-body\",\n\"httparse\",\n@@ -1370,7 +1374,7 @@ dependencies = [\n\"net2\",\n\"pin-project\",\n\"time\",\n- \"tokio 0.2.16\",\n+ \"tokio 0.2.20\",\n\"tower-service 0.3.0\",\n\"want\",\n]\n@@ -1384,7 +1388,7 @@ dependencies = [\n\"bytes 0.5.4\",\n\"hyper\",\n\"native-tls\",\n- \"tokio 0.2.16\",\n+ \"tokio 0.2.20\",\n\"tokio-tls\",\n]\n@@ -1421,9 +1425,9 @@ dependencies = [\n[[package]]\nname = \"instant\"\n-version = \"0.1.2\"\n+version = \"0.1.3\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"6c346c299e3fe8ef94dc10c2c0253d858a69aac1245157a3bf4125915d528caf\"\n+checksum = \"f7152d2aed88aa566e7a342250f21ba2222c1ae230ad577499dbfa3c18475b80\"\n[[package]]\nname = \"iovec\"\n@@ -1469,7 +1473,7 @@ version = \"0.14.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"b3d862c86f7867f19b693ec86765e0252d82e53d4240b9b629815675a0714ad1\"\ndependencies = [\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n]\n[[package]]\n@@ -1519,9 +1523,9 @@ dependencies = [\n[[package]]\nname = \"js-sys\"\n-version = \"0.3.37\"\n+version = \"0.3.39\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"6a27d435371a2fa5b6d2b028a74bbdb1234f308da363226a2854ca3ff8ba7055\"\n+checksum = \"fa5a448de267e7358beaf4a5d849518fe9a0c13fce7afd44b06e68550e5562a7\"\ndependencies = [\n\"wasm-bindgen\",\n]\n@@ -1562,9 +1566,9 @@ checksum = \"b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f\"\n[[package]]\nname = \"lettre\"\n-version = \"0.9.2\"\n+version = \"0.9.3\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"c66afaa5dfadbb81d4e00fd1d1ab057c7cd4c799c5a44e0009386d553587e728\"\n+checksum = \"bf43f3202a879fbdab4ecafec3349b0139f81d31c626246d53bcbb546253ffaa\"\ndependencies = [\n\"base64 0.10.1\",\n\"bufstream\",\n@@ -1573,16 +1577,16 @@ dependencies = [\n\"log\",\n\"native-tls\",\n\"nom 4.2.3\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"serde_derive\",\n\"serde_json\",\n]\n[[package]]\nname = \"lettre_email\"\n-version = \"0.9.2\"\n+version = \"0.9.4\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"bbb68ca999042d965476e47bbdbacd52db0927348b6f8062c44dd04a3b1fd43b\"\n+checksum = \"fd02480f8dcf48798e62113974d6ccca2129a51d241fa20f1ea349c8a42559d5\"\ndependencies = [\n\"base64 0.10.1\",\n\"email\",\n@@ -1608,9 +1612,9 @@ dependencies = [\n[[package]]\nname = \"libc\"\n-version = \"0.2.68\"\n+version = \"0.2.70\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0\"\n+checksum = \"3baa92041a6fec78c687fa0cc2b3fae8884f743d672cf551bed1d6dac6988d0f\"\n[[package]]\nname = \"libflate\"\n@@ -1650,9 +1654,9 @@ dependencies = [\n[[package]]\nname = \"linked-hash-map\"\n-version = \"0.5.2\"\n+version = \"0.5.3\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83\"\n+checksum = \"8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a\"\n[[package]]\nname = \"lock_api\"\n@@ -1666,9 +1670,9 @@ dependencies = [\n[[package]]\nname = \"lock_api\"\n-version = \"0.3.3\"\n+version = \"0.3.4\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"79b2de95ecb4691949fea4716ca53cdbcfccb2c612e19644a8bad05edcf9f47b\"\n+checksum = \"c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75\"\ndependencies = [\n\"scopeguard 1.1.0\",\n]\n@@ -1688,7 +1692,7 @@ version = \"0.1.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c\"\ndependencies = [\n- \"linked-hash-map 0.5.2\",\n+ \"linked-hash-map 0.5.3\",\n]\n[[package]]\n@@ -1763,9 +1767,9 @@ dependencies = [\n[[package]]\nname = \"mio\"\n-version = \"0.6.21\"\n+version = \"0.6.22\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f\"\n+checksum = \"fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430\"\ndependencies = [\n\"cfg-if\",\n\"fuchsia-zircon\",\n@@ -1782,9 +1786,9 @@ dependencies = [\n[[package]]\nname = \"mio-uds\"\n-version = \"0.6.7\"\n+version = \"0.6.8\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125\"\n+checksum = \"afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0\"\ndependencies = [\n\"iovec\",\n\"libc\",\n@@ -1847,9 +1851,9 @@ dependencies = [\n[[package]]\nname = \"net2\"\n-version = \"0.2.33\"\n+version = \"0.2.34\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88\"\n+checksum = \"2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7\"\ndependencies = [\n\"cfg-if\",\n\"libc\",\n@@ -1906,7 +1910,7 @@ dependencies = [\n\"autocfg 1.0.0\",\n\"num-integer\",\n\"num-traits 0.2.11\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n]\n[[package]]\n@@ -1925,9 +1929,9 @@ version = \"0.3.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"0c8b15b261814f992e33760b1fca9fe8b693d8a65299f20c9901688636cfb746\"\ndependencies = [\n- \"proc-macro2 1.0.9\",\n- \"quote 1.0.3\",\n- \"syn 1.0.17\",\n+ \"proc-macro2 1.0.12\",\n+ \"quote 1.0.5\",\n+ \"syn 1.0.21\",\n]\n[[package]]\n@@ -1992,20 +1996,26 @@ dependencies = [\n\"num\",\n\"num-derive\",\n\"num-traits 0.2.11\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"serde_derive\",\n]\n[[package]]\nname = \"num_cpus\"\n-version = \"1.12.0\"\n+version = \"1.13.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6\"\n+checksum = \"05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3\"\ndependencies = [\n\"hermit-abi\",\n\"libc\",\n]\n+[[package]]\n+name = \"once_cell\"\n+version = \"1.3.1\"\n+source = \"registry+https://github.com/rust-lang/crates.io-index\"\n+checksum = \"b1c601810575c99596d4afc46f78a678c80105117c379eb3650cf99b8a21ce5b\"\n+\n[[package]]\nname = \"oncemutex\"\nversion = \"0.1.1\"\n@@ -2020,9 +2030,9 @@ checksum = \"2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c\"\n[[package]]\nname = \"openssl\"\n-version = \"0.10.28\"\n+version = \"0.10.29\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"973293749822d7dd6370d6da1e523b0d1db19f06c459134c658b2a4261378b52\"\n+checksum = \"cee6d85f4cb4c4f59a6a85d5b68a233d280c82e29e822913b9c8b129fbf20bdd\"\ndependencies = [\n\"bitflags\",\n\"cfg-if\",\n@@ -2040,9 +2050,9 @@ checksum = \"77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de\"\n[[package]]\nname = \"openssl-sys\"\n-version = \"0.9.54\"\n+version = \"0.9.56\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"1024c0a59774200a555087a6da3f253a9095a5f344e353b212ac4c8b8e450986\"\n+checksum = \"f02309a7f127000ed50594f0b50ecc69e7c654e16d41b4e8156d1b3df8e0b52e\"\ndependencies = [\n\"autocfg 1.0.0\",\n\"cc\",\n@@ -2053,11 +2063,11 @@ dependencies = [\n[[package]]\nname = \"oping\"\n-version = \"0.3.3\"\n+version = \"0.3.4\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"c9800d51dab9ada09da41b9182e62df3bc86493a0386eb321b3d00eab568166f\"\n+checksum = \"74683b059d76f1b24b7e90c7aaa8bc16e2c193b4be0ffa9f49f082076e3b4050\"\ndependencies = [\n- \"gcc\",\n+ \"cc\",\n\"libc\",\n]\n@@ -2086,19 +2096,19 @@ version = \"0.9.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252\"\ndependencies = [\n- \"lock_api 0.3.3\",\n+ \"lock_api 0.3.4\",\n\"parking_lot_core 0.6.2\",\n\"rustc_version\",\n]\n[[package]]\nname = \"parking_lot\"\n-version = \"0.10.0\"\n+version = \"0.10.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc\"\n+checksum = \"d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e\"\ndependencies = [\n- \"lock_api 0.3.3\",\n- \"parking_lot_core 0.7.0\",\n+ \"lock_api 0.3.4\",\n+ \"parking_lot_core 0.7.2\",\n]\n[[package]]\n@@ -2131,15 +2141,15 @@ dependencies = [\n[[package]]\nname = \"parking_lot_core\"\n-version = \"0.7.0\"\n+version = \"0.7.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"7582838484df45743c8434fbff785e8edf260c28748353d44bc0da32e0ceabf1\"\n+checksum = \"d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3\"\ndependencies = [\n\"cfg-if\",\n\"cloudabi\",\n\"libc\",\n\"redox_syscall\",\n- \"smallvec 1.2.0\",\n+ \"smallvec 1.4.0\",\n\"winapi 0.3.8\",\n]\n@@ -2182,9 +2192,9 @@ checksum = \"99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55\"\ndependencies = [\n\"pest\",\n\"pest_meta\",\n- \"proc-macro2 1.0.9\",\n- \"quote 1.0.3\",\n- \"syn 1.0.17\",\n+ \"proc-macro2 1.0.12\",\n+ \"quote 1.0.5\",\n+ \"syn 1.0.21\",\n]\n[[package]]\n@@ -2214,41 +2224,41 @@ dependencies = [\n\"quick-xml\",\n\"regex\",\n\"regex-cache\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"serde_derive\",\n]\n[[package]]\nname = \"pin-project\"\n-version = \"0.4.8\"\n+version = \"0.4.16\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"7804a463a8d9572f13453c516a5faea534a2403d7ced2f0c7e100eeff072772c\"\n+checksum = \"81d480cb4e89522ccda96d0eed9af94180b7a5f93fb28f66e1fd7d68431663d1\"\ndependencies = [\n\"pin-project-internal\",\n]\n[[package]]\nname = \"pin-project-internal\"\n-version = \"0.4.8\"\n+version = \"0.4.16\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"385322a45f2ecf3410c68d2a549a4a2685e8051d0f278e39743ff4e451cb9b3f\"\n+checksum = \"a82996f11efccb19b685b14b5df818de31c1edcee3daa256ab5775dd98e72feb\"\ndependencies = [\n- \"proc-macro2 1.0.9\",\n- \"quote 1.0.3\",\n- \"syn 1.0.17\",\n+ \"proc-macro2 1.0.12\",\n+ \"quote 1.0.5\",\n+ \"syn 1.0.21\",\n]\n[[package]]\nname = \"pin-project-lite\"\n-version = \"0.1.4\"\n+version = \"0.1.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"237844750cfbb86f67afe27eee600dfbbcb6188d734139b534cbfbf4f96792ae\"\n+checksum = \"f7505eeebd78492e0f6108f7171c4948dbb120ee8119d9d77d0afa5469bef67f\"\n[[package]]\nname = \"pin-utils\"\n-version = \"0.1.0-alpha.4\"\n+version = \"0.1.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587\"\n+checksum = \"8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184\"\n[[package]]\nname = \"pkg-config\"\n@@ -2273,35 +2283,35 @@ dependencies = [\n[[package]]\nname = \"proc-macro-error\"\n-version = \"0.4.11\"\n+version = \"0.4.12\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"e7959c6467d962050d639361f7703b2051c43036d03493c36f01d440fdd3138a\"\n+checksum = \"18f33027081eba0a6d8aba6d1b1c3a3be58cbb12106341c2d5759fcd9b5277e7\"\ndependencies = [\n\"proc-macro-error-attr\",\n- \"proc-macro2 1.0.9\",\n- \"quote 1.0.3\",\n- \"syn 1.0.17\",\n+ \"proc-macro2 1.0.12\",\n+ \"quote 1.0.5\",\n+ \"syn 1.0.21\",\n\"version_check 0.9.1\",\n]\n[[package]]\nname = \"proc-macro-error-attr\"\n-version = \"0.4.11\"\n+version = \"0.4.12\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"e4002d9f55991d5e019fb940a90e1a95eb80c24e77cb2462dd4dc869604d543a\"\n+checksum = \"8a5b4b77fdb63c1eca72173d68d24501c54ab1269409f6b672c85deb18af69de\"\ndependencies = [\n- \"proc-macro2 1.0.9\",\n- \"quote 1.0.3\",\n- \"syn 1.0.17\",\n+ \"proc-macro2 1.0.12\",\n+ \"quote 1.0.5\",\n+ \"syn 1.0.21\",\n\"syn-mid\",\n\"version_check 0.9.1\",\n]\n[[package]]\nname = \"proc-macro-hack\"\n-version = \"0.5.14\"\n+version = \"0.5.15\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"fcfdefadc3d57ca21cf17990a28ef4c0f7c61383a28cb7604cf4a18e6ede1420\"\n+checksum = \"0d659fe7c6d27f25e9d80a1a094c223f5246f6a6596453e09d7229bf42750b63\"\n[[package]]\nname = \"proc-macro-nested\"\n@@ -2320,9 +2330,9 @@ dependencies = [\n[[package]]\nname = \"proc-macro2\"\n-version = \"1.0.9\"\n+version = \"1.0.12\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435\"\n+checksum = \"8872cf6f48eee44265156c111456a700ab3483686b3f96df4cf5481c89157319\"\ndependencies = [\n\"unicode-xid 0.2.0\",\n]\n@@ -2353,11 +2363,11 @@ dependencies = [\n[[package]]\nname = \"quote\"\n-version = \"1.0.3\"\n+version = \"1.0.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f\"\n+checksum = \"42934bc9c8ab0d3b273a16d8551c8f0fcff46be73276ca083ec2414c15c4ba5e\"\ndependencies = [\n- \"proc-macro2 1.0.9\",\n+ \"proc-macro2 1.0.12\",\n]\n[[package]]\n@@ -2367,7 +2377,7 @@ source = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"1497e40855348e4a8a40767d8e55174bce1e445a3ac9254ad44ad468ee0485af\"\ndependencies = [\n\"log\",\n- \"parking_lot 0.10.0\",\n+ \"parking_lot 0.10.2\",\n\"scheduled-thread-pool\",\n]\n@@ -2571,9 +2581,9 @@ checksum = \"2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84\"\n[[package]]\nname = \"regex\"\n-version = \"1.3.5\"\n+version = \"1.3.7\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"8900ebc1363efa7ea1c399ccc32daed870b4002651e0bed86e72d501ebbe0048\"\n+checksum = \"a6020f034922e3194c711b82a627453881bc4682166cabb07134a10c26ba7692\"\ndependencies = [\n\"aho-corasick\",\n\"memchr\",\n@@ -2631,11 +2641,11 @@ dependencies = [\n\"native-tls\",\n\"percent-encoding 2.1.0\",\n\"pin-project-lite\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"serde_json\",\n\"serde_urlencoded 0.6.1\",\n\"time\",\n- \"tokio 0.2.16\",\n+ \"tokio 0.2.20\",\n\"tokio-tls\",\n\"url 2.1.1\",\n\"wasm-bindgen\",\n@@ -2682,7 +2692,7 @@ dependencies = [\n\"failure\",\n\"flate2\",\n\"futures 0.1.29\",\n- \"futures 0.3.4\",\n+ \"futures 0.3.5\",\n\"handlebars\",\n\"hex-literal\",\n\"ipnetwork 0.14.0\",\n@@ -2702,7 +2712,7 @@ dependencies = [\n\"rand 0.7.3\",\n\"regex\",\n\"reqwest\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"serde_derive\",\n\"serde_json\",\n\"settings\",\n@@ -2763,9 +2773,9 @@ dependencies = [\n[[package]]\nname = \"ryu\"\n-version = \"1.0.3\"\n+version = \"1.0.4\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"535622e6be132bccd223f4bb2b8ac8d53cda3c7a6394944d3b2b33fb974f9d76\"\n+checksum = \"ed3d612bc64430efeb3f7ee6ef26d590dce0c43249217bddc62112540c7941e1\"\n[[package]]\nname = \"safemem\"\n@@ -2784,9 +2794,9 @@ dependencies = [\n[[package]]\nname = \"schannel\"\n-version = \"0.1.18\"\n+version = \"0.1.19\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"039c25b130bd8c1321ee2d7de7fde2659fa9c2744e4bb29711cfc852ea53cd19\"\n+checksum = \"8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75\"\ndependencies = [\n\"lazy_static\",\n\"winapi 0.3.8\",\n@@ -2798,7 +2808,7 @@ version = \"0.2.4\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"0988d7fdf88d5e5fcf5923a0f1e8ab345f3e98ab4bc6bc45a2d5ff7f7458fbf6\"\ndependencies = [\n- \"parking_lot 0.10.0\",\n+ \"parking_lot 0.10.2\",\n]\n[[package]]\n@@ -2815,31 +2825,40 @@ checksum = \"d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd\"\n[[package]]\nname = \"secp256k1\"\n-version = \"0.15.5\"\n+version = \"0.17.2\"\n+source = \"registry+https://github.com/rust-lang/crates.io-index\"\n+checksum = \"2932dc07acd2066ff2e3921a4419606b220ba6cd03a9935123856cc534877056\"\n+dependencies = [\n+ \"secp256k1-sys\",\n+]\n+\n+[[package]]\n+name = \"secp256k1-sys\"\n+version = \"0.1.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"4d311229f403d64002e9eed9964dfa5a0a0c1ac443344f7546bf48e916c6053a\"\n+checksum = \"7ab2c26f0d3552a0f12e639ae8a64afc2e3db9c52fe32f5fc6c289d38519f220\"\ndependencies = [\n\"cc\",\n- \"rand 0.6.5\",\n]\n[[package]]\nname = \"security-framework\"\n-version = \"0.4.1\"\n+version = \"0.4.4\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"97bbedbe81904398b6ebb054b3e912f99d55807125790f3198ac990d98def5b0\"\n+checksum = \"64808902d7d99f78eaddd2b4e2509713babc3dc3c85ad6f4c447680f3c01e535\"\ndependencies = [\n\"bitflags\",\n\"core-foundation\",\n\"core-foundation-sys\",\n+ \"libc\",\n\"security-framework-sys\",\n]\n[[package]]\nname = \"security-framework-sys\"\n-version = \"0.4.1\"\n+version = \"0.4.3\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"06fd2f23e31ef68dd2328cc383bd493142e46107a3a0e24f7d734e3f3b80fe4c\"\n+checksum = \"17bf11d99252f512695eb468de5516e5cf75455521e69dfe343f3b74e4748405\"\ndependencies = [\n\"core-foundation-sys\",\n\"libc\",\n@@ -2868,9 +2887,9 @@ checksum = \"9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8\"\n[[package]]\nname = \"serde\"\n-version = \"1.0.105\"\n+version = \"1.0.110\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"e707fbbf255b8fc8c3b99abb91e7257a622caeb20a9818cbadbeeede4e0932ff\"\n+checksum = \"99e7b308464d16b56eba9964e4972a3eee817760ab60d88c3f86e1fecb08204c\"\ndependencies = [\n\"serde_derive\",\n]\n@@ -2897,38 +2916,38 @@ dependencies = [\n\"byteorder\",\n\"error\",\n\"num\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n]\n[[package]]\nname = \"serde_bytes\"\n-version = \"0.10.5\"\n+version = \"0.11.4\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"defbb8a83d7f34cc8380751eeb892b825944222888aff18996ea7901f24aec88\"\n+checksum = \"3bf487fbf5c6239d7ea2ff8b10cb6b811cd4b5080d1c2aeed1dec18753c06e10\"\ndependencies = [\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n]\n[[package]]\nname = \"serde_derive\"\n-version = \"1.0.105\"\n+version = \"1.0.110\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"ac5d00fc561ba2724df6758a17de23df5914f20e41cb00f94d5b7ae42fffaff8\"\n+checksum = \"818fbf6bfa9a42d3bfcaca148547aa00c7b915bec71d1757aa2d44ca68771984\"\ndependencies = [\n- \"proc-macro2 1.0.9\",\n- \"quote 1.0.3\",\n- \"syn 1.0.17\",\n+ \"proc-macro2 1.0.12\",\n+ \"quote 1.0.5\",\n+ \"syn 1.0.21\",\n]\n[[package]]\nname = \"serde_json\"\n-version = \"1.0.48\"\n+version = \"1.0.53\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"9371ade75d4c2d6cb154141b9752cf3781ec9c05e0e5cf35060e1e70ee7b9c25\"\n+checksum = \"993948e75b189211a9b31a7528f950c6adc21f9720b6438ff80a7fa2f864cea2\"\ndependencies = [\n\"itoa\",\n\"ryu\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n]\n[[package]]\n@@ -2948,7 +2967,7 @@ checksum = \"642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a\"\ndependencies = [\n\"dtoa\",\n\"itoa\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"url 1.7.2\",\n]\n@@ -2960,7 +2979,7 @@ checksum = \"9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97\"\ndependencies = [\n\"dtoa\",\n\"itoa\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"url 2.1.1\",\n]\n@@ -2978,7 +2997,7 @@ dependencies = [\n\"log\",\n\"num256\",\n\"owning_ref\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"serde_derive\",\n\"serde_json\",\n\"toml\",\n@@ -3042,15 +3061,15 @@ dependencies = [\n[[package]]\nname = \"smallvec\"\n-version = \"1.2.0\"\n+version = \"1.4.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc\"\n+checksum = \"c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4\"\n[[package]]\nname = \"socket2\"\n-version = \"0.3.11\"\n+version = \"0.3.12\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85\"\n+checksum = \"03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918\"\ndependencies = [\n\"cfg-if\",\n\"libc\",\n@@ -3066,7 +3085,7 @@ checksum = \"585232e78a4fc18133eef9946d3080befdf68b906c51b621531c37e91787fa2b\"\ndependencies = [\n\"libc\",\n\"libsodium-sys\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n]\n[[package]]\n@@ -3109,12 +3128,12 @@ dependencies = [\n[[package]]\nname = \"syn\"\n-version = \"1.0.17\"\n+version = \"1.0.21\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03\"\n+checksum = \"4696caa4048ac7ce2bcd2e484b3cef88c1004e41b8e945a277e2c25dc0b72060\"\ndependencies = [\n- \"proc-macro2 1.0.9\",\n- \"quote 1.0.3\",\n+ \"proc-macro2 1.0.12\",\n+ \"quote 1.0.5\",\n\"unicode-xid 0.2.0\",\n]\n@@ -3124,9 +3143,9 @@ version = \"0.5.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a\"\ndependencies = [\n- \"proc-macro2 1.0.9\",\n- \"quote 1.0.3\",\n- \"syn 1.0.17\",\n+ \"proc-macro2 1.0.12\",\n+ \"quote 1.0.5\",\n+ \"syn 1.0.21\",\n]\n[[package]]\n@@ -3135,9 +3154,9 @@ version = \"0.12.3\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545\"\ndependencies = [\n- \"proc-macro2 1.0.9\",\n- \"quote 1.0.3\",\n- \"syn 1.0.17\",\n+ \"proc-macro2 1.0.12\",\n+ \"quote 1.0.5\",\n+ \"syn 1.0.21\",\n\"unicode-xid 0.2.0\",\n]\n@@ -3193,12 +3212,11 @@ dependencies = [\n[[package]]\nname = \"time\"\n-version = \"0.1.42\"\n+version = \"0.1.43\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f\"\n+checksum = \"ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438\"\ndependencies = [\n\"libc\",\n- \"redox_syscall\",\n\"winapi 0.3.8\",\n]\n@@ -3228,9 +3246,9 @@ dependencies = [\n[[package]]\nname = \"tokio\"\n-version = \"0.2.16\"\n+version = \"0.2.20\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"ee5a0dd887e37d37390c13ff8ac830f992307fe30a1fff0ab8427af67211ba28\"\n+checksum = \"05c1d570eb1a36f0345a5ce9c6c6e665b70b73d11236912c0b477616aeec47b1\"\ndependencies = [\n\"bytes 0.5.4\",\n\"fnv\",\n@@ -3399,12 +3417,12 @@ dependencies = [\n[[package]]\nname = \"tokio-tls\"\n-version = \"0.3.0\"\n+version = \"0.3.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"7bde02a3a5291395f59b06ec6945a3077602fac2b07eeeaf0dee2122f3619828\"\n+checksum = \"9a70f4fcd7b3b24fb194f837560168208f669ca8cb70d0c4b862944452396343\"\ndependencies = [\n\"native-tls\",\n- \"tokio 0.2.16\",\n+ \"tokio 0.2.20\",\n]\n[[package]]\n@@ -3451,7 +3469,7 @@ dependencies = [\n\"futures-sink\",\n\"log\",\n\"pin-project-lite\",\n- \"tokio 0.2.16\",\n+ \"tokio 0.2.20\",\n]\n[[package]]\n@@ -3460,7 +3478,7 @@ version = \"0.5.6\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a\"\ndependencies = [\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n]\n[[package]]\n@@ -3565,9 +3583,9 @@ checksum = \"1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887\"\n[[package]]\nname = \"typenum\"\n-version = \"1.11.2\"\n+version = \"1.12.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9\"\n+checksum = \"373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33\"\n[[package]]\nname = \"ucd-trie\"\n@@ -3599,7 +3617,7 @@ version = \"0.1.12\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4\"\ndependencies = [\n- \"smallvec 1.2.0\",\n+ \"smallvec 1.4.0\",\n]\n[[package]]\n@@ -3662,9 +3680,9 @@ source = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"c2ca2a14bc3fc5b64d188b087a7d3a927df87b152e941ccfbc66672e20c467ae\"\ndependencies = [\n\"nom 4.2.3\",\n- \"proc-macro2 1.0.9\",\n- \"quote 1.0.3\",\n- \"syn 1.0.17\",\n+ \"proc-macro2 1.0.12\",\n+ \"quote 1.0.5\",\n+ \"syn 1.0.21\",\n]\n[[package]]\n@@ -3724,36 +3742,36 @@ checksum = \"cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519\"\n[[package]]\nname = \"wasm-bindgen\"\n-version = \"0.2.60\"\n+version = \"0.2.62\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"2cc57ce05287f8376e998cbddfb4c8cb43b84a7ec55cf4551d7c00eef317a47f\"\n+checksum = \"e3c7d40d09cdbf0f4895ae58cf57d92e1e57a9dd8ed2e8390514b54a47cc5551\"\ndependencies = [\n\"cfg-if\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"serde_json\",\n\"wasm-bindgen-macro\",\n]\n[[package]]\nname = \"wasm-bindgen-backend\"\n-version = \"0.2.60\"\n+version = \"0.2.62\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"d967d37bf6c16cca2973ca3af071d0a2523392e4a594548155d89a678f4237cd\"\n+checksum = \"c3972e137ebf830900db522d6c8fd74d1900dcfc733462e9a12e942b00b4ac94\"\ndependencies = [\n\"bumpalo\",\n\"lazy_static\",\n\"log\",\n- \"proc-macro2 1.0.9\",\n- \"quote 1.0.3\",\n- \"syn 1.0.17\",\n+ \"proc-macro2 1.0.12\",\n+ \"quote 1.0.5\",\n+ \"syn 1.0.21\",\n\"wasm-bindgen-shared\",\n]\n[[package]]\nname = \"wasm-bindgen-futures\"\n-version = \"0.4.10\"\n+version = \"0.4.12\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"7add542ea1ac7fdaa9dc25e031a6af33b7d63376292bd24140c637d00d1c312a\"\n+checksum = \"8a369c5e1dfb7569e14d62af4da642a3cbc2f9a3652fe586e26ac22222aa4b04\"\ndependencies = [\n\"cfg-if\",\n\"js-sys\",\n@@ -3763,38 +3781,38 @@ dependencies = [\n[[package]]\nname = \"wasm-bindgen-macro\"\n-version = \"0.2.60\"\n+version = \"0.2.62\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"8bd151b63e1ea881bb742cd20e1d6127cef28399558f3b5d415289bc41eee3a4\"\n+checksum = \"2cd85aa2c579e8892442954685f0d801f9129de24fa2136b2c6a539c76b65776\"\ndependencies = [\n- \"quote 1.0.3\",\n+ \"quote 1.0.5\",\n\"wasm-bindgen-macro-support\",\n]\n[[package]]\nname = \"wasm-bindgen-macro-support\"\n-version = \"0.2.60\"\n+version = \"0.2.62\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"d68a5b36eef1be7868f668632863292e37739656a80fc4b9acec7b0bd35a4931\"\n+checksum = \"8eb197bd3a47553334907ffd2f16507b4f4f01bbec3ac921a7719e0decdfe72a\"\ndependencies = [\n- \"proc-macro2 1.0.9\",\n- \"quote 1.0.3\",\n- \"syn 1.0.17\",\n+ \"proc-macro2 1.0.12\",\n+ \"quote 1.0.5\",\n+ \"syn 1.0.21\",\n\"wasm-bindgen-backend\",\n\"wasm-bindgen-shared\",\n]\n[[package]]\nname = \"wasm-bindgen-shared\"\n-version = \"0.2.60\"\n+version = \"0.2.62\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"daf76fe7d25ac79748a37538b7daeed1c7a6867c92d3245c12c6222e4a20d639\"\n+checksum = \"a91c2916119c17a8e316507afaaa2dd94b47646048014bbdf6bef098c1bb58ad\"\n[[package]]\nname = \"web-sys\"\n-version = \"0.3.37\"\n+version = \"0.3.39\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"2d6f51648d8c56c366144378a33290049eafdd784071077f6fe37dae64c1c4cb\"\n+checksum = \"8bc359e5dd3b46cb9687a051d50a2fdd228e4ba7cf6fcf861a5365c3d671a642\"\ndependencies = [\n\"js-sys\",\n\"wasm-bindgen\",\n@@ -3815,7 +3833,7 @@ dependencies = [\n\"futures-timer\",\n\"log\",\n\"num256\",\n- \"serde 1.0.105\",\n+ \"serde 1.0.110\",\n\"serde_derive\",\n\"serde_json\",\n\"tokio 0.1.22\",\n@@ -3857,9 +3875,9 @@ checksum = \"ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6\"\n[[package]]\nname = \"winapi-util\"\n-version = \"0.1.3\"\n+version = \"0.1.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80\"\n+checksum = \"70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178\"\ndependencies = [\n\"winapi 0.3.8\",\n]\n@@ -3922,5 +3940,5 @@ version = \"0.4.3\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d\"\ndependencies = [\n- \"linked-hash-map 0.5.2\",\n+ \"linked-hash-map 0.5.3\",\n]\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Update Clarity and other deps
Adds support for EIP55 compatible addresses, which are now the default
display type. This is backwards compatible because the parse() impl
over in Clarity is permissive. |
20,244 | 13.05.2020 14:21:00 | 14,400 | 1c49d378b653e219416ee2a8ca75a23ee27293e0 | Run Clippy across all crates
Previously we've run clippy in Rita but not against everything
in the althea_rs repo | [
{
"change_type": "MODIFY",
"old_path": "scripts/test.sh",
"new_path": "scripts/test.sh",
"diff": "@@ -5,7 +5,7 @@ NODES=${NODES:='None'}\n# test rita and rita_exit\nRUST_TEST_THREADS=1 cargo test --all\n# check for nits\n-cargo clippy --all-targets --all-features -- -D warnings\n+cargo clippy --all --all-targets --all-features -- -D warnings\n# test rita only on many architectures\nCROSS_TEST_ARGS=\"--verbose -p rita --bin rita --features bundle_openssl -- --test-threads=1\"\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Run Clippy across all crates
Previously we've run clippy in Rita but not against everything
in the althea_rs repo |
20,244 | 13.05.2020 14:21:57 | 14,400 | 38fa3994ca7f2cf5a85191a33a624443034beb74 | Clippy fixes for AltheaTypes | [
{
"change_type": "MODIFY",
"old_path": "althea_types/src/interop.rs",
"new_path": "althea_types/src/interop.rs",
"diff": "@@ -187,20 +187,20 @@ impl Default for ExitState {\nimpl ExitState {\npub fn general_details(&self) -> Option<&ExitDetails> {\n- match self {\n- &ExitState::GotInfo {\n+ match *self {\n+ ExitState::GotInfo {\nref general_details,\n..\n} => Some(general_details),\n- &ExitState::Registering {\n+ ExitState::Registering {\nref general_details,\n..\n} => Some(general_details),\n- &ExitState::Pending {\n+ ExitState::Pending {\nref general_details,\n..\n} => Some(general_details),\n- &ExitState::Registered {\n+ ExitState::Registered {\nref general_details,\n..\n} => Some(general_details),\n@@ -209,8 +209,8 @@ impl ExitState {\n}\npub fn our_details(&self) -> Option<&ExitClientDetails> {\n- match self {\n- &ExitState::Registered {\n+ match *self {\n+ ExitState::Registered {\nref our_details, ..\n} => Some(our_details),\n_ => None,\n@@ -218,14 +218,14 @@ impl ExitState {\n}\npub fn message(&self) -> String {\n- match self {\n- &ExitState::New => \"New exit\".to_string(),\n- &ExitState::GotInfo { ref message, .. } => message.clone(),\n- &ExitState::Registering { ref message, .. } => message.clone(),\n- &ExitState::Pending { ref message, .. } => message.clone(),\n- &ExitState::Registered { ref message, .. } => message.clone(),\n- &ExitState::Denied { ref message, .. } => message.clone(),\n- &ExitState::Disabled => \"Exit disabled\".to_string(),\n+ match *self {\n+ ExitState::New => \"New exit\".to_string(),\n+ ExitState::GotInfo { ref message, .. } => message.clone(),\n+ ExitState::Registering { ref message, .. } => message.clone(),\n+ ExitState::Pending { ref message, .. } => message.clone(),\n+ ExitState::Registered { ref message, .. } => message.clone(),\n+ ExitState::Denied { ref message, .. } => message.clone(),\n+ ExitState::Disabled => \"Exit disabled\".to_string(),\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "althea_types/src/monitoring.rs",
"new_path": "althea_types/src/monitoring.rs",
"diff": "@@ -14,7 +14,7 @@ pub struct RTTimestamps {\n/// Implements https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm\n/// to keep track of neighbor latency in an online fashion for a specific interface\n-#[derive(Debug, Clone, Copy, Serialize, Deserialize)]\n+#[derive(Debug, Clone, Copy, Serialize, Deserialize, Default)]\npub struct RunningLatencyStats {\ncount: u32,\nmean: f32,\n@@ -125,7 +125,7 @@ impl RunningLatencyStats {\n/// more data processing to get correct values. 'Reach' is a 16 second bitvector of hello/IHU\n/// outcomes, but we're sampling every 5 seconds, in order to keep samples from interfering with\n/// each other we take the top 5 bits and use that to compute packet loss.\n-#[derive(Debug, Clone, Serialize, Deserialize)]\n+#[derive(Debug, Clone, Serialize, Deserialize, Default)]\npub struct RunningPacketLossStats {\n/// the number of packets lost during each 5 second sample period over the last five minutes\nfive_minute_loss: Vec<u8>,\n"
},
{
"change_type": "MODIFY",
"old_path": "althea_types/src/wg_key.rs",
"new_path": "althea_types/src/wg_key.rs",
"diff": "/// This file under Apache 2.0\n-use base64;\nuse serde::de::{Deserialize, Error, Unexpected, Visitor};\nuse serde::ser::{Serialize, Serializer};\nuse serde::Deserializer;\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Clippy fixes for AltheaTypes |
20,244 | 13.05.2020 14:22:05 | 14,400 | 919dff5b1e703b00c60ad17d63de778452dccb61 | Clippy fixes for Clu | [
{
"change_type": "MODIFY",
"old_path": "clu/src/lib.rs",
"new_path": "clu/src/lib.rs",
"diff": "@@ -10,12 +10,9 @@ extern crate lazy_static;\nuse althea_kernel_interface::KI;\nuse clarity::PrivateKey;\nuse failure::Error;\n-use ipgen;\n-use rand;\nuse rand::distributions::Alphanumeric;\nuse rand::{thread_rng, Rng};\nuse regex::Regex;\n-use settings;\nuse settings::exit::RitaExitSettings;\nuse settings::RitaCommonSettings;\nuse std::fs::File;\n@@ -57,17 +54,15 @@ pub fn cleanup() -> Result<(), Error> {\nfor i in KI.get_interfaces()? {\nif RE.is_match(&i) {\n- match KI.del_interface(&i) {\n- Err(e) => trace!(\"Failed to delete wg# {:?}\", e),\n- _ => (),\n- };\n+ if let Err(e) = KI.del_interface(&i) {\n+ trace!(\"Failed to delete wg# {:?}\", e);\n+ }\n}\n}\n- match KI.del_interface(\"wg_exit\") {\n- Err(e) => trace!(\"Failed to delete wg_exit {:?}\", e),\n- _ => (),\n- };\n+ if let Err(e) = KI.del_interface(\"wg_exit\") {\n+ trace!(\"Failed to delete wg_exit {:?}\", e);\n+ }\nOk(())\n}\n@@ -78,9 +73,9 @@ fn linux_init(config: Arc<RwLock<settings::client::RitaSettingsStruct>>) -> Resu\n// handle things we need to generate at runtime\nlet mut network_settings = config.get_network_mut();\n- let mesh_ip_option = network_settings.mesh_ip.clone();\n- let wg_pubkey_option = network_settings.wg_public_key.clone();\n- let wg_privkey_option = network_settings.wg_private_key.clone();\n+ let mesh_ip_option = network_settings.mesh_ip;\n+ let wg_pubkey_option = network_settings.wg_public_key;\n+ let wg_privkey_option = network_settings.wg_private_key;\nlet device_option = network_settings.device.clone();\nmatch mesh_ip_option {\n@@ -124,10 +119,9 @@ fn linux_init(config: Arc<RwLock<settings::client::RitaSettingsStruct>>) -> Resu\nfor line in contents.lines() {\nif line.starts_with(\"device:\") {\n- let device = line.split(\" \").nth(1).ok_or(format_err!(\n- \"Could not obtain device name from line {:?}\",\n- line\n- ))?;\n+ let device = line.split(' ').nth(1).ok_or_else(|| {\n+ format_err!(\"Could not obtain device name from line {:?}\", line)\n+ })?;\nnetwork_settings.device = Some(device.to_string());\n@@ -171,7 +165,7 @@ fn linux_init(config: Arc<RwLock<settings::client::RitaSettingsStruct>>) -> Resu\ndrop(network_settings);\nlet mut payment_settings = config.get_payment_mut();\n- let eth_private_key_option = payment_settings.eth_private_key.clone();\n+ let eth_private_key_option = payment_settings.eth_private_key;\nmatch eth_private_key_option {\nSome(existing_eth_private_key) => {\n@@ -206,9 +200,9 @@ fn linux_exit_init(\ndrop(exit_network_settings_ref);\nlet mut network_settings = config.get_network_mut();\n- let mesh_ip_option = network_settings.mesh_ip.clone();\n- let wg_pubkey_option = network_settings.wg_public_key.clone();\n- let wg_privkey_option = network_settings.wg_private_key.clone();\n+ let mesh_ip_option = network_settings.mesh_ip;\n+ let wg_pubkey_option = network_settings.wg_public_key;\n+ let wg_privkey_option = network_settings.wg_private_key;\nmatch mesh_ip_option {\nSome(existing_mesh_ip) => {\n@@ -255,7 +249,7 @@ fn linux_exit_init(\ndrop(network_settings);\nlet mut payment_settings = config.get_payment_mut();\n- let eth_private_key_option = payment_settings.eth_private_key.clone();\n+ let eth_private_key_option = payment_settings.eth_private_key;\nmatch eth_private_key_option {\nSome(existing_eth_private_key) => {\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Clippy fixes for Clu |
20,244 | 13.05.2020 14:22:15 | 14,400 | 84625b062c386556bb2cc55806149c8ea445a091 | Clippy fixes for Settings | [
{
"change_type": "MODIFY",
"old_path": "settings/src/client.rs",
"new_path": "settings/src/client.rs",
"diff": "@@ -8,11 +8,9 @@ use crate::payment::PaymentSettings;\nuse crate::spawn_watch_thread;\nuse crate::RitaCommonSettings;\nuse althea_types::{ExitRegistrationDetails, ExitState, Identity};\n-use config;\nuse config::Config;\nuse failure::Error;\nuse owning_ref::{RwLockReadGuardRef, RwLockWriteGuardRefMut};\n-use serde_json;\nuse std::collections::{HashMap, HashSet};\nuse std::sync::{Arc, RwLock};\n@@ -185,7 +183,7 @@ impl RitaSettingsStruct {\npub fn new_watched(file_name: &str) -> Result<Arc<RwLock<Self>>, Error> {\nlet mut s = Config::new();\ns.merge(config::File::with_name(file_name).required(false))?;\n- let settings: Self = s.clone().try_into()?;\n+ let settings: Self = s.try_into()?;\nlet settings = Arc::new(RwLock::new(settings));\n@@ -197,7 +195,7 @@ impl RitaSettingsStruct {\n}\npub fn get_exit_id(&self) -> Option<Identity> {\n- Some(self.exit_client.get_current_exit().as_ref()?.id.clone())\n+ Some(self.exit_client.get_current_exit().as_ref()?.id)\n}\n}\n@@ -276,10 +274,10 @@ impl RitaCommonSettings<RitaSettingsStruct> for Arc<RwLock<RitaSettingsStruct>>\nfn get_identity(&self) -> Option<Identity> {\nSome(Identity::new(\n- self.get_network().mesh_ip?.clone(),\n- self.get_payment().eth_address.clone()?,\n- self.get_network().wg_public_key.clone()?,\n- self.get_network().nickname.clone(),\n+ self.get_network().mesh_ip?,\n+ self.get_payment().eth_address?,\n+ self.get_network().wg_public_key?,\n+ self.get_network().nickname,\n))\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "settings/src/exit.rs",
"new_path": "settings/src/exit.rs",
"diff": "-use althea_types::WgKey;\n-use config;\n-use core::str::FromStr;\n-\n-use serde_json;\n-\n-use owning_ref::{RwLockReadGuardRef, RwLockWriteGuardRefMut};\n-\n-use std::collections::HashSet;\n-use std::net::Ipv4Addr;\n-use std::sync::{Arc, RwLock};\n-\n-use config::Config;\n-\n-use althea_types::Identity;\n-\n-use failure::Error;\n-\nuse crate::json_merge;\nuse crate::localization::LocalizationSettings;\nuse crate::network::NetworkSettings;\nuse crate::payment::PaymentSettings;\nuse crate::spawn_watch_thread;\nuse crate::RitaCommonSettings;\n+use althea_types::Identity;\n+use althea_types::WgKey;\n+use config::Config;\n+use core::str::FromStr;\n+use failure::Error;\n+use owning_ref::{RwLockReadGuardRef, RwLockWriteGuardRefMut};\n+use std::collections::HashSet;\n+use std::net::Ipv4Addr;\n+use std::sync::{Arc, RwLock};\n/// This is the network settings specific to rita_exit\n#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]\n@@ -273,7 +264,7 @@ impl RitaExitSettingsStruct {\npub fn new_watched(file_name: &str) -> Result<Arc<RwLock<Self>>, Error> {\nlet mut s = Config::new();\ns.merge(config::File::with_name(file_name).required(false))?;\n- let settings: Self = s.clone().try_into()?;\n+ let settings: Self = s.try_into()?;\nlet settings = Arc::new(RwLock::new(settings));\n@@ -350,10 +341,10 @@ impl RitaCommonSettings<RitaExitSettingsStruct> for Arc<RwLock<RitaExitSettingsS\nfn get_identity(&self) -> Option<Identity> {\nSome(Identity::new(\n- self.get_network().mesh_ip.clone()?,\n- self.get_payment().eth_address.clone()?,\n- self.get_network().wg_public_key.clone()?,\n- self.get_network().nickname.clone(),\n+ self.get_network().mesh_ip?,\n+ self.get_payment().eth_address?,\n+ self.get_network().wg_public_key?,\n+ self.get_network().nickname,\n))\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "settings/src/lib.rs",
"new_path": "settings/src/lib.rs",
"diff": "@@ -15,38 +15,28 @@ extern crate lazy_static;\nextern crate serde_derive;\n#[macro_use]\nextern crate log;\n-\nextern crate arrayvec;\n-#[cfg(test)]\n-use std::sync::Mutex;\n-\n-use toml;\n-\n-use serde;\n-use serde_json;\n-\n-use owning_ref::{RwLockReadGuardRef, RwLockWriteGuardRefMut};\n-\n-use std::fs::File;\n-use std::io::Write;\n-use std::sync::{Arc, RwLock};\n-use std::thread;\n-use std::time::Duration;\n-\n+use crate::localization::LocalizationSettings;\n+use crate::network::NetworkSettings;\n+use crate::payment::PaymentSettings;\nuse althea_kernel_interface::KernelInterface;\n-\n#[cfg(not(test))]\nuse althea_kernel_interface::LinuxCommandRunner;\n#[cfg(test)]\nuse althea_kernel_interface::TestCommandRunner;\n-\nuse althea_types::Identity;\n-\n+use failure::Error;\n+use owning_ref::{RwLockReadGuardRef, RwLockWriteGuardRefMut};\nuse serde::{Deserialize, Serialize};\nuse serde_json::Value;\n-\n-use failure::Error;\n+use std::fs::File;\n+use std::io::Write;\n+#[cfg(test)]\n+use std::sync::Mutex;\n+use std::sync::{Arc, RwLock};\n+use std::thread;\n+use std::time::Duration;\npub mod client;\npub mod dao;\n@@ -57,10 +47,6 @@ pub mod network;\npub mod operator;\npub mod payment;\n-use crate::localization::LocalizationSettings;\n-use crate::network::NetworkSettings;\n-use crate::payment::PaymentSettings;\n-\n#[cfg(test)]\nlazy_static! {\nstatic ref KI: Box<dyn KernelInterface> = Box::new(TestCommandRunner {\n@@ -141,9 +127,8 @@ where\nif old_settings != new_settings {\ntrace!(\"writing updated config: {:?}\", new_settings);\n- match settings.read().unwrap().write(&file_path) {\n- Err(e) => warn!(\"writing updated config failed {:?}\", e),\n- _ => (),\n+ if let Err(e) = settings.read().unwrap().write(&file_path) {\n+ warn!(\"writing updated config failed {:?}\", e);\n}\n}\n}\n@@ -157,7 +142,7 @@ where\nT: Serialize,\n{\nfn write(&self, file_name: &str) -> Result<(), Error> {\n- let ser = toml::Value::try_from(self.clone())?;\n+ let ser = toml::Value::try_from(self)?;\nlet ser = toml::to_string(&ser)?;\nlet mut file = File::create(file_name)?;\nfile.write_all(ser.as_bytes())?;\n"
},
{
"change_type": "MODIFY",
"old_path": "settings/src/payment.rs",
"new_path": "settings/src/payment.rs",
"diff": "@@ -18,7 +18,7 @@ fn default_max_fee() -> u32 {\n}\nfn default_close_threshold() -> Int256 {\n- (-8400000000000000i64).into()\n+ (-8_400_000_000_000_000i64).into()\n}\nfn default_pay_threshold() -> Int256 {\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Clippy fixes for Settings |
20,244 | 13.05.2020 14:22:29 | 14,400 | 0fd8a9a4cbd86829f33636f769bb97b9461b4782 | Clippy fixes for Rita | [
{
"change_type": "MODIFY",
"old_path": "rita/build.rs",
"new_path": "rita/build.rs",
"diff": "@@ -6,6 +6,6 @@ fn main() {\n.output()\n.ok()\n.and_then(|output| String::from_utf8(output.stdout).ok())\n- .unwrap_or(\"(unknown)\".to_string());\n+ .unwrap_or_else(|| \"(unknown)\".to_string());\nprintln!(\"cargo:rustc-env=GIT_HASH={}\", git_hash);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/exit_manager/mod.rs",
"new_path": "rita/src/rita_client/exit_manager/mod.rs",
"diff": "@@ -22,10 +22,11 @@ use crate::rita_client::traffic_watcher::{QueryExitDebts, TrafficWatcher};\nuse crate::rita_common::blockchain_oracle::low_balance;\nuse crate::KI;\nuse crate::SETTING;\n-use ::actix::registry::SystemService;\n-use ::actix::{Actor, Arbiter, Context, Handler, ResponseFuture, Supervised};\n-use ::actix_web::client::Connection;\n-use ::actix_web::{client, HttpMessage, Result};\n+use actix::registry::SystemService;\n+use actix::{Actor, Arbiter, Context, Handler, ResponseFuture, Supervised};\n+use actix_web::client::Connection;\n+use actix_web::{client, HttpMessage, Result};\n+use althea_kernel_interface::exit_client_tunnel::ClientExitTunnelConfig;\nuse althea_types::ExitClientDetails;\nuse althea_types::ExitDetails;\nuse althea_types::WgKey;\n@@ -57,15 +58,18 @@ fn linux_setup_exit_tunnel(\nKI.update_settings_route(&mut SETTING.get_network_mut().default_route)?;\nKI.setup_wg_if_named(\"wg_exit\")?;\n- KI.set_client_exit_tunnel_config(\n- SocketAddr::new(current_exit.id.mesh_ip, general_details.wg_exit_port),\n- current_exit.id.wg_public_key,\n- SETTING.get_network().wg_private_key_path.clone(),\n- SETTING.get_exit_client().wg_listen_port,\n- our_details.client_internal_ip,\n- general_details.netmask,\n- SETTING.get_network().rita_hello_port,\n- )?;\n+\n+ let args = ClientExitTunnelConfig {\n+ endpoint: SocketAddr::new(current_exit.id.mesh_ip, general_details.wg_exit_port),\n+ pubkey: current_exit.id.wg_public_key,\n+ private_key_path: SETTING.get_network().wg_private_key_path.clone(),\n+ listen_port: SETTING.get_exit_client().wg_listen_port,\n+ local_ip: our_details.client_internal_ip,\n+ netmask: general_details.netmask,\n+ rita_hello_port: SETTING.get_network().rita_hello_port,\n+ };\n+\n+ KI.set_client_exit_tunnel_config(args)?;\nKI.set_route_to_tunnel(&general_details.server_internal_ip)?;\nKI.create_client_nat_rules()?;\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/token_bridge/mod.rs",
"new_path": "rita/src/rita_common/token_bridge/mod.rs",
"diff": "@@ -531,7 +531,7 @@ fn xdai_bridge(state: State, bridge: &TokenBridge) {\n.and_then(move |_| {\ninfo!(\"Issued an eth transfer for withdraw! Now complete!\");\n// we only exit the withdraw state on success or timeout\n- TokenBridge::from_registry().do_send(StateChange(State::Ready {former_state: Some(Box::new(State::Withdrawing{to, amount: amount, timestamp, withdraw_all}))}));\n+ TokenBridge::from_registry().do_send(StateChange(State::Ready {former_state: Some(Box::new(State::Withdrawing{to, amount, timestamp, withdraw_all}))}));\nOk(())}))\n} else {\ninfo!(\"withdraw is waiting on bridge\");\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/tunnel_manager/mod.rs",
"new_path": "rita/src/rita_common/tunnel_manager/mod.rs",
"diff": "@@ -16,6 +16,7 @@ use crate::SETTING;\nuse actix::actors::mocker::Mocker;\nuse actix::actors::resolver;\nuse actix::{Actor, Arbiter, Context, Handler, Message, Supervised, SystemService};\n+use althea_kernel_interface::open_tunnel::TunnelOpenArgs;\nuse althea_types::Identity;\nuse althea_types::LocalIdentity;\nuse babel_monitor::monitor;\n@@ -185,20 +186,22 @@ impl Tunnel {\n/// Open a real tunnel to match the virtual tunnel we store in memory\npub fn open(&self, light_client_details: Option<Ipv4Addr>) -> Result<(), Error> {\nlet network = SETTING.get_network().clone();\n- KI.open_tunnel(\n- &self.iface_name,\n- self.listen_port,\n- &SocketAddr::new(self.ip, self.neigh_id.wg_port),\n- &self.neigh_id.global.wg_public_key,\n- Path::new(&network.wg_private_key_path),\n- &match network.mesh_ip {\n+ let args = TunnelOpenArgs {\n+ interface: self.iface_name.clone(),\n+ port: self.listen_port,\n+ endpoint: SocketAddr::new(self.ip, self.neigh_id.wg_port),\n+ remote_pub_key: self.neigh_id.global.wg_public_key,\n+ private_key_path: Path::new(&network.wg_private_key_path),\n+ own_ip: match network.mesh_ip {\nSome(ip) => ip,\nNone => bail!(\"No mesh IP configured yet\"),\n},\n- network.external_nic.clone(),\n- &mut SETTING.get_network_mut().default_route,\n- light_client_details,\n- )?;\n+ external_nic: network.external_nic.clone(),\n+ settings_default_route: &mut SETTING.get_network_mut().default_route,\n+ allowed_ipv4_address: light_client_details,\n+ };\n+\n+ KI.open_tunnel(args)?;\nKI.set_codel_shaping(&self.iface_name, self.speed_limit)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_exit/database/mod.rs",
"new_path": "rita/src/rita_exit/database/mod.rs",
"diff": "@@ -531,11 +531,11 @@ pub fn enforce_exit_clients(\nlet res = if debt_entry.payment_details.action == DebtAction::SuspendTunnel\n{\ninfo!(\"Exit is enforcing on {} because their debt of {} is greater than the limit of {}\", client.wg_pubkey, debt_entry.payment_details.debt, close_threshold);\n- KI.set_class_limit(\"wg_exit\", free_tier_limit, free_tier_limit, &ip)\n+ KI.set_class_limit(\"wg_exit\", free_tier_limit, free_tier_limit, ip)\n} else {\n// set to 500mbps garunteed bandwidth and 1gbps\n// absolute max\n- KI.set_class_limit(\"wg_exit\", 500_000, 1_000_000, &ip)\n+ KI.set_class_limit(\"wg_exit\", 500_000, 1_000_000, ip)\n};\nif res.is_err() {\npanic!(\"Failed to limit {} with {:?}\", ip, res);\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Clippy fixes for Rita |
20,244 | 13.05.2020 14:45:40 | 14,400 | b758262bf7641954ed7812e7e560cd2957589dd4 | Bump for Beta 14 RC2 | [
{
"change_type": "MODIFY",
"old_path": "Cargo.lock",
"new_path": "Cargo.lock",
"diff": "@@ -2676,7 +2676,7 @@ dependencies = [\n[[package]]\nname = \"rita\"\n-version = \"0.5.47\"\n+version = \"0.5.48\"\ndependencies = [\n\"actix\",\n\"actix-web\",\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/Cargo.toml",
"new_path": "rita/Cargo.toml",
"diff": "[package]\nname = \"rita\"\n-version = \"0.5.47\"\n+version = \"0.5.48\"\nauthors = [\"Justin <justin@althea.net>\", \"Jehan <jehan.tremback@gmail.com>\", \"Ben <wangben3@gmail.com>\"]\nbuild = \"build.rs\"\nedition = \"2018\"\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/dashboard/own_info.rs",
"new_path": "rita/src/rita_common/dashboard/own_info.rs",
"diff": "@@ -6,7 +6,7 @@ use failure::Error;\nuse num256::{Int256, Uint256};\nuse settings::RitaCommonSettings;\n-pub static READABLE_VERSION: &str = \"Beta 14 RC1\";\n+pub static READABLE_VERSION: &str = \"Beta 14 RC2\";\n#[derive(Serialize)]\npub struct OwnInfo {\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Bump for Beta 14 RC2 |
20,244 | 17.05.2020 18:41:27 | 14,400 | 67f4c5e75d1fa1682d48bebdcc2e9b06c7fc6f66 | Add sensor detection and reading
The hardware info struct now performs sensor detection using
the linux /sys/class/hwmon interface. This reads the maximum,
minimum, critial, and current temp from devices. Looking at the
deployed fleet it seems that all the routers ship with the
software they need to detect temps. | [
{
"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 althea_types::HardwareInfo;\n+use althea_types::SensorReading;\nuse failure::Error;\n+use std::fs;\n/// Gets the load average and memory of the system from /proc should be plenty\n/// efficient and safe to run. Requires the device name to be passed in because\n@@ -9,6 +11,34 @@ use failure::Error;\n/// both are rather large steps up complexity wise to parse due to the lack of consistent\n/// formatting\npub fn get_hardware_info(device_name: Option<String>) -> Result<HardwareInfo, Error> {\n+ let (one_minute_load_avg, five_minute_load_avg, fifteen_minute_load_avg) = get_load_avg()?;\n+ let (mem_total, mem_free) = get_memory_info()?;\n+\n+ let model = match device_name {\n+ Some(name) => name,\n+ None => \"Unknown Device\".to_string(),\n+ };\n+\n+ let num_cpus = get_numcpus()?;\n+\n+ let sensor_readings = match get_sensor_readings() {\n+ Ok(readings) => Some(readings),\n+ Err(_e) => None,\n+ };\n+\n+ Ok(HardwareInfo {\n+ logical_processors: num_cpus,\n+ load_avg_one_minute: one_minute_load_avg,\n+ load_avg_five_minute: five_minute_load_avg,\n+ load_avg_fifteen_minute: fifteen_minute_load_avg,\n+ system_memory: mem_total,\n+ allocated_memory: mem_free,\n+ model,\n+ sensor_readings,\n+ })\n+}\n+\n+fn get_load_avg() -> Result<(f32, f32, f32), Error> {\n// cpu load average\nlet load_average_error = Err(format_err!(\"Failed to get load average\"));\nlet lines = get_lines(\"/proc/loadavg\")?;\n@@ -29,7 +59,14 @@ pub fn get_hardware_info(device_name: Option<String>) -> Result<HardwareInfo, Er\nSome(val) => val.parse()?,\nNone => return load_average_error,\n};\n+ Ok((\n+ one_minute_load_avg,\n+ five_minute_load_avg,\n+ fifteen_minute_load_avg,\n+ ))\n+}\n+fn get_memory_info() -> Result<(u64, u64), Error> {\n// memory info\nlet lines = get_lines(\"/proc/meminfo\")?;\nlet mut lines = lines.iter();\n@@ -48,19 +85,70 @@ pub fn get_hardware_info(device_name: Option<String>) -> Result<HardwareInfo, Er\n},\nNone => return memory_info_error,\n};\n- let model = match device_name {\n- Some(name) => name,\n- None => \"Unknown Device\".to_string(),\n- };\n- Ok(HardwareInfo {\n- load_avg_one_minute: one_minute_load_avg,\n- load_avg_five_minute: five_minute_load_avg,\n- load_avg_fifteen_minute: fifteen_minute_load_avg,\n- system_memory: mem_total,\n- allocated_memory: mem_free,\n- model,\n- })\n+ Ok((mem_total, mem_free))\n+}\n+\n+/// gets the number of logical (not physical) cores\n+/// by parsing /proc/cpuinfo may be inaccurate\n+fn get_numcpus() -> Result<u32, Error> {\n+ // memory info\n+ let lines = get_lines(\"/proc/cpuinfo\")?;\n+ let mut num_cpus = 0;\n+ for line in lines {\n+ if line.contains(\"processor\") {\n+ num_cpus += 1;\n+ }\n+ }\n+ Ok(num_cpus)\n+}\n+\n+fn maybe_get_single_line_u64(path: &str) -> Option<u64> {\n+ match get_lines(path) {\n+ Ok(line) => match line.iter().next() {\n+ Some(val) => match val.parse() {\n+ Ok(res) => Some(res),\n+ Err(_e) => None,\n+ },\n+ None => None,\n+ },\n+ Err(_e) => None,\n+ }\n+}\n+\n+fn maybe_get_single_line_string(path: &str) -> Option<String> {\n+ match get_lines(path) {\n+ Ok(line) => match line.iter().next() {\n+ Some(val) => Some(val.to_string()),\n+ None => None,\n+ },\n+ Err(_e) => None,\n+ }\n+}\n+\n+fn get_sensor_readings() -> Result<Vec<SensorReading>, Error> {\n+ // sensors are zero indexed and there will never be gaps\n+ let mut sensor_num = 0;\n+ let mut ret = Vec::new();\n+ let mut path = format!(\"/sys/class/hwmon/hwmon{}\", sensor_num);\n+ while fs::metadata(path.clone()).is_ok() {\n+ if let (Some(reading), Some(name)) = (\n+ maybe_get_single_line_u64(&format!(\"{}/temp1_input\", path)),\n+ maybe_get_single_line_string(&format!(\"{}/name\", path)),\n+ ) {\n+ ret.push(SensorReading {\n+ name: name,\n+ reading: reading,\n+ min: maybe_get_single_line_u64(&format!(\"{}/temp1_min\", path)),\n+ crit: maybe_get_single_line_u64(&format!(\"{}/temp1_crit\", path)),\n+ max: maybe_get_single_line_u64(&format!(\"{}/temp1_max\", path)),\n+ });\n+ }\n+\n+ sensor_num += 1;\n+ path = format!(\"/sys/class/hwmon/hwmon{}\", sensor_num);\n+ }\n+ Ok(ret)\n}\n#[test]\n@@ -69,3 +157,17 @@ fn test_read_hw_info() {\nlet hw_info = res.unwrap();\nassert_eq!(hw_info.model, \"test\");\n}\n+\n+#[test]\n+fn test_numcpus() {\n+ let res = get_numcpus();\n+ let cpus = res.unwrap();\n+ assert!(cpus != 0);\n+}\n+\n+#[test]\n+fn test_sensors() {\n+ let res = get_sensor_readings();\n+ println!(\"{:?}\", res);\n+ assert!(res.is_ok());\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "althea_types/src/interop.rs",
"new_path": "althea_types/src/interop.rs",
"diff": "@@ -479,18 +479,63 @@ pub struct OperatorCheckinMessage {\n/// like strings\npub contact_details: Option<ContactDetails>,\n/// Info about the current state of this device, including it's model, CPU,\n- /// memory, and hopefully some day more info like temperature\n+ /// memory, and temperature if sensors are available\npub hardware_info: Option<HardwareInfo>,\n}\n#[derive(Debug, Clone, Serialize, Deserialize)]\n+/// A set of info derived from /proc/ and /sys/ about the recent\n+/// load on the system\npub struct HardwareInfo {\n+ /// the number of logical processors on the system, derived\n+ /// by parsing /proc/cpuinfo and counting the number of instances\n+ /// of the word 'processor'\n+ pub logical_processors: u32,\n+ /// The load average of the system over the last 1 minute please\n+ /// see this reference before making decisions based on this value\n+ /// http://www.brendangregg.com/blog/2017-08-08/linux-load-averages.html\n+ /// parsed from /proc/loadvg\npub load_avg_one_minute: f32,\n+ /// The load average of the system over the last 5 minutes please\n+ /// see this reference before making decisions based on this value\n+ /// http://www.brendangregg.com/blog/2017-08-08/linux-load-averages.html\n+ /// parsed from /proc/loadavg\npub load_avg_five_minute: f32,\n+ /// The load average of the system over the last 15 minutes please\n+ /// see this reference before making decisions based on this value\n+ /// http://www.brendangregg.com/blog/2017-08-08/linux-load-averages.html\n+ /// parsed from /proc/loadavg\npub load_avg_fifteen_minute: f32,\n+ /// Available system memory in kilobytes parsed from /proc/meminfo\npub system_memory: u64,\n+ /// Allocated system memory in kilobytes parsed from /proc/meminfo\npub allocated_memory: u64,\n+ /// The model name of this router which is inserted into the config\n+ /// at build time by the firmware builder. Note that this is an Althea\n+ /// specific identifying name since we define it ourselves there\npub model: String,\n+ /// An array of sensors data, one entry for each sensor discovered by\n+ /// traversing /sys/class/hwmon\n+ pub sensor_readings: Option<Vec<SensorReading>>,\n+}\n+\n+#[derive(Debug, Clone, Serialize, Deserialize)]\n+/// Representation of a sensor discovered in /sys/class/hwmon\n+/// https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface\n+/// TODO not completely implemented\n+pub struct SensorReading {\n+ /// Human readable device name\n+ pub name: String,\n+ /// The sensor reading in Units of centi-celsius not all readings\n+ /// will end up being read because TODO the interface parsing is not\n+ /// complete\n+ pub reading: u64,\n+ /// The minimum reading this sensor can read in centi-celsius\n+ pub min: Option<u64>,\n+ /// The maximum reading this sensor can read in centi-celsius\n+ pub max: Option<u64>,\n+ /// A provided temp at which this device starts to risk failure in centi-celsius\n+ pub crit: Option<u64>,\n}\n/// Struct for storing peer status data for reporting to the operator tools server\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Add sensor detection and reading
The hardware info struct now performs sensor detection using
the linux /sys/class/hwmon interface. This reads the maximum,
minimum, critial, and current temp from devices. Looking at the
deployed fleet it seems that all the routers ship with the
software they need to detect temps. |
20,244 | 19.05.2020 09:51:00 | 14,400 | 05f2acd90a529445127f596a5dd7d509c3bb8aab | Spellcheck for forwarding client comments | [
{
"change_type": "MODIFY",
"old_path": "antenna_forwarding_client/src/lib.rs",
"new_path": "antenna_forwarding_client/src/lib.rs",
"diff": "@@ -46,7 +46,7 @@ const PING_TIMEOUT: Duration = Duration::from_millis(100);\nconst FORWARD_TIMEOUT: Duration = Duration::from_secs(600);\n/// Starts a thread that will check in with the provided server repeatedly and forward antennas\n-/// when the right signal is recieved. The type bound is so that you can use custom hashers and\n+/// when the right signal is received. The type bound is so that you can use custom hashers and\n/// may not really be worth keeping around.\npub fn start_antenna_forwarding_proxy<S: 'static + std::marker::Send + ::std::hash::BuildHasher>(\ncheckin_address: String,\n@@ -195,7 +195,7 @@ fn process_messages(\n);\n}\nErr(e) => error!(\n- \"Failed to write to anntenna stream id {} with {:?}\",\n+ \"Failed to write to antenna stream id {} with {:?}\",\nstream_id, e\n),\n}\n@@ -271,7 +271,7 @@ fn setup_networking<S: ::std::hash::BuildHasher>(\nmatch find_antenna(antenna_ip, interfaces) {\nOk(_iface) => {}\nErr(e) => {\n- error!(\"Could not find anntenna {:?}\", e);\n+ error!(\"Could not find antenna {:?}\", e);\nreturn Err(e);\n}\n};\n@@ -313,7 +313,7 @@ fn find_antenna<S: ::std::hash::BuildHasher>(\n);\ntrace!(\"Added our own test ip with {:?}\", res);\n// you need to use src here to disambiguate the sending address\n- // otherwise the first avaialble ipv4 address on the interface will\n+ // otherwise the first available ipv4 address on the interface will\n// be used\nmatch KI.run_command(\n\"ip\",\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Spellcheck for forwarding client comments |
20,244 | 19.05.2020 09:54:12 | 14,400 | 87e157f9db853238012e21fe2bd85d56303f2ce6 | Fix variable name spelling in UsageTracker
sadly this requires a whole migration code set | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/usage_tracker/mod.rs",
"new_path": "rita/src/rita_common/usage_tracker/mod.rs",
"diff": "//! in that round and exactly what type of bandwidth it is is sent to this module, from there\n//! 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-//!\n-//! Persistant storage is planned but not currently implemented.\nuse crate::SETTING;\nuse actix::Actor;\n@@ -87,7 +85,7 @@ fn to_formatted_payment_tx(input: PaymentTx) -> FormattedPaymentTx {\n}\n}\n-/// A struct for tracking each hours of paymetns indexed in hours since unix epoch\n+/// A struct for tracking each hours of payments indexed in hours since unix epoch\n#[derive(Clone, Debug, Serialize, Deserialize)]\npub struct PaymentHour {\nindex: u64,\n@@ -98,6 +96,19 @@ pub struct PaymentHour {\n/// at some point loading and saving will be defined in service started\n#[derive(Clone, Debug, Serialize, Deserialize)]\npub struct UsageTracker {\n+ last_save_hour: u64,\n+ // at least one of these will be left unused\n+ client_bandwidth: VecDeque<UsageHour>,\n+ relay_bandwidth: VecDeque<UsageHour>,\n+ exit_bandwidth: VecDeque<UsageHour>,\n+ /// A history of payments\n+ payments: VecDeque<PaymentHour>,\n+}\n+\n+/// A legacy struct required to parse the old member names\n+/// and convert into the new version\n+#[derive(Clone, Debug, Serialize, Deserialize)]\n+pub struct UsageTrackerMisspelled {\nlast_save_hour: u64,\n// at least one of these will be left unused\nclient_bandwith: VecDeque<UsageHour>,\n@@ -107,15 +118,27 @@ pub struct UsageTracker {\npayments: VecDeque<PaymentHour>,\n}\n+impl UsageTrackerMisspelled {\n+ pub fn upgrade(self) -> UsageTracker {\n+ UsageTracker {\n+ last_save_hour: self.last_save_hour,\n+ client_bandwidth: self.client_bandwith,\n+ relay_bandwidth: self.relay_bandwith,\n+ exit_bandwidth: self.exit_bandwith,\n+ payments: self.payments,\n+ }\n+ }\n+}\n+\nimpl Default for UsageTracker {\nfn default() -> UsageTracker {\nlet file = File::open(SETTING.get_network().usage_tracker_file.clone());\n// if the loading process goes wrong for any reason, we just start again\nlet blank_usage_tracker = UsageTracker {\nlast_save_hour: 0,\n- client_bandwith: VecDeque::new(),\n- relay_bandwith: VecDeque::new(),\n- exit_bandwith: VecDeque::new(),\n+ client_bandwidth: VecDeque::new(),\n+ relay_bandwidth: VecDeque::new(),\n+ exit_bandwidth: VecDeque::new(),\npayments: VecDeque::new(),\n};\n@@ -135,9 +158,16 @@ impl Default for UsageTracker {\ntrace!(\"found a compressed json stream\");\nlet deserialized: Result<UsageTracker, SerdeError> =\nserde_json::from_slice(&contents);\n- match deserialized {\n- Ok(value) => value,\n- Err(e) => {\n+\n+ let legacy_deserialized: Result<\n+ UsageTrackerMisspelled,\n+ SerdeError,\n+ > = serde_json::from_slice(&contents);\n+\n+ match (deserialized, legacy_deserialized) {\n+ (Ok(value), _) => value,\n+ (Err(_e), Ok(value)) => value.upgrade(),\n+ (Err(e), Err(_e)) => {\nerror!(\"Failed to deserialize bytes in compressed bw history {:?}\", e);\nblank_usage_tracker\n}\n@@ -153,10 +183,16 @@ impl Default for UsageTracker {\nlet deserialized: Result<UsageTracker, SerdeError> =\nserde_json::from_str(&contents_str);\n- match deserialized {\n- Ok(value) => value,\n- Err(e) => {\n- error!(\"Failed to deserialize usage tracker from flatfile {:?}\", e);\n+ let legacy_deserialized: Result<\n+ UsageTrackerMisspelled,\n+ SerdeError,\n+ > = serde_json::from_slice(&contents);\n+\n+ match (deserialized, legacy_deserialized) {\n+ (Ok(value), _) => value,\n+ (Err(_e), Ok(value)) => value.upgrade(),\n+ (Err(e), Err(_e)) => {\n+ error!(\"Failed to deserialize bytes in compressed bw history {:?}\", e);\nblank_usage_tracker\n}\n}\n@@ -248,9 +284,9 @@ impl Handler<UpdateUsage> for UsageTracker {\nfn process_usage_update(current_hour: u64, msg: UpdateUsage, data: &mut UsageTracker) {\n// history contains a reference to whatever the correct storage array is\nlet history = match msg.kind {\n- UsageType::Client => &mut data.client_bandwith,\n- UsageType::Relay => &mut data.relay_bandwith,\n- UsageType::Exit => &mut data.exit_bandwith,\n+ UsageType::Client => &mut data.client_bandwidth,\n+ UsageType::Relay => &mut data.relay_bandwidth,\n+ UsageType::Exit => &mut data.exit_bandwidth,\n};\n// we grab the front entry from the VecDeque, if there is an entry one we check if it's\n// up to date, if it is we add to it, if it's not or there is no entry we create one.\n@@ -345,9 +381,9 @@ impl Handler<GetUsage> for UsageTracker {\ntype Result = Result<VecDeque<UsageHour>, Error>;\nfn handle(&mut self, msg: GetUsage, _: &mut Context<Self>) -> Self::Result {\nmatch msg.kind {\n- UsageType::Client => Ok(self.client_bandwith.clone()),\n- UsageType::Relay => Ok(self.relay_bandwith.clone()),\n- UsageType::Exit => Ok(self.exit_bandwith.clone()),\n+ UsageType::Client => Ok(self.client_bandwidth.clone()),\n+ UsageType::Relay => Ok(self.relay_bandwidth.clone()),\n+ UsageType::Exit => Ok(self.exit_bandwidth.clone()),\n}\n}\n}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Fix variable name spelling in UsageTracker
sadly this requires a whole migration code set |
20,244 | 19.05.2020 15:11:31 | 14,400 | 6cb865e086885eff8cd5e70122198b5fa092661a | Fix spelling in TrafficWatcher | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/traffic_watcher/mod.rs",
"new_path": "rita/src/rita_common/traffic_watcher/mod.rs",
"diff": "@@ -89,7 +89,7 @@ pub fn prepare_helper_maps(\npub fn get_babel_info(routes: Vec<Route>) -> Result<(HashMap<IpAddr, i128>, u32), Error> {\ntrace!(\"Got {} routes: {:?}\", routes.len(), routes);\nlet mut destinations = HashMap::new();\n- // we assume this matches what is actually set it babel becuase we\n+ // we assume this matches what is actually set it babel because we\n// panic on startup if it does not get set correctly\nlet local_fee = SETTING.get_payment().local_fee;\n@@ -235,7 +235,7 @@ pub fn get_output_counters() -> Result<HashMap<(IpAddr, String), u64>, Error> {\nOk(total_output_counters)\n}\n-/// Takes and sumns the input and output counters for logging\n+/// Takes and sums the input and output counters for logging\nfn update_usage(\ninput: &HashMap<(IpAddr, String), u64>,\noutput: &HashMap<(IpAddr, String), u64>,\n@@ -305,7 +305,7 @@ pub fn watch(routes: Vec<Route>, neighbors: &[Neighbor]) -> Result<(), Error> {\n}\n}\n// this can be caused by a peer that has not yet formed a babel route\n- // we use _ because ip_to_if is created from identites, if one fails the other must\n+ // we use _ because ip_to_if is created from identities, if one fails the other must\n(None, Some(if_to_id)) => warn!(\n\"We have an id {:?} but not destination for {}\",\nif_to_id.mesh_ip, ip\n@@ -333,7 +333,7 @@ pub fn watch(routes: Vec<Route>, neighbors: &[Neighbor]) -> Result<(), Error> {\nNone => warn!(\"No debts entry for input entry id {:?}\", id_from_if),\n},\n// this can be caused by a peer that has not yet formed a babel route\n- // we use _ because ip_to_if is created from identites, if one fails the other must\n+ // we use _ because ip_to_if is created from identities, if one fails the other must\n(None, Some(id_from_if)) => warn!(\n\"We have an id {:?} but not destination for {}\",\nid_from_if.mesh_ip, ip\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Fix spelling in TrafficWatcher |
20,244 | 19.05.2020 15:32:56 | 14,400 | 0f92ac0c8a9db7e963e0b413e987ab2969de2baa | Add todo to usage tracker | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/usage_tracker/mod.rs",
"new_path": "rita/src/rita_common/usage_tracker/mod.rs",
"diff": "@@ -66,6 +66,9 @@ pub struct FormattedPaymentTx {\npub amount: Uint256,\n// should always be populated in this case\npub txid: String,\n+ // TODO add \"payment_type\" here which will allow the frontend\n+ // to easily tell what this payment is for and prevent the need\n+ // for hacky classification\n}\nfn to_formatted_payment_tx(input: PaymentTx) -> FormattedPaymentTx {\n@@ -174,6 +177,7 @@ impl Default for UsageTracker {\n}\n}\nErr(e) => {\n+ // no active devices are using the flatfile, this should be safe to remove\ninfo!(\"Failed to decompress with, trying flatfile {:?}\", e);\nfile.seek(SeekFrom::Start(0))\n.expect(\"Failed to return to start of file!\");\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Add todo to usage tracker |
20,244 | 19.05.2020 15:57:33 | 14,400 | 145efcf62cc8fd13ed1b68610fcae47c01aae2f7 | Operator remove not remote | [
{
"change_type": "MODIFY",
"old_path": "rita/src/client.rs",
"new_path": "rita/src/client.rs",
"diff": "@@ -285,7 +285,7 @@ fn start_client_dashboard() {\n.route(\"/dao_fee/{fee}\", Method::POST, set_dao_fee)\n.route(\"/operator\", Method::GET, get_operator)\n.route(\"/operator\", Method::POST, change_operator)\n- .route(\"/operator/remote\", Method::POST, remove_operator)\n+ .route(\"/operator/remove\", Method::POST, remove_operator)\n.route(\"/operator_fee\", Method::GET, get_operator_fee)\n.route(\"/debts\", Method::GET, get_debts)\n.route(\"/debts/reset\", Method::POST, reset_debt)\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Operator remove not remote |
20,244 | 19.05.2020 17:07:51 | 14,400 | f0f8056707f4165565a083e6f4a17f10bb4e8048 | Add OperatorAction support
This adds support for the already defined operator actions ResetRouterPassword
and ResetWifiPassword. It also adds support for the new OperatorAction 'reboot'.
These are all things an operator might want to do for a client | [
{
"change_type": "MODIFY",
"old_path": "althea_types/src/interop.rs",
"new_path": "althea_types/src/interop.rs",
"diff": "@@ -368,6 +368,7 @@ pub enum OperatorAction {\nResetRouterPassword,\nResetWiFiPassword,\nResetShaper,\n+ Reboot,\n}\n/// Operator update that we get from the operator server during our checkin\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/wifi.rs",
"new_path": "rita/src/rita_client/dashboard/wifi.rs",
"diff": "@@ -146,6 +146,9 @@ fn set_ssid(wifi_ssid: &WifiSSID) -> Result<HttpResponse, Error> {\nOk(HttpResponse::Ok().json(ret))\n}\n+/// In the past this was used to set the wifi password, it's now been replaced\n+/// by the multiple value set wifi endpoint that lets people change all the wifi\n+/// credentials at once\npub fn set_wifi_pass(wifi_pass: Json<WifiPass>) -> Result<HttpResponse, Error> {\ndebug!(\"/wifi_settings/pass hit with {:?}\", wifi_pass);\n@@ -153,6 +156,19 @@ pub fn set_wifi_pass(wifi_pass: Json<WifiPass>) -> Result<HttpResponse, Error> {\nset_pass(&wifi_pass)\n}\n+/// Resets the wifi password to the stock value for all radios\n+pub fn reset_wifi_pass() -> Result<(), Error> {\n+ let config = get_wifi_config_internal()?;\n+ for interface in config {\n+ let pass = WifiPass {\n+ radio: interface.device.section_name,\n+ pass: \"ChangeMe\".to_string(),\n+ };\n+ set_pass(&pass)?;\n+ }\n+ Ok(())\n+}\n+\nfn set_pass(wifi_pass: &WifiPass) -> Result<HttpResponse, Error> {\nlet mut ret = HashMap::new();\n@@ -366,6 +382,11 @@ fn validate_config_value(s: &str) -> Result<(), ValidationError> {\npub fn get_wifi_config(_req: HttpRequest) -> Result<Json<Vec<WifiInterface>>, Error> {\ndebug!(\"Get wificonfig hit!\");\n+ let config = get_wifi_config_internal()?;\n+ Ok(Json(config))\n+}\n+\n+fn get_wifi_config_internal() -> Result<Vec<WifiInterface>, Error> {\nlet mut interfaces = Vec::new();\nlet mut devices = HashMap::new();\nlet config = KI.ubus_call(\"uci\", \"get\", \"{ \\\"config\\\": \\\"wireless\\\"}\")?;\n@@ -401,5 +422,5 @@ pub fn get_wifi_config(_req: HttpRequest) -> Result<Json<Vec<WifiInterface>>, Er\ninterfaces.push(interface);\n}\n}\n- Ok(Json(interfaces))\n+ Ok(interfaces)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/operator_update/mod.rs",
"new_path": "rita/src/rita_client/operator_update/mod.rs",
"diff": "//! This module is responsible for checking in with the operator server and getting updated local settings\nuse crate::rita_client::dashboard::system_chain::set_system_blockchain;\n+use crate::rita_client::dashboard::wifi::reset_wifi_pass;\nuse crate::rita_client::rita_loop::CLIENT_LOOP_TIMEOUT;\nuse crate::rita_common::token_bridge::ReloadAddresses;\nuse crate::rita_common::token_bridge::TokenBridge;\nuse crate::rita_common::tunnel_manager::shaping::flag_reset_shaper;\nuse crate::rita_common::tunnel_manager::shaping::get_shaping_status;\n+use crate::KI;\nuse crate::SETTING;\nuse actix::{Actor, Arbiter, Context, Handler, Message, Supervised, SystemService};\nuse actix_web::Error;\n@@ -208,8 +210,18 @@ fn checkin() {\nTokenBridge::from_registry().do_send(ReloadAddresses());\n}\n- if let Some(OperatorAction::ResetShaper) = new_settings.operator_action {\n- flag_reset_shaper()\n+ match new_settings.operator_action {\n+ Some(OperatorAction::ResetShaper) => flag_reset_shaper(),\n+ Some(OperatorAction::Reboot) => {\n+ let _res = KI.run_command(\"reboot\", &[]);\n+ }\n+ Some(OperatorAction::ResetRouterPassword) => {\n+ SETTING.get_network_mut().rita_dashboard_password = None;\n+ }\n+ Some(OperatorAction::ResetWiFiPassword) => {\n+ let _res = reset_wifi_pass();\n+ }\n+ None => {}\n}\nlet mut network = SETTING.get_network_mut();\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Add OperatorAction support
This adds support for the already defined operator actions ResetRouterPassword
and ResetWifiPassword. It also adds support for the new OperatorAction 'reboot'.
These are all things an operator might want to do for a client |
20,244 | 19.05.2020 20:56:11 | 14,400 | 0bf6d3cff3caa83e22d619470c5d1f160014826f | Prevent upshaper from getting stuck
Since we increase by 5% but round to the nearest mbps integer values below
20mbps are 'inescapable' meaning the upshaper will never increase them
due to the way integer rounding works.
To prevent this from happening we now test this case and increase the
speed by 1mbps increments. | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/tunnel_manager/shaping.rs",
"new_path": "rita/src/rita_common/tunnel_manager/shaping.rs",
"diff": "@@ -129,7 +129,7 @@ impl Handler<ShapeMany> for TunnelManager {\n}\n// increase the value by 5% until we reach the starting value\n(Some(val), ShapingAdjustAction::IncreaseSpeed) => {\n- let new_val = (val as f32 * 1.05f32) as usize;\n+ let new_val = increase_speed(val);\nif new_val < starting_bandwidth_limit {\ninfo!(\n\"Interface {} for peer {} has not shown bloat new speed value {}\",\n@@ -158,3 +158,14 @@ fn set_shaping_or_error(iface: &str, limit: Option<usize>) {\nerror!(\"Failed to shape tunnel for bloat! {}\", e);\n}\n}\n+\n+/// increase the speed by 5% or 1mbps if the value is too small\n+/// for a 5% increase\n+fn increase_speed(input: usize) -> usize {\n+ let new = (input as f32 * 1.05f32) as usize;\n+ if new == input {\n+ input + 1\n+ } else {\n+ new\n+ }\n+}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Prevent upshaper from getting stuck
Since we increase by 5% but round to the nearest mbps integer values below
20mbps are 'inescapable' meaning the upshaper will never increase them
due to the way integer rounding works.
To prevent this from happening we now test this case and increase the
speed by 1mbps increments. |
20,244 | 20.05.2020 08:39:02 | 14,400 | 389a709c6e004aff1af4de9e2bdf43b94ce0d3e4 | Add sysctl dependency for tests
New version of debian changed the default install set | [
{
"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-RUN 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\n+RUN 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\nENV POSTGRES_USER=postgres\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Add sysctl dependency for tests
New version of debian changed the default install set |
20,244 | 20.05.2020 14:38:38 | 14,400 | 6c7f769b3c528ca2f43f21dd85cb4977c0ee3ad5 | Add human readable version to rita --version | [
{
"change_type": "MODIFY",
"old_path": "rita/src/client.rs",
"new_path": "rita/src/client.rs",
"diff": "@@ -55,6 +55,7 @@ mod rita_common;\nuse crate::rita_client::enable_remote_logging;\nuse crate::rita_client::rita_loop::check_rita_client_actors;\nuse crate::rita_client::rita_loop::start_rita_client_endpoints;\n+use crate::rita_common::dashboard::own_info::READABLE_VERSION;\nuse crate::rita_common::rita_loop::check_rita_common_actors;\nuse crate::rita_common::rita_loop::start_core_rita_endpoints;\n@@ -95,16 +96,21 @@ pub struct Args {\nflag_future: bool,\n}\n+// TODO we should remove --platform as it's not used, but that requires\n+// changing how rita is invoked everywhere, because that's difficult\n+// with in the field routers this is waiting on another more pressing\n+// upgrade to the init file for Rita on the routers\nlazy_static! {\nstatic ref USAGE: String = format!(\n\"Usage: rita --config=<settings> --platform=<platform> [--future]\nOptions:\n-c, --config=<settings> Name of config file\n- -p, --platform=<platform> Platform (linux or openwrt)\n+ -p, --platform=<platform> Platform (linux or OpenWrt)\n--future Enable B side of A/B releases\nAbout:\n- Version {}\n+ Version {} - {}\ngit hash {}\",\n+ READABLE_VERSION,\nenv!(\"CARGO_PKG_VERSION\"),\nenv!(\"GIT_HASH\")\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/exit.rs",
"new_path": "rita/src/exit.rs",
"diff": "@@ -58,9 +58,9 @@ mod middleware;\nmod rita_common;\nmod rita_exit;\n+use crate::rita_common::dashboard::own_info::READABLE_VERSION;\nuse rita_common::rita_loop::check_rita_common_actors;\nuse rita_common::rita_loop::start_core_rita_endpoints;\n-\nuse 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;\n@@ -91,8 +91,9 @@ Options:\n-c, --config=<settings> Name of config file\n--future Enable B side of A/B releases\nAbout:\n- Version {}\n+ Version {} - {}\ngit hash {}\",\n+ READABLE_VERSION,\nenv!(\"CARGO_PKG_VERSION\"),\nenv!(\"GIT_HASH\")\n);\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Add human readable version to rita --version |
20,244 | 20.05.2020 14:39:28 | 14,400 | 20b57979c379f1a7f83d1fb26d6de7a57af6d65f | Bump for Beta 14 RC3 | [
{
"change_type": "MODIFY",
"old_path": "Cargo.lock",
"new_path": "Cargo.lock",
"diff": "@@ -2676,7 +2676,7 @@ dependencies = [\n[[package]]\nname = \"rita\"\n-version = \"0.5.48\"\n+version = \"0.5.49\"\ndependencies = [\n\"actix\",\n\"actix-web\",\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/Cargo.toml",
"new_path": "rita/Cargo.toml",
"diff": "[package]\nname = \"rita\"\n-version = \"0.5.48\"\n+version = \"0.5.49\"\nauthors = [\"Justin <justin@althea.net>\", \"Jehan <jehan.tremback@gmail.com>\", \"Ben <wangben3@gmail.com>\"]\nbuild = \"build.rs\"\nedition = \"2018\"\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/dashboard/own_info.rs",
"new_path": "rita/src/rita_common/dashboard/own_info.rs",
"diff": "@@ -6,7 +6,7 @@ use failure::Error;\nuse num256::{Int256, Uint256};\nuse settings::RitaCommonSettings;\n-pub static READABLE_VERSION: &str = \"Beta 14 RC2\";\n+pub static READABLE_VERSION: &str = \"Beta 14 RC3\";\n#[derive(Serialize)]\npub struct OwnInfo {\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Bump for Beta 14 RC3 |
20,244 | 20.05.2020 15:47:32 | 14,400 | 487c1307387abb3b768f3a271ed86faf489de59f | Add dashboard debugging feature
Makes it easier to disable cors | [
{
"change_type": "MODIFY",
"old_path": "Cargo.toml",
"new_path": "Cargo.toml",
"diff": "@@ -6,6 +6,7 @@ edition = \"2018\"\n[features]\ndevelopment = [\"rita/development\"]\n+dash_debug = [\"rita/dash_debug\"]\nserver = [\"rita/server\"]\nbundle_openssl = [\"rita/bundle_openssl\"]\njemalloc = [\"rita/jemalloc\"]\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/Cargo.toml",
"new_path": "rita/Cargo.toml",
"diff": "@@ -86,4 +86,6 @@ jemalloc = [\"jemallocator\"]\nbundle_openssl = [\"openssl\"]\n# Features for big iron devices with more ram\nserver = [\"jemalloc\", \"openssl\"]\n-development = []\n+# disables cors for dash debugging\n+dash_debug = []\n+development = [\"dash_debug\"]\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/middleware.rs",
"new_path": "rita/src/middleware.rs",
"diff": "@@ -40,10 +40,16 @@ impl<S> Middleware<S> for Headers {\n}\nif origin != \"\" {\n+ #[cfg(not(feature = \"dash_debug\"))]\nresp.headers_mut().insert(\nheader::HeaderName::try_from(\"Access-Control-Allow-Origin\").unwrap(),\nheader::HeaderValue::from_str(&format!(\"http://{}\", origin)).unwrap(),\n);\n+ #[cfg(feature = \"dash_debug\")]\n+ resp.headers_mut().insert(\n+ header::HeaderName::try_from(\"Access-Control-Allow-Origin\").unwrap(),\n+ header::HeaderValue::from_str(\"*\").unwrap(),\n+ );\n}\nresp.headers_mut().insert(\nheader::HeaderName::try_from(\"Access-Control-Allow-Headers\").unwrap(),\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Add dashboard debugging feature
Makes it easier to disable cors |
20,244 | 20.05.2020 19:25:46 | 14,400 | b2995e8d025813fda83db020d7af5de921342ae2 | Operator debt endpoint
This is used by the frontend to determine what amount is owed to the
operator. This is then added to the debt and paid to the user to explain
where their money goes on deposit | [
{
"change_type": "MODIFY",
"old_path": "rita/src/client.rs",
"new_path": "rita/src/client.rs",
"diff": "@@ -293,6 +293,7 @@ fn start_client_dashboard() {\n.route(\"/operator\", Method::POST, change_operator)\n.route(\"/operator/remove\", Method::POST, remove_operator)\n.route(\"/operator_fee\", Method::GET, get_operator_fee)\n+ .route(\"/operator_debt\", Method::GET, get_operator_debt)\n.route(\"/debts\", Method::GET, get_debts)\n.route(\"/debts/reset\", Method::POST, reset_debt)\n.route(\"/exits/sync\", Method::POST, exits_sync)\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/operator.rs",
"new_path": "rita/src/rita_client/dashboard/operator.rs",
"diff": "+use crate::rita_client::operator_fee_manager::get_operator_fee_debt;\nuse crate::ARGS;\nuse crate::SETTING;\nuse actix_web::Path;\n@@ -92,3 +93,8 @@ pub fn get_operator_fee(_req: HttpRequest) -> Result<HttpResponse, Error> {\ndebug!(\"get operator GET hit\");\nOk(HttpResponse::Ok().json(SETTING.get_operator().operator_fee.clone()))\n}\n+\n+pub fn get_operator_debt(_req: HttpRequest) -> Result<HttpResponse, Error> {\n+ debug!(\"get operator debt hit\");\n+ Ok(HttpResponse::Ok().json(get_operator_fee_debt()))\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/operator_fee_manager/mod.rs",
"new_path": "rita/src/rita_client/operator_fee_manager/mod.rs",
"diff": "@@ -21,9 +21,18 @@ use num256::Int256;\nuse num256::Uint256;\nuse settings::client::RitaClientSettings;\nuse settings::RitaCommonSettings;\n+use std::sync::{Arc, RwLock};\nuse std::time::Instant;\nuse web30::client::Web3;\n+lazy_static! {\n+ static ref OPERATOR_FEE_DEBT: Arc<RwLock<Uint256>> = Arc::new(RwLock::new(Uint256::from(0u8)));\n+}\n+\n+pub fn get_operator_fee_debt() -> Uint256 {\n+ OPERATOR_FEE_DEBT.read().unwrap().clone()\n+}\n+\npub struct OperatorFeeManager {\nlast_payment_time: Instant,\n}\n@@ -34,7 +43,7 @@ impl Actor for OperatorFeeManager {\nimpl Supervised for OperatorFeeManager {}\nimpl SystemService for OperatorFeeManager {\nfn service_started(&mut self, _ctx: &mut Context<Self>) {\n- info!(\"DAO manager started\");\n+ info!(\"OperatorFee manager started\");\n}\n}\n@@ -85,6 +94,7 @@ impl Handler<Tick> for OperatorFeeManager {\nSome(id) => id,\nNone => return,\n};\n+ let our_balance = payment_settings.balance.clone();\nlet gas_price = payment_settings.gas_price.clone();\nlet nonce = payment_settings.nonce.clone();\nlet pay_threshold = payment_settings.pay_threshold.clone();\n@@ -95,16 +105,23 @@ impl Handler<Tick> for OperatorFeeManager {\nlet operator_fee = operator_settings.operator_fee.clone();\nlet amount_to_pay =\nUint256::from(self.last_payment_time.elapsed().as_secs()) * operator_fee;\n- let should_pay =\n- amount_to_pay.to_int256().unwrap_or_else(|| Int256::from(0)) > pay_threshold;\nlet net_version = payment_settings.net_version;\n+\n+ // we should pay if the amount is greater than the pay threshold and if we have the\n+ // balance to do so. If we don't have the balance then we'll do all the signing and\n+ // network request for nothing\n+ let should_pay = amount_to_pay.to_int256().unwrap_or_else(|| Int256::from(0))\n+ > pay_threshold\n+ && amount_to_pay <= our_balance;\ndrop(payment_settings);\ntrace!(\"We should pay our operator {}\", should_pay);\n+ *OPERATOR_FEE_DEBT.write().unwrap() = amount_to_pay.clone();\n+\nif should_pay {\ntrace!(\"Paying subnet operator fee to {}\", operator_address);\n- let dao_identity = Identity {\n+ let operator_identity = Identity {\neth_address: operator_address,\n// this key has no meaning, it's here so that we don't have to change\n// the identity indexing\n@@ -142,8 +159,9 @@ impl Handler<Tick> for OperatorFeeManager {\nlet transaction_status = web3.eth_send_raw_transaction(transaction_bytes);\n- // in theory this may fail, for now there is no handler and\n- // we will just underpay when that occurs\n+ // in theory this may fail to get into a block, for now there is no handler and\n+ // we will just underpay when that occurs. Failure to successfully submit the tx\n+ // will be properly retried\nArbiter::spawn(transaction_status.then(move |res| match res {\nOk(txid) => {\ninfo!(\n@@ -152,7 +170,7 @@ impl Handler<Tick> for OperatorFeeManager {\n);\nUsageTracker::from_registry().do_send(UpdatePayments {\npayment: PaymentTx {\n- to: dao_identity,\n+ to: operator_identity,\nfrom: our_id,\namount: amount_to_pay.clone(),\ntxid: Some(txid),\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Operator debt endpoint
This is used by the frontend to determine what amount is owed to the
operator. This is then added to the debt and paid to the user to explain
where their money goes on deposit |
20,244 | 20.05.2020 19:36:03 | 14,400 | d842381bc7038b9f248a8a4008b1cfdb8caa199a | Remove DAO settings
This is now completely phased out and can be removed | [
{
"change_type": "MODIFY",
"old_path": "rita/src/client.rs",
"new_path": "rita/src/client.rs",
"diff": "@@ -201,26 +201,6 @@ fn wait_for_settings(settings_file: &str) -> RitaSettingsStruct {\n}\nfn main() {\n- // Remove in Beta 14, migrates settings from the old dao structure to\n- // the operator structure in settings.\n- {\n- let dao = { SETTING.get_dao().clone() };\n- let mut operator = SETTING.get_operator_mut();\n-\n- // suppose a migration has occured and the user then tries to\n- // change the operator address, it will revert on restart every time\n- // because the 'migration' will run again. So we should check first.\n- if operator.operator_address.is_none() {\n- // get the first address in the list\n- operator.operator_address = match dao.dao_addresses.get(0) {\n- Some(val) => Some(*val),\n- None => None,\n- };\n- operator.operator_fee = dao.dao_fee;\n- operator.use_operator_price = dao.use_oracle_price;\n- }\n- }\n-\n// On Linux static builds we need to probe ssl certs path to be able to\n// do TLS stuff.\nopenssl_probe::init_ssl_cert_env_vars();\n"
},
{
"change_type": "MODIFY",
"old_path": "settings/src/client.rs",
"new_path": "settings/src/client.rs",
"diff": "-use crate::dao::SubnetDAOSettings;\nuse crate::json_merge;\nuse crate::localization::LocalizationSettings;\nuse crate::logging::LoggingSettings;\n@@ -96,12 +95,6 @@ pub trait RitaClientSettings {\nfn get_log_mut<'ret, 'me: 'ret>(\n&'me self,\n) -> RwLockWriteGuardRefMut<'ret, RitaSettingsStruct, LoggingSettings>;\n- fn get_dao<'ret, 'me: 'ret>(\n- &'me self,\n- ) -> RwLockReadGuardRef<'ret, RitaSettingsStruct, SubnetDAOSettings>;\n- fn get_dao_mut<'ret, 'me: 'ret>(\n- &'me self,\n- ) -> RwLockWriteGuardRefMut<'ret, RitaSettingsStruct, SubnetDAOSettings>;\nfn get_operator<'ret, 'me: 'ret>(\n&'me self,\n) -> RwLockReadGuardRef<'ret, RitaSettingsStruct, OperatorSettings>;\n@@ -146,18 +139,6 @@ impl RitaClientSettings for Arc<RwLock<RitaSettingsStruct>> {\nRwLockWriteGuardRefMut::new(self.write().unwrap()).map_mut(|g| &mut g.log)\n}\n- fn get_dao<'ret, 'me: 'ret>(\n- &'me self,\n- ) -> RwLockReadGuardRef<'ret, RitaSettingsStruct, SubnetDAOSettings> {\n- RwLockReadGuardRef::new(self.read().unwrap()).map(|g| &g.dao)\n- }\n-\n- fn get_dao_mut<'ret, 'me: 'ret>(\n- &'me self,\n- ) -> RwLockWriteGuardRefMut<'ret, RitaSettingsStruct, SubnetDAOSettings> {\n- RwLockWriteGuardRefMut::new(self.write().unwrap()).map_mut(|g| &mut g.dao)\n- }\n-\nfn get_operator<'ret, 'me: 'ret>(\n&'me self,\n) -> RwLockReadGuardRef<'ret, RitaSettingsStruct, OperatorSettings> {\n@@ -204,8 +185,6 @@ impl RitaSettingsStruct {\npub struct RitaSettingsStruct {\npayment: PaymentSettings,\n#[serde(default)]\n- dao: SubnetDAOSettings,\n- #[serde(default)]\nlog: LoggingSettings,\n#[serde(default)]\noperator: OperatorSettings,\n"
},
{
"change_type": "DELETE",
"old_path": "settings/src/dao.rs",
"new_path": null,
"diff": "-use clarity::Address;\n-use num256::Uint256;\n-\n-fn default_dao_address() -> Vec<Address> {\n- Vec::new()\n-}\n-\n-fn default_oracle_enabled() -> bool {\n- true\n-}\n-\n-fn default_use_oracle_price() -> bool {\n- true\n-}\n-\n-// if you are changing this double check the default currency and the default node url\n-fn default_oracle_url() -> Option<String> {\n- Some(\"https://updates.althea.net/xdaiprices\".to_string())\n-}\n-\n-#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq, Default)]\n-pub struct SubnetDAOSettings {\n- /// List of subnet DAO's to which we are a member\n- #[serde(default = \"default_dao_address\")]\n- pub dao_addresses: Vec<Address>,\n- /// The amount in wei that will be sent to the dao in one second\n- #[serde(default)]\n- pub dao_fee: Uint256,\n- /// If the user desires to disable the oracle from making local settings changes they\n- /// may set this to false. This essentially opts them out of the DAO and won't stop\n- /// the DAO from kicking them out when they for example fail to pay or exceed the maximum allowed\n- /// price. Neither of those are implemented yet so for now it's a get out of jail free card until\n- /// the human organizer notices.\n- #[serde(default = \"default_oracle_enabled\")]\n- pub oracle_enabled: bool,\n- /// It's possible the user wants to ignore the suggested price but still take the suggested settings\n- /// at which point they should change this option.\n- #[serde(default = \"default_use_oracle_price\")]\n- pub use_oracle_price: bool,\n- /// The oracle used to just be for pricing, now we are using it as a proxy for\n- /// the DAO's ability to help generate consensus on router settings so it contains\n- /// price as well as other updates. A None here would indicate that there's no oracle\n- /// configured\n- #[serde(default = \"default_oracle_url\")]\n- pub oracle_url: Option<String>,\n-}\n"
},
{
"change_type": "MODIFY",
"old_path": "settings/src/lib.rs",
"new_path": "settings/src/lib.rs",
"diff": "@@ -39,7 +39,6 @@ use std::thread;\nuse std::time::Duration;\npub mod client;\n-pub mod dao;\npub mod exit;\npub mod localization;\npub mod logging;\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Remove DAO settings
This is now completely phased out and can be removed |
20,244 | 26.05.2020 08:04:32 | 14,400 | e04a16ec030699c7dadeee83d2f01d53245f8fc4 | Clean up some interop doc comments | [
{
"change_type": "MODIFY",
"old_path": "althea_types/src/interop.rs",
"new_path": "althea_types/src/interop.rs",
"diff": "@@ -306,12 +306,15 @@ impl Message for LocalIdentity {\n#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Hash, Clone, Copy)]\npub struct LightClientLocalIdentity {\npub wg_port: u16,\n- pub have_tunnel: Option<bool>, // If we have an existing tunnel, None if we don't know\n+ /// If we have an existing tunnel, None if we don't know\n+ pub have_tunnel: Option<bool>,\npub global: Identity,\n- pub tunnel_address: Ipv4Addr, // we have to replicate dhcp ourselves due to the android vpn api\n- pub price: u128, // the local_fee of the node passing light client traffic, much bigger\n- // than the actual babel price field for ergonomics around downcasting\n- // the number after upcasting when we compute it.\n+ /// we have to replicate dhcp ourselves due to the android vpn api\n+ pub tunnel_address: Ipv4Addr,\n+ /// the local_fee of the node passing light client traffic, much bigger\n+ /// than the actual babel price field for ergonomics around downcasting\n+ /// the number after upcasting when we compute it.\n+ pub price: u128,\n}\n#[cfg(feature = \"actix\")]\n@@ -319,7 +322,7 @@ impl Message for LightClientLocalIdentity {\ntype Result = ();\n}\n-/// This is a stand-in for channel updates. representing a payment\n+/// This represents a generic payment that may be to or from us\n/// when completed it contains a txid from a published transaction\n/// that should be validated against the blockchain\n#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Clone)]\n@@ -362,7 +365,7 @@ impl FromStr for ReleaseStatus {\n}\n}\n-/// Somthing the operator may want to do to a router under their control\n+/// Something the operator may want to do to a router under their control\n#[derive(Debug, Clone, Copy, Serialize, Deserialize, Hash, Eq, PartialEq)]\npub enum OperatorAction {\nResetRouterPassword,\n@@ -411,7 +414,7 @@ pub struct OperatorUpdateMessage {\n/// The system blockchain that is currently being used, if it is 'none' here it is\n/// interpreted as \"don't change anything\"\npub system_chain: Option<SystemChain>,\n- /// The wtihdraw blockchain that is currently being used, if it is 'none' here it is\n+ /// The withdraw blockchain that is currently being used, if it is 'none' here it is\n/// interpreted as \"don't change anything\"\npub withdraw_chain: Option<SystemChain>,\n/// A release feed to be applied to the /etc/opkg/customfeeds.config, None means do not\n@@ -439,7 +442,7 @@ pub struct OperatorUpdateMessage {\npub struct ShaperSettings {\npub enabled: bool,\n/// The speed the bandwidth shaper will start at, keep in mind this is not the maximum device\n- /// speed as all interfaces start at 'unlmited' this is instead the speed the shaper will deploy\n+ /// speed as all interfaces start at 'unlimited' this is instead the speed the shaper will deploy\n/// when it detects problems on the interface and a speed it will not go above when it's increasing\n/// the speed after the problem is gone\npub max_speed: usize,\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Clean up some interop doc comments |
20,244 | 26.05.2020 09:15:36 | 14,400 | 1967348569d306afc452a77b2112dae7ed820ff2 | Add installation details
This adds the installation details struct, an object that represents
info about this routers installation. This is stored in the operator
settings until it can be uploaded to the operator tools | [
{
"change_type": "MODIFY",
"old_path": "Cargo.lock",
"new_path": "Cargo.lock",
"diff": "@@ -188,7 +188,9 @@ dependencies = [\n\"clarity\",\n\"failure\",\n\"hex\",\n+ \"lettre\",\n\"num256\",\n+ \"phonenumber\",\n\"serde 1.0.110\",\n\"serde_derive\",\n\"serde_json\",\n@@ -3008,6 +3010,7 @@ dependencies = [\n\"log\",\n\"num256\",\n\"owning_ref\",\n+ \"phonenumber\",\n\"serde 1.0.110\",\n\"serde_derive\",\n\"serde_json\",\n"
},
{
"change_type": "MODIFY",
"old_path": "althea_types/Cargo.toml",
"new_path": "althea_types/Cargo.toml",
"diff": "@@ -19,4 +19,6 @@ actix = { version = \"0.7\", optional = true}\nclarity = \"0.1\"\narrayvec = {version= \"0.5\", features = [\"serde\"]}\nfailure = \"0.1\"\n+phonenumber = \"0.2\"\n+lettre = {version = \"0.9\", features = [\"serde\"]}\n"
},
{
"change_type": "DELETE",
"old_path": "althea_types/readme.md",
"new_path": null,
"diff": "-This crate contains types that are shared across different Althea daemons. All types in this crate implement serde Serialize and Deserialize.\n"
},
{
"change_type": "MODIFY",
"old_path": "althea_types/src/interop.rs",
"new_path": "althea_types/src/interop.rs",
"diff": "@@ -4,7 +4,9 @@ use babel_monitor::Neighbor;\nuse babel_monitor::Route;\nuse clarity::Address;\nuse failure::Error;\n+use lettre::EmailAddress;\nuse num256::Uint256;\n+use phonenumber::PhoneNumber;\nuse std::collections::hash_map::DefaultHasher;\nuse std::fmt;\nuse std::fmt::Display;\n@@ -12,6 +14,7 @@ use std::hash::{Hash, Hasher};\nuse std::net::IpAddr;\nuse std::net::Ipv4Addr;\nuse std::str::FromStr;\n+use std::time::SystemTime;\n#[cfg(feature = \"actix\")]\nuse actix::Message;\n@@ -553,13 +556,74 @@ pub struct NeighborStatus {\npub shaper_speed: Option<usize>,\n}\n-/// Struct for storing user contact details\n+/// Struct for storing user contact details, being phased out in favor\n+/// of InstallationDetails in Beta 15\n#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]\npub struct ContactDetails {\npub phone: Option<String>,\npub email: Option<String>,\n}\n+/// This enum is used to represent the fact that while we may not have a phone\n+/// number and may not have an Email we are required to have at least one to\n+/// facilitate exit registration.\n+#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]\n+pub enum ContactType {\n+ Phone {\n+ number: PhoneNumber,\n+ },\n+ Email {\n+ email: EmailAddress,\n+ },\n+ Both {\n+ number: PhoneNumber,\n+ email: EmailAddress,\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.\n+ Bad {\n+ invalid_number: Option<String>,\n+ invalid_email: Option<String>,\n+ },\n+}\n+\n+/// Struct for storing details about this user installation. This particular\n+/// struct exists in the settings on the router because it has to be persisted\n+/// long enough to make it to the operator tools, once it's been uploaded though\n+/// it has no reason to hand around and is mostly dead weight in the config. The\n+/// question is if we want to delete it or manage it somehow.\n+#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]\n+pub struct InstallationDetails {\n+ /// The contact type for this user, could be phone, email, or both.\n+ pub contact_type: ContactType,\n+ /// The CPE ip of this client. This field seems straightforward but actually\n+ /// has quite a bit of optionality. What if the user is connected via l2 bridge\n+ /// (for example a cable, or fiber) in that case this could be None. If the client\n+ /// is multihomed which ip is the client antenna and which one is the relay antenna?\n+ /// That can be decided randomly without any problems I think.\n+ pub client_antenna_ip: Option<Ipv4Addr>,\n+ /// A list of addresses for relay antennas, this could include sectors and/or\n+ /// point to point links going downstream. If the vec is empty there are no\n+ /// relay antennas\n+ pub relay_antennas: Vec<Ipv4Addr>,\n+ /// A list of addresses for light client antennas. The vec can of course\n+ /// be empty representing no phone client antennas.\n+ pub phone_client_antennas: Vec<Ipv4Addr>,\n+ /// The mailing address of this installation, assumed to be in whatever\n+ /// format the local nation has for addresses. Optional as this install\n+ /// may not have a formal mailing address\n+ pub mailing_address: Option<String>,\n+ /// The address of this installation, this has no structure and should\n+ /// simply be displayed. Depending on the country address formats will\n+ /// be very different and we might even only have GPS points\n+ pub physical_address: String,\n+ /// Description of the installation and equipment at the\n+ /// location\n+ pub equipment_details: String,\n+ /// Time of install, in milliseconds since Unix Epoch\n+ pub install_date: SystemTime,\n+}\n+\n/// Heartbeat sent to the operator server to help monitor\n/// liveness and network state\n#[derive(Debug, Clone, Serialize, Deserialize)]\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/client.rs",
"new_path": "rita/src/client.rs",
"diff": "@@ -63,6 +63,7 @@ use crate::rita_client::dashboard::auth::*;\nuse crate::rita_client::dashboard::backup_created::*;\nuse crate::rita_client::dashboard::eth_private_key::*;\nuse crate::rita_client::dashboard::exits::*;\n+use crate::rita_client::dashboard::installation_details::*;\nuse crate::rita_client::dashboard::interfaces::*;\nuse crate::rita_client::dashboard::localization::*;\nuse crate::rita_client::dashboard::logging::*;\n@@ -389,6 +390,16 @@ fn start_client_dashboard() {\n.route(\"/wipe\", Method::POST, wipe)\n.route(\"/crash_actors\", Method::POST, crash_actors)\n.route(\"/localization\", Method::GET, get_localization)\n+ .route(\n+ \"/installation_details\",\n+ Method::POST,\n+ set_installation_details,\n+ )\n+ .route(\n+ \"/installation_details\",\n+ Method::GET,\n+ get_installation_details,\n+ )\n})\n.workers(1)\n.bind(format!(\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "rita/src/rita_client/dashboard/installation_details.rs",
"diff": "+use crate::SETTING;\n+use actix_web::HttpResponse;\n+use actix_web::{HttpRequest, Json};\n+use althea_types::ContactType;\n+use althea_types::InstallationDetails;\n+use settings::client::RitaClientSettings;\n+use std::net::Ipv4Addr;\n+use std::time::SystemTime;\n+\n+/// This is a utility type that is used by the front end when sending us\n+/// installation details. This lets us do the validation and parsing here\n+/// rather than relying on serde to get it right.\n+#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]\n+pub struct InstallationDetailsPost {\n+ pub phone: Option<String>,\n+ pub email: Option<String>,\n+ pub client_antenna_ip: Option<Ipv4Addr>,\n+ pub relay_antennas: Vec<Ipv4Addr>,\n+ pub phone_client_antennas: Vec<Ipv4Addr>,\n+ pub mailing_address: Option<String>,\n+ pub physical_address: String,\n+ pub equipment_details: String,\n+}\n+\n+pub fn set_installation_details(req: Json<InstallationDetailsPost>) -> HttpResponse {\n+ let input = req.into_inner();\n+ let mut operator_settings = SETTING.get_operator_mut();\n+ let contact_details = match (input.phone, input.email) {\n+ (None, None) => return HttpResponse::BadRequest().finish(),\n+ (Some(phone), Some(email)) => match (phone.parse(), email.parse()) {\n+ (Ok(p), Ok(e)) => ContactType::Both {\n+ number: p,\n+ email: e,\n+ },\n+ (_, _) => return HttpResponse::BadRequest().finish(),\n+ },\n+ (None, Some(email)) => match email.parse() {\n+ Ok(e) => ContactType::Email { email: e },\n+ Err(_e) => return HttpResponse::BadRequest().finish(),\n+ },\n+ (Some(phone), None) => match phone.parse() {\n+ Ok(p) => ContactType::Phone { number: p },\n+ Err(_e) => return HttpResponse::BadRequest().finish(),\n+ },\n+ };\n+\n+ let new_installation_details = InstallationDetails {\n+ contact_type: contact_details,\n+ client_antenna_ip: input.client_antenna_ip,\n+ relay_antennas: input.relay_antennas,\n+ phone_client_antennas: input.phone_client_antennas,\n+ mailing_address: input.mailing_address,\n+ physical_address: input.physical_address,\n+ equipment_details: input.equipment_details,\n+ install_date: SystemTime::now(),\n+ };\n+\n+ operator_settings.installation_details = Some(new_installation_details);\n+ HttpResponse::Ok().finish()\n+}\n+\n+pub fn get_installation_details(_req: HttpRequest) -> HttpResponse {\n+ let operator_settings = SETTING.get_operator();\n+ HttpResponse::Ok().json(operator_settings.installation_details.clone())\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/mod.rs",
"new_path": "rita/src/rita_client/dashboard/mod.rs",
"diff": "@@ -8,6 +8,7 @@ pub mod auth;\npub mod backup_created;\npub mod eth_private_key;\npub mod exits;\n+pub mod installation_details;\npub mod interfaces;\npub mod localization;\npub mod logging;\n"
},
{
"change_type": "MODIFY",
"old_path": "settings/Cargo.toml",
"new_path": "settings/Cargo.toml",
"diff": "@@ -19,3 +19,4 @@ owning_ref = \"0.4\"\nlazy_static = \"1.4\"\nclarity = \"0.1\"\narrayvec = {version= \"0.5\", features = [\"serde\"]}\n+phonenumber = \"0.2\"\n"
},
{
"change_type": "MODIFY",
"old_path": "settings/src/localization.rs",
"new_path": "settings/src/localization.rs",
"diff": "+use phonenumber::PhoneNumber;\n+\nfn default_wyre_enabled() -> bool {\ntrue\n}\n@@ -10,6 +12,17 @@ fn default_display_currency_symbol() -> bool {\ntrue\n}\n+fn default_support_number() -> PhoneNumber {\n+ \"+18664ALTHEA\".parse().unwrap()\n+}\n+\n+fn default_wyre_preface_message() -> String {\n+ \"Our payment partner Wyre, is international and expects phone numbers in international format. \\\n+ The United States country code is +1 followed by your area code and number. \\\n+ You may also see the charge come from outside the United States, this is normal.\"\n+ .to_string()\n+}\n+\n#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]\npub struct LocalizationSettings {\n/// A flag indicating whether or not the dashboard should give users the option to purchase\n@@ -19,11 +32,21 @@ pub struct LocalizationSettings {\n/// Wyre account_id used to associate transactions with a specific Wyre account\n#[serde(default = \"default_wyre_account_id\")]\npub wyre_account_id: String,\n+ /// This is a message that prefaces the Wyre deposit to include some warnings for the\n+ /// user. Wyre often changes their flow or introduces pitfalls for users. We sadly need\n+ /// to be able to modify our prep message\n+ #[serde(default = \"default_wyre_preface_message\")]\n+ pub wyre_preface_message: String,\n/// If we should display the $ symbol or just the DAI star symbol next\n- /// to the balance, designed to help manage how prominent we want the cryptocurrency\n+ /// to the balance, designed to help manage how prominently we want the cryptocurrency\n/// aspect of Althea to be displayed to the user.\n#[serde(default = \"default_display_currency_symbol\")]\npub display_currency_symbol: bool,\n+ /// This is the support number the user should call based on their deployment and other\n+ /// factors. It's up to the operator tools to overwrite the default global number with\n+ /// a locally relevant one if possible.\n+ #[serde(default = \"default_support_number\")]\n+ pub support_number: PhoneNumber,\n}\nimpl Default for LocalizationSettings {\n@@ -31,7 +54,14 @@ impl Default for LocalizationSettings {\nLocalizationSettings {\nwyre_enabled: default_wyre_enabled(),\nwyre_account_id: default_wyre_account_id(),\n+ wyre_preface_message: default_wyre_preface_message(),\ndisplay_currency_symbol: default_display_currency_symbol(),\n+ support_number: default_support_number(),\n+ }\n}\n}\n+\n+#[test]\n+fn test_default_localization() {\n+ let _def = LocalizationSettings::default();\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "settings/src/operator.rs",
"new_path": "settings/src/operator.rs",
"diff": "//! simplifies things a lot (no need for complex trustless enforcement). If you find that both DAO settings and this exist at the same time\n//! that means the transition is still in prgress.\n+use althea_types::interop::InstallationDetails;\nuse clarity::Address;\nuse num256::Uint256;\n@@ -47,6 +48,9 @@ pub struct OperatorSettings {\n/// The server used to checkin and grab settings\n#[serde(default = \"default_checkin_url\")]\npub checkin_url: String,\n+ /// Details about this devices installation see the doc comments on the struct\n+ /// this is set at startup time for the router\n+ pub installation_details: Option<InstallationDetails>,\n}\nimpl Default for OperatorSettings {\n@@ -57,6 +61,7 @@ impl Default for OperatorSettings {\nuse_operator_price: default_force_use_operator_price(),\nforce_use_operator_price: default_force_use_operator_price(),\ncheckin_url: default_checkin_url(),\n+ installation_details: None,\n}\n}\n}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Add installation details
This adds the installation details struct, an object that represents
info about this routers installation. This is stored in the operator
settings until it can be uploaded to the operator tools |
20,244 | 26.05.2020 10:08:15 | 14,400 | 97e2ac6dcea1f340ffdad89210879f4e5ee1c220 | Remove mesh_ip endpoint
Now that we're off the SubnetDAO path I don't see any reason for
this to exist | [
{
"change_type": "MODIFY",
"old_path": "rita/src/client.rs",
"new_path": "rita/src/client.rs",
"diff": "@@ -306,7 +306,6 @@ fn start_client_dashboard() {\n.route(\"/eth_private_key\", Method::GET, get_eth_private_key)\n.route(\"/eth_private_key\", Method::POST, set_eth_private_key)\n.route(\"/mesh_ip\", Method::GET, get_mesh_ip)\n- .route(\"/mesh_ip\", Method::POST, set_mesh_ip)\n.route(\"/neighbors\", Method::GET, get_neighbor_info)\n.route(\"/routes\", Method::GET, get_routes)\n.route(\"/remote_logging/enabled\", Method::GET, get_remote_logging)\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/mesh_ip.rs",
"new_path": "rita/src/rita_client/dashboard/mesh_ip.rs",
"diff": "-use crate::ARGS;\n-use crate::KI;\nuse crate::SETTING;\n-use ::actix_web::{HttpRequest, HttpResponse, Json};\n+use ::actix_web::{HttpRequest, HttpResponse};\nuse failure::Error;\n-use settings::FileWrite;\nuse settings::RitaCommonSettings;\nuse std::collections::HashMap;\n-use std::net::IpAddr;\npub fn get_mesh_ip(_req: HttpRequest) -> Result<HttpResponse, Error> {\ndebug!(\"/mesh_ip GET hit\");\n@@ -26,52 +22,3 @@ pub fn get_mesh_ip(_req: HttpRequest) -> Result<HttpResponse, Error> {\nOk(HttpResponse::Ok().json(ret))\n}\n-\n-pub fn set_mesh_ip(mesh_ip_data: Json<HashMap<String, String>>) -> Result<HttpResponse, Error> {\n- debug!(\"/mesh_ip POST hit\");\n-\n- let mut ret = HashMap::new();\n-\n- match mesh_ip_data.into_inner().get(\"mesh_ip\") {\n- Some(ip_str) => match ip_str.parse::<IpAddr>() {\n- Ok(parsed) => {\n- if parsed.is_ipv6() && !parsed.is_unspecified() {\n- SETTING.get_network_mut().mesh_ip = Some(parsed);\n- } else {\n- let error_msg = format!(\n- \"set_mesh_ip: Attempted to set a non-IPv6 or unsepcified address {} as mesh_ip\",\n- parsed\n- );\n- info!(\"{}\", error_msg);\n- ret.insert(\"error\".to_owned(), error_msg);\n- }\n- }\n- Err(e) => {\n- let error_msg = format!(\n- \"set_mesh_ip: Failed to parse the address string {:?}\",\n- ip_str\n- );\n- info!(\"{}\", error_msg);\n- ret.insert(\"error\".to_owned(), error_msg);\n- ret.insert(\"rust_error\".to_owned(), e.to_string());\n- }\n- },\n- None => {\n- let error_msg = \"set_mesh_ip: \\\"mesh_ip\\\" not found in supplied JSON\";\n- info!(\"{}\", error_msg);\n- ret.insert(\"error\".to_owned(), error_msg.to_string());\n- }\n- }\n-\n- // try and save the config and fail if we can't\n- if let Err(e) = SETTING.write().unwrap().write(&ARGS.flag_config) {\n- return Err(e);\n- }\n- // it's now safe to restart the process, return an error if that fails somehow\n- if let Err(e) = KI.run_command(\"/etc/init.d/rita\", &[\"restart\"]) {\n- return Err(e);\n- }\n-\n- // Note: This will never be reached\n- Ok(HttpResponse::Ok().json(ret))\n-}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Remove mesh_ip endpoint
Now that we're off the SubnetDAO path I don't see any reason for
this to exist |
20,244 | 26.05.2020 10:25:48 | 14,400 | 0bf558c270e1da3e9d76089e7564bfeb47ae3cc5 | Remove set eth_private_key endpoint
This isn't useful since it screws with exit registration. No one
can actually use it without causing more trouble than it's worth. | [
{
"change_type": "MODIFY",
"old_path": "rita/src/client.rs",
"new_path": "rita/src/client.rs",
"diff": "@@ -304,7 +304,6 @@ fn start_client_dashboard() {\nwlan_lightclient_set,\n)\n.route(\"/eth_private_key\", Method::GET, get_eth_private_key)\n- .route(\"/eth_private_key\", Method::POST, set_eth_private_key)\n.route(\"/mesh_ip\", Method::GET, get_mesh_ip)\n.route(\"/neighbors\", Method::GET, get_neighbor_info)\n.route(\"/routes\", Method::GET, get_routes)\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/eth_private_key.rs",
"new_path": "rita/src/rita_client/dashboard/eth_private_key.rs",
"diff": "-use crate::ARGS;\n-use crate::KI;\nuse crate::SETTING;\n-use actix_web::{HttpRequest, HttpResponse, Json};\n-use althea_types::ExitState;\n-use clarity::PrivateKey;\n+use actix_web::{HttpRequest, HttpResponse};\nuse failure::Error;\n-use settings::client::RitaClientSettings;\n-use settings::FileWrite;\nuse settings::RitaCommonSettings;\nuse std::collections::HashMap;\n@@ -33,47 +27,3 @@ pub fn get_eth_private_key(_req: HttpRequest) -> Result<HttpResponse, Error> {\nOk(HttpResponse::Ok().json(ret))\n}\n-\n-pub fn set_eth_private_key(data: Json<EthPrivateKey>) -> Result<HttpResponse, Error> {\n- debug!(\"/eth_private_key POST hit\");\n-\n- let pk: PrivateKey = data.into_inner().eth_private_key.parse()?;\n-\n- let mut payment_settings = SETTING.get_payment_mut();\n- payment_settings.eth_private_key = Some(pk);\n- payment_settings.eth_address = Some(pk.to_public_key()?);\n- drop(payment_settings);\n-\n- // remove the wg_public_key and regenerate wg private key, we don't do that here\n- // so it will happen on process restart. We could just call the linux client init\n- // from clu but we would need to handle already deployed tunnels and it's just not\n- // worth the trouble.\n- let mut network_settings = SETTING.get_network_mut();\n- network_settings.wg_private_key = None;\n- network_settings.wg_public_key = None;\n- network_settings.mesh_ip = None;\n- drop(network_settings);\n-\n- // unset current exit\n- let mut exit_client_settings = SETTING.get_exit_client_mut();\n- exit_client_settings.current_exit = None;\n- drop(exit_client_settings);\n-\n- let mut exit_settings = SETTING.get_exits_mut();\n- for mut exit in exit_settings.iter_mut() {\n- exit.1.info = ExitState::New;\n- }\n- drop(exit_settings);\n-\n- // try and save the config and fail if we can't\n- if let Err(e) = SETTING.write().unwrap().write(&ARGS.flag_config) {\n- return Err(e);\n- }\n-\n- // it's now safe to reboot the router\n- if let Err(e) = KI.run_command(\"reboot\", &[]) {\n- return Err(e);\n- }\n-\n- Ok(HttpResponse::Ok().finish())\n-}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Remove set eth_private_key endpoint
This isn't useful since it screws with exit registration. No one
can actually use it without causing more trouble than it's worth. |
20,244 | 26.05.2020 10:26:32 | 14,400 | e746d1d6c0151c8cdaa282c1986ea19ecb68b698 | Clean up comments in blockchain oracle | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/blockchain_oracle/mod.rs",
"new_path": "rita/src/rita_common/blockchain_oracle/mod.rs",
"diff": "-//! This module is dedicated to updating local state with various pieces of infromation\n-//! relating to the blockchain being used. First and formost is maintaining an updated\n+//! This module is dedicated to updating local state with various pieces of information\n+//! relating to the blockchain being used. First and foremost is maintaining an updated\n//! balance and nonce as well as computing more complicated things like the closing and\n-//! payment treshhold based on gas prices.\n+//! payment threshold based on gas prices.\nuse crate::rita_common::rita_loop::fast_loop::FAST_LOOP_TIMEOUT;\nuse crate::rita_common::rita_loop::get_web3_server;\n@@ -20,7 +20,7 @@ use web30::client::Web3;\npub struct BlockchainOracle {\n/// An instant representing the start of a short period where the balance can\n- /// actually go to zero. This is becuase full nodes (incluing Infura) have an infuriating\n+ /// actually go to zero. This is because full nodes (including Infura) have an infuriating\n/// chance of returning a zero balance if they are not fully synced, causing all sorts of\n/// disruption. So instead when we manually zero the balance (send a withdraw_all) we open\n/// up a short five minute window during which we will actually trust the full node if it\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Clean up comments in blockchain oracle |
20,244 | 26.05.2020 20:24:37 | 14,400 | 923d03c501e564554536c976e7d388717cc1b127 | Migrate old reg_details
It's bit too soon to go deleting the old reg_details field, so I've
restored it here and added a migrate routine. | [
{
"change_type": "MODIFY",
"old_path": "althea_types/src/interop.rs",
"new_path": "althea_types/src/interop.rs",
"diff": "@@ -624,6 +624,68 @@ pub enum ContactType {\n},\n}\n+impl ContactType {\n+ pub fn convert(old: ExitRegistrationDetails) -> Option<Self> {\n+ match old {\n+ ExitRegistrationDetails {\n+ phone: Some(phone),\n+ email: Some(email),\n+ phone_code: _,\n+ email_code: _,\n+ } => match (phone.parse(), email.parse()) {\n+ (Ok(validated_phone), Ok(validated_email)) => Some(ContactType::Both {\n+ number: validated_phone,\n+ email: validated_email,\n+ }),\n+ (Err(_e), Ok(validated_email)) => Some(ContactType::Email {\n+ email: validated_email,\n+ }),\n+ (Ok(validated_phone), Err(_e)) => Some(ContactType::Phone {\n+ number: validated_phone,\n+ }),\n+ (Err(_ea), Err(_eb)) => Some(ContactType::Bad {\n+ invalid_email: Some(email),\n+ invalid_number: Some(phone),\n+ }),\n+ },\n+ ExitRegistrationDetails {\n+ phone: Some(phone),\n+ email: None,\n+ phone_code: _,\n+ email_code: _,\n+ } => match phone.parse() {\n+ Ok(validated_phone) => Some(ContactType::Phone {\n+ number: validated_phone,\n+ }),\n+ Err(_e) => Some(ContactType::Bad {\n+ invalid_number: Some(phone),\n+ invalid_email: None,\n+ }),\n+ },\n+ ExitRegistrationDetails {\n+ phone: None,\n+ email: Some(email),\n+ phone_code: _,\n+ email_code: _,\n+ } => match email.parse() {\n+ Ok(validated_email) => Some(ContactType::Email {\n+ email: validated_email,\n+ }),\n+ Err(_e) => Some(ContactType::Bad {\n+ invalid_number: Some(email),\n+ invalid_email: None,\n+ }),\n+ },\n+ ExitRegistrationDetails {\n+ phone: None,\n+ email: None,\n+ phone_code: _,\n+ email_code: _,\n+ } => None,\n+ }\n+ }\n+}\n+\n/// Struct for storing details about this user installation. This particular\n/// struct exists in the settings on the router because it has to be persisted\n/// long enough to make it to the operator tools, once it's been uploaded though\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/client.rs",
"new_path": "rita/src/client.rs",
"diff": "@@ -124,6 +124,7 @@ use althea_kernel_interface::KernelInterface;\nuse althea_kernel_interface::LinuxCommandRunner;\n#[cfg(test)]\nuse althea_kernel_interface::TestCommandRunner;\n+use althea_types::ContactType;\n#[cfg(test)]\nlazy_static! {\n@@ -203,6 +204,15 @@ fn wait_for_settings(settings_file: &str) -> RitaSettingsStruct {\n}\nfn main() {\n+ {\n+ let mut exit_client = SETTING.get_exit_client_mut();\n+ let reg_details = exit_client.reg_details.clone();\n+ if let Some(reg_details) = reg_details {\n+ let contact_info: Option<ContactType> = ContactType::convert(reg_details);\n+ exit_client.contact_info = contact_info;\n+ }\n+ }\n+\n// On Linux static builds we need to probe ssl certs path to be able to\n// do TLS stuff.\nopenssl_probe::init_ssl_cert_env_vars();\n"
},
{
"change_type": "MODIFY",
"old_path": "settings/src/client.rs",
"new_path": "settings/src/client.rs",
"diff": "@@ -6,7 +6,7 @@ use crate::operator::OperatorSettings;\nuse crate::payment::PaymentSettings;\nuse crate::spawn_watch_thread;\nuse crate::RitaCommonSettings;\n-use althea_types::{ContactType, ExitState, Identity};\n+use althea_types::{ContactType, ExitRegistrationDetails, ExitState, Identity};\nuse config::Config;\nuse failure::Error;\nuse owning_ref::{RwLockReadGuardRef, RwLockWriteGuardRefMut};\n@@ -48,6 +48,8 @@ pub struct ExitClientSettings {\npub contact_info: Option<ContactType>,\n/// This controls which interfaces will be proxied over the exit tunnel\npub lan_nics: HashSet<String>,\n+ /// legacy contact details storage, to be phased out in beta 15 after everyone has migrated\n+ pub reg_details: Option<ExitRegistrationDetails>,\n/// Specifies if the user would like to receive low balance messages from the exit\n#[serde(default = \"default_balance_notification\")]\npub low_balance_notification: bool,\n@@ -59,6 +61,7 @@ impl Default for ExitClientSettings {\nexits: HashMap::new(),\ncurrent_exit: None,\nwg_listen_port: 59999,\n+ reg_details: None,\ncontact_info: None,\nlan_nics: HashSet::new(),\nlow_balance_notification: true,\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Migrate old reg_details
It's bit too soon to go deleting the old reg_details field, so I've
restored it here and added a migrate routine. |
20,244 | 27.05.2020 06:57:00 | 14,400 | 03194463196cff1dfe1331b46ec54c6415764616 | Add get_last_handshake_time() utility function
This is going to be useful for locating stale tunnels
and removing them with some level of certainty that they
are not being used | [
{
"change_type": "MODIFY",
"old_path": "althea_kernel_interface/src/setup_wg_if.rs",
"new_path": "althea_kernel_interface/src/setup_wg_if.rs",
"diff": "@@ -79,6 +79,28 @@ impl dyn KernelInterface {\n}\nOk(num)\n}\n+\n+ /// Returns the last handshake time of every client on this tunnel.\n+ pub fn get_last_handshake_time(&self, ifname: &str) -> Result<Vec<(WgKey, SystemTime)>, Error> {\n+ let output = self.run_command(\"wg\", &[\"show\", ifname, \"latest-handshakes\"])?;\n+ let out = String::from_utf8(output.stdout)?;\n+ let mut timestamps = Vec::new();\n+ for line in out.lines() {\n+ let content: Vec<&str> = line.split('\\t').collect();\n+ let mut itr = content.iter();\n+ let wg_key: WgKey = match itr.next() {\n+ Some(val) => val.parse()?,\n+ None => return Err(format_err!(\"Invalid line!\")),\n+ };\n+ let timestamp = match itr.next() {\n+ Some(val) => val.parse()?,\n+ None => return Err(format_err!(\"Invalid line!\")),\n+ };\n+ let d = UNIX_EPOCH + Duration::from_secs(timestamp);\n+ timestamps.push((wg_key, d))\n+ }\n+ Ok(timestamps)\n+ }\n}\n#[test]\n@@ -151,3 +173,57 @@ fn test_get_wg_exit_clients_online() {\nassert_eq!(KI.get_wg_exit_clients_online().unwrap(), 1);\n}\n+\n+#[test]\n+fn test_get_last_handshake_time() {\n+ use crate::KI;\n+\n+ use std::os::unix::process::ExitStatusExt;\n+ use std::process::ExitStatus;\n+ use std::process::Output;\n+\n+ let mut counter = 0;\n+\n+ let link_args = &[\"show\", \"wg1\", \"latest-handshakes\"];\n+ KI.set_mock(Box::new(move |program, args| {\n+ assert_eq!(program, \"wg\");\n+ counter += 1;\n+\n+ match counter {\n+ 1 => {\n+ assert_eq!(args, link_args);\n+ Ok(Output{\n+ stdout: format!(\"88gbNAZx7NoNK9hatYuDkeZOjQ8EBmJ8VBpcFhXPqHs= {}\\nbGkj7Z6bX1593G0pExfzxocWKhS3Un9uifIhZP9c5iM= 1536936247\\n9jRr6euMHu3tBIsZyqxUmjbuKVVFZCBOYApOR2pLNkQ= 0\", SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs()).as_bytes().to_vec(),\n+ stderr: b\"\".to_vec(),\n+ status: ExitStatus::from_raw(0),\n+ })\n+ }\n+ _ => panic!(\"command called too many times\"),\n+ }\n+ }));\n+\n+ let wgkey1: WgKey = \"88gbNAZx7NoNK9hatYuDkeZOjQ8EBmJ8VBpcFhXPqHs=\"\n+ .parse()\n+ .unwrap();\n+ let wgkey2: WgKey = \"bGkj7Z6bX1593G0pExfzxocWKhS3Un9uifIhZP9c5iM=\"\n+ .parse()\n+ .unwrap();\n+ let wgkey3: WgKey = \"9jRr6euMHu3tBIsZyqxUmjbuKVVFZCBOYApOR2pLNkQ=\"\n+ .parse()\n+ .unwrap();\n+\n+ let res = KI\n+ .get_last_handshake_time(\"wg1\")\n+ .expect(\"Failed to run get_last_handshake_time!\");\n+ assert!(res.contains(&(wgkey3, SystemTime::UNIX_EPOCH)));\n+ assert!(res.contains(&(\n+ wgkey2,\n+ (SystemTime::UNIX_EPOCH + Duration::from_secs(1_536_936_247))\n+ )));\n+ for (key, time) in res {\n+ if key == wgkey1 {\n+ // system time is very high resolution but within a second is fine\n+ assert!(time > SystemTime::now() - Duration::from_secs(1));\n+ }\n+ }\n+}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Add get_last_handshake_time() utility function
This is going to be useful for locating stale tunnels
and removing them with some level of certainty that they
are not being used |
20,244 | 27.05.2020 10:02:30 | 14,400 | 2d3a5a1899cc30cb5290ffd748bcec44d1fd469d | Upgrade integration tests for new exit registration endpoints
Had to modify the endpoint to take straight strings and enable
call retry by default. Which might break Travis in the future
but I figure we should be running in docker on travis as well | [
{
"change_type": "MODIFY",
"old_path": "integration-tests/integration-test-script/rita.py",
"new_path": "integration-tests/integration-test-script/rita.py",
"diff": "@@ -99,10 +99,6 @@ EXIT_SETTINGS = {\n},\n\"current_exit\": \"exit_a\",\n\"wg_listen_port\": 59999,\n- \"reg_details\": {\n- \"zip_code\": \"1234\",\n- \"email\": \"1234@gmail.com\"\n- }\n}\nEXIT_SELECT = {\n"
},
{
"change_type": "MODIFY",
"old_path": "integration-tests/integration-test-script/utils.py",
"new_path": "integration-tests/integration-test-script/utils.py",
"diff": "@@ -251,7 +251,7 @@ def start_babel(node, BABELD):\n)\n-def start_rita(node, dname, RITA, EXIT_SETTINGS, retry):\n+def start_rita(node, dname, RITA, EXIT_SETTINGS):\nid = node.id\nsettings = get_rita_defaults()\n@@ -261,7 +261,7 @@ def start_rita(node, dname, RITA, EXIT_SETTINGS, retry):\nid=id, pwd=dname)\nsettings[\"network\"][\"peer_interfaces\"] = node.get_veth_interfaces()\nsettings[\"payment\"][\"local_fee\"] = node.local_fee\n- settings[\"metric_factor\"] = 0 # We explicity want to disregard quality\n+ settings[\"metric_factor\"] = 0 # We explicitly want to disregard quality\nsave_rita_settings(id, settings)\ntime.sleep(0.2)\nos.system(\n@@ -272,15 +272,20 @@ def start_rita(node, dname, RITA, EXIT_SETTINGS, retry):\n)\ntime.sleep(1)\n- EXIT_SETTINGS[\"reg_details\"][\"email\"] = \"{}@example.com\".format(id)\n+ email = \"{}@example.com\".format(id)\n- # only enabled for large configs, becuase curl is not always up to date enough to have this option\n- if retry:\n+ # this works in travis if your looking for it\n+ # else:\n+ # time.sleep(1)\n+ # os.system(\"ip netns exec netlab-{id} curl -XPOST 127.0.0.1:4877/settings -H 'Content-Type: application/json' -i -d '{data}'\"\n+ # .format(id=id, data=json.dumps({\"exit_client\": EXIT_SETTINGS})))\n+ # time.sleep(1)\n+ # os.system(\"ip netns exec netlab-{id} curl -XPOST 127.0.0.1:4877/email -H 'Content-Type: application/json' -i -d '{data}'\"\n+ # .format(id=id, data=email)\nos.system(\"ip netns exec netlab-{id} curl --retry 5 --retry-connrefused -m 60 -XPOST 127.0.0.1:4877/settings -H 'Content-Type: application/json' -i -d '{data}'\"\n.format(id=id, data=json.dumps({\"exit_client\": EXIT_SETTINGS})))\n- else:\n- os.system(\"ip netns exec netlab-{id} curl -XPOST 127.0.0.1:4877/settings -H 'Content-Type: application/json' -i -d '{data}'\"\n- .format(id=id, data=json.dumps({\"exit_client\": EXIT_SETTINGS})))\n+ os.system(\"ip netns exec netlab-{id} curl --retry 5 --retry-connrefused -m 60 -XPOST 127.0.0.1:4877/email -H 'Content-Type: application/json' -i -d '{data}'\"\n+ .format(id=id, data=email))\ndef start_rita_exit(node, dname, RITA_EXIT):\n"
},
{
"change_type": "MODIFY",
"old_path": "integration-tests/integration-test-script/world.py",
"new_path": "integration-tests/integration-test-script/world.py",
"diff": "@@ -148,7 +148,7 @@ class World:\nif id != self.exit_id and id != self.external:\n(RITA, RITA_EXIT) = switch_binaries(id, VERBOSE, RITA, RITA_EXIT,\nCOMPAT_LAYOUT, COMPAT_LAYOUTS, RITA_A, RITA_EXIT_A, RITA_B, RITA_EXIT_B)\n- start_rita(node, dname, RITA, EXIT_SETTINGS, len(self.nodes) > 7)\n+ start_rita(node, dname, RITA, EXIT_SETTINGS)\ntime.sleep(0.5 + random.random() / 2) # wait 0.5s - 1s\nprint()\nprint(\"rita started\")\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/contact_info.rs",
"new_path": "rita/src/rita_client/dashboard/contact_info.rs",
"diff": "use crate::SETTING;\nuse actix_web::HttpRequest;\nuse actix_web::HttpResponse;\n-use actix_web::Json;\nuse althea_types::interop::ContactType;\nuse lettre::EmailAddress;\nuse phonenumber::PhoneNumber;\nuse settings::client::RitaClientSettings;\n-pub fn set_phone_number(req: Json<String>) -> HttpResponse {\n- let number: PhoneNumber = match req.into_inner().parse() {\n+pub fn set_phone_number(req: String) -> HttpResponse {\n+ trace!(\"Got number {:?}\", req);\n+ let number: PhoneNumber = match req.parse() {\nOk(p) => p,\nErr(_e) => return HttpResponse::BadRequest().finish(),\n};\n@@ -34,17 +34,18 @@ pub fn set_phone_number(req: Json<String>) -> HttpResponse {\npub fn get_phone_number(_req: HttpRequest) -> HttpResponse {\nlet exit_client = SETTING.get_exit_client();\nmatch &exit_client.contact_info {\n- Some(ContactType::Phone { number }) => HttpResponse::Ok().json(number),\n+ Some(ContactType::Phone { number }) => HttpResponse::Ok().json(number.to_string()),\nSome(ContactType::Both {\nemail: _email,\nnumber,\n- }) => HttpResponse::Ok().json(number),\n+ }) => HttpResponse::Ok().json(number.to_string()),\n_ => HttpResponse::Ok().finish(),\n}\n}\n-pub fn set_email(req: Json<String>) -> HttpResponse {\n- let email: EmailAddress = match req.into_inner().parse() {\n+pub fn set_email(req: String) -> HttpResponse {\n+ trace!(\"Got email {:?}\", req);\n+ let email: EmailAddress = match req.parse() {\nOk(p) => p,\nErr(_e) => return HttpResponse::BadRequest().finish(),\n};\n@@ -66,11 +67,11 @@ pub fn set_email(req: Json<String>) -> HttpResponse {\npub fn get_email(_req: HttpRequest) -> HttpResponse {\nlet exit_client = SETTING.get_exit_client();\nmatch &exit_client.contact_info {\n- Some(ContactType::Email { email }) => HttpResponse::Ok().json(email),\n+ Some(ContactType::Email { email }) => HttpResponse::Ok().json(email.to_string()),\nSome(ContactType::Both {\nnumber: _number,\nemail,\n- }) => HttpResponse::Ok().json(email),\n+ }) => HttpResponse::Ok().json(email.to_string()),\n_ => HttpResponse::Ok().finish(),\n}\n}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Upgrade integration tests for new exit registration endpoints
Had to modify the endpoint to take straight strings and enable
call retry by default. Which might break Travis in the future
but I figure we should be running in docker on travis as well |
20,244 | 27.05.2020 11:40:21 | 14,400 | d5ce133c722d3805e0500475c459618bb7497d13 | Fix clippy nit with tunnel gc
I tested that rust does not run b in a statment like a || b
if a is true for any opt level. This means it's safe for to
use this logic and avoid running a shell out command for every
tunnel when tunnel gc runs. | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/tunnel_manager/mod.rs",
"new_path": "rita/src/rita_common/tunnel_manager/mod.rs",
"diff": "@@ -498,9 +498,9 @@ impl Handler<TriggerGC> for TunnelManager {\n// checker issues, we should consider a method that does modify in place\nfor (_identity, tunnels) in self.tunnels.iter() {\nfor tunnel in tunnels.iter() {\n- if tunnel.last_contact.elapsed() < msg.tunnel_timeout {\n- insert_into_tunnel_list(tunnel, &mut good);\n- } else if check_handshake_time(msg.tunnel_handshake_timeout, &tunnel.iface_name) {\n+ if tunnel.last_contact.elapsed() < msg.tunnel_timeout\n+ || check_handshake_time(msg.tunnel_handshake_timeout, &tunnel.iface_name)\n+ {\ninsert_into_tunnel_list(tunnel, &mut good);\n} else {\ninsert_into_tunnel_list(tunnel, &mut timed_out)\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Fix clippy nit with tunnel gc
I tested that rust does not run b in a statment like a || b
if a is true for any opt level. This means it's safe for to
use this logic and avoid running a shell out command for every
tunnel when tunnel gc runs. |
20,244 | 27.05.2020 17:19:25 | 14,400 | e9325895359d7cbcadfdf7d9f8206489277ce864 | Fix typo in TunnelManager | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/tunnel_manager/mod.rs",
"new_path": "rita/src/rita_common/tunnel_manager/mod.rs",
"diff": "@@ -636,7 +636,7 @@ impl Handler<PeersToContact> for TunnelManager {\n}\nErr(_) => {\n// Do not contact manual peers on the internet if we are not a gateway\n- // it will just fill the logs with faild dns resolution attempts or result\n+ // it will just fill the logs with failed dns resolution attempts or result\n// in bad behavior, we do allow the addressing of direct ip address gateways\n// for the special case that the user is attempting some special behavior\nif is_gateway {\n@@ -1142,7 +1142,7 @@ fn tunnel_state_change(\n}\n/// Takes the tunnels list and iterates over it to update all of the traffic control settings\n-/// since we can't figure out how to combine interfaces badnwidth budgets we're subdividing it\n+/// since we can't figure out how to combine interfaces bandwidth budgets we're subdividing it\n/// here with manual terminal commands whenever there is a change\nfn tunnel_bw_limit_update(tunnels: &HashMap<Identity, Vec<Tunnel>>) -> Result<(), Error> {\ninfo!(\"Running tunnel bw limit update!\");\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Fix typo in TunnelManager |
20,244 | 28.05.2020 09:44:37 | 14,400 | 8ac400f4449314d4292f3eb828d1762c1a0944fa | Reduce return type complexity on client dash endpoints
In many cases Result<HttpResponse, Error> isn't needed as we only
return variants of HTTP response and don't make use of operators
like ? to handle errors.
In those cases we just present extra return type complexity to the
reader. | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/contact_info.rs",
"new_path": "rita/src/rita_client/dashboard/contact_info.rs",
"diff": "//! the exit settings struct is the one true source. All the others are updated as needed and you should try to phase them out if practical.\nuse crate::rita_common::utils::option_convert;\n+use crate::ARGS;\nuse crate::SETTING;\nuse actix_web::HttpRequest;\nuse actix_web::HttpResponse;\nuse althea_types::ContactType;\nuse lettre::EmailAddress;\nuse phonenumber::PhoneNumber;\n-use settings::client::RitaClientSettings;\n+use settings::{client::RitaClientSettings, FileWrite};\nfn clean_quotes(val: &str) -> String {\nval.trim().trim_matches('\"').trim_matches('\\\\').to_string()\n@@ -38,6 +39,12 @@ pub fn set_phone_number(req: String) -> HttpResponse {\nNone => Some(ContactType::Phone { number }),\n};\nexit_client.contact_info = option_convert(res);\n+\n+ // try and save the config and fail if we can't\n+ if let Err(_e) = SETTING.write().unwrap().write(&ARGS.flag_config) {\n+ return HttpResponse::InternalServerError().finish();\n+ }\n+\nHttpResponse::Ok().finish()\n}\n@@ -76,6 +83,12 @@ pub fn set_email(req: String) -> HttpResponse {\nNone => Some(ContactType::Email { email }),\n};\nexit_client.contact_info = option_convert(res);\n+\n+ // try and save the config and fail if we can't\n+ if let Err(_e) = SETTING.write().unwrap().write(&ARGS.flag_config) {\n+ return HttpResponse::InternalServerError().finish();\n+ }\n+\nHttpResponse::Ok().finish()\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/mesh_ip.rs",
"new_path": "rita/src/rita_client/dashboard/mesh_ip.rs",
"diff": "use crate::SETTING;\nuse ::actix_web::{HttpRequest, HttpResponse};\n-use failure::Error;\nuse settings::RitaCommonSettings;\nuse std::collections::HashMap;\n-pub fn get_mesh_ip(_req: HttpRequest) -> Result<HttpResponse, Error> {\n+pub fn get_mesh_ip(_req: HttpRequest) -> HttpResponse {\ndebug!(\"/mesh_ip GET hit\");\nlet mut ret = HashMap::new();\n@@ -20,5 +19,5 @@ pub fn get_mesh_ip(_req: HttpRequest) -> Result<HttpResponse, Error> {\n}\n}\n- Ok(HttpResponse::Ok().json(ret))\n+ HttpResponse::Ok().json(ret)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/notifications.rs",
"new_path": "rita/src/rita_client/dashboard/notifications.rs",
"diff": "@@ -2,25 +2,23 @@ use crate::ARGS;\nuse crate::SETTING;\nuse ::actix_web::Path;\nuse ::actix_web::{HttpRequest, HttpResponse};\n-use failure::Error;\nuse settings::client::RitaClientSettings;\nuse settings::FileWrite;\n-pub fn get_low_balance_notification(_req: HttpRequest) -> Result<HttpResponse, Error> {\n+pub fn get_low_balance_notification(_req: HttpRequest) -> HttpResponse {\nlet setting = SETTING.get_exit_client().low_balance_notification;\n- Ok(HttpResponse::Ok().json(setting.to_string()))\n+ HttpResponse::Ok().json(setting.to_string())\n}\n-pub fn set_low_balance_notification(path: Path<bool>) -> Result<HttpResponse, Error> {\n+pub fn set_low_balance_notification(path: Path<bool>) -> HttpResponse {\nlet value = path.into_inner();\ndebug!(\"Set low balance notification hit!\");\nSETTING.get_exit_client_mut().low_balance_notification = value;\n// try and save the config and fail if we can't\n- if let Err(e) = SETTING.write().unwrap().write(&ARGS.flag_config) {\n- error!(\"error saving config {:?}\", e);\n- return Err(e);\n+ if let Err(_e) = SETTING.write().unwrap().write(&ARGS.flag_config) {\n+ return HttpResponse::InternalServerError().finish();\n}\n- Ok(HttpResponse::Ok().json(()))\n+ HttpResponse::Ok().json(())\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/operator.rs",
"new_path": "rita/src/rita_client/dashboard/operator.rs",
"diff": "@@ -20,46 +20,44 @@ pub fn get_dao_list(_req: HttpRequest) -> Result<Json<Vec<Address>>, Error> {\n}\n/// TODO remove after beta 12, provided for backwards compat\n-pub fn add_to_dao_list(path: Path<Address>) -> Result<Json<()>, Error> {\n+pub fn add_to_dao_list(path: Path<Address>) -> HttpResponse {\ntrace!(\"Add to dao list: Hit\");\nlet provided_address = path.into_inner();\nSETTING.get_operator_mut().operator_address = Some(provided_address);\n- // try and save the config and fail if we can't\n- if let Err(e) = SETTING.write().unwrap().write(&ARGS.flag_config) {\n- return Err(e);\n+ if let Err(_e) = SETTING.write().unwrap().write(&ARGS.flag_config) {\n+ return HttpResponse::InternalServerError().finish();\n}\n- Ok(Json(()))\n+ HttpResponse::Ok().finish()\n}\n/// TODO remove after beta 12, provided for backwards compat\n-pub fn remove_from_dao_list(_path: Path<Address>) -> Result<Json<()>, Error> {\n+pub fn remove_from_dao_list(_path: Path<Address>) -> HttpResponse {\nSETTING.get_operator_mut().operator_address = None;\n- if let Err(e) = SETTING.write().unwrap().write(&ARGS.flag_config) {\n- return Err(e);\n+ if let Err(_e) = SETTING.write().unwrap().write(&ARGS.flag_config) {\n+ return HttpResponse::InternalServerError().finish();\n}\n- Ok(Json(()))\n+ HttpResponse::Ok().finish()\n}\n/// TODO remove after beta 12, provided for backwards compat\n-pub fn get_dao_fee(_req: HttpRequest) -> Result<HttpResponse, Error> {\n+pub fn get_dao_fee(_req: HttpRequest) -> HttpResponse {\ndebug!(\"/dao_fee GET hit\");\nlet mut ret = HashMap::new();\nret.insert(\"dao_fee\", SETTING.get_operator().operator_fee.clone());\n- Ok(HttpResponse::Ok().json(ret))\n+ HttpResponse::Ok().json(ret)\n}\n/// TODO remove after beta 12, provided for backwards compat\n-pub fn set_dao_fee(path: Path<Uint256>) -> Result<Json<()>, Error> {\n+pub fn set_dao_fee(path: Path<Uint256>) -> HttpResponse {\nlet new_fee = path.into_inner();\ndebug!(\"/dao_fee/{} POST hit\", new_fee);\nSETTING.get_operator_mut().operator_fee = new_fee;\n- // try and save the config and fail if we can't\n- if let Err(e) = SETTING.write().unwrap().write(&ARGS.flag_config) {\n- return Err(e);\n+ if let Err(_e) = SETTING.write().unwrap().write(&ARGS.flag_config) {\n+ return HttpResponse::InternalServerError().finish();\n}\n- Ok(Json(()))\n+ HttpResponse::Ok().finish()\n}\npub fn get_operator(_req: HttpRequest) -> Json<Option<Address>> {\n@@ -70,31 +68,30 @@ pub fn get_operator(_req: HttpRequest) -> Json<Option<Address>> {\n}\n}\n-pub fn change_operator(path: Path<Address>) -> Result<Json<()>, Error> {\n+pub fn change_operator(path: Path<Address>) -> HttpResponse {\ntrace!(\"add operator address: Hit\");\nlet provided_address = path.into_inner();\nSETTING.get_operator_mut().operator_address = Some(provided_address);\n- // try and save the config and fail if we can't\n- if let Err(e) = SETTING.write().unwrap().write(&ARGS.flag_config) {\n- return Err(e);\n+ if let Err(_e) = SETTING.write().unwrap().write(&ARGS.flag_config) {\n+ return HttpResponse::InternalServerError().finish();\n}\n- Ok(Json(()))\n+ HttpResponse::Ok().finish()\n}\n-pub fn remove_operator(_path: Path<Address>) -> Result<Json<()>, Error> {\n+pub fn remove_operator(_path: Path<Address>) -> HttpResponse {\nSETTING.get_operator_mut().operator_address = None;\n- if let Err(e) = SETTING.write().unwrap().write(&ARGS.flag_config) {\n- return Err(e);\n+ if let Err(_e) = SETTING.write().unwrap().write(&ARGS.flag_config) {\n+ return HttpResponse::InternalServerError().finish();\n}\n- Ok(Json(()))\n+ HttpResponse::Ok().finish()\n}\n-pub fn get_operator_fee(_req: HttpRequest) -> Result<HttpResponse, Error> {\n+pub fn get_operator_fee(_req: HttpRequest) -> HttpResponse {\ndebug!(\"get operator GET hit\");\n- Ok(HttpResponse::Ok().json(SETTING.get_operator().operator_fee.clone()))\n+ HttpResponse::Ok().json(SETTING.get_operator().operator_fee.clone())\n}\n-pub fn get_operator_debt(_req: HttpRequest) -> Result<HttpResponse, Error> {\n+pub fn get_operator_debt(_req: HttpRequest) -> HttpResponse {\ndebug!(\"get operator debt hit\");\n- Ok(HttpResponse::Ok().json(get_operator_fee_debt()))\n+ HttpResponse::Ok().json(get_operator_fee_debt())\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/release_feed.rs",
"new_path": "rita/src/rita_client/dashboard/release_feed.rs",
"diff": "@@ -15,26 +15,26 @@ pub fn get_release_feed_http(_req: HttpRequest) -> Result<HttpResponse, Error> {\nOk(HttpResponse::Ok().json(res))\n}\n-pub fn set_release_feed_http(path: Path<String>) -> Result<HttpResponse, Error> {\n+pub fn set_release_feed_http(path: Path<String>) -> HttpResponse {\nif !KI.is_openwrt() {\n- return Ok(HttpResponse::new(StatusCode::BAD_REQUEST));\n+ return HttpResponse::new(StatusCode::BAD_REQUEST);\n}\nlet val = path.into_inner().parse();\nif val.is_err() {\n- return Ok(HttpResponse::new(StatusCode::BAD_REQUEST)\n+ return HttpResponse::new(StatusCode::BAD_REQUEST)\n.into_builder()\n.json(format!(\n\"Could not parse {:?} into a ReleaseStatus enum!\",\nval\n- )));\n+ ));\n}\nlet val = val.unwrap();\nif let Err(e) = set_release_feed(val) {\n- return Ok(HttpResponse::new(StatusCode::INTERNAL_SERVER_ERROR)\n+ return HttpResponse::new(StatusCode::INTERNAL_SERVER_ERROR)\n.into_builder()\n- .json(format!(\"Failed to write new release feed with {:?}\", e)));\n+ .json(format!(\"Failed to write new release feed with {:?}\", e));\n}\n- Ok(HttpResponse::Ok().json(()))\n+ HttpResponse::Ok().json(())\n}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Reduce return type complexity on client dash endpoints
In many cases Result<HttpResponse, Error> isn't needed as we only
return variants of HTTP response and don't make use of operators
like ? to handle errors.
In those cases we just present extra return type complexity to the
reader. |
20,244 | 28.05.2020 10:32:53 | 14,400 | d4812a294fce04ca72105e074bc739f5c285d117 | Migrate contact details only once | [
{
"change_type": "MODIFY",
"old_path": "rita/src/client.rs",
"new_path": "rita/src/client.rs",
"diff": "@@ -208,10 +208,14 @@ fn main() {\nlet mut exit_client = SETTING.get_exit_client_mut();\nlet reg_details = exit_client.reg_details.clone();\nif let Some(reg_details) = reg_details {\n+ // only migrate if it has not already been done, otherwise we might\n+ // overwrite changed details\n+ if exit_client.contact_info.is_none() {\nlet contact_info: Option<ContactStorage> = ContactStorage::convert(reg_details);\nexit_client.contact_info = contact_info;\n}\n}\n+ }\n// On Linux static builds we need to probe ssl certs path to be able to\n// do TLS stuff.\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Migrate contact details only once |
20,244 | 28.05.2020 10:33:07 | 14,400 | 753bc8792d397b4a652184cf0480111c2da149cd | Don't deadlock contact info on save | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/contact_info.rs",
"new_path": "rita/src/rita_client/dashboard/contact_info.rs",
"diff": "@@ -39,6 +39,7 @@ pub fn set_phone_number(req: String) -> HttpResponse {\nNone => Some(ContactType::Phone { number }),\n};\nexit_client.contact_info = option_convert(res);\n+ drop(exit_client);\n// try and save the config and fail if we can't\nif let Err(_e) = SETTING.write().unwrap().write(&ARGS.flag_config) {\n@@ -83,6 +84,7 @@ pub fn set_email(req: String) -> HttpResponse {\nNone => Some(ContactType::Email { email }),\n};\nexit_client.contact_info = option_convert(res);\n+ drop(exit_client);\n// try and save the config and fail if we can't\nif let Err(_e) = SETTING.write().unwrap().write(&ARGS.flag_config) {\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Don't deadlock contact info on save |
20,244 | 28.05.2020 10:39:57 | 14,400 | a381480b4cab8fd2ce14bf37266190a0c6a7cd43 | Don't return PhoneNumber type from the localization endpoint
The validated struct is great to work with in Rust, not so much
in Javascript. So we should return just the string format. | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/localization.rs",
"new_path": "rita/src/rita_client/dashboard/localization.rs",
"diff": "use crate::SETTING;\n-use actix_web::{HttpRequest, HttpResponse, Result};\n-use failure::Error;\n-use settings::RitaCommonSettings;\n+use actix_web::{HttpRequest, Json};\n+use settings::{localization::LocalizationSettings, RitaCommonSettings};\n-pub fn get_localization(_req: HttpRequest) -> Result<HttpResponse, Error> {\n+/// A version of the localization struct that serializes into a more easily\n+/// consumable form\n+#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]\n+pub struct LocalizationReturn {\n+ pub wyre_enabled: bool,\n+ pub wyre_account_id: String,\n+ pub wyre_preface_message: String,\n+ pub display_currency_symbol: bool,\n+ pub support_number: String,\n+}\n+\n+impl From<LocalizationSettings> for LocalizationReturn {\n+ fn from(input: LocalizationSettings) -> Self {\n+ LocalizationReturn {\n+ wyre_enabled: input.wyre_enabled,\n+ wyre_account_id: input.wyre_account_id,\n+ wyre_preface_message: input.wyre_preface_message,\n+ display_currency_symbol: input.display_currency_symbol,\n+ support_number: input.support_number.to_string(),\n+ }\n+ }\n+}\n+\n+pub fn get_localization(_req: HttpRequest) -> Json<LocalizationReturn> {\ndebug!(\"/localization GET hit\");\nlet localization = SETTING.get_localization().clone();\n- Ok(HttpResponse::Ok().json(localization))\n+ Json(localization.into())\n}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Don't return PhoneNumber type from the localization endpoint
The validated struct is great to work with in Rust, not so much
in Javascript. So we should return just the string format. |
20,244 | 28.05.2020 12:05:20 | 14,400 | 77a46506c19ecaafeafc7c90b3f3b91b1d658d4b | No Wyre preface message
Can't figure out how to make this look good, so it goes for now | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/localization.rs",
"new_path": "rita/src/rita_client/dashboard/localization.rs",
"diff": "@@ -8,7 +8,6 @@ use settings::{localization::LocalizationSettings, RitaCommonSettings};\npub struct LocalizationReturn {\npub wyre_enabled: bool,\npub wyre_account_id: String,\n- pub wyre_preface_message: String,\npub display_currency_symbol: bool,\npub support_number: String,\n}\n@@ -18,7 +17,6 @@ impl From<LocalizationSettings> for LocalizationReturn {\nLocalizationReturn {\nwyre_enabled: input.wyre_enabled,\nwyre_account_id: input.wyre_account_id,\n- wyre_preface_message: input.wyre_preface_message,\ndisplay_currency_symbol: input.display_currency_symbol,\nsupport_number: input.support_number.to_string(),\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "settings/src/localization.rs",
"new_path": "settings/src/localization.rs",
"diff": "@@ -16,13 +16,6 @@ fn default_support_number() -> PhoneNumber {\n\"+18664ALTHEA\".parse().unwrap()\n}\n-fn default_wyre_preface_message() -> String {\n- \"Our payment partner Wyre, is international and expects phone numbers in international format. \\\n- The United States country code is +1 followed by your area code and number. \\\n- You may also see the charge come from outside the United States, this is normal.\"\n- .to_string()\n-}\n-\n#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]\npub struct LocalizationSettings {\n/// A flag indicating whether or not the dashboard should give users the option to purchase\n@@ -32,11 +25,6 @@ pub struct LocalizationSettings {\n/// Wyre account_id used to associate transactions with a specific Wyre account\n#[serde(default = \"default_wyre_account_id\")]\npub wyre_account_id: String,\n- /// This is a message that prefaces the Wyre deposit to include some warnings for the\n- /// user. Wyre often changes their flow or introduces pitfalls for users. We sadly need\n- /// to be able to modify our prep message\n- #[serde(default = \"default_wyre_preface_message\")]\n- pub wyre_preface_message: String,\n/// If we should display the $ symbol or just the DAI star symbol next\n/// to the balance, designed to help manage how prominently we want the cryptocurrency\n/// aspect of Althea to be displayed to the user.\n@@ -54,7 +42,6 @@ impl Default for LocalizationSettings {\nLocalizationSettings {\nwyre_enabled: default_wyre_enabled(),\nwyre_account_id: default_wyre_account_id(),\n- wyre_preface_message: default_wyre_preface_message(),\ndisplay_currency_symbol: default_display_currency_symbol(),\nsupport_number: default_support_number(),\n}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | No Wyre preface message
Can't figure out how to make this look good, so it goes for now |
20,244 | 28.05.2020 16:37:33 | 14,400 | 511490d6a25643a882116e4d652591ed12bc596f | Display operator setup
This is a super simple backend toggle that makes sure that when we
dismiss the operator setup it goes away for good. | [
{
"change_type": "MODIFY",
"old_path": "rita/src/client.rs",
"new_path": "rita/src/client.rs",
"diff": "@@ -413,6 +413,12 @@ fn start_client_dashboard() {\nMethod::GET,\nget_installation_details,\n)\n+ .route(\n+ \"/operator_setup/{enabled}\",\n+ Method::POST,\n+ set_display_operator_setup,\n+ )\n+ .route(\"/operator_setup\", Method::GET, display_operator_setup)\n.route(\"/phone\", Method::GET, get_phone_number)\n.route(\"/phone\", Method::POST, set_phone_number)\n.route(\"/email\", Method::GET, get_email)\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/installation_details.rs",
"new_path": "rita/src/rita_client/dashboard/installation_details.rs",
"diff": "use crate::SETTING;\nuse actix_web::HttpResponse;\n-use actix_web::{HttpRequest, Json};\n+use actix_web::{HttpRequest, Json, Path};\nuse althea_types::ContactType;\nuse althea_types::InstallationDetails;\nuse settings::client::RitaClientSettings;\n@@ -68,3 +68,12 @@ pub fn get_installation_details(_req: HttpRequest) -> HttpResponse {\nlet operator_settings = SETTING.get_operator();\nHttpResponse::Ok().json(operator_settings.installation_details.clone())\n}\n+\n+pub fn display_operator_setup(_req: HttpRequest) -> HttpResponse {\n+ HttpResponse::Ok().json(SETTING.get_operator().display_operator_setup)\n+}\n+\n+pub fn set_display_operator_setup(val: Path<bool>) -> HttpResponse {\n+ SETTING.get_operator_mut().display_operator_setup = val.into_inner();\n+ HttpResponse::Ok().finish()\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "settings/src/operator.rs",
"new_path": "settings/src/operator.rs",
"diff": "@@ -19,6 +19,11 @@ fn default_use_operator_price() -> bool {\ntrue\n}\n+/// If we are displaying the operator setup card on the front page or not\n+fn default_display_operator_setup() -> bool {\n+ true\n+}\n+\n/// If the operator has indicated that users should not be able to change\n/// their own prices\nfn default_force_use_operator_price() -> bool {\n@@ -51,6 +56,9 @@ pub struct OperatorSettings {\n/// Details about this devices installation see the doc comments on the struct\n/// this is set at startup time for the router\npub installation_details: Option<InstallationDetails>,\n+ /// If we should display the operator setup on the dashboard\n+ #[serde(default = \"default_display_operator_setup\")]\n+ pub display_operator_setup: bool,\n}\nimpl Default for OperatorSettings {\n@@ -62,6 +70,7 @@ impl Default for OperatorSettings {\nforce_use_operator_price: default_force_use_operator_price(),\ncheckin_url: default_checkin_url(),\ninstallation_details: None,\n+ display_operator_setup: true,\n}\n}\n}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Display operator setup
This is a super simple backend toggle that makes sure that when we
dismiss the operator setup it goes away for good. |
20,244 | 29.05.2020 09:03:15 | 14,400 | d55caead020484def5f10ff8bdc87402d13197c7 | Finish up installer details collection
This contains all the final tweaks for installer details collection to
work properly. Including better parsing logic and testing and actually
submitting these details to the operator tools dashboard. | [
{
"change_type": "MODIFY",
"old_path": "althea_types/src/interop.rs",
"new_path": "althea_types/src/interop.rs",
"diff": "@@ -117,7 +117,7 @@ impl Display for SystemChain {\nimpl Default for SystemChain {\nfn default() -> SystemChain {\n- SystemChain::Ethereum\n+ SystemChain::Xdai\n}\n}\n@@ -489,6 +489,13 @@ pub struct OperatorCheckinMessage {\n/// see the type definition for more details about how this type restricts values\n/// This only exists in Beta 14+\npub contact_info: Option<ContactType>,\n+ /// Details about this installation, including ip addresses, address and other\n+ /// info to insert into a spreadsheet displayed by operator tools. This is set\n+ /// all the time but only accepted by operator tools once. The reason we store\n+ /// it in the config is so that values can be set before the device is connected\n+ /// and then be sent up at a later date. This does result in a constant resending\n+ /// of this data forever just to discard it on the other end. TODO optimize sending\n+ pub install_details: Option<InstallationDetails>,\n/// Info about the current state of this device, including it's model, CPU,\n/// memory, and temperature if sensors are available\npub hardware_info: Option<HardwareInfo>,\n@@ -591,8 +598,9 @@ pub struct InstallationDetails {\n/// Description of the installation and equipment at the\n/// location\npub equipment_details: String,\n- /// Time of install, in milliseconds since Unix Epoch\n- pub install_date: SystemTime,\n+ /// Time of install, this is set by the operator tools when it accepts\n+ /// the value because the router system clocks may be problematic.\n+ pub install_date: Option<SystemTime>,\n}\n/// Heartbeat sent to the operator server to help monitor\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/installation_details.rs",
"new_path": "rita/src/rita_client/dashboard/installation_details.rs",
"diff": "+use crate::ARGS;\nuse crate::SETTING;\nuse actix_web::HttpResponse;\nuse actix_web::{HttpRequest, Json, Path};\nuse althea_types::ContactType;\nuse althea_types::InstallationDetails;\n-use settings::client::RitaClientSettings;\n-use std::net::Ipv4Addr;\n-use std::time::SystemTime;\n+use settings::{client::RitaClientSettings, FileWrite};\n/// This is a utility type that is used by the front end when sending us\n/// installation details. This lets us do the validation and parsing here\n@@ -14,9 +13,9 @@ use std::time::SystemTime;\npub struct InstallationDetailsPost {\npub phone: Option<String>,\npub email: Option<String>,\n- pub client_antenna_ip: Option<Ipv4Addr>,\n- pub relay_antennas: Vec<Ipv4Addr>,\n- pub phone_client_antennas: Vec<Ipv4Addr>,\n+ pub client_antenna_ip: Option<String>,\n+ pub relay_antennas: Option<String>,\n+ pub phone_client_antennas: Option<String>,\npub mailing_address: Option<String>,\npub physical_address: String,\npub equipment_details: String,\n@@ -24,6 +23,8 @@ pub struct InstallationDetailsPost {\npub fn set_installation_details(req: Json<InstallationDetailsPost>) -> HttpResponse {\nlet input = req.into_inner();\n+ trace!(\"Setting install details with {:?}\", input);\n+\nlet mut exit_client = SETTING.get_exit_client_mut();\nlet contact_details = match (input.phone, input.email) {\n(None, None) => return HttpResponse::BadRequest().finish(),\n@@ -43,6 +44,41 @@ pub fn set_installation_details(req: Json<InstallationDetailsPost>) -> HttpRespo\nErr(_e) => return HttpResponse::BadRequest().finish(),\n},\n};\n+ // this lets us do less formatting on the frontend and simply\n+ // take a common separated string and parse it into the correct\n+ // values\n+ let mut parsed_relay_antenna_ips = Vec::new();\n+ let mut parsed_phone_client_anntenna_ips = Vec::new();\n+ if let Some(val) = input.relay_antennas {\n+ for ip_str in val.split(',') {\n+ if let Ok(ip) = ip_str.parse() {\n+ parsed_relay_antenna_ips.push(ip);\n+ } else {\n+ trace!(\"false to parse {}\", ip_str);\n+ // it's permissible to have nothing but it's not permissable to have improperly\n+ // formatted data\n+ return HttpResponse::BadRequest().finish();\n+ }\n+ }\n+ }\n+ if let Some(val) = input.phone_client_antennas {\n+ for ip_str in val.split(',') {\n+ if let Ok(ip) = ip_str.parse() {\n+ parsed_phone_client_anntenna_ips.push(ip);\n+ } else {\n+ trace!(\"false to parse {}\", ip_str);\n+ return HttpResponse::BadRequest().finish();\n+ }\n+ }\n+ }\n+ let parsed_client_antenna_ip = match input.client_antenna_ip {\n+ Some(ip_str) => match ip_str.parse() {\n+ Ok(ip) => Some(ip),\n+ Err(_e) => return HttpResponse::BadRequest().finish(),\n+ },\n+ None => None,\n+ };\n+\n// update the contact info, we display this as part of the forum but it's\n// stored separately since it's used elsewhere and sent to the operator tools\n// on it's own.\n@@ -50,17 +86,25 @@ pub fn set_installation_details(req: Json<InstallationDetailsPost>) -> HttpRespo\ndrop(exit_client);\nlet new_installation_details = InstallationDetails {\n- client_antenna_ip: input.client_antenna_ip,\n- relay_antennas: input.relay_antennas,\n- phone_client_antennas: input.phone_client_antennas,\n+ client_antenna_ip: parsed_client_antenna_ip,\n+ relay_antennas: parsed_relay_antenna_ips,\n+ phone_client_antennas: parsed_phone_client_anntenna_ips,\nmailing_address: input.mailing_address,\nphysical_address: input.physical_address,\nequipment_details: input.equipment_details,\n- install_date: SystemTime::now(),\n+ install_date: None,\n};\nlet mut operator_settings = SETTING.get_operator_mut();\noperator_settings.installation_details = Some(new_installation_details);\n+ operator_settings.display_operator_setup = false;\n+\n+ drop(operator_settings);\n+\n+ // try and save the config and fail if we can't\n+ if let Err(_e) = SETTING.write().unwrap().write(&ARGS.flag_config) {\n+ return HttpResponse::InternalServerError().finish();\n+ }\nHttpResponse::Ok().finish()\n}\n@@ -74,6 +118,15 @@ pub fn display_operator_setup(_req: HttpRequest) -> HttpResponse {\n}\npub fn set_display_operator_setup(val: Path<bool>) -> HttpResponse {\n+ // scoped so that this value gets dropped before we get to save, preventing\n+ // deadlock\n+ {\nSETTING.get_operator_mut().display_operator_setup = val.into_inner();\n+ }\n+\n+ // try and save the config and fail if we can't\n+ if let Err(_e) = SETTING.write().unwrap().write(&ARGS.flag_config) {\n+ return HttpResponse::InternalServerError().finish();\n+ }\nHttpResponse::Ok().finish()\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/operator_update/mod.rs",
"new_path": "rita/src/rita_client/operator_update/mod.rs",
"diff": "@@ -93,6 +93,7 @@ fn checkin() {\nlet id = SETTING.get_identity().unwrap();\nlet contact_info = option_convert(SETTING.get_exit_client().contact_info.clone());\n+ let install_details = operator_settings.installation_details.clone();\ndrop(operator_settings);\n@@ -138,6 +139,7 @@ fn checkin() {\nneighbor_info: Some(neighbor_info),\ncontact_details: None,\ncontact_info,\n+ install_details,\nhardware_info,\n})\n.unwrap()\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Finish up installer details collection
This contains all the final tweaks for installer details collection to
work properly. Including better parsing logic and testing and actually
submitting these details to the operator tools dashboard. |
20,244 | 29.05.2020 09:19:40 | 14,400 | eda020788dc64d1666318a6bbd38c64751c00a67 | Bump for Beta 14 RC4 | [
{
"change_type": "MODIFY",
"old_path": "rita/Cargo.toml",
"new_path": "rita/Cargo.toml",
"diff": "[package]\nname = \"rita\"\n-version = \"0.5.49\"\n+version = \"0.5.50\"\nauthors = [\"Justin <justin@althea.net>\", \"Jehan <jehan.tremback@gmail.com>\", \"Ben <wangben3@gmail.com>\"]\nbuild = \"build.rs\"\nedition = \"2018\"\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/dashboard/own_info.rs",
"new_path": "rita/src/rita_common/dashboard/own_info.rs",
"diff": "@@ -6,7 +6,7 @@ use failure::Error;\nuse num256::{Int256, Uint256};\nuse settings::RitaCommonSettings;\n-pub static READABLE_VERSION: &str = \"Beta 14 RC3\";\n+pub static READABLE_VERSION: &str = \"Beta 14 RC4\";\n#[derive(Serialize)]\npub struct OwnInfo {\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Bump for Beta 14 RC4 |
20,244 | 29.05.2020 14:59:57 | 14,400 | f9da202e461540aa83064eb1073fc4c8dc3a0830 | Add username to Installation details | [
{
"change_type": "MODIFY",
"old_path": "althea_types/src/interop.rs",
"new_path": "althea_types/src/interop.rs",
"diff": "@@ -574,6 +574,8 @@ pub struct NeighborStatus {\n/// question is if we want to delete it or manage it somehow.\n#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]\npub struct InstallationDetails {\n+ /// The users name\n+ pub user_name: String,\n/// The CPE ip of this client. This field seems straightforward but actually\n/// has quite a bit of optionality. What if the user is connected via l2 bridge\n/// (for example a cable, or fiber) in that case this could be None. If the client\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/installation_details.rs",
"new_path": "rita/src/rita_client/dashboard/installation_details.rs",
"diff": "@@ -11,6 +11,7 @@ use settings::{client::RitaClientSettings, FileWrite};\n/// rather than relying on serde to get it right.\n#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]\npub struct InstallationDetailsPost {\n+ pub user_name: String,\npub phone: Option<String>,\npub email: Option<String>,\npub client_antenna_ip: Option<String>,\n@@ -86,6 +87,7 @@ pub fn set_installation_details(req: Json<InstallationDetailsPost>) -> HttpRespo\ndrop(exit_client);\nlet new_installation_details = InstallationDetails {\n+ user_name: input.user_name,\nclient_antenna_ip: parsed_client_antenna_ip,\nrelay_antennas: parsed_relay_antenna_ips,\nphone_client_antennas: parsed_phone_client_anntenna_ips,\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Add username to Installation details |
20,244 | 29.05.2020 15:12:05 | 14,400 | 8be0bab8a6924b2a8467a5d49ef9688d38c29272 | Upgrade Bytes and Handlebars, remove exits url sync
Decided it was worth the crate update over a feature that's not used | [
{
"change_type": "MODIFY",
"old_path": "Cargo.lock",
"new_path": "Cargo.lock",
"diff": "@@ -1230,27 +1230,16 @@ dependencies = [\n[[package]]\nname = \"handlebars\"\n-version = \"2.0.4\"\n+version = \"3.0.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"af92141a22acceb515fb6b13ac59d6d0b3dd3437e13832573af8e0d3247f29d5\"\n+checksum = \"ba758d094d31274eb49d15da6f326b96bf3185239a6359bf684f3d5321148900\"\ndependencies = [\n- \"hashbrown\",\n\"log\",\n\"pest\",\n\"pest_derive\",\n\"quick-error\",\n\"serde 1.0.110\",\n\"serde_json\",\n- \"walkdir\",\n-]\n-\n-[[package]]\n-name = \"hashbrown\"\n-version = \"0.5.0\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353\"\n-dependencies = [\n- \"serde 1.0.110\",\n]\n[[package]]\n@@ -1809,9 +1798,9 @@ dependencies = [\n[[package]]\nname = \"mockito\"\n-version = \"0.23.3\"\n+version = \"0.25.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"ae82e6bad452dd42b0f4437414eae3c8c27b958a55dc6c198e351042c4e3024e\"\n+checksum = \"03dbb09048f444da040f95049763815e4352c9dcb49e4250f7ff2c6853e595dc\"\ndependencies = [\n\"assert-json-diff\",\n\"colored\",\n@@ -2677,7 +2666,7 @@ dependencies = [\n[[package]]\nname = \"rita\"\n-version = \"0.5.49\"\n+version = \"0.5.50\"\ndependencies = [\n\"actix\",\n\"actix-web\",\n@@ -2690,7 +2679,7 @@ dependencies = [\n\"auto-bridge\",\n\"babel_monitor\",\n\"byteorder\",\n- \"bytes 0.4.12\",\n+ \"bytes 0.5.4\",\n\"clarity\",\n\"clu\",\n\"compressed_log\",\n@@ -2795,15 +2784,6 @@ version = \"0.3.3\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072\"\n-[[package]]\n-name = \"same-file\"\n-version = \"1.0.6\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502\"\n-dependencies = [\n- \"winapi-util\",\n-]\n-\n[[package]]\nname = \"schannel\"\nversion = \"0.1.19\"\n@@ -3702,17 +3682,6 @@ version = \"0.9.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed\"\n-[[package]]\n-name = \"walkdir\"\n-version = \"2.3.1\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d\"\n-dependencies = [\n- \"same-file\",\n- \"winapi 0.3.8\",\n- \"winapi-util\",\n-]\n-\n[[package]]\nname = \"want\"\nversion = \"0.3.0\"\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/Cargo.toml",
"new_path": "rita/Cargo.toml",
"diff": "@@ -30,7 +30,7 @@ web30 = {git = \"https://github.com/althea-net/web30\", branch = \"master\"}\nactix = \"0.7\"\nactix-web = { version = \"0.7\", default_features = false, features= [\"ssl\"] }\nactix_derive = \"0.5\"\n-bytes = \"0.4\"\n+bytes = \"0.5\"\nconfig = \"0.10\"\ndiesel = { version = \"1.4\", features = [\"postgres\", \"r2d2\"] }\ndocopt = \"1.1\"\n@@ -39,12 +39,12 @@ env_logger = \"0.7\"\nfailure = \"0.1\"\nfutures01 = { package = \"futures\", version = \"0.1\"}\nfutures = { version = \"0.3\", features = [\"compat\"] }\n-handlebars = \"2.0\"\n+handlebars = \"3.0\"\nipnetwork = \"0.14\"\nlazy_static = \"1.4\"\nlog = { version = \"0.4\", features = [\"release_max_level_info\"] }\nminihttpse = \"0.1\"\n-mockito = \"0.23\"\n+mockito = \"0.25\"\nmockstream = \"0.0\"\nrand = \"0.7\"\nserde = \"1.0\"\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/client.rs",
"new_path": "rita/src/client.rs",
"diff": "@@ -292,7 +292,6 @@ fn start_client_dashboard() {\n.route(\"/operator_debt\", Method::GET, get_operator_debt)\n.route(\"/debts\", Method::GET, get_debts)\n.route(\"/debts/reset\", Method::POST, reset_debt)\n- .route(\"/exits/sync\", Method::POST, exits_sync)\n.route(\"/exits\", Method::GET, get_exit_info)\n.route(\"/exits\", Method::POST, add_exits)\n.route(\"/exits/{name}/register\", Method::POST, register_to_exit)\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/exits.rs",
"new_path": "rita/src/rita_client/dashboard/exits.rs",
"diff": "@@ -6,11 +6,8 @@ use crate::ARGS;\nuse crate::KI;\nuse crate::SETTING;\nuse actix::{Handler, Message, ResponseFuture, SystemService};\n-use actix_web::client;\n-use actix_web::error::PayloadError;\nuse actix_web::http::StatusCode;\nuse actix_web::AsyncResponder;\n-use actix_web::HttpMessage;\nuse actix_web::Path;\nuse actix_web::{HttpRequest, HttpResponse, Json};\nuse althea_types::ExitState;\n@@ -18,7 +15,6 @@ use babel_monitor::do_we_have_route;\nuse babel_monitor::open_babel_stream;\nuse babel_monitor::parse_routes;\nuse babel_monitor::start_connection;\n-use bytes::Bytes;\nuse failure::Error;\nuse futures01::{future, Future};\nuse settings::client::{ExitServer, RitaClientSettings};\n@@ -132,117 +128,6 @@ pub fn add_exits(\nBox::new(future::ok(HttpResponse::Ok().json(exits.clone())))\n}\n-pub fn exits_sync(\n- list_url_json: Json<HashMap<String, String>>,\n-) -> Box<dyn Future<Item = HttpResponse, Error = Error>> {\n- debug!(\"/exits/sync hit with {:?}\", list_url_json);\n-\n- let list_url = match list_url_json.get(\"url\") {\n- Some(url) if url.starts_with(\"https://\") => url,\n- Some(_unsafe_url) => {\n- let mut ret = HashMap::new();\n- ret.insert(\n- \"error\".to_owned(),\n- \"Attempted to use a non-HTTPS url\".to_owned(),\n- );\n- return Box::new(future::ok(\n- HttpResponse::new(StatusCode::BAD_REQUEST)\n- .into_builder()\n- .json(ret),\n- ));\n- }\n- None => {\n- let mut ret = HashMap::new();\n-\n- ret.insert(\n- \"error\".to_owned(),\n- \"Could not find a \\\"url\\\" key in supplied JSON\".to_owned(),\n- );\n- return Box::new(future::ok(\n- HttpResponse::new(StatusCode::BAD_REQUEST)\n- .into_builder()\n- .json(ret),\n- ));\n- }\n- }\n- .to_string();\n-\n- let res = client::get(list_url.clone())\n- .header(\"User-Agent\", \"Actix-web\")\n- .finish()\n- .unwrap()\n- .send()\n- .from_err()\n- .and_then(move |response| {\n- response\n- .body()\n- .then(move |message_body: Result<Bytes, PayloadError>| {\n- if let Err(e) = message_body {\n- return Box::new(future::ok(\n- HttpResponse::new(StatusCode::INTERNAL_SERVER_ERROR)\n- .into_builder()\n- .json(format!(\"Actix encountered a payload error {:?}\", e)),\n- ));\n- }\n- let message_body = message_body.unwrap();\n-\n- // .json() only works on application/json content types unlike reqwest which handles bytes\n- // transparently actix requests need to get the body and deserialize using serde_json in\n- // an explicit fashion\n- match serde_json::from_slice::<HashMap<String, ExitServer>>(&message_body) {\n- Ok(mut new_exits) => {\n- info!(\"exit_sync list: {:#?}\", new_exits);\n-\n- let mut exit_client = SETTING.get_exit_client_mut();\n-\n- // if the entry already exists copy the registration info over\n- for new_exit in new_exits.iter_mut() {\n- let nick = new_exit.0;\n- let new_settings = new_exit.1;\n- if let Some(old_exit) = exit_client.exits.get(nick) {\n- new_settings.info = old_exit.info.clone();\n- }\n- }\n- exit_client.exits.extend(new_exits);\n- let exits = exit_client.exits.clone();\n- drop(exit_client);\n-\n- // try and save the config and fail if we can't\n- if let Err(e) = SETTING.write().unwrap().write(&ARGS.flag_config) {\n- trace!(\"Failed to write settings\");\n- return Box::new(future::err(e));\n- }\n-\n- Box::new(future::ok(HttpResponse::Ok().json(exits)))\n- }\n- Err(e) => {\n- let mut ret = HashMap::<String, String>::new();\n-\n- error!(\n- \"Could not deserialize exit list at {:?} because of error: {:?}\",\n- list_url, e\n- );\n- ret.insert(\n- \"error\".to_owned(),\n- format!(\n- \"Could not deserialize exit list at URL {:?} because of error {:?}\",\n- list_url, e\n- ),\n- );\n-\n- Box::new(future::ok(\n- HttpResponse::new(StatusCode::BAD_REQUEST)\n- .into_builder()\n- .json(ret),\n- ))\n- }\n- }\n- })\n- });\n-\n- Box::new(res)\n-}\n-\npub fn get_exit_info(\n_req: HttpRequest,\n) -> Box<dyn Future<Item = Json<Vec<ExitInfo>>, Error = Error>> {\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/peer_listener/message.rs",
"new_path": "rita/src/rita_common/peer_listener/message.rs",
"diff": "@@ -64,7 +64,7 @@ impl PeerMessage {\nmatch *self {\nPeerMessage::ImHere(addr) => {\nbuf.put_u8(MSG_IM_HERE);\n- buf.put_u16_be(MSG_IM_HERE_LEN);\n+ buf.put_u16(MSG_IM_HERE_LEN);\nlet ipaddr_bytes: [u8; 16] = addr.octets();\nfor i in ipaddr_bytes.iter() {\nbuf.put_u8(*i);\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Upgrade Bytes and Handlebars, remove exits url sync
Decided it was worth the crate update over a feature that's not used |
20,244 | 29.05.2020 15:13:29 | 14,400 | 9e12ff0c347ce8c4303c993ea6ac6ec5c37ce489 | Upgrade base64 dep | [
{
"change_type": "MODIFY",
"old_path": "Cargo.lock",
"new_path": "Cargo.lock",
"diff": "@@ -182,7 +182,7 @@ dependencies = [\n\"actix\",\n\"arrayvec 0.5.1\",\n\"babel_monitor\",\n- \"base64 0.11.0\",\n+ \"base64 0.12.1\",\n\"clarity\",\n\"failure\",\n\"hex\",\n@@ -389,6 +389,12 @@ version = \"0.11.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7\"\n+[[package]]\n+name = \"base64\"\n+version = \"0.12.1\"\n+source = \"registry+https://github.com/rust-lang/crates.io-index\"\n+checksum = \"53d1ccbaf7d9ec9537465a97bf19edc1a4e158ecb49fc16178202238c569cc42\"\n+\n[[package]]\nname = \"bincode\"\nversion = \"1.2.1\"\n"
},
{
"change_type": "MODIFY",
"old_path": "althea_types/Cargo.toml",
"new_path": "althea_types/Cargo.toml",
"diff": "@@ -9,7 +9,7 @@ license = \"Apache-2.0\"\n[dependencies]\nbabel_monitor = { path = \"../babel_monitor\" }\nnum256 = \"0.2\"\n-base64 = \"0.11\"\n+base64 = \"0.12\"\nserde_derive = \"1.0\"\nserde = \"1.0\"\nserde_json = \"1.0\"\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Upgrade base64 dep |
20,244 | 01.06.2020 18:00:26 | 14,400 | b0adbe40db3022bf8d421bee5789324102031aaa | Don't display operator setup forum on upgrade | [
{
"change_type": "MODIFY",
"old_path": "settings/src/operator.rs",
"new_path": "settings/src/operator.rs",
"diff": "@@ -20,8 +20,14 @@ fn default_use_operator_price() -> bool {\n}\n/// If we are displaying the operator setup card on the front page or not\n+/// this is false by default but set to true using the config template in\n+/// the firmware builder. The reasoning for this is that when we upgrade\n+/// older routers we don't want this form to suddenly show up, we want to\n+/// show it only for new routers being setup. Once everyone is upgraded\n+/// having this starting value be true will have the same affect but that's\n+/// not until Beta 15 at least\nfn default_display_operator_setup() -> bool {\n- true\n+ false\n}\n/// If the operator has indicated that users should not be able to change\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Don't display operator setup forum on upgrade |
20,244 | 01.06.2020 18:01:17 | 14,400 | 509f494e1496585ca3fbf5876b9153c9f09abf96 | Bump for Beta 14 RC5 | [
{
"change_type": "MODIFY",
"old_path": "Cargo.lock",
"new_path": "Cargo.lock",
"diff": "@@ -2672,7 +2672,7 @@ dependencies = [\n[[package]]\nname = \"rita\"\n-version = \"0.5.50\"\n+version = \"0.5.51\"\ndependencies = [\n\"actix\",\n\"actix-web\",\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/Cargo.toml",
"new_path": "rita/Cargo.toml",
"diff": "[package]\nname = \"rita\"\n-version = \"0.5.50\"\n+version = \"0.5.51\"\nauthors = [\"Justin <justin@althea.net>\", \"Jehan <jehan.tremback@gmail.com>\", \"Ben <wangben3@gmail.com>\"]\nbuild = \"build.rs\"\nedition = \"2018\"\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/dashboard/own_info.rs",
"new_path": "rita/src/rita_common/dashboard/own_info.rs",
"diff": "@@ -6,7 +6,7 @@ use failure::Error;\nuse num256::{Int256, Uint256};\nuse settings::RitaCommonSettings;\n-pub static READABLE_VERSION: &str = \"Beta 14 RC4\";\n+pub static READABLE_VERSION: &str = \"Beta 14 RC5\";\n#[derive(Serialize)]\npub struct OwnInfo {\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Bump for Beta 14 RC5 |
20,244 | 03.06.2020 15:03:30 | 14,400 | c316ab27bd13e70b41f6b7b961a31437277fbaed | Don't pass available memory as allocated memory
Stupid error here. Forgot to convert from free memory into
allocated memory. | [
{
"change_type": "MODIFY",
"old_path": "althea_kernel_interface/src/hardware_info.rs",
"new_path": "althea_kernel_interface/src/hardware_info.rs",
"diff": "@@ -25,6 +25,10 @@ pub fn get_hardware_info(device_name: Option<String>) -> Result<HardwareInfo, Er\nOk(readings) => Some(readings),\nErr(_e) => None,\n};\n+ let allocated_memory = match mem_total.checked_sub(mem_free) {\n+ Some(val) => val,\n+ None => return Err(format_err!(\"Failed to get accurate memory numbers\")),\n+ };\nOk(HardwareInfo {\nlogical_processors: num_cpus,\n@@ -32,7 +36,7 @@ pub fn get_hardware_info(device_name: Option<String>) -> Result<HardwareInfo, Er\nload_avg_five_minute: five_minute_load_avg,\nload_avg_fifteen_minute: fifteen_minute_load_avg,\nsystem_memory: mem_total,\n- allocated_memory: mem_free,\n+ allocated_memory,\nmodel,\nsensor_readings,\n})\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Don't pass available memory as allocated memory
Stupid error here. Forgot to convert from free memory into
allocated memory. |
20,244 | 04.06.2020 13:45:25 | 14,400 | d08207b557bddd2a534decb159c5ec68f71dca33 | Remove auto_register
It's abandoned and not actually used to do anything | [
{
"change_type": "MODIFY",
"old_path": "althea_types/src/interop.rs",
"new_path": "althea_types/src/interop.rs",
"diff": "@@ -157,9 +157,6 @@ pub enum ExitState {\nGotInfo {\ngeneral_details: ExitDetails,\nmessage: String,\n-\n- #[serde(default)]\n- auto_register: bool,\n},\nRegistering {\ngeneral_details: ExitDetails,\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/exit_manager/mod.rs",
"new_path": "rita/src/rita_client/exit_manager/mod.rs",
"diff": "@@ -534,12 +534,7 @@ impl Handler<Tick> for ExitManager {\nfor (k, s) in servers {\nmatch s.info {\n- ExitState::Denied { .. }\n- | ExitState::Disabled\n- | ExitState::GotInfo {\n- auto_register: false,\n- ..\n- } => {}\n+ ExitState::Denied { .. } | ExitState::Disabled | ExitState::GotInfo { .. } => {}\nExitState::New { .. } => {\nfuts.push(Box::new(exit_general_details_request(k.clone()).then(\nmove |res| {\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_exit/database/email.rs",
"new_path": "rita/src/rita_exit/database/email.rs",
"diff": "@@ -101,7 +101,6 @@ pub fn handle_email_registration(\n\"Wait {} more seconds for verification cooldown\",\ncooldown - time_since_last_email\n),\n- auto_register: true,\n})\n} else {\nmatch update_mail_sent_time(&client, &conn) {\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_exit/network_endpoints/mod.rs",
"new_path": "rita/src/rita_exit/network_endpoints/mod.rs",
"diff": "@@ -223,7 +223,6 @@ pub fn get_exit_info_http(_req: HttpRequest) -> Result<Json<ExitState>, Error> {\nOk(Json(ExitState::GotInfo {\ngeneral_details: get_exit_info(),\nmessage: \"Got info successfully\".to_string(),\n- auto_register: false,\n}))\n}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Remove auto_register
It's abandoned and not actually used to do anything |
20,244 | 04.06.2020 13:47:33 | 14,400 | 98b42cef4ba375f183c7c10400509f584b606a49 | Allow New -> Registered Client Exit state transition | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/exit_manager/mod.rs",
"new_path": "rita/src/rita_client/exit_manager/mod.rs",
"diff": "@@ -242,13 +242,6 @@ fn exit_general_details_request(exit: String) -> impl Future<Item = (), Error =\nNone => bail!(\"Could not find exit {}\", exit),\n};\n- match exit_details {\n- ExitState::GotInfo { .. } => {\n- trace!(\"Got exit info response {:?}\", exit_details);\n- }\n- _ => bail!(\"got incorrect state from exit details request\"),\n- }\n-\ncurrent_exit.info = exit_details;\nOk(())\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Allow New -> Registered Client Exit state transition |
20,244 | 04.06.2020 17:28:22 | 14,400 | da84b0dc2110e5cbbc6391c737b251d8047f3b6b | Add from_str for OperatorAction | [
{
"change_type": "MODIFY",
"old_path": "althea_types/src/interop.rs",
"new_path": "althea_types/src/interop.rs",
"diff": "@@ -375,6 +375,23 @@ pub enum OperatorAction {\nReboot,\n}\n+impl FromStr for OperatorAction {\n+ type Err = Error;\n+ fn from_str(s: &str) -> Result<OperatorAction, Error> {\n+ match s {\n+ \"ResetRouterPassword\" => Ok(OperatorAction::ResetRouterPassword),\n+ \"ResetWiFiPassword\" => Ok(OperatorAction::ResetWiFiPassword),\n+ \"ResetShaper\" => Ok(OperatorAction::ResetShaper),\n+ \"Reboot\" => Ok(OperatorAction::Reboot),\n+ \"resetrouterpassword\" => Ok(OperatorAction::ResetRouterPassword),\n+ \"resetwifipassword\" => Ok(OperatorAction::ResetWiFiPassword),\n+ \"resetshaper\" => Ok(OperatorAction::ResetShaper),\n+ \"reboot\" => Ok(OperatorAction::Reboot),\n+ _ => Err(format_err!(\"Invalid Operator Action\")),\n+ }\n+ }\n+}\n+\n/// Operator update that we get from the operator server during our checkin\n#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct OperatorUpdateMessage {\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Add from_str for OperatorAction |
20,244 | 05.06.2020 08:46:26 | 14,400 | 94eaae6a2410e73d918c8b3c8849b5780f935313 | Add upgrade path todo in Rita exit | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_exit/database/database_tools.rs",
"new_path": "rita/src/rita_exit/database/database_tools.rs",
"diff": "@@ -132,6 +132,10 @@ pub fn get_client(\nlet filtered_list = clients\n.filter(mesh_ip.eq(ip.to_string()))\n.filter(wg_pubkey.eq(wg.to_string()))\n+ // TODO search for EIP-55 capitalized key string and add a fallback\n+ // to upgrade entires that are using the old all lowercase format. This should\n+ // simplify the code some and reduce calls to .to_lowercase and worst of all the chance\n+ // that we might forget a lowercase call, which type-checking can't protect us from.\n.filter(eth_address.eq(key.to_string().to_lowercase()));\nmatch filtered_list.load::<models::Client>(conn) {\nOk(entry) => {\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Add upgrade path todo in Rita exit |
20,244 | 05.06.2020 10:53:57 | 14,400 | f0271e31f36e9a3efabbe2c9db10d50af8fe10c7 | Print support number in national format
If people are having such trouble with international numbers
for Wyre then I would presume they would have similar trouble with
calling an international number for help | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/localization.rs",
"new_path": "rita/src/rita_client/dashboard/localization.rs",
"diff": "use crate::SETTING;\nuse actix_web::{HttpRequest, Json};\n+use phonenumber::Mode;\nuse settings::{localization::LocalizationSettings, RitaCommonSettings};\n/// A version of the localization struct that serializes into a more easily\n@@ -18,7 +19,11 @@ impl From<LocalizationSettings> for LocalizationReturn {\nwyre_enabled: input.wyre_enabled,\nwyre_account_id: input.wyre_account_id,\ndisplay_currency_symbol: input.display_currency_symbol,\n- support_number: input.support_number.to_string(),\n+ support_number: input\n+ .support_number\n+ .format()\n+ .mode(Mode::National)\n+ .to_string(),\n}\n}\n}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Print support number in national format
If people are having such trouble with international numbers
for Wyre then I would presume they would have similar trouble with
calling an international number for help |
20,244 | 05.06.2020 10:55:33 | 14,400 | 745094ccc95fe531c10edbe8307d1e3343f9d2b0 | Bump for Beta 14 RC6 | [
{
"change_type": "MODIFY",
"old_path": "Cargo.lock",
"new_path": "Cargo.lock",
"diff": "@@ -2672,7 +2672,7 @@ dependencies = [\n[[package]]\nname = \"rita\"\n-version = \"0.5.51\"\n+version = \"0.5.52\"\ndependencies = [\n\"actix\",\n\"actix-web\",\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/Cargo.toml",
"new_path": "rita/Cargo.toml",
"diff": "[package]\nname = \"rita\"\n-version = \"0.5.51\"\n+version = \"0.5.52\"\nauthors = [\"Justin <justin@althea.net>\", \"Jehan <jehan.tremback@gmail.com>\", \"Ben <wangben3@gmail.com>\"]\nbuild = \"build.rs\"\nedition = \"2018\"\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/dashboard/own_info.rs",
"new_path": "rita/src/rita_common/dashboard/own_info.rs",
"diff": "@@ -6,7 +6,7 @@ use failure::Error;\nuse num256::{Int256, Uint256};\nuse settings::RitaCommonSettings;\n-pub static READABLE_VERSION: &str = \"Beta 14 RC5\";\n+pub static READABLE_VERSION: &str = \"Beta 14 RC6\";\n#[derive(Serialize)]\npub struct OwnInfo {\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Bump for Beta 14 RC6 |
20,244 | 05.06.2020 13:39:58 | 14,400 | 8816c7276f21590bfefd33caac65f30c6a88187c | Remove unneeded braces
new version of rust has deemed these as un-needed | [
{
"change_type": "MODIFY",
"old_path": "rita/src/client.rs",
"new_path": "rita/src/client.rs",
"diff": "@@ -172,7 +172,7 @@ lazy_static! {\n#[cfg(test)]\nlazy_static! {\npub static ref SETTING: Arc<RwLock<RitaSettingsStruct>> =\n- { Arc::new(RwLock::new(RitaSettingsStruct::default())) };\n+ Arc::new(RwLock::new(RitaSettingsStruct::default()));\n}\nfn env_vars_contains(var_name: &str) -> bool {\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/exit.rs",
"new_path": "rita/src/exit.rs",
"diff": "@@ -205,7 +205,7 @@ lazy_static! {\n#[cfg(test)]\nlazy_static! {\npub static ref SETTING: Arc<RwLock<RitaExitSettingsStruct>> =\n- { Arc::new(RwLock::new(RitaExitSettingsStruct::test_default())) };\n+ Arc::new(RwLock::new(RitaExitSettingsStruct::test_default()));\n}\n/// used to crash the exit on first startup if config does not make sense\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/operator_update/mod.rs",
"new_path": "rita/src/rita_client/operator_update/mod.rs",
"diff": "@@ -122,7 +122,7 @@ fn checkin() {\n});\n}\n- let hardware_info = match get_hardware_info({ SETTING.get_network().device.clone() }) {\n+ let hardware_info = match get_hardware_info(SETTING.get_network().device.clone()) {\nOk(info) => Some(info),\nErr(e) => {\nerror!(\"Failed to get hardware info with {:?}\", e);\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Remove unneeded braces
new version of rust has deemed these as un-needed |
20,244 | 05.06.2020 14:18:08 | 14,400 | 7fd4196238e9ae955f409c01d56c06ca62c57849 | Add phone network port toggling
This allows users to attach phone network extenders using the normal port
toggling interface.
These extenders must be configured in bridge mode so that they simply pass
traffic to the phone client network bridge. | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/interfaces.rs",
"new_path": "rita/src/rita_client/dashboard/interfaces.rs",
"diff": "@@ -21,17 +21,36 @@ pub struct InterfaceToSet {\n#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Copy)]\npub enum InterfaceMode {\n+ /// 'Mesh' mode essentially defines a port where Rita is attached and performing\n+ /// it's own hello/ImHere protocol as defined in PeerListener. These ports are just\n+ /// setup as static in the OpenWRT config and so long as SLACC IPv6 linklocal auto\n+ /// negotiation is on Rita takes it from there. Some key caveats is that a port\n+ /// may not be 'mesh' (eg: defined in Rita's peer_interfaces var) and also configured\n+ /// as a WAN port.\nMesh,\n+ /// LAN port is essentially defined as any port attached to the br-lan bridge. The br-lan\n+ /// bridge then provides DHCP. Finally Rita comes in and places a default route though the\n+ /// exit server so that users can actually reach the internet.\nLAN,\n+ /// WAN port, specifically means that this device is listening for DHCP (instead of providing DHCP\n+ /// like on LAN). This route will be accepted and installed. Keep in mind if a WAN port is set this\n+ /// device will count itself as a 'gateway' regardless of if there is actual activity on the port.\n+ /// Example effects of a device being defined as a 'gateway' include making DHCP requests for manual_peers\n+ /// in tunnel_manager and taking the gateway price in operator_update\nWAN,\n- /// StaticWAN is used to set interfaces but once set isn't\n- /// seen as any different than WAN elsewhere in the system\n+ /// Same as WAN but configures a static IP for this device.\nStaticWAN {\nnetmask: Ipv4Addr,\nipaddr: Ipv4Addr,\ngateway: Ipv4Addr,\n},\n- Unknown, // Ambiguous wireless modes like monitor or promiscuous\n+ /// This represents a port dedicated to phone network extending antennas. This is an extension of the\n+ /// AltheaMobile SSID and can be boiled down to attaching the port to br-pbs over which devices will\n+ /// then be assigned phone network DHCP and IPs\n+ Phone,\n+ /// Ambiguous wireless modes like monitor, or promiscuous show up here, but other things that might also\n+ /// be unknown are various forms of malformed configs. Take for example a StaticWAN missing a config param\n+ Unknown,\n}\nimpl ToString for InterfaceMode {\n@@ -41,6 +60,7 @@ impl ToString for InterfaceMode {\nInterfaceMode::LAN => \"LAN\".to_owned(),\nInterfaceMode::WAN => \"WAN\".to_owned(),\nInterfaceMode::StaticWAN { .. } => \"StaticWAN\".to_owned(),\n+ InterfaceMode::Phone => \"Phone\".to_owned(),\nInterfaceMode::Unknown => \"unknown\".to_owned(),\n}\n}\n@@ -53,20 +73,22 @@ pub fn get_interfaces() -> Result<HashMap<String, InterfaceMode>, Error> {\n// Wired\nfor (setting_name, value) in KI.uci_show(Some(\"network\"))? {\n// Only non-loopback non-bridge interface names should get past\n- if setting_name.contains(\"ifname\")\n- && !value.contains(\"backhaul\")\n- && value != \"lo\"\n- && !value.contains(\"pbs-wlan\")\n- {\n+ if setting_name.contains(\"ifname\") && !value.contains(\"backhaul\") && value != \"lo\" {\n// it's a list and we need to handle that\nif value.contains(' ') {\nfor list_member in value.split(' ') {\n+ if list_member.contains(\"pbs-wlan\") {\n+ continue;\n+ }\nretval.insert(\nlist_member.replace(\" \", \"\").to_string(),\nethernet2mode(&value, &setting_name)?,\n);\n}\n} else {\n+ if value.contains(\"pbs-wlan\") {\n+ continue;\n+ }\nretval.insert(value.clone(), ethernet2mode(&value, &setting_name)?);\n}\n}\n@@ -87,6 +109,7 @@ pub fn ethernet2mode(ifname: &str, setting_name: &str) -> Result<InterfaceMode,\nOk(match &setting_name.replace(\".ifname\", \"\") {\ns if s.contains(\"rita_\") => InterfaceMode::Mesh,\ns if s.contains(\"lan\") => InterfaceMode::LAN,\n+ s if s.contains(\"pbs\") => InterfaceMode::Phone,\ns if s.contains(\"backhaul\") => {\nlet prefix = \"network.backhaul\";\nlet backhaul = KI.uci_show(Some(prefix))?;\n@@ -184,14 +207,23 @@ pub fn ethernet_transform_mode(\nlet ret = KI.del_uci_var(\"network.backhaul\");\nreturn_codes.push(ret);\n}\n- // lan is a little more complicated, wifi interfaces\n- // may depend on it so we only remove the ifname entry\n+ // LAN is a bridge and the lan bridge must always remain because things\n+ // like WiFi interfaces are attached to it. So we just remove the interface\n+ // from the list\nInterfaceMode::LAN => {\nlet list = KI.get_uci_var(\"network.lan.ifname\")?;\nlet new_list = list_remove(&list, ifname);\nlet ret = KI.set_uci_var(\"network.lan.ifname\", &new_list);\nreturn_codes.push(ret);\n}\n+ // just like LAN we are adding and removing a device from the list just this time\n+ // on pbs\n+ InterfaceMode::Phone => {\n+ let list = KI.get_uci_var(\"network.pbs.ifname\")?;\n+ let new_list = list_remove(&list, ifname);\n+ let ret = KI.set_uci_var(\"network.pbs.ifname\", &new_list);\n+ return_codes.push(ret);\n+ }\n// for mesh we need to send an unlisten so that Rita stops\n// listening then we can remove the section, we also need to remove it\n// from the config\n@@ -237,7 +269,7 @@ pub fn ethernet_transform_mode(\nlet ret = KI.set_uci_var(\"network.backhaul.gateway\", &format!(\"{}\", gateway));\nreturn_codes.push(ret);\n}\n- // since we left lan mostly unomidifed we just pop in the ifname\n+ // since we left lan mostly unmodified we just pop in the ifname\nInterfaceMode::LAN => {\ntrace!(\"Converting interface to lan with ifname {:?}\", ifname);\nlet ret = KI.get_uci_var(\"network.lan.ifname\");\n@@ -261,6 +293,29 @@ pub fn ethernet_transform_mode(\n}\n}\n}\n+ InterfaceMode::Phone => {\n+ trace!(\"Converting interface to Phone with ifname {:?}\", ifname);\n+ let ret = KI.get_uci_var(\"network.pbs.ifname\");\n+ match ret {\n+ Ok(list) => {\n+ trace!(\"The existing Phone interfaces list is {:?}\", list);\n+ let new_list = list_add(&list, &ifname);\n+ trace!(\"Setting the new list {:?}\", new_list);\n+ let ret = KI.set_uci_var(\"network.pbs.ifname\", &new_list);\n+ return_codes.push(ret);\n+ }\n+ Err(e) => {\n+ if e.to_string().contains(\"Entry not found\") {\n+ trace!(\"No Phone interfaces found, setting one now\");\n+ let ret = KI.set_uci_var(\"network.pbs.ifname\", &ifname);\n+ return_codes.push(ret);\n+ } else {\n+ warn!(\"Trying to read Phone ifname returned {:?}\", e);\n+ return_codes.push(Err(e));\n+ }\n+ }\n+ }\n+ }\nInterfaceMode::Mesh => {\nSETTING\n.get_network_mut()\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Add phone network port toggling
This allows users to attach phone network extenders using the normal port
toggling interface.
These extenders must be configured in bridge mode so that they simply pass
traffic to the phone client network bridge. |
20,244 | 07.06.2020 16:52:09 | 14,400 | 253822c951a08b8e2555868d17fb1281ecf99673 | Disable operator info when we detect an old dashboard edge case | [
{
"change_type": "MODIFY",
"old_path": "rita/src/client.rs",
"new_path": "rita/src/client.rs",
"diff": "@@ -203,7 +203,9 @@ fn wait_for_settings(settings_file: &str) -> RitaSettingsStruct {\n}\n}\n-pub fn migrate_contact_info() {\n+/// Migrates from the old contact details structure to the new one, returns true\n+/// if a migration has occurred.\n+pub fn migrate_contact_info() -> bool {\nlet mut exit_client = SETTING.get_exit_client_mut();\nlet reg_details = exit_client.reg_details.clone();\nif let Some(reg_details) = reg_details {\n@@ -212,8 +214,10 @@ pub fn migrate_contact_info() {\nif exit_client.contact_info.is_none() {\nlet contact_info: Option<ContactStorage> = ContactStorage::convert(reg_details);\nexit_client.contact_info = contact_info;\n+ return true;\n}\n}\n+ false\n}\nfn main() {\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/exits.rs",
"new_path": "rita/src/rita_client/dashboard/exits.rs",
"diff": "@@ -218,7 +218,7 @@ pub fn register_to_exit(path: Path<String>) -> Box<dyn Future<Item = HttpRespons\n// and without performing a migration. We could intercept that at the settings endpoint but it's easier\n// to just re-run the migration here and check to see if we have old style contact details set that we\n// have no already migrated.\n- migrate_contact_info();\n+ migrate_contact_info_and_hide_operator_info();\nBox::new(exit_setup_request(exit_name, None).then(|res| {\nlet mut ret = HashMap::new();\n@@ -245,7 +245,7 @@ pub fn verify_on_exit_with_code(\ndebug!(\"/exits/{}/verify/{} hit\", exit_name, code);\n// same as register_to_exit() but I'm actually 99% sure it's not actually needed here.\n- migrate_contact_info();\n+ migrate_contact_info_and_hide_operator_info();\nBox::new(exit_setup_request(exit_name, Some(code)).then(|res| {\nlet mut ret = HashMap::new();\n@@ -264,3 +264,16 @@ pub fn verify_on_exit_with_code(\n}\n}))\n}\n+\n+/// We need to do a migration in this file if and only if the user has used the\n+/// old dashboard to set their email or phone number since reboot. In that case\n+/// they probably have an old version of the dash cached and are not seeing the\n+/// new operator setup screen. Since we don't want the customer eventually seeing\n+/// it we should hide it\n+pub fn migrate_contact_info_and_hide_operator_info() {\n+ let res = migrate_contact_info();\n+ if res {\n+ let mut operator = SETTING.get_operator_mut();\n+ operator.display_operator_setup = false;\n+ }\n+}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Disable operator info when we detect an old dashboard edge case |
20,244 | 07.06.2020 17:01:02 | 14,400 | 962ac3c48d65750549d7a0957bb21c9b3d024346 | Fix Clippy nits
The borrow checker must have a new category of allowed borrows in this
version of Rust. | [
{
"change_type": "MODIFY",
"old_path": "althea_kernel_interface/src/exit_server_tunnel.rs",
"new_path": "althea_kernel_interface/src/exit_server_tunnel.rs",
"diff": "@@ -41,7 +41,7 @@ impl dyn KernelInterface {\nargs.push(\"persistent-keepalive\".into());\nargs.push(\"5\".into());\n- client_pubkeys.insert(c.public_key.clone());\n+ client_pubkeys.insert(c.public_key);\n}\nlet arg_str: Vec<&str> = args.iter().map(|s| s.as_str()).collect();\n"
},
{
"change_type": "MODIFY",
"old_path": "althea_kernel_interface/src/wg_iface_counter.rs",
"new_path": "althea_kernel_interface/src/wg_iface_counter.rs",
"diff": "@@ -38,7 +38,7 @@ pub fn prepare_usage_history<S: ::std::hash::BuildHasher>(\nwg_key,\nbytes\n);\n- usage_history.insert(wg_key.clone(), bytes.clone());\n+ usage_history.insert(*wg_key, *bytes);\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/exit_manager/mod.rs",
"new_path": "rita/src/rita_client/exit_manager/mod.rs",
"diff": "@@ -411,7 +411,7 @@ impl Handler<Tick> for ExitManager {\ntrace!(\"About to setup exit tunnel!\");\nif let Some(exit) = exit_server {\ntrace!(\"We have selected an exit!\");\n- if let Some(general_details) = exit.info.clone().general_details() {\n+ if let Some(general_details) = exit.info.general_details() {\ntrace!(\"We have details for the selected exit!\");\nlet signed_up_for_exit = exit.info.our_details().is_some();\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/debt_keeper/mod.rs",
"new_path": "rita/src/rita_common/debt_keeper/mod.rs",
"diff": "@@ -447,7 +447,7 @@ impl DebtKeeper {\nfn get_debt_data_mut(&mut self, ident: &Identity) -> &mut NodeDebtData {\nself.debt_data\n- .entry(ident.clone())\n+ .entry(*ident)\n.or_insert_with(NodeDebtData::new)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/payment_controller/mod.rs",
"new_path": "rita/src/rita_common/payment_controller/mod.rs",
"diff": "@@ -186,7 +186,7 @@ fn make_payment(mut pmt: PaymentTx) -> Result<(), Error> {\ntxid: tx_id,\ncontact_socket,\nneigh_url: neighbor_url,\n- pmt: pmt.clone(),\n+ pmt,\nattempt: 0u8,\n}));\nOk(())\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/tunnel_manager/mod.rs",
"new_path": "rita/src/rita_common/tunnel_manager/mod.rs",
"diff": "@@ -550,7 +550,7 @@ fn insert_into_tunnel_list(input: &Tunnel, tunnels_list: &mut HashMap<Identity,\nif tunnels_list.contains_key(identity) {\ntunnels_list.get_mut(identity).unwrap().push(input);\n} else {\n- tunnels_list.insert(identity.clone(), Vec::new());\n+ tunnels_list.insert(*identity, Vec::new());\ntunnels_list.get_mut(identity).unwrap().push(input);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_exit/traffic_watcher/mod.rs",
"new_path": "rita/src/rita_exit/traffic_watcher/mod.rs",
"diff": "@@ -114,7 +114,7 @@ fn generate_helper_maps(our_id: &Identity, clients: &[Identity]) -> Result<Helpe\nlet mut identities: HashMap<WgKey, Identity> = HashMap::new();\nlet mut id_from_ip: HashMap<IpAddr, Identity> = HashMap::new();\nlet our_settings = SETTING.get_network();\n- id_from_ip.insert(our_settings.mesh_ip.unwrap(), our_id.clone());\n+ id_from_ip.insert(our_settings.mesh_ip.unwrap(), *our_id);\nfor ident in clients.iter() {\nidentities.insert(ident.wg_public_key, *ident);\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Fix Clippy nits
The borrow checker must have a new category of allowed borrows in this
version of Rust. |
20,244 | 07.06.2020 17:37:48 | 14,400 | c45518def25cb5eb846b72ab13da4ae440e0d857 | Bump for Beta 14 RC7 | [
{
"change_type": "MODIFY",
"old_path": "Cargo.lock",
"new_path": "Cargo.lock",
"diff": "@@ -2672,7 +2672,7 @@ dependencies = [\n[[package]]\nname = \"rita\"\n-version = \"0.5.52\"\n+version = \"0.5.53\"\ndependencies = [\n\"actix\",\n\"actix-web\",\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/Cargo.toml",
"new_path": "rita/Cargo.toml",
"diff": "[package]\nname = \"rita\"\n-version = \"0.5.52\"\n+version = \"0.5.53\"\nauthors = [\"Justin <justin@althea.net>\", \"Jehan <jehan.tremback@gmail.com>\", \"Ben <wangben3@gmail.com>\"]\nbuild = \"build.rs\"\nedition = \"2018\"\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/dashboard/own_info.rs",
"new_path": "rita/src/rita_common/dashboard/own_info.rs",
"diff": "@@ -6,7 +6,7 @@ use failure::Error;\nuse num256::{Int256, Uint256};\nuse settings::RitaCommonSettings;\n-pub static READABLE_VERSION: &str = \"Beta 14 RC6\";\n+pub static READABLE_VERSION: &str = \"Beta 14 RC7\";\n#[derive(Serialize)]\npub struct OwnInfo {\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Bump for Beta 14 RC7 |
20,244 | 08.06.2020 16:12:19 | 14,400 | 74b4e982f72b2e77b3d8b11c13dfc0f2989cb40d | Make minimum to deposit remotely configurable
The minimum has become too low and I don't want to end up in the situation
of having to roll out an update to fix it again. Also modified here is a
small randomization in rescue dai to fight issues we've been having with
duplicate tx imports | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/token_bridge/mod.rs",
"new_path": "rita/src/rita_common/token_bridge/mod.rs",
"diff": "@@ -66,7 +66,8 @@ use futures01::future;\nuse futures01::future::Future;\nuse num256::Uint256;\nuse num_traits::identities::Zero;\n-use settings::RitaCommonSettings;\n+use rand::{thread_rng, Rng};\n+use settings::{payment::PaymentSettings, RitaCommonSettings};\nuse std::fmt;\nuse std::fmt::Display;\nuse std::time::Duration;\n@@ -163,8 +164,7 @@ impl SystemService for TokenBridge {\n}\n}\n-fn token_bridge_core_from_settings() -> TokenBridgeCore {\n- let payment_settings = SETTING.get_payment();\n+fn token_bridge_core_from_settings(payment_settings: &PaymentSettings) -> TokenBridgeCore {\nlet addresses = payment_settings.bridge_addresses.clone();\nTokenBridgeCore::new(\naddresses.uniswap_address,\n@@ -180,11 +180,27 @@ fn token_bridge_core_from_settings() -> TokenBridgeCore {\nimpl Default for TokenBridge {\nfn default() -> TokenBridge {\n+ let mut payment_settings = SETTING.get_payment_mut();\n+ let minimum_to_exchange = match payment_settings.bridge_addresses.minimum_to_exchange {\n+ Some(val) => val,\n+ None => {\n+ payment_settings.bridge_addresses.minimum_to_exchange = Some(4);\n+ 4\n+ }\n+ };\n+ let reserve_amount = match payment_settings.bridge_addresses.reserve_amount {\n+ Some(val) => val,\n+ None => {\n+ payment_settings.bridge_addresses.reserve_amount = Some(2);\n+ 2\n+ }\n+ };\n+\nTokenBridge {\n- bridge: token_bridge_core_from_settings(),\n+ bridge: token_bridge_core_from_settings(&payment_settings),\nstate: State::Ready { former_state: None },\n- minimum_to_exchange: 2,\n- reserve_amount: 1,\n+ minimum_to_exchange,\n+ reserve_amount,\nminimum_stranded_dai_transfer: 1,\ndetailed_state: DetailedBridgeState::NoOp {\neth_balance: Uint256::zero(),\n@@ -212,10 +228,20 @@ fn rescue_dai(\namount: dai_balance.clone(),\n},\n));\n+\n+ // Remove up to U16_MAX wei from this transaction, this is well under a cent.\n+ // what this does is randomly change the tx hash and help prevent 'stuck' transactions\n+ // thanks to anti-spam mechanisms. Payments get this 'for free' thanks to changing debts\n+ // numbers. And other tx's here do thanks to changing exchange rates and other external factors\n+ // this is the only transaction that will be exactly the same for a very long period.\n+ let mut rng = thread_rng();\n+ let some_wei: u16 = rng.gen();\n+ let amount = dai_balance - Uint256::from(some_wei);\n+\n// Over the bridge into xDai\nBox::new(\nbridge\n- .dai_to_xdai_bridge(dai_balance, ETH_TRANSFER_TIMEOUT)\n+ .dai_to_xdai_bridge(amount, ETH_TRANSFER_TIMEOUT)\n.and_then(|_res| Ok(())),\n)\n} else {\n@@ -418,10 +444,10 @@ fn xdai_bridge(state: State, bridge: &TokenBridge) {\n// if the do_send at the end of state depositing fails we can get stuck here\n// at the time time we don't want to submit multiple eth transactions for each\n// step above, especially if they take a long time (note the timeouts are in the 10's of minutes)\n- // so we often 'tick' in depositing because there's a background future we don't want to interuppt\n+ // so we often 'tick' in depositing because there's a background future we don't want to interrupt\n// if that future fails it's state change do_send a few lines up from here we're screwed and the bridge\n// forever sits in this no-op state. This is a rescue setup for that situation where we check that enough\n- // time has elapsed. The theroretical max here is the uniswap timeout plus the eth transfer timeout\n+ // time has elapsed. The theoretical max here is the uniswap timeout plus the eth transfer timeout\nlet now = Instant::now();\nif now\n> timestamp\n@@ -751,6 +777,7 @@ impl Message for ReloadAddresses {\nimpl Handler<ReloadAddresses> for TokenBridge {\ntype Result = ();\nfn handle(&mut self, _msg: ReloadAddresses, _ctx: &mut Context<Self>) -> Self::Result {\n- self.bridge = token_bridge_core_from_settings();\n+ let payment_settings = SETTING.get_payment();\n+ self.bridge = token_bridge_core_from_settings(&payment_settings);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "settings/src/payment.rs",
"new_path": "settings/src/payment.rs",
"diff": "@@ -86,6 +86,11 @@ fn default_bridge_addresses() -> TokenBridgeAddresses {\n.unwrap(),\neth_full_node_url: \"https://eth.althea.org\".into(),\nxdai_full_node_url: \"https://dai.althea.org\".into(),\n+ // TODO convert to u32 in Beta16 this is needed for migration\n+ // only since we can't use serde_default within a struct the\n+ // actual default values are set in TokenBridge\n+ minimum_to_exchange: None,\n+ reserve_amount: None,\n}\n}\n@@ -124,6 +129,8 @@ pub struct TokenBridgeAddresses {\npub foreign_dai_contract_address: Address,\npub eth_full_node_url: String,\npub xdai_full_node_url: String,\n+ pub reserve_amount: Option<u32>,\n+ pub minimum_to_exchange: Option<u32>,\n}\n/// This struct is used by both rita and rita_exit to configure the dummy payment controller and\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Make minimum to deposit remotely configurable
The minimum has become too low and I don't want to end up in the situation
of having to roll out an update to fix it again. Also modified here is a
small randomization in rescue dai to fight issues we've been having with
duplicate tx imports |
20,244 | 08.06.2020 16:15:12 | 14,400 | b73528afcfdb98a4ab32fd00d7fb96011e8be352 | Bump for Beta 14 RC8 | [
{
"change_type": "MODIFY",
"old_path": "Cargo.lock",
"new_path": "Cargo.lock",
"diff": "@@ -2672,7 +2672,7 @@ dependencies = [\n[[package]]\nname = \"rita\"\n-version = \"0.5.53\"\n+version = \"0.5.54\"\ndependencies = [\n\"actix\",\n\"actix-web\",\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/Cargo.toml",
"new_path": "rita/Cargo.toml",
"diff": "[package]\nname = \"rita\"\n-version = \"0.5.53\"\n+version = \"0.5.54\"\nauthors = [\"Justin <justin@althea.net>\", \"Jehan <jehan.tremback@gmail.com>\", \"Ben <wangben3@gmail.com>\"]\nbuild = \"build.rs\"\nedition = \"2018\"\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/dashboard/own_info.rs",
"new_path": "rita/src/rita_common/dashboard/own_info.rs",
"diff": "@@ -6,7 +6,7 @@ use failure::Error;\nuse num256::{Int256, Uint256};\nuse settings::RitaCommonSettings;\n-pub static READABLE_VERSION: &str = \"Beta 14 RC7\";\n+pub static READABLE_VERSION: &str = \"Beta 14 RC8\";\n#[derive(Serialize)]\npub struct OwnInfo {\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Bump for Beta 14 RC8 |
20,244 | 09.06.2020 09:35:55 | 14,400 | 03661ef6f40084da448d2f0c39cbffa93cba515b | Further expand contact type conversions
Hopefully we're finally done adding boilerplate conversions here | [
{
"change_type": "MODIFY",
"old_path": "althea_types/src/contact_info.rs",
"new_path": "althea_types/src/contact_info.rs",
"diff": "@@ -15,6 +15,59 @@ pub struct ContactDetails {\npub email: Option<String>,\n}\n+impl From<ContactType> for ContactDetails {\n+ fn from(val: ContactType) -> Self {\n+ match val {\n+ ContactType::Phone { number } => ContactDetails {\n+ phone: Some(number.to_string()),\n+ email: None,\n+ },\n+ ContactType::Email { email } => ContactDetails {\n+ phone: None,\n+ email: Some(email.to_string()),\n+ },\n+ ContactType::Both { email, number } => ContactDetails {\n+ phone: Some(number.to_string()),\n+ email: Some(email.to_string()),\n+ },\n+ ContactType::Bad {\n+ invalid_email,\n+ invalid_number,\n+ } => ContactDetails {\n+ phone: invalid_number,\n+ email: invalid_email,\n+ },\n+ }\n+ }\n+}\n+\n+impl ContactType {\n+ pub fn convert(val: ContactDetails) -> Option<Self> {\n+ let same = ExitRegistrationDetails {\n+ phone: val.phone,\n+ email: val.email,\n+ phone_code: None,\n+ email_code: None,\n+ };\n+ match ContactStorage::convert(same) {\n+ Some(val) => Some(val.into()),\n+ None => None,\n+ }\n+ }\n+}\n+\n+impl From<Option<ContactType>> for ContactDetails {\n+ fn from(val: Option<ContactType>) -> Self {\n+ match val {\n+ Some(val) => val.into(),\n+ None => ContactDetails {\n+ phone: None,\n+ email: None,\n+ },\n+ }\n+ }\n+}\n+\n/// This enum is used to represent the fact that while we may not have a phone\n/// number and may not have an Email we are required to have at least one to\n/// facilitate exit registration.\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Further expand contact type conversions
Hopefully we're finally done adding boilerplate conversions here |
20,244 | 10.06.2020 10:14:34 | 14,400 | af0c026a0eac894e8aec6290aee928e1fdd1b3cd | Migrate auto_bridge into althea_rs
It's more trouble to maintain this as a seperate repo so I'm going
to move it on in. | [
{
"change_type": "MODIFY",
"old_path": "Cargo.lock",
"new_path": "Cargo.lock",
"diff": "@@ -291,7 +291,6 @@ dependencies = [\n[[package]]\nname = \"auto-bridge\"\nversion = \"0.1.5\"\n-source = \"git+https://github.com/althea-net/auto_bridge?tag=v0.1.5#995f9cea1d7bdcb395a4cd0a8c02d82b8b883824\"\ndependencies = [\n\"actix\",\n\"clarity\",\n"
},
{
"change_type": "MODIFY",
"old_path": "Cargo.toml",
"new_path": "Cargo.toml",
"diff": "@@ -15,7 +15,7 @@ jemalloc = [\"rita/jemalloc\"]\nrita = { path = \"./rita\" }\n[workspace]\n-members = [\"althea_kernel_interface\", \"settings\", \"clu\", \"exit_db\", \"antenna_forwarding_client\", \"antenna_forwarding_protocol\"]\n+members = [\"althea_kernel_interface\", \"settings\", \"clu\", \"exit_db\", \"antenna_forwarding_client\", \"antenna_forwarding_protocol\", \"auto_bridge\"]\n[profile.release]\nopt-level = \"z\"\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "auto_bridge/Cargo.toml",
"diff": "+[package]\n+name = \"auto-bridge\"\n+version = \"0.1.5\"\n+authors = [\"Jehan <jehan.tremback@gmail.com>\"]\n+edition = \"2018\"\n+\n+[dependencies]\n+web30 = { git = \"https://github.com/althea-mesh/web30\", branch = \"master\" }\n+actix = \"0.7\"\n+futures = \"0.1\"\n+failure = \"0.1\"\n+num256 = \"0.2\"\n+clarity = \"0.1\"\n+futures-timer = \"0.1\"\n+rand = \"0.7\"\n+num = \"0.2\"\n+log = \"0.4\"\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "auto_bridge/src/lib.rs",
"diff": "+#[macro_use]\n+extern crate log;\n+\n+use clarity::abi::encode_call;\n+use clarity::{Address, PrivateKey};\n+use failure::bail;\n+use failure::Error;\n+use futures::Future;\n+use futures_timer::FutureExt;\n+use num::Bounded;\n+use num256::Uint256;\n+use std::time::Duration;\n+use web30::client::Web3;\n+use web30::types::SendTxOption;\n+\n+#[derive(Clone)]\n+pub struct TokenBridge {\n+ pub xdai_web3: Web3,\n+ pub eth_web3: Web3,\n+ pub uniswap_address: Address,\n+ /// This is the address of the xDai bridge on Eth\n+ pub xdai_foreign_bridge_address: Address,\n+ /// This is the address of the xDai bridge on xDai\n+ pub xdai_home_bridge_address: Address,\n+ /// This is the address of the Dai token contract on Eth\n+ pub foreign_dai_contract_address: Address,\n+ pub own_address: Address,\n+ pub secret: PrivateKey,\n+}\n+\n+impl TokenBridge {\n+ pub fn new(\n+ uniswap_address: Address,\n+ xdai_home_bridge_address: Address,\n+ xdai_foreign_bridge_address: Address,\n+ foreign_dai_contract_address: Address,\n+ own_address: Address,\n+ secret: PrivateKey,\n+ eth_full_node_url: String,\n+ xdai_full_node_url: String,\n+ ) -> TokenBridge {\n+ TokenBridge {\n+ uniswap_address,\n+ xdai_home_bridge_address,\n+ xdai_foreign_bridge_address,\n+ foreign_dai_contract_address,\n+ own_address,\n+ secret,\n+ xdai_web3: Web3::new(&xdai_full_node_url, Duration::from_secs(10)),\n+ eth_web3: Web3::new(ð_full_node_url, Duration::from_secs(10)),\n+ }\n+ }\n+\n+ /// This just sends some Eth. Returns the tx hash.\n+ pub fn eth_transfer(\n+ &self,\n+ to: Address,\n+ amount: Uint256,\n+ timeout: u64,\n+ ) -> Box<dyn Future<Item = (), Error = Error>> {\n+ let web3 = self.eth_web3.clone();\n+ let own_address = self.own_address.clone();\n+ let secret = self.secret.clone();\n+\n+ Box::new(\n+ web3.send_transaction(to, Vec::new(), amount, own_address, secret, vec![])\n+ .and_then(move |tx_hash| {\n+ web3.wait_for_transaction(tx_hash.into())\n+ .timeout(Duration::from_secs(timeout));\n+ Ok(())\n+ }),\n+ )\n+ }\n+\n+ /// Price of ETH in Dai\n+ pub fn eth_to_dai_price(\n+ &self,\n+ amount: Uint256,\n+ ) -> Box<dyn Future<Item = Uint256, Error = Error>> {\n+ let web3 = self.eth_web3.clone();\n+ let uniswap_address = self.uniswap_address.clone();\n+ let own_address = self.own_address.clone();\n+\n+ Box::new(\n+ web3.contract_call(\n+ uniswap_address,\n+ \"getEthToTokenInputPrice(uint256)\",\n+ &[amount.into()],\n+ own_address,\n+ )\n+ .and_then(move |tokens_bought| {\n+ Ok(Uint256::from_bytes_be(match tokens_bought.get(0..32) {\n+ Some(val) => val,\n+ None => bail!(\n+ \"Malformed output from uniswap getEthToTokenInputPrice call {:?}\",\n+ tokens_bought\n+ ),\n+ }))\n+ }),\n+ )\n+ }\n+\n+ /// Price of Dai in Eth\n+ pub fn dai_to_eth_price(\n+ &self,\n+ amount: Uint256,\n+ ) -> Box<dyn Future<Item = Uint256, Error = Error>> {\n+ let web3 = self.eth_web3.clone();\n+ let uniswap_address = self.uniswap_address.clone();\n+ let own_address = self.own_address.clone();\n+\n+ Box::new(\n+ web3.contract_call(\n+ uniswap_address,\n+ \"getTokenToEthInputPrice(uint256)\",\n+ &[amount.into()],\n+ own_address,\n+ )\n+ .and_then(move |eth_bought| {\n+ Ok(Uint256::from_bytes_be(match eth_bought.get(0..32) {\n+ Some(val) => val,\n+ None => bail!(\n+ \"Malformed output from uniswap getTokenToEthInputPrice call {:?}\",\n+ eth_bought\n+ ),\n+ }))\n+ }),\n+ )\n+ }\n+\n+ /// Sell `eth_amount` ETH for Dai.\n+ /// This function will error out if it takes longer than 'timeout' and the transaction is guaranteed not\n+ /// to be accepted on the blockchain after this time.\n+ pub fn eth_to_dai_swap(\n+ &self,\n+ eth_amount: Uint256,\n+ timeout: u64,\n+ ) -> Box<dyn Future<Item = Uint256, Error = Error>> {\n+ let uniswap_address = self.uniswap_address.clone();\n+ let own_address = self.own_address.clone();\n+ let secret = self.secret.clone();\n+ let web3 = self.eth_web3.clone();\n+\n+ Box::new(\n+ web3.eth_get_latest_block()\n+ .join(self.eth_to_dai_price(eth_amount.clone()))\n+ .and_then(move |(block, expected_dai)| {\n+ // Equivalent to `amount * (1 - 0.025)` without using decimals\n+ let expected_dai = (expected_dai / 40u64.into()) * 39u64.into();\n+ let deadline = block.timestamp + timeout.into();\n+ let payload = encode_call(\n+ \"ethToTokenSwapInput(uint256,uint256)\",\n+ &[expected_dai.clone().into(), deadline.into()],\n+ );\n+\n+ web3.send_transaction(\n+ uniswap_address,\n+ payload,\n+ eth_amount,\n+ own_address,\n+ secret,\n+ vec![SendTxOption::GasLimit(80_000u64.into())],\n+ )\n+ .join(\n+ web3.wait_for_event_alt(\n+ uniswap_address,\n+ \"TokenPurchase(address,uint256,uint256)\",\n+ Some(vec![own_address.into()]),\n+ None,\n+ None,\n+ |_| true,\n+ )\n+ .timeout(Duration::from_secs(timeout)),\n+ )\n+ .and_then(move |(_tx, response)| {\n+ let transfered_dai = Uint256::from_bytes_be(&response.topics[3]);\n+ Ok(transfered_dai)\n+ })\n+ }),\n+ )\n+ }\n+\n+ /// Checks if the uniswap contract has been approved to spend dai from our account.\n+ pub fn check_if_uniswap_dai_approved(&self) -> Box<dyn Future<Item = bool, Error = Error>> {\n+ let web3 = self.eth_web3.clone();\n+ let uniswap_address = self.uniswap_address.clone();\n+ let dai_address = self.foreign_dai_contract_address.clone();\n+ let own_address = self.own_address.clone();\n+\n+ Box::new(\n+ web3.contract_call(\n+ dai_address,\n+ \"allowance(address,address)\",\n+ &[own_address.into(), uniswap_address.into()],\n+ own_address,\n+ )\n+ .and_then(move |allowance| {\n+ let allowance = Uint256::from_bytes_be(match allowance.get(0..32) {\n+ Some(val) => val,\n+ None => bail!(\n+ \"Malformed output from uniswap getTokenToEthInputPrice call {:?}\",\n+ allowance\n+ ),\n+ });\n+\n+ // Check if the allowance remaining is greater than half of a Uint256- it's as good\n+ // a test as any.\n+ Ok(allowance > (Uint256::max_value() / 2u32.into()))\n+ }),\n+ )\n+ }\n+\n+ /// Sends transaction to the DAI contract to approve uniswap transactions, this future will not\n+ /// resolve until the process is either successful for the timeout finishes\n+ pub fn approve_uniswap_dai_transfers(\n+ &self,\n+ timeout: Duration,\n+ ) -> Box<dyn Future<Item = (), Error = Error>> {\n+ let dai_address = self.foreign_dai_contract_address.clone();\n+ let own_address = self.own_address.clone();\n+ let uniswap_address = self.uniswap_address.clone();\n+ let secret = self.secret.clone();\n+ let web3 = self.eth_web3.clone();\n+\n+ let payload = encode_call(\n+ \"approve(address,uint256)\",\n+ &[uniswap_address.into(), Uint256::max_value().into()],\n+ );\n+\n+ Box::new(\n+ web3.send_transaction(\n+ dai_address,\n+ payload,\n+ 0u32.into(),\n+ own_address,\n+ secret,\n+ vec![],\n+ )\n+ .join(web3.wait_for_event_alt(\n+ dai_address,\n+ \"Approval(address,address,uint256)\",\n+ Some(vec![own_address.into()]),\n+ Some(vec![uniswap_address.into()]),\n+ None,\n+ |_| true,\n+ ))\n+ .timeout(timeout)\n+ .and_then(move |_| Ok(())),\n+ )\n+ }\n+\n+ /// Sell `dai_amount` Dai for ETH\n+ /// This function will error out if it takes longer than 'timeout' and the transaction is guaranteed not\n+ /// to be accepted on the blockchain after this time.\n+ pub fn dai_to_eth_swap(\n+ &self,\n+ dai_amount: Uint256,\n+ timeout: u64,\n+ ) -> Box<dyn Future<Item = Uint256, Error = Error>> {\n+ let uniswap_address = self.uniswap_address.clone();\n+ let own_address = self.own_address.clone();\n+ let secret = self.secret.clone();\n+ let web3 = self.eth_web3.clone();\n+ let salf = self.clone();\n+\n+ Box::new(\n+ self.check_if_uniswap_dai_approved()\n+ .and_then({\n+ let salf = self.clone();\n+ move |is_approved| {\n+ trace!(\"uniswap approved {}\", is_approved);\n+ if is_approved {\n+ Box::new(futures::future::ok(()))\n+ as Box<dyn Future<Item = (), Error = Error>>\n+ } else {\n+ salf.approve_uniswap_dai_transfers(Duration::from_secs(600))\n+ }\n+ }\n+ })\n+ .and_then(move |_| {\n+ web3.eth_get_latest_block()\n+ .join(salf.dai_to_eth_price(dai_amount.clone()))\n+ .and_then(move |(block, expected_eth)| {\n+ // Equivalent to `amount * (1 - 0.025)` without using decimals\n+ let expected_eth = (expected_eth / 40u64.into()) * 39u64.into();\n+ let deadline = block.timestamp + timeout.into();\n+ let payload = encode_call(\n+ \"tokenToEthSwapInput(uint256,uint256,uint256)\",\n+ &[\n+ dai_amount.into(),\n+ expected_eth.clone().into(),\n+ deadline.into(),\n+ ],\n+ );\n+\n+ web3.send_transaction(\n+ uniswap_address,\n+ payload,\n+ 0u32.into(),\n+ own_address,\n+ secret,\n+ vec![SendTxOption::GasLimit(80_000u64.into())],\n+ )\n+ .join(\n+ web3.wait_for_event_alt(\n+ uniswap_address,\n+ \"EthPurchase(address,uint256,uint256)\",\n+ Some(vec![own_address.into()]),\n+ None,\n+ None,\n+ |_| true,\n+ )\n+ .timeout(Duration::from_secs(timeout)),\n+ )\n+ .and_then(move |(_tx, response)| {\n+ let transfered_eth = Uint256::from_bytes_be(&response.topics[3]);\n+ Ok(transfered_eth)\n+ })\n+ })\n+ }),\n+ )\n+ }\n+\n+ /// Bridge `dai_amount` dai to xdai\n+ pub fn dai_to_xdai_bridge(\n+ &self,\n+ dai_amount: Uint256,\n+ timeout: u64,\n+ ) -> Box<dyn Future<Item = Uint256, Error = Error>> {\n+ let eth_web3 = self.eth_web3.clone();\n+ let foreign_dai_contract_address = self.foreign_dai_contract_address.clone();\n+ let xdai_foreign_bridge_address = self.xdai_foreign_bridge_address.clone();\n+ let own_address = self.own_address.clone();\n+ let secret = self.secret.clone();\n+\n+ // You basically just send it some coins\n+ // We have no idea when this has succeeded since the events are not indexed\n+ Box::new(\n+ eth_web3\n+ .send_transaction(\n+ foreign_dai_contract_address,\n+ encode_call(\n+ \"transfer(address,uint256)\",\n+ &[\n+ xdai_foreign_bridge_address.into(),\n+ dai_amount.clone().into(),\n+ ],\n+ ),\n+ 0u32.into(),\n+ own_address,\n+ secret,\n+ vec![SendTxOption::GasLimit(80_000u64.into())],\n+ )\n+ .and_then(move |tx_hash| {\n+ eth_web3\n+ .wait_for_transaction(tx_hash.into())\n+ .timeout(Duration::from_secs(timeout));\n+ Ok(dai_amount)\n+ }),\n+ )\n+ }\n+\n+ /// Bridge `xdai_amount` xdai to dai\n+ pub fn xdai_to_dai_bridge(\n+ &self,\n+ xdai_amount: Uint256,\n+ ) -> Box<dyn Future<Item = Uint256, Error = Error>> {\n+ let xdai_web3 = self.xdai_web3.clone();\n+\n+ let xdai_home_bridge_address = self.xdai_home_bridge_address.clone();\n+\n+ let own_address = self.own_address.clone();\n+ let secret = self.secret.clone();\n+\n+ // You basically just send it some coins\n+ Box::new(xdai_web3.send_transaction(\n+ xdai_home_bridge_address,\n+ Vec::new(),\n+ xdai_amount,\n+ own_address,\n+ secret,\n+ vec![\n+ SendTxOption::GasPrice(10_000_000_000u128.into()),\n+ SendTxOption::NetworkId(100u64),\n+ ],\n+ ))\n+ }\n+\n+ pub fn get_dai_balance(\n+ &self,\n+ address: Address,\n+ ) -> Box<dyn Future<Item = Uint256, Error = Error>> {\n+ let web3 = self.eth_web3.clone();\n+ let dai_address = self.foreign_dai_contract_address;\n+ let own_address = self.own_address;\n+ Box::new(\n+ web3.contract_call(\n+ dai_address,\n+ \"balanceOf(address)\",\n+ &[address.into()],\n+ own_address,\n+ )\n+ .and_then(|balance| {\n+ Ok(Uint256::from_bytes_be(match balance.get(0..32) {\n+ Some(val) => val,\n+ None => bail!(\n+ \"Got bad output for DAI balance from the full node {:?}\",\n+ balance\n+ ),\n+ }))\n+ }),\n+ )\n+ }\n+}\n+\n+#[cfg(test)]\n+mod tests {\n+ use super::*;\n+ use actix;\n+ use std::str::FromStr;\n+\n+ fn new_token_bridge() -> TokenBridge {\n+ let pk = PrivateKey::from_str(&format!(\n+ \"FE1FC0A7A29503BAF72274A{}601D67309E8F3{}D22\",\n+ \"AA3ECDE6DB3E20\", \"29F7AB4BA52\"\n+ ))\n+ .unwrap();\n+\n+ TokenBridge::new(\n+ Address::from_str(\"0x09cabEC1eAd1c0Ba254B09efb3EE13841712bE14\".into()).unwrap(),\n+ Address::from_str(\"0x7301CFA0e1756B71869E93d4e4Dca5c7d0eb0AA6\".into()).unwrap(),\n+ Address::from_str(\"0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016\".into()).unwrap(),\n+ Address::from_str(\"0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359\".into()).unwrap(),\n+ Address::from_str(\"0x79AE13432950bF5CDC3499f8d4Cf5963c3F0d42c\".into()).unwrap(),\n+ pk,\n+ \"https://eth.althea.org\".into(),\n+ \"https://dai.althea.org\".into(),\n+ )\n+ }\n+\n+ fn eth_to_wei(eth: f64) -> Uint256 {\n+ let wei = (eth * 1000000000000000000f64) as u64;\n+ wei.into()\n+ }\n+\n+ #[test]\n+ fn test_is_approved() {\n+ let pk = PrivateKey::from_str(&format!(\n+ \"FE1FC0A7A29503BAF72274A{}601D67309E8F3{}D22\",\n+ \"AA3ECDE6DB3E20\", \"29F7AB4BA52\"\n+ ))\n+ .unwrap();\n+\n+ let system = actix::System::new(\"test\");\n+\n+ let token_bridge = new_token_bridge();\n+\n+ let unapproved_token_bridge = TokenBridge::new(\n+ Address::from_str(\"0x09cabEC1eAd1c0Ba254B09efb3EE13841712bE14\".into()).unwrap(),\n+ Address::from_str(\"0x7301CFA0e1756B71869E93d4e4Dca5c7d0eb0AA6\".into()).unwrap(),\n+ Address::from_str(\"0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016\".into()).unwrap(),\n+ Address::from_str(\"0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359\".into()).unwrap(),\n+ Address::from_str(\"0x6d943740746934b2f5D9c9E6Cb1908758A42452f\".into()).unwrap(),\n+ pk,\n+ \"https://eth.althea.org\".into(),\n+ \"https://dai.althea.org\".into(),\n+ );\n+\n+ actix::spawn(\n+ token_bridge\n+ .check_if_uniswap_dai_approved()\n+ .and_then(move |is_approved| {\n+ assert!(is_approved);\n+ unapproved_token_bridge\n+ .check_if_uniswap_dai_approved()\n+ .and_then(move |is_approved| {\n+ assert!(!is_approved);\n+ Ok(())\n+ })\n+ })\n+ .then(|res| {\n+ res.unwrap();\n+ actix::System::current().stop();\n+ Box::new(futures::future::ok(()))\n+ }),\n+ );\n+ system.run();\n+ }\n+\n+ #[test]\n+ fn test_eth_to_dai_swap() {\n+ let system = actix::System::new(\"test\");\n+\n+ let token_bridge = new_token_bridge();\n+\n+ actix::spawn(\n+ token_bridge\n+ .dai_to_eth_price(eth_to_wei(0.01f64))\n+ .and_then(move |one_cent_in_eth| {\n+ token_bridge.eth_to_dai_swap(one_cent_in_eth.clone(), 600)\n+ })\n+ .then(|res| {\n+ res.unwrap();\n+ actix::System::current().stop();\n+ Box::new(futures::future::ok(()))\n+ }),\n+ );\n+\n+ system.run();\n+ }\n+\n+ #[test]\n+ fn test_dai_to_eth_swap() {\n+ let system = actix::System::new(\"test\");\n+ let token_bridge = new_token_bridge();\n+\n+ actix::spawn(\n+ token_bridge\n+ .approve_uniswap_dai_transfers(Duration::from_secs(600))\n+ .and_then(move |_| token_bridge.dai_to_eth_swap(eth_to_wei(0.01f64), 600))\n+ .then(|res| {\n+ res.unwrap();\n+ actix::System::current().stop();\n+ Box::new(futures::future::ok(()))\n+ }),\n+ );\n+\n+ system.run();\n+ }\n+\n+ #[test]\n+ fn test_dai_to_xdai_bridge() {\n+ let system = actix::System::new(\"test\");\n+\n+ let token_bridge = new_token_bridge();\n+\n+ actix::spawn(\n+ token_bridge\n+ // All we can really do here is test that it doesn't throw. Check your balances in\n+ // 5-10 minutes to see if the money got transferred.\n+ .dai_to_xdai_bridge(eth_to_wei(0.01f64), 600)\n+ .then(|res| {\n+ res.unwrap();\n+ actix::System::current().stop();\n+ Box::new(futures::future::ok(()))\n+ }),\n+ );\n+\n+ system.run();\n+ }\n+\n+ #[test]\n+ fn test_xdai_to_dai_bridge() {\n+ let system = actix::System::new(\"test\");\n+\n+ let token_bridge = new_token_bridge();\n+\n+ actix::spawn(\n+ token_bridge\n+ // All we can really do here is test that it doesn't throw. Check your balances in\n+ // 5-10 minutes to see if the money got transferred.\n+ .xdai_to_dai_bridge(eth_to_wei(0.01f64))\n+ .then(|res| {\n+ res.unwrap();\n+ actix::System::current().stop();\n+ Box::new(futures::future::ok(()))\n+ }),\n+ );\n+\n+ system.run();\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/Cargo.toml",
"new_path": "rita/Cargo.toml",
"diff": "@@ -22,7 +22,7 @@ exit_db = { path = \"../exit_db\" }\nnum256 = \"0.2\"\nsettings = { path = \"../settings\" }\nantenna_forwarding_client = {path = \"../antenna_forwarding_client\"}\n-auto-bridge = {git = \"https://github.com/althea-net/auto_bridge\", tag = \"v0.1.5\"}\n+auto-bridge = {path = \"../auto_bridge\"}\nactix-web-httpauth = {git = \"https://github.com/althea-net/actix-web-httpauth\"}\nclarity = \"0.1\"\nweb30 = {git = \"https://github.com/althea-net/web30\", branch = \"master\"}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Migrate auto_bridge into althea_rs
It's more trouble to maintain this as a seperate repo so I'm going
to move it on in. |
20,244 | 12.06.2020 09:41:28 | 14,400 | acd9ff1974fc2a21c2c7de9c4fa682859e40db78 | Improve comments for shaping | [
{
"change_type": "MODIFY",
"old_path": "althea_types/src/monitoring.rs",
"new_path": "althea_types/src/monitoring.rs",
"diff": "@@ -78,7 +78,7 @@ impl RunningLatencyStats {\n// much sense from a stats perspective but here's why it works. Often\n// when links start you get a lot of transient bad states, like 2000ms\n// latency and the like. Because the history is reset in network_monitor after\n- // this is triggered it doesn't immeidately trigger again. The std_dev and average\n+ // this is triggered it doesn't immediately trigger again. The std_dev and average\n// are both high and this protects connections from rapid excessive down shaping.\n// the other key is that as things run longer the average goes down so spikes in\n// std-dev are properly responded to. This is *not* a good metric for up-shaping\n@@ -87,7 +87,7 @@ impl RunningLatencyStats {\n//\n// If for some reason you feel the need to edit this you should probably not\n// do anything until you have more than 100 or so samples and then carve out\n- // exceptions for conditions like avgerage latency under 10ms becuase fiber lines\n+ // exceptions for conditions like average latency under 10ms because fiber lines\n// are a different beast than the wireless connections. Do remember that exits can\n// be a lot more than 50ms away so you need to account for distant but stable connections\n// as well. This somehow does all of that at once, so here it stands\n@@ -95,7 +95,15 @@ impl RunningLatencyStats {\n(_, _) => false,\n}\n}\n- /// A hand tuned heuristic used to determine if a connection is good\n+ /// A hand tuned heuristic used to determine if a connection is good this works differently than\n+ /// is_bloated because false positives are less damaging. We can rate limit speed increases to once\n+ /// every few minutes. While making the connection stable needs to be done right away, making it faster\n+ /// can be done more slowly. We use a combined average and std-dev measure specifically for fiber connections\n+ /// lets say you have a fiber connection and it has a 2ms normal latency and then one 2 second spike, that's\n+ /// going throw off your std-dev essentially forever. Which is why we have the out when the average is near the\n+ /// lowest. On wireless links the lowest you ever see will almost always be much lower than the average, on fiber\n+ /// it happens all the time. Over on the wireless link side we have a much less clustered distribution so the std-dev\n+ /// is more stable and a good metric.\npub fn is_good(&self) -> bool {\nlet std_dev = self.get_std_dev();\nlet avg = self.get_avg();\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Improve comments for shaping |
20,244 | 12.06.2020 11:23:08 | 14,400 | 30f132e8d16e0a1602f2015a3b824bf07b9b1588 | Force on logging when an operator address is configured
Previously behaivor here was inconsistent, we should make sure that
we checked in over the tcp checkin endpoint but did not send heartbeats
or reach out for antenna forwarder features | [
{
"change_type": "MODIFY",
"old_path": "rita/src/client.rs",
"new_path": "rita/src/client.rs",
"diff": "@@ -227,7 +227,13 @@ fn main() {\n// do TLS stuff.\nopenssl_probe::init_ssl_cert_env_vars();\n- if !SETTING.get_log().enabled || env_vars_contains(\"NO_REMOTE_LOG\") {\n+ // we should remove log if there's an operator address or if logging is enabled\n+ let should_remote_log =\n+ SETTING.get_log().enabled || SETTING.get_operator().operator_address.is_some();\n+ // if remote logging is disabled, or the NO_REMOTE_LOG env var is set we should use the\n+ // local logger and log to std-out. Note we don't care what is actually set in NO_REMOTE_LOG\n+ // just that it is set\n+ if !should_remote_log || env_vars_contains(\"NO_REMOTE_LOG\") {\nenv_logger::init();\n} else {\nlet res = enable_remote_logging();\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/rita_loop/mod.rs",
"new_path": "rita/src/rita_client/rita_loop/mod.rs",
"diff": "@@ -116,7 +116,7 @@ impl Handler<Tick> for RitaLoop {\n.then(|_res| Ok(()))\n}));\n- if SETTING.get_log().enabled {\n+ if SETTING.get_log().enabled || SETTING.get_operator().operator_address.is_some() {\nsend_udp_heartbeat();\nif !self.antenna_forwarder_started {\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Force on logging when an operator address is configured
Previously behaivor here was inconsistent, we should make sure that
we checked in over the tcp checkin endpoint but did not send heartbeats
or reach out for antenna forwarder features |
20,244 | 12.06.2020 20:07:02 | 14,400 | 02f0e3201c95c622955211662084d9a1c3c65f67 | Use saturating add for network monitoring | [
{
"change_type": "MODIFY",
"old_path": "althea_types/src/monitoring.rs",
"new_path": "althea_types/src/monitoring.rs",
"diff": "@@ -54,7 +54,10 @@ impl RunningLatencyStats {\n}\n}\npub fn add_sample(&mut self, sample: f32) {\n- self.count += 1;\n+ match self.count.checked_add(1) {\n+ Some(val) => self.count = val,\n+ None => self.reset(),\n+ }\nlet delta = sample - self.mean;\nself.mean += delta / self.count as f32;\nlet delta2 = sample - self.mean;\n@@ -127,6 +130,9 @@ impl RunningLatencyStats {\nself.last_changed\n.expect(\"Tried to get changed on a serialized counter!\")\n}\n+ pub fn samples(&self) -> u32 {\n+ self.count\n+ }\n}\n/// Due to the way babel communicates packet loss the functions here require slightly\n@@ -160,8 +166,20 @@ impl RunningPacketLossStats {\n// babel displays a 16 second window of hellos, so adjust this based on\n// any changes in run rate of this function\nlet lost_packets = SAMPLE_PERIOD - get_first_n_set_bits(sample, SAMPLE_PERIOD);\n- self.total_lost += u32::from(lost_packets);\n- self.total_packets += u32::from(SAMPLE_PERIOD);\n+ match self.total_lost.checked_add(u32::from(lost_packets)) {\n+ Some(val) => self.total_lost = val,\n+ None => {\n+ self.total_packets = 0;\n+ self.total_lost = 0;\n+ }\n+ }\n+ match self.total_packets.checked_add(u32::from(SAMPLE_PERIOD)) {\n+ Some(val) => self.total_packets = val,\n+ None => {\n+ self.total_packets = 0;\n+ self.total_lost = 0;\n+ }\n+ }\nself.five_minute_loss[self.front] = lost_packets;\nself.front = (self.front + 1) % SAMPLES_IN_FIVE_MINUTES;\n}\n@@ -177,6 +195,12 @@ impl RunningPacketLossStats {\nlet sum_loss: usize = self.five_minute_loss.iter().map(|i| *i as usize).sum();\nsum_loss as f32 / total_packets as f32\n}\n+ pub fn get_count(&self) -> u32 {\n+ self.total_packets\n+ }\n+ pub fn get_lost(&self) -> u32 {\n+ self.total_lost\n+ }\n}\n/// Counts the number of bits set to 1 in the first n bits (reading left to right so MSB first) of\n@@ -237,4 +261,19 @@ mod tests {\nfn test_get_first_n_set_bits_impossible() {\nlet _count = get_first_n_set_bits(0b1110_0000_0000_1100, 32);\n}\n+\n+ #[test]\n+ fn test_rtt_increment() {\n+ let mut stats = RunningLatencyStats::new();\n+ stats.add_sample(0.12);\n+ assert_eq!(stats.samples(), 1);\n+ }\n+\n+ #[test]\n+ fn test_packet_loss_increment() {\n+ let mut stats = RunningPacketLossStats::new();\n+ stats.add_sample(0);\n+ assert_eq!(stats.get_count(), SAMPLE_PERIOD as u32);\n+ assert_eq!(stats.get_lost(), SAMPLE_PERIOD as u32);\n+ }\n}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Use saturating add for network monitoring |
20,244 | 12.06.2020 20:31:56 | 14,400 | a918ed9c626ea031796d061645f318e75a838770 | Cleanup autobridge
Cleans up redundant clones and fixes the tests not to run by default
since they take a significant amount of wall clock time and actual
money | [
{
"change_type": "MODIFY",
"old_path": "auto_bridge/src/lib.rs",
"new_path": "auto_bridge/src/lib.rs",
"diff": "@@ -29,6 +29,7 @@ pub struct TokenBridge {\n}\nimpl TokenBridge {\n+ #[allow(clippy::too_many_arguments)]\npub fn new(\nuniswap_address: Address,\nxdai_home_bridge_address: Address,\n@@ -59,8 +60,8 @@ impl TokenBridge {\ntimeout: u64,\n) -> Box<dyn Future<Item = (), Error = Error>> {\nlet web3 = self.eth_web3.clone();\n- let own_address = self.own_address.clone();\n- let secret = self.secret.clone();\n+ let own_address = self.own_address;\n+ let secret = self.secret;\nBox::new(\nweb3.send_transaction(to, Vec::new(), amount, own_address, secret, vec![])\n@@ -78,8 +79,8 @@ impl TokenBridge {\namount: Uint256,\n) -> Box<dyn Future<Item = Uint256, Error = Error>> {\nlet web3 = self.eth_web3.clone();\n- let uniswap_address = self.uniswap_address.clone();\n- let own_address = self.own_address.clone();\n+ let uniswap_address = self.uniswap_address;\n+ let own_address = self.own_address;\nBox::new(\nweb3.contract_call(\n@@ -106,8 +107,8 @@ impl TokenBridge {\namount: Uint256,\n) -> Box<dyn Future<Item = Uint256, Error = Error>> {\nlet web3 = self.eth_web3.clone();\n- let uniswap_address = self.uniswap_address.clone();\n- let own_address = self.own_address.clone();\n+ let uniswap_address = self.uniswap_address;\n+ let own_address = self.own_address;\nBox::new(\nweb3.contract_call(\n@@ -136,9 +137,9 @@ impl TokenBridge {\neth_amount: Uint256,\ntimeout: u64,\n) -> Box<dyn Future<Item = Uint256, Error = Error>> {\n- let uniswap_address = self.uniswap_address.clone();\n- let own_address = self.own_address.clone();\n- let secret = self.secret.clone();\n+ let uniswap_address = self.uniswap_address;\n+ let own_address = self.own_address;\n+ let secret = self.secret;\nlet web3 = self.eth_web3.clone();\nBox::new(\n@@ -150,7 +151,7 @@ impl TokenBridge {\nlet deadline = block.timestamp + timeout.into();\nlet payload = encode_call(\n\"ethToTokenSwapInput(uint256,uint256)\",\n- &[expected_dai.clone().into(), deadline.into()],\n+ &[expected_dai.into(), deadline.into()],\n);\nweb3.send_transaction(\n@@ -183,9 +184,9 @@ impl TokenBridge {\n/// Checks if the uniswap contract has been approved to spend dai from our account.\npub fn check_if_uniswap_dai_approved(&self) -> Box<dyn Future<Item = bool, Error = Error>> {\nlet web3 = self.eth_web3.clone();\n- let uniswap_address = self.uniswap_address.clone();\n- let dai_address = self.foreign_dai_contract_address.clone();\n- let own_address = self.own_address.clone();\n+ let uniswap_address = self.uniswap_address;\n+ let dai_address = self.foreign_dai_contract_address;\n+ let own_address = self.own_address;\nBox::new(\nweb3.contract_call(\n@@ -216,10 +217,10 @@ impl TokenBridge {\n&self,\ntimeout: Duration,\n) -> Box<dyn Future<Item = (), Error = Error>> {\n- let dai_address = self.foreign_dai_contract_address.clone();\n- let own_address = self.own_address.clone();\n- let uniswap_address = self.uniswap_address.clone();\n- let secret = self.secret.clone();\n+ let dai_address = self.foreign_dai_contract_address;\n+ let own_address = self.own_address;\n+ let uniswap_address = self.uniswap_address;\n+ let secret = self.secret;\nlet web3 = self.eth_web3.clone();\nlet payload = encode_call(\n@@ -257,9 +258,9 @@ impl TokenBridge {\ndai_amount: Uint256,\ntimeout: u64,\n) -> Box<dyn Future<Item = Uint256, Error = Error>> {\n- let uniswap_address = self.uniswap_address.clone();\n- let own_address = self.own_address.clone();\n- let secret = self.secret.clone();\n+ let uniswap_address = self.uniswap_address;\n+ let own_address = self.own_address;\n+ let secret = self.secret;\nlet web3 = self.eth_web3.clone();\nlet salf = self.clone();\n@@ -286,11 +287,7 @@ impl TokenBridge {\nlet deadline = block.timestamp + timeout.into();\nlet payload = encode_call(\n\"tokenToEthSwapInput(uint256,uint256,uint256)\",\n- &[\n- dai_amount.into(),\n- expected_eth.clone().into(),\n- deadline.into(),\n- ],\n+ &[dai_amount.into(), expected_eth.into(), deadline.into()],\n);\nweb3.send_transaction(\n@@ -328,10 +325,10 @@ impl TokenBridge {\ntimeout: u64,\n) -> Box<dyn Future<Item = Uint256, Error = Error>> {\nlet eth_web3 = self.eth_web3.clone();\n- let foreign_dai_contract_address = self.foreign_dai_contract_address.clone();\n- let xdai_foreign_bridge_address = self.xdai_foreign_bridge_address.clone();\n- let own_address = self.own_address.clone();\n- let secret = self.secret.clone();\n+ let foreign_dai_contract_address = self.foreign_dai_contract_address;\n+ let xdai_foreign_bridge_address = self.xdai_foreign_bridge_address;\n+ let own_address = self.own_address;\n+ let secret = self.secret;\n// You basically just send it some coins\n// We have no idea when this has succeeded since the events are not indexed\n@@ -367,10 +364,10 @@ impl TokenBridge {\n) -> Box<dyn Future<Item = Uint256, Error = Error>> {\nlet xdai_web3 = self.xdai_web3.clone();\n- let xdai_home_bridge_address = self.xdai_home_bridge_address.clone();\n+ let xdai_home_bridge_address = self.xdai_home_bridge_address;\n- let own_address = self.own_address.clone();\n- let secret = self.secret.clone();\n+ let own_address = self.own_address;\n+ let secret = self.secret;\n// You basically just send it some coins\nBox::new(xdai_web3.send_transaction(\n@@ -416,7 +413,6 @@ impl TokenBridge {\n#[cfg(test)]\nmod tests {\nuse super::*;\n- use actix;\nuse std::str::FromStr;\nfn new_token_bridge() -> TokenBridge {\n@@ -427,11 +423,11 @@ mod tests {\n.unwrap();\nTokenBridge::new(\n- Address::from_str(\"0x09cabEC1eAd1c0Ba254B09efb3EE13841712bE14\".into()).unwrap(),\n- Address::from_str(\"0x7301CFA0e1756B71869E93d4e4Dca5c7d0eb0AA6\".into()).unwrap(),\n- Address::from_str(\"0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016\".into()).unwrap(),\n- Address::from_str(\"0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359\".into()).unwrap(),\n- Address::from_str(\"0x79AE13432950bF5CDC3499f8d4Cf5963c3F0d42c\".into()).unwrap(),\n+ Address::from_str(\"0x09cabEC1eAd1c0Ba254B09efb3EE13841712bE14\").unwrap(),\n+ Address::from_str(\"0x7301CFA0e1756B71869E93d4e4Dca5c7d0eb0AA6\").unwrap(),\n+ Address::from_str(\"0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016\").unwrap(),\n+ Address::from_str(\"0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359\").unwrap(),\n+ Address::from_str(\"0x79AE13432950bF5CDC3499f8d4Cf5963c3F0d42c\").unwrap(),\npk,\n\"https://eth.althea.org\".into(),\n\"https://dai.althea.org\".into(),\n@@ -444,6 +440,7 @@ mod tests {\n}\n#[test]\n+ #[ignore]\nfn test_is_approved() {\nlet pk = PrivateKey::from_str(&format!(\n\"FE1FC0A7A29503BAF72274A{}601D67309E8F3{}D22\",\n@@ -456,11 +453,11 @@ mod tests {\nlet token_bridge = new_token_bridge();\nlet unapproved_token_bridge = TokenBridge::new(\n- Address::from_str(\"0x09cabEC1eAd1c0Ba254B09efb3EE13841712bE14\".into()).unwrap(),\n- Address::from_str(\"0x7301CFA0e1756B71869E93d4e4Dca5c7d0eb0AA6\".into()).unwrap(),\n- Address::from_str(\"0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016\".into()).unwrap(),\n- Address::from_str(\"0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359\".into()).unwrap(),\n- Address::from_str(\"0x6d943740746934b2f5D9c9E6Cb1908758A42452f\".into()).unwrap(),\n+ Address::from_str(\"0x09cabEC1eAd1c0Ba254B09efb3EE13841712bE14\").unwrap(),\n+ Address::from_str(\"0x7301CFA0e1756B71869E93d4e4Dca5c7d0eb0AA6\").unwrap(),\n+ Address::from_str(\"0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016\").unwrap(),\n+ Address::from_str(\"0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359\").unwrap(),\n+ Address::from_str(\"0x6d943740746934b2f5D9c9E6Cb1908758A42452f\").unwrap(),\npk,\n\"https://eth.althea.org\".into(),\n\"https://dai.althea.org\".into(),\n@@ -488,6 +485,7 @@ mod tests {\n}\n#[test]\n+ #[ignore]\nfn test_eth_to_dai_swap() {\nlet system = actix::System::new(\"test\");\n@@ -496,9 +494,7 @@ mod tests {\nactix::spawn(\ntoken_bridge\n.dai_to_eth_price(eth_to_wei(0.01f64))\n- .and_then(move |one_cent_in_eth| {\n- token_bridge.eth_to_dai_swap(one_cent_in_eth.clone(), 600)\n- })\n+ .and_then(move |one_cent_in_eth| token_bridge.eth_to_dai_swap(one_cent_in_eth, 600))\n.then(|res| {\nres.unwrap();\nactix::System::current().stop();\n@@ -510,6 +506,7 @@ mod tests {\n}\n#[test]\n+ #[ignore]\nfn test_dai_to_eth_swap() {\nlet system = actix::System::new(\"test\");\nlet token_bridge = new_token_bridge();\n@@ -529,6 +526,7 @@ mod tests {\n}\n#[test]\n+ #[ignore]\nfn test_dai_to_xdai_bridge() {\nlet system = actix::System::new(\"test\");\n@@ -550,6 +548,7 @@ mod tests {\n}\n#[test]\n+ #[ignore]\nfn test_xdai_to_dai_bridge() {\nlet system = actix::System::new(\"test\");\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Cleanup autobridge
Cleans up redundant clones and fixes the tests not to run by default
since they take a significant amount of wall clock time and actual
money |
20,244 | 14.06.2020 12:05:17 | 14,400 | e10469eb993b2e3fb67c553a7e0bbd5da9fe6ff4 | Antennna forwarding on all interfaces except lan
we have to exclude lan for privacy reasons, but the other interfaces
should be fair game for the forwarder | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/rita_loop/mod.rs",
"new_path": "rita/src/rita_client/rita_loop/mod.rs",
"diff": "//! This loop manages exit signup based on the settings configuration state and deploys an exit vpn\n//! tunnel if the signup was successful on the selected exit.\n+use crate::rita_client::dashboard::interfaces::get_interfaces;\n+use crate::rita_client::dashboard::interfaces::InterfaceMode;\nuse crate::rita_client::exit_manager::ExitManager;\nuse crate::rita_client::heartbeat::send_udp_heartbeat;\nuse crate::rita_client::heartbeat::HEARTBEAT_SERVER_KEY;\n@@ -32,6 +34,7 @@ use failure::Error;\nuse futures01::future::Future;\nuse settings::client::RitaClientSettings;\nuse settings::RitaCommonSettings;\n+use std::collections::HashSet;\nuse std::time::{Duration, Instant};\npub struct RitaLoop {\n@@ -123,13 +126,31 @@ impl Handler<Tick> for RitaLoop {\nlet network = SETTING.get_network();\nlet our_id = SETTING.get_identity().unwrap();\nlet logging = SETTING.get_log();\n+ let interfaces = match get_interfaces() {\n+ Ok(val) => {\n+ let mut v = HashSet::new();\n+ for (iface, mode) in val {\n+ if mode != InterfaceMode::LAN {\n+ v.insert(iface);\n+ }\n+ }\n+ info!(\"Starting antenna forwarder on {:?}\", v);\n+ v\n+ }\n+ Err(e) => {\n+ error!(\n+ \"Failed to get interfaces, starting forwarder on peer interfaces only!, {:?}\", e\n+ );\n+ network.peer_interfaces.clone()\n+ }\n+ };\nstart_antenna_forwarding_proxy(\nlogging.forwarding_checkin_url.clone(),\nour_id,\n*HEARTBEAT_SERVER_KEY,\nnetwork.wg_public_key.unwrap(),\nnetwork.wg_private_key.unwrap(),\n- network.peer_interfaces.clone(),\n+ interfaces,\n);\nself.antenna_forwarder_started = true;\n}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Antennna forwarding on all interfaces except lan
we have to exclude lan for privacy reasons, but the other interfaces
should be fair game for the forwarder |
20,244 | 14.06.2020 12:06:57 | 14,400 | 68cda2d1ebf415aac05f72a2fe7d4f139b95e0b1 | Bump for Beta 14 RC9 | [
{
"change_type": "MODIFY",
"old_path": "Cargo.lock",
"new_path": "Cargo.lock",
"diff": "@@ -2671,7 +2671,7 @@ dependencies = [\n[[package]]\nname = \"rita\"\n-version = \"0.5.54\"\n+version = \"0.5.55\"\ndependencies = [\n\"actix\",\n\"actix-web\",\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/Cargo.toml",
"new_path": "rita/Cargo.toml",
"diff": "[package]\nname = \"rita\"\n-version = \"0.5.54\"\n+version = \"0.5.55\"\nauthors = [\"Justin <justin@althea.net>\", \"Jehan <jehan.tremback@gmail.com>\", \"Ben <wangben3@gmail.com>\"]\nbuild = \"build.rs\"\nedition = \"2018\"\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/dashboard/own_info.rs",
"new_path": "rita/src/rita_common/dashboard/own_info.rs",
"diff": "@@ -6,7 +6,7 @@ use failure::Error;\nuse num256::{Int256, Uint256};\nuse settings::RitaCommonSettings;\n-pub static READABLE_VERSION: &str = \"Beta 14 RC8\";\n+pub static READABLE_VERSION: &str = \"Beta 14 RC9\";\n#[derive(Serialize)]\npub struct OwnInfo {\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Bump for Beta 14 RC9 |
20,244 | 14.06.2020 20:09:13 | 14,400 | 234160bc0589531011fa1c1e4f3e281968a52db5 | Wait longer for very slow antenna messages
We've found some production situations where the one minute timeout
is insufficient. | [
{
"change_type": "MODIFY",
"old_path": "antenna_forwarding_protocol/src/lib.rs",
"new_path": "antenna_forwarding_protocol/src/lib.rs",
"diff": "@@ -174,7 +174,7 @@ pub fn process_streams<S: ::std::hash::BuildHasher>(\nlet mut streams_to_remove: Vec<u64> = Vec::new();\n// First we we have to iterate over all of these connections\n// and read to send messages up the server pipe. We need to do\n- // this first becuase we may exit in the next section if there's\n+ // this first because we may exit in the next section if there's\n// nothing to write\nfor (stream_id, antenna_stream) in streams.iter_mut() {\n// in theory we will figure out if the connection is closed here\n@@ -678,6 +678,7 @@ impl ForwardingProtocolMessage {\nbytes[bytes_read..].to_vec(),\nvec![msg],\n0,\n+ None,\n)\n}\n(Err(ForwardingProtocolError::SliceTooSmall { .. }), _) => {\n@@ -716,14 +717,20 @@ impl ForwardingProtocolMessage {\npub fn read_messages(\ninput: &mut TcpStream,\n) -> Result<Vec<ForwardingProtocolMessage>, FailureError> {\n- ForwardingProtocolMessage::read_messages_internal(input, Vec::new(), Vec::new(), 0)\n+ ForwardingProtocolMessage::read_messages_internal(input, Vec::new(), Vec::new(), 0, None)\n}\n+ /// internal helper function designed to handle the complexities of reading off of a buffer and breaking down into messages, if we find a message\n+ /// it is pushed onto the messages vec, if we have bytes left over from our read we recurse and try and parse a message out of them, if we have a\n+ /// packet that promises more bytes than we have that means we need to wait for the remainder by sleeping for spinlock time. In very bad situations\n+ /// the connection may actually be that slow and we use last_read_bytes to ensure that if any packets are delivered in a minute we keep trying\n+ /// last read bytes is only filled out when we recurse for an unfinished message\nfn read_messages_internal(\ninput: &mut TcpStream,\nremaining_bytes: Vec<u8>,\nmessages: Vec<ForwardingProtocolMessage>,\ndepth: u16,\n+ last_read_bytes: Option<u32>,\n) -> Result<Vec<ForwardingProtocolMessage>, FailureError> {\n// don't wait the first time in order to speed up execution\n// if we are recursing we want to wait for the message to finish\n@@ -761,6 +768,7 @@ impl ForwardingProtocolMessage {\nremaining_bytes[bytes..].to_vec(),\nmessages,\ndepth + 1,\n+ None,\n)\n} else {\nOk(messages)\n@@ -769,11 +777,24 @@ impl ForwardingProtocolMessage {\nErr(e) => match e {\nForwardingProtocolError::SliceTooSmall { expected, actual } => {\nerror!(\"Expected {} bytes, got {} bytes\", expected, actual);\n+ if let Some(last_actual) = last_read_bytes {\n+ // we got some new bytes, reset the counter\n+ if actual > last_actual {\n+ return ForwardingProtocolMessage::read_messages_internal(\n+ input,\n+ remaining_bytes,\n+ messages,\n+ 0,\n+ Some(actual),\n+ );\n+ }\n+ }\nForwardingProtocolMessage::read_messages_internal(\ninput,\nremaining_bytes,\nmessages,\ndepth + 1,\n+ Some(actual),\n)\n}\n_ => {\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Wait longer for very slow antenna messages
We've found some production situations where the one minute timeout
is insufficient. |
20,244 | 14.06.2020 20:35:03 | 14,400 | a93c3d7f2a6638fa13adc123de8105281e45f7ae | Fix default for packetloss stats | [
{
"change_type": "MODIFY",
"old_path": "althea_types/src/monitoring.rs",
"new_path": "althea_types/src/monitoring.rs",
"diff": "@@ -139,7 +139,7 @@ impl RunningLatencyStats {\n/// more data processing to get correct values. 'Reach' is a 16 second bitvector of hello/IHU\n/// outcomes, but we're sampling every 5 seconds, in order to keep samples from interfering with\n/// each other we take the top 5 bits and use that to compute packet loss.\n-#[derive(Debug, Clone, Serialize, Deserialize, Default)]\n+#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct RunningPacketLossStats {\n/// the number of packets lost during each 5 second sample period over the last five minutes\nfive_minute_loss: Vec<u8>,\n@@ -151,8 +151,8 @@ pub struct RunningPacketLossStats {\ntotal_lost: u32,\n}\n-impl RunningPacketLossStats {\n- pub fn new() -> RunningPacketLossStats {\n+impl Default for RunningPacketLossStats {\n+ fn default() -> Self {\nlet mut new = Vec::with_capacity(SAMPLES_IN_FIVE_MINUTES);\nnew.extend_from_slice(&[0; SAMPLES_IN_FIVE_MINUTES]);\nRunningPacketLossStats {\n@@ -162,7 +162,20 @@ impl RunningPacketLossStats {\ntotal_lost: 0u32,\n}\n}\n+}\n+\n+impl RunningPacketLossStats {\n+ pub fn new() -> RunningPacketLossStats {\n+ RunningPacketLossStats::default()\n+ }\npub fn add_sample(&mut self, sample: u16) {\n+ // handles when 'default' was miscalled\n+ if self.five_minute_loss.is_empty() {\n+ let mut new = Vec::with_capacity(SAMPLES_IN_FIVE_MINUTES);\n+ new.extend_from_slice(&[0; SAMPLES_IN_FIVE_MINUTES]);\n+ self.five_minute_loss = new;\n+ }\n+\n// babel displays a 16 second window of hellos, so adjust this based on\n// any changes in run rate of this function\nlet lost_packets = SAMPLE_PERIOD - get_first_n_set_bits(sample, SAMPLE_PERIOD);\n@@ -192,8 +205,12 @@ impl RunningPacketLossStats {\n}\npub fn get_five_min_average(&self) -> f32 {\nlet total_packets = SAMPLES_IN_FIVE_MINUTES * SAMPLE_PERIOD as usize;\n+ if total_packets > 0 {\nlet sum_loss: usize = self.five_minute_loss.iter().map(|i| *i as usize).sum();\nsum_loss as f32 / total_packets as f32\n+ } else {\n+ 0.0\n+ }\n}\npub fn get_count(&self) -> u32 {\nself.total_packets\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Fix default for packetloss stats |
20,244 | 15.06.2020 10:11:34 | 14,400 | 122b1a43037514c4f9f5fbaa54a8400ab4107e49 | Add get_lowest() to RunningLatencyStats | [
{
"change_type": "MODIFY",
"old_path": "althea_types/src/monitoring.rs",
"new_path": "althea_types/src/monitoring.rs",
"diff": "@@ -133,6 +133,9 @@ impl RunningLatencyStats {\npub fn samples(&self) -> u32 {\nself.count\n}\n+ pub fn get_lowest(&self) -> Option<f32> {\n+ self.lowest\n+ }\n}\n/// Due to the way babel communicates packet loss the functions here require slightly\n@@ -169,7 +172,7 @@ impl RunningPacketLossStats {\nRunningPacketLossStats::default()\n}\npub fn add_sample(&mut self, sample: u16) {\n- // handles when 'default' was miscalled\n+ // handles when 'default' was miscalled, this should be safe to remove\nif self.five_minute_loss.is_empty() {\nlet mut new = Vec::with_capacity(SAMPLES_IN_FIVE_MINUTES);\nnew.extend_from_slice(&[0; SAMPLES_IN_FIVE_MINUTES]);\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Add get_lowest() to RunningLatencyStats |
20,244 | 15.06.2020 10:12:09 | 14,400 | 1f4e36e706e95d5030b688d9410980e2b92c946e | Fix spelling in client.rs | [
{
"change_type": "MODIFY",
"old_path": "rita/src/client.rs",
"new_path": "rita/src/client.rs",
"diff": "//! This is the main source file for the Rita client binary, by 'client' we mean 'not an exit server'\n-//! all meshing and billing functionaltiy is contained in `rita_common` and is common to both rita and\n+//! all meshing and billing functionality is contained in `rita_common` and is common to both rita and\n//! `rita_exit`. The major difference is billing and connection code for the 'exit', the mandatory\n//! vpn system integrated into the Althea network design, as well as API endpoints for a management\n//! dashboard of router functions like wifi, which the exit is not expected to have.\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Fix spelling in client.rs |
20,244 | 16.06.2020 09:37:41 | 14,400 | aa81511538294a1904f98775b8c4ce8e43f8c06b | Handle lowest latency zero in running latency stats
obviously latency can't actually be zero, so a zero here is ridiculous | [
{
"change_type": "MODIFY",
"old_path": "althea_types/src/monitoring.rs",
"new_path": "althea_types/src/monitoring.rs",
"diff": "@@ -65,7 +65,9 @@ impl RunningLatencyStats {\nself.last_value = Some(sample);\nmatch self.lowest {\nSome(lowest) => {\n- if sample < lowest {\n+ // fix for bad \"default\" where some lowest as zero's slipped in\n+ // TODO remove operator tools fixing hack\n+ if sample < lowest || lowest == 0 {\nself.lowest = Some(sample)\n}\n}\n@@ -173,6 +175,7 @@ impl RunningPacketLossStats {\n}\npub fn add_sample(&mut self, sample: u16) {\n// handles when 'default' was miscalled, this should be safe to remove\n+ // TODO remove operator tools fixing hack\nif self.five_minute_loss.is_empty() {\nlet mut new = Vec::with_capacity(SAMPLES_IN_FIVE_MINUTES);\nnew.extend_from_slice(&[0; SAMPLES_IN_FIVE_MINUTES]);\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Handle lowest latency zero in running latency stats
obviously latency can't actually be zero, so a zero here is ridiculous |
20,244 | 16.06.2020 20:56:22 | 14,400 | 99c72b91a05bab9b55cbb344b8059d2b0a84ca9c | Update install details to be wyre compatible
We now collect install and billing details as seperate structs this
makes it easier to send just billing details to the operator tools for a
WyreReservationRequest. We also parse and validate more detailed address
info as required by Wyre and likley any other payment partner. | [
{
"change_type": "MODIFY",
"old_path": "althea_types/src/interop.rs",
"new_path": "althea_types/src/interop.rs",
"diff": "use crate::{\ncontact_info::{ContactDetails, ContactType},\nwg_key::WgKey,\n+ BillingDetails, InstallationDetails,\n};\nuse arrayvec::ArrayString;\nuse babel_monitor::Neighbor;\n@@ -15,7 +16,6 @@ use std::hash::{Hash, Hasher};\nuse std::net::IpAddr;\nuse std::net::Ipv4Addr;\nuse std::str::FromStr;\n-use std::time::SystemTime;\n#[cfg(feature = \"actix\")]\nuse actix::Message;\n@@ -503,13 +503,13 @@ pub struct OperatorCheckinMessage {\n/// see the type definition for more details about how this type restricts values\n/// This only exists in Beta 14+\npub contact_info: Option<ContactType>,\n- /// Details about this installation, including ip addresses, address and other\n- /// info to insert into a spreadsheet displayed by operator tools. This is set\n- /// all the time but only accepted by operator tools once. The reason we store\n- /// it in the config is so that values can be set before the device is connected\n- /// and then be sent up at a later date. This does result in a constant resending\n- /// of this data forever just to discard it on the other end. TODO optimize sending\n+ /// Details about this installation, including ip addresses, phone ip address and other\n+ /// info to insert into a spreadsheet displayed by operator tools.\npub install_details: Option<InstallationDetails>,\n+ /// Details about this user, including city, state, postal code and other\n+ /// info to insert into a spreadsheet displayed by operator tools. Or submit\n+ /// to a billing partner to ease onboarding.\n+ pub billing_details: Option<BillingDetails>,\n/// Info about the current state of this device, including it's model, CPU,\n/// memory, and temperature if sensors are available\npub hardware_info: Option<HardwareInfo>,\n@@ -581,44 +581,6 @@ pub struct NeighborStatus {\npub shaper_speed: Option<usize>,\n}\n-/// Struct for storing details about this user installation. This particular\n-/// struct exists in the settings on the router because it has to be persisted\n-/// long enough to make it to the operator tools, once it's been uploaded though\n-/// it has no reason to hand around and is mostly dead weight in the config. The\n-/// question is if we want to delete it or manage it somehow.\n-#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]\n-pub struct InstallationDetails {\n- /// The users name\n- pub user_name: String,\n- /// The CPE ip of this client. This field seems straightforward but actually\n- /// has quite a bit of optionality. What if the user is connected via l2 bridge\n- /// (for example a cable, or fiber) in that case this could be None. If the client\n- /// is multihomed which ip is the client antenna and which one is the relay antenna?\n- /// That can be decided randomly without any problems I think.\n- pub client_antenna_ip: Option<Ipv4Addr>,\n- /// A list of addresses for relay antennas, this could include sectors and/or\n- /// point to point links going downstream. If the vec is empty there are no\n- /// relay antennas\n- pub relay_antennas: Vec<Ipv4Addr>,\n- /// A list of addresses for light client antennas. The vec can of course\n- /// be empty representing no phone client antennas.\n- pub phone_client_antennas: Vec<Ipv4Addr>,\n- /// The mailing address of this installation, assumed to be in whatever\n- /// format the local nation has for addresses. Optional as this install\n- /// may not have a formal mailing address\n- pub mailing_address: Option<String>,\n- /// The address of this installation, this has no structure and should\n- /// simply be displayed. Depending on the country address formats will\n- /// be very different and we might even only have GPS points\n- pub physical_address: String,\n- /// Description of the installation and equipment at the\n- /// location\n- pub equipment_details: String,\n- /// Time of install, this is set by the operator tools when it accepts\n- /// the value because the router system clocks may be problematic.\n- pub install_date: Option<SystemTime>,\n-}\n-\n/// Heartbeat sent to the operator server to help monitor\n/// liveness and network state\n#[derive(Debug, Clone, Serialize, Deserialize)]\n"
},
{
"change_type": "MODIFY",
"old_path": "althea_types/src/lib.rs",
"new_path": "althea_types/src/lib.rs",
"diff": "@@ -8,10 +8,12 @@ extern crate arrayvec;\npub mod contact_info;\npub mod interop;\npub mod monitoring;\n+pub mod user_info;\npub mod wg_key;\npub use crate::contact_info::*;\npub use crate::interop::*;\npub use crate::monitoring::*;\n+pub use crate::user_info::*;\npub use crate::wg_key::WgKey;\npub use std::str::FromStr;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "althea_types/src/user_info.rs",
"diff": "+use std::net::Ipv4Addr;\n+use std::time::SystemTime;\n+\n+/// Contains all the data you need for an American mailing address\n+/// hopefully also compatible with a few other countries\n+#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]\n+pub struct MailingAddress {\n+ /// full string country name including spaces\n+ pub country: String,\n+ /// postal code, in whatever the local format is\n+ pub postal_code: String,\n+ /// State, country may not contain states so optional\n+ pub state: Option<String>,\n+ pub city: String,\n+ pub street: String,\n+}\n+\n+#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]\n+/// This struct contains details about the users billing address\n+/// name, etc. It does not duplicate ContactType and does not store\n+/// direct contact info like phone or email\n+pub struct BillingDetails {\n+ /// The users first name\n+ pub user_first_name: String,\n+ /// The users last name\n+ pub user_last_name: String,\n+ /// The mailing address of this installation, assumed to be in whatever\n+ /// format the local nation has for addresses. Optional as this install\n+ /// may not have a formal mailing address\n+ pub mailing_address: MailingAddress,\n+}\n+\n+/// Struct for storing details about this user installation. This particular\n+/// struct exists in the settings on the router because it has to be persisted\n+/// long enough to make it to the operator tools, once it's been uploaded though\n+/// it has no reason to hand around and is mostly dead weight in the config. The\n+/// question is if we want to delete it or manage it somehow.\n+#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]\n+pub struct InstallationDetails {\n+ /// The CPE ip of this client. This field seems straightforward but actually\n+ /// has quite a bit of optionality. What if the user is connected via l2 bridge\n+ /// (for example a cable, or fiber) in that case this could be None. If the client\n+ /// is multihomed which ip is the client antenna and which one is the relay antenna?\n+ /// That can be decided randomly without any problems I think.\n+ pub client_antenna_ip: Option<Ipv4Addr>,\n+ /// A list of addresses for relay antennas, this could include sectors and/or\n+ /// point to point links going downstream. If the vec is empty there are no\n+ /// relay antennas\n+ pub relay_antennas: Vec<Ipv4Addr>,\n+ /// A list of addresses for light client antennas. The vec can of course\n+ /// be empty representing no phone client antennas.\n+ pub phone_client_antennas: Vec<Ipv4Addr>,\n+ /// The address of this installation, this has no structure and should\n+ /// simply be displayed. Depending on the country address formats will\n+ /// be very different and we might even only have GPS points\n+ pub physical_address: String,\n+ /// Description of the installation and equipment at the\n+ /// location\n+ pub equipment_details: String,\n+ /// Time of install, this is set by the operator tools when it accepts\n+ /// the value because the router system clocks may be problematic.\n+ pub install_date: Option<SystemTime>,\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/installation_details.rs",
"new_path": "rita/src/rita_client/dashboard/installation_details.rs",
"diff": "@@ -4,6 +4,7 @@ use actix_web::HttpResponse;\nuse actix_web::{HttpRequest, Json, Path};\nuse althea_types::ContactType;\nuse althea_types::InstallationDetails;\n+use althea_types::{BillingDetails, MailingAddress};\nuse settings::{client::RitaClientSettings, FileWrite};\n/// This is a utility type that is used by the front end when sending us\n@@ -11,7 +12,13 @@ use settings::{client::RitaClientSettings, FileWrite};\n/// rather than relying on serde to get it right.\n#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]\npub struct InstallationDetailsPost {\n- pub user_name: String,\n+ pub first_name: String,\n+ pub last_name: String,\n+ pub country: String,\n+ pub postal_code: String,\n+ pub state: Option<String>,\n+ pub city: String,\n+ pub street: String,\npub phone: Option<String>,\npub email: Option<String>,\npub client_antenna_ip: Option<String>,\n@@ -87,18 +94,28 @@ pub fn set_installation_details(req: Json<InstallationDetailsPost>) -> HttpRespo\ndrop(exit_client);\nlet new_installation_details = InstallationDetails {\n- user_name: input.user_name,\nclient_antenna_ip: parsed_client_antenna_ip,\nrelay_antennas: parsed_relay_antenna_ips,\nphone_client_antennas: parsed_phone_client_anntenna_ips,\n- mailing_address: input.mailing_address,\nphysical_address: input.physical_address,\nequipment_details: input.equipment_details,\ninstall_date: None,\n};\n+ let new_billing_details = BillingDetails {\n+ user_first_name: input.first_name,\n+ user_last_name: input.last_name,\n+ mailing_address: MailingAddress {\n+ country: input.country,\n+ postal_code: input.postal_code,\n+ state: input.state,\n+ city: input.city,\n+ street: input.street,\n+ },\n+ };\nlet mut operator_settings = SETTING.get_operator_mut();\noperator_settings.installation_details = Some(new_installation_details);\n+ operator_settings.billing_details = Some(new_billing_details);\noperator_settings.display_operator_setup = false;\ndrop(operator_settings);\n"
},
{
"change_type": "MODIFY",
"old_path": "settings/src/operator.rs",
"new_path": "settings/src/operator.rs",
"diff": "//! simplifies things a lot (no need for complex trustless enforcement). If you find that both DAO settings and this exist at the same time\n//! that means the transition is still in prgress.\n-use althea_types::interop::InstallationDetails;\n+use althea_types::{BillingDetails, InstallationDetails};\nuse clarity::Address;\nuse num256::Uint256;\n@@ -60,8 +60,11 @@ pub struct OperatorSettings {\n#[serde(default = \"default_checkin_url\")]\npub checkin_url: String,\n/// Details about this devices installation see the doc comments on the struct\n- /// this is set at startup time for the router\n+ /// this is set at install time for the router\npub installation_details: Option<InstallationDetails>,\n+ /// Details about this devices installation see the doc comments on the struct\n+ /// this is set at install time for the router\n+ pub billing_details: Option<BillingDetails>,\n/// If we should display the operator setup on the dashboard\n#[serde(default = \"default_display_operator_setup\")]\npub display_operator_setup: bool,\n@@ -76,6 +79,7 @@ impl Default for OperatorSettings {\nforce_use_operator_price: default_force_use_operator_price(),\ncheckin_url: default_checkin_url(),\ninstallation_details: None,\n+ billing_details: None,\ndisplay_operator_setup: true,\n}\n}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Update install details to be wyre compatible
We now collect install and billing details as seperate structs this
makes it easier to send just billing details to the operator tools for a
WyreReservationRequest. We also parse and validate more detailed address
info as required by Wyre and likley any other payment partner. |
20,244 | 17.06.2020 15:47:58 | 14,400 | 940751d161fc5a8728a2c3caf28229b9ceb1f5cd | Add median to RunningLatencyStats
Adds median collection to RunningLatencyStats, does not do anything
with the computed values by default yet. | [
{
"change_type": "MODIFY",
"old_path": "Cargo.lock",
"new_path": "Cargo.lock",
"diff": "@@ -189,6 +189,7 @@ dependencies = [\n\"lettre\",\n\"num256\",\n\"phonenumber\",\n+ \"rand 0.4.6\",\n\"serde 1.0.110\",\n\"serde_derive\",\n\"serde_json\",\n"
},
{
"change_type": "MODIFY",
"old_path": "althea_types/Cargo.toml",
"new_path": "althea_types/Cargo.toml",
"diff": "@@ -22,3 +22,6 @@ failure = \"0.1\"\nphonenumber = \"0.2\"\nlettre = {version = \"0.9\", features = [\"serde\"]}\n+[dev-dependencies]\n+rand = \"0.4\"\n+\n"
},
{
"change_type": "MODIFY",
"old_path": "althea_types/src/monitoring.rs",
"new_path": "althea_types/src/monitoring.rs",
"diff": "@@ -3,6 +3,8 @@ use std::time::SystemTime;\npub const SAMPLE_PERIOD: u8 = 5u8;\nconst SAMPLES_IN_FIVE_MINUTES: usize = 300 / SAMPLE_PERIOD as usize;\n+/// The size of the latency history array, this covers about 10 minutes\n+const LATENCY_HISTORY: usize = 100;\n/// This is a helper struct for measuring the round trip time over the exit tunnel independently\n/// from Babel. In the future, `RTTimestamps` should aid in RTT-related overadvertisement detection.\n@@ -14,7 +16,7 @@ pub struct RTTimestamps {\n/// Implements https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm\n/// to keep track of neighbor latency in an online fashion for a specific interface\n-#[derive(Debug, Clone, Copy, Serialize, Deserialize, Default)]\n+#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct RunningLatencyStats {\ncount: u32,\nmean: f32,\n@@ -26,10 +28,16 @@ pub struct RunningLatencyStats {\n/// the last time this counters interface was invalidated by a change\n#[serde(skip_serializing, skip_deserializing)]\nlast_changed: Option<Instant>,\n+ /// the front of the latency history ring buffer\n+ front: usize,\n+ /// A history of the last few values we have seen, used to compute the median\n+ history: Vec<f32>,\n}\n-impl RunningLatencyStats {\n- pub fn new() -> RunningLatencyStats {\n+impl Default for RunningLatencyStats {\n+ fn default() -> Self {\n+ let mut new = Vec::with_capacity(LATENCY_HISTORY);\n+ new.extend_from_slice(&[0.0; LATENCY_HISTORY]);\nRunningLatencyStats {\ncount: 0u32,\nmean: 0f32,\n@@ -37,8 +45,16 @@ impl RunningLatencyStats {\nlowest: None,\nlast_value: None,\nlast_changed: Some(Instant::now()),\n+ front: 0,\n+ history: new,\n+ }\n}\n}\n+\n+impl RunningLatencyStats {\n+ pub fn new() -> RunningLatencyStats {\n+ RunningLatencyStats::default()\n+ }\npub fn get_avg(&self) -> Option<f32> {\nif self.count > 2 {\nSome(self.mean)\n@@ -73,14 +89,16 @@ impl RunningLatencyStats {\n}\nNone => self.lowest = Some(sample),\n}\n+ self.history[self.front] = sample;\n+ self.front = (self.front + 1) % LATENCY_HISTORY;\n}\n/// A hand tuned heuristic used to determine if a connection is bloated\npub fn is_bloated(&self) -> bool {\nlet std_dev = self.get_std_dev();\nlet avg = self.get_avg();\nmatch (std_dev, avg) {\n- // you probably don't want to touch this, yes I know it doesn't make\n- // much sense from a stats perspective but here's why it works. Often\n+ // comparing std_dev to a multiple of the average doesn't make sense from a stats perspective\n+ // but has a compensating affect across a wide array of connections, here's why it works. Often\n// when links start you get a lot of transient bad states, like 2000ms\n// latency and the like. Because the history is reset in network_monitor after\n// this is triggered it doesn't immediately trigger again. The std_dev and average\n@@ -90,12 +108,11 @@ impl RunningLatencyStats {\n// it's too subject to not being positive when it should be whereas those false\n// negatives are probably better here.\n//\n- // If for some reason you feel the need to edit this you should probably not\n- // do anything until you have more than 100 or so samples and then carve out\n- // exceptions for conditions like average latency under 10ms because fiber lines\n- // are a different beast than the wireless connections. Do remember that exits can\n- // be a lot more than 50ms away so you need to account for distant but stable connections\n- // as well. This somehow does all of that at once, so here it stands\n+ // the other exceptions you see here are cases where we have very low latency links\n+ // this causes mundane latency spikes to really change the std-dev. For example\n+ // a wireless link with 1ms latency spikes to 50ms, we carve out our first exception\n+ // there. Then we carve out exceptions for links with low averages to handle short distance\n+ // p2p links that can have very unstable std_dev\n(Some(std_dev), Some(avg)) => std_dev > 10f32 * avg && avg > 10f32,\n(_, _) => false,\n}\n@@ -109,7 +126,7 @@ impl RunningLatencyStats {\n/// lowest. On wireless links the lowest you ever see will almost always be much lower than the average, on fiber\n/// it happens all the time. Over on the wireless link side we have a much less clustered distribution so the std-dev\n/// is more stable and a good metric. With the exception of ultra-short distance wireless links, which have their own\n- /// exception at <10ms\n+ /// exception at avg < 10ms\npub fn is_good(&self) -> bool {\nlet std_dev = self.get_std_dev();\nlet avg = self.get_avg();\n@@ -141,6 +158,12 @@ impl RunningLatencyStats {\npub fn get_lowest(&self) -> Option<f32> {\nself.lowest\n}\n+ /// gets the median of the last LATENCY_HISTORY inputs\n+ pub fn get_median(&self) -> f32 {\n+ let mut history = self.history.clone();\n+ history.sort_unstable_by(|a, b| a.partial_cmp(b).unwrap());\n+ history[history.len() / 2]\n+ }\n}\n/// Due to the way babel communicates packet loss the functions here require slightly\n@@ -257,6 +280,9 @@ pub fn has_packet_loss(sample: u16) -> bool {\n#[cfg(test)]\nmod tests {\nuse super::*;\n+ use rand::thread_rng;\n+ use rand::Rng;\n+\n#[test]\nfn test_get_first_n_set_bits() {\nlet count = get_first_n_set_bits(0b1110_0000_0000_0000, 5);\n@@ -295,6 +321,20 @@ mod tests {\nassert_eq!(stats.samples(), 1);\n}\n+ #[test]\n+ fn test_rtt_many_samples() {\n+ let mut stats = RunningLatencyStats::new();\n+ for _i in 0..10000 {\n+ stats.get_avg();\n+ stats.get_lowest();\n+ stats.get_std_dev();\n+ stats.get_median();\n+ let sample: f32 = thread_rng().gen();\n+ stats.add_sample(sample);\n+ }\n+ assert!(stats.get_median() != 0.0);\n+ }\n+\n#[test]\nfn test_packet_loss_increment() {\nlet mut stats = RunningPacketLossStats::new();\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Add median to RunningLatencyStats
Adds median collection to RunningLatencyStats, does not do anything
with the computed values by default yet. |
20,244 | 18.06.2020 09:24:08 | 14,400 | bd4d39a7995c4027a364703a88d9fdba9ef8bfef | WIP: Wyre reservation endpoint | [
{
"change_type": "MODIFY",
"old_path": "althea_types/src/interop.rs",
"new_path": "althea_types/src/interop.rs",
"diff": "@@ -486,7 +486,7 @@ fn default_shaper_settings() -> ShaperSettings {\npub struct OperatorCheckinMessage {\npub id: Identity,\npub operator_address: Option<Address>,\n- /// we include a system chain here becuase if there is no operator address\n+ /// we include a system chain here because if there is no operator address\n/// we don't know what this router is supposed to be configured like, the best\n/// proxy for that is the system chain value\npub system_chain: SystemChain,\n"
},
{
"change_type": "MODIFY",
"old_path": "althea_types/src/user_info.rs",
"new_path": "althea_types/src/user_info.rs",
"diff": "+use crate::ContactType;\n+use clarity::Address;\nuse std::net::Ipv4Addr;\nuse std::time::SystemTime;\n@@ -53,7 +55,8 @@ pub struct InstallationDetails {\n/// The address of this installation, this has no structure and should\n/// simply be displayed. Depending on the country address formats will\n/// be very different and we might even only have GPS points\n- pub physical_address: String,\n+ /// will only exist if mailing address over in contact info is blank\n+ pub physical_address: Option<String>,\n/// Description of the installation and equipment at the\n/// location\npub equipment_details: String,\n@@ -61,3 +64,44 @@ pub struct InstallationDetails {\n/// the value because the router system clocks may be problematic.\npub install_date: Option<SystemTime>,\n}\n+\n+/// This struct carries info to the operator tools\n+/// to perform the registration request\n+#[derive(Debug, Clone, Serialize, Deserialize)]\n+pub struct WyreReservationRequestCarrier {\n+ /// the actual amount the user is requesting to deposit\n+ pub amount: f32,\n+ pub address: Address,\n+ pub contact_info: ContactType,\n+ pub billing_details: BillingDetails,\n+}\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+}\n+\n+#[derive(Debug, Clone, Serialize, Deserialize)]\n+pub struct WyreReservationResponse {\n+ url: String,\n+ reservation: String,\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/client.rs",
"new_path": "rita/src/client.rs",
"diff": "@@ -414,6 +414,7 @@ fn start_client_dashboard() {\n.route(\"/wipe\", Method::POST, wipe)\n.route(\"/crash_actors\", Method::POST, crash_actors)\n.route(\"/localization\", Method::GET, get_localization)\n+ .route(\"/wyre_reservation\", Method::POST, get_wyre_reservation)\n.route(\n\"/installation_details\",\nMethod::POST,\n@@ -424,6 +425,8 @@ fn start_client_dashboard() {\nMethod::GET,\nget_installation_details,\n)\n+ .route(\"/billing_details\", Method::GET, get_billing_details)\n+ .route(\"/billing_details\", Method::POST, set_billing_details)\n.route(\n\"/operator_setup/{enabled}\",\nMethod::POST,\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/installation_details.rs",
"new_path": "rita/src/rita_client/dashboard/installation_details.rs",
"diff": "@@ -24,8 +24,7 @@ pub struct InstallationDetailsPost {\npub client_antenna_ip: Option<String>,\npub relay_antennas: Option<String>,\npub phone_client_antennas: Option<String>,\n- pub mailing_address: Option<String>,\n- pub physical_address: String,\n+ pub physical_address: Option<String>,\npub equipment_details: String,\n}\n@@ -149,3 +148,14 @@ pub fn set_display_operator_setup(val: Path<bool>) -> HttpResponse {\n}\nHttpResponse::Ok().finish()\n}\n+\n+pub fn get_billing_details(_req: HttpRequest) -> HttpResponse {\n+ let operator_settings = SETTING.get_operator();\n+ HttpResponse::Ok().json(operator_settings.billing_details.clone())\n+}\n+\n+pub fn set_billing_details(req: Json<BillingDetails>) -> HttpResponse {\n+ let mut operator_settings = SETTING.get_operator_mut();\n+ operator_settings.billing_details = Some(req.into_inner());\n+ HttpResponse::Ok().finish()\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/localization.rs",
"new_path": "rita/src/rita_client/dashboard/localization.rs",
"diff": "use crate::SETTING;\n-use actix_web::{HttpRequest, Json};\n+use actix_web::error::JsonPayloadError;\n+use actix_web::{client, HttpMessage, HttpRequest, HttpResponse, Json};\n+use althea_types::WyreReservationRequestCarrier;\n+use althea_types::WyreReservationResponse;\n+use failure::Error;\n+use futures01::future;\n+use futures01::future::Either;\n+use futures01::Future;\nuse phonenumber::Mode;\n-use settings::{localization::LocalizationSettings, RitaCommonSettings};\n+use settings::client::RitaClientSettings;\n+use settings::localization::LocalizationSettings;\n+use settings::RitaCommonSettings;\n+use std::time::Duration;\n/// A version of the localization struct that serializes into a more easily\n/// consumable form\n@@ -33,3 +43,50 @@ pub fn get_localization(_req: HttpRequest) -> Json<LocalizationReturn> {\nlet localization = SETTING.get_localization().clone();\nJson(localization.into())\n}\n+\n+#[derive(Debug, Serialize, Deserialize, Clone)]\n+pub struct AmountRequest {\n+ amount: f32,\n+}\n+\n+pub fn get_wyre_reservation(\n+ amount: Json<AmountRequest>,\n+) -> Box<dyn Future<Item = HttpResponse, Error = Error>> {\n+ trace!(\"Getting wyre reservation\");\n+ let exit_client = SETTING.get_exit_client();\n+ let operator = SETTING.get_operator();\n+ let payment = SETTING.get_payment();\n+ let payload = WyreReservationRequestCarrier {\n+ amount: amount.amount,\n+ address: payment.eth_address.unwrap(),\n+ // todo fix this\n+ contact_info: exit_client.contact_info.clone().unwrap().into(),\n+ // todo fix this\n+ billing_details: operator.billing_details.clone().unwrap(),\n+ };\n+\n+ let api_url = \"https://operator.althea.net:8080/wyre_reservation\";\n+ //let api_url = \"http://192.168.10.2:8080/wyre_reservation\";\n+ Box::new(\n+ client::post(&api_url)\n+ .timeout(Duration::from_secs(10))\n+ .json(&payload)\n+ .unwrap()\n+ .send()\n+ .then(move |response| match response {\n+ Ok(response) => Either::A(response.json().then(\n+ move |value: Result<WyreReservationResponse, JsonPayloadError>| match value {\n+ Ok(value) => Ok(HttpResponse::Ok().json(value)),\n+ Err(e) => {\n+ trace!(\"Failed to deserialize wyre response {:?}\", e);\n+ Ok(HttpResponse::InternalServerError().finish())\n+ }\n+ },\n+ )),\n+ Err(e) => {\n+ trace!(\"Failed to send wyre request {:?}\", e);\n+ Either::B(future::ok(HttpResponse::InternalServerError().finish()))\n+ }\n+ }),\n+ )\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/operator_update/mod.rs",
"new_path": "rita/src/rita_client/operator_update/mod.rs",
"diff": "@@ -94,6 +94,7 @@ fn checkin() {\nlet contact_info = option_convert(SETTING.get_exit_client().contact_info.clone());\nlet install_details = operator_settings.installation_details.clone();\n+ let billing_details = operator_settings.billing_details.clone();\ndrop(operator_settings);\n@@ -140,6 +141,7 @@ fn checkin() {\ncontact_details: None,\ncontact_info,\ninstall_details,\n+ billing_details,\nhardware_info,\n})\n.unwrap()\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | WIP: Wyre reservation endpoint |
20,244 | 18.06.2020 21:32:48 | 14,400 | 826726c45c75055fb384caa0c6a8279b8779db0c | Better logging on exit tunnel change
Finding some long running bugs here, need better messages | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/exit_manager/mod.rs",
"new_path": "rita/src/rita_client/exit_manager/mod.rs",
"diff": "@@ -424,7 +424,7 @@ impl Handler<Tick> for ExitManager {\nmatch (signed_up_for_exit, exit_has_changed, correct_default_route) {\n(true, true, _) => {\n- trace!(\"Exit change, setting up exit tunnel\");\n+ info!(\"Exit change, setting up exit tunnel\");\nlinux_setup_exit_tunnel(\n&exit,\n&general_details.clone(),\n@@ -435,7 +435,7 @@ impl Handler<Tick> for ExitManager {\nself.last_exit = Some(exit.clone());\n}\n(true, false, false) => {\n- trace!(\"DHCP overwrite setup exit tunnel again\");\n+ info!(\"DHCP overwrite setup exit tunnel again\");\nlinux_setup_exit_tunnel(\n&exit,\n&general_details.clone(),\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Better logging on exit tunnel change
Finding some long running bugs here, need better messages |
20,244 | 18.06.2020 21:35:37 | 14,400 | 4de2d702c2714096345a8153c2ab1eac8640f8b0 | Better logging for the exit signup process
This isn't run often enough for trace to be a significant savings
in logging storage and the exact debugging details are useful | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_exit/database/mod.rs",
"new_path": "rita/src/rita_exit/database/mod.rs",
"diff": "@@ -110,15 +110,15 @@ pub fn secs_since_unix_epoch() -> i64 {\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\npub fn signup_client(client: ExitClientIdentity) -> impl Future<Item = ExitState, Error = Error> {\n- trace!(\"got setup request {:?}\", client);\n+ info!(\"got setup request {:?}\", client);\nget_gateway_ip_single(client.global.mesh_ip).and_then(move |gateway_ip| {\n- trace!(\"got gateway ip {:?}\", client);\n+ info!(\"got gateway ip {:?}\", client);\nverify_ip(gateway_ip).and_then(move |verify_status| {\n- trace!(\"verified the ip country {:?}\", client);\n+ info!(\"verified the ip country {:?}\", client);\nget_country_async(gateway_ip).and_then(move |user_country| {\n- trace!(\"got the country country {:?}\", client);\n+ info!(\"got the country {:?}\", client);\nget_database_connection().and_then(move |conn| {\n- trace!(\"Doing database work for {:?} in country {} with verify_status {}\", client, user_country, verify_status);\n+ info!(\"Doing database work for {:?} in country {} with verify_status {}\", client, user_country, verify_status);\n// check if we have any users with conflicting details\nmatch client_conflict(&client, &conn) {\nOk(true) => {\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Better logging for the exit signup process
This isn't run often enough for trace to be a significant savings
in logging storage and the exact debugging details are useful |
20,244 | 19.06.2020 09:40:59 | 14,400 | e8950bffb5fb57c28cb9d6f8db0530d5f87946db | Allow geoip restricted exits to register directly attached clients | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/utils/ip_increment.rs",
"new_path": "rita/src/rita_common/utils/ip_increment.rs",
"diff": "@@ -67,6 +67,20 @@ pub fn increment(address: IpAddr, netmask: u8) -> Result<IpAddr, Error> {\n}\n}\n+/// Lifted directly from https://doc.rust-lang.org/src/std/net/ip.rs.html\n+/// this identifies fe80 linklocal addresses\n+#[allow(dead_code)]\n+pub fn is_unicast_link_local(input: &Ipv6Addr) -> bool {\n+ (input.segments()[0] & 0xffc0) == 0xfe80\n+}\n+\n+/// Lifted directly from https://doc.rust-lang.org/src/std/net/ip.rs.html\n+/// this identifies fd local addresses in short mesh addresses\n+#[allow(dead_code)]\n+pub fn is_unique_local(input: &Ipv6Addr) -> bool {\n+ (input.segments()[0] & 0xfe00) == 0xfc00\n+}\n+\n#[cfg(test)]\nmod tests {\nuse super::*;\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_exit/database/geoip.rs",
"new_path": "rita/src/rita_exit/database/geoip.rs",
"diff": "+use crate::rita_common::utils::ip_increment::is_unicast_link_local;\nuse crate::KI;\nuse crate::SETTING;\nuse babel_monitor::open_babel_stream;\n@@ -139,6 +140,24 @@ pub fn get_country(ip: IpAddr) -> Result<String, Error> {\nreturn Ok(String::new());\n}\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 go ahead and assign the user one of our allowed countries\n+ // and move on. In the common case where we have only one allowed country\n+ // this will produce the correct result. We can affirm this will never panic\n+ // because we just checked that allowed countries contains at least one value\n+ // above\n+ if let IpAddr::V6(val) = ip {\n+ if is_unicast_link_local(&val) {\n+ return Ok(SETTING\n+ .get_allowed_countries()\n+ .iter()\n+ .next()\n+ .unwrap()\n+ .clone());\n+ }\n+ }\n+\n// on the other hand if there is a configured list of allowed countries\n// but no configured api details, we panic\nlet api_user = SETTING\n@@ -205,6 +224,16 @@ pub fn verify_ip(request_ip: IpAddr) -> impl Future<Item = bool, Error = Error>\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_sync(request_ip: IpAddr) -> Result<bool, Error> {\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+ // we assume the exit itself is in one of it's allowed countries.\n+ if let IpAddr::V6(val) = request_ip {\n+ if is_unicast_link_local(&val) {\n+ return Ok(true);\n+ }\n+ }\n+\nif SETTING.get_allowed_countries().is_empty() {\nOk(true)\n} else {\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Allow geoip restricted exits to register directly attached clients |
20,244 | 22.06.2020 21:57:44 | 14,400 | 0d1ee0589edfb1741426eb36bcdaeb6f84a2c6f5 | Bump for Beta 14 RC10 | [
{
"change_type": "MODIFY",
"old_path": "Cargo.lock",
"new_path": "Cargo.lock",
"diff": "@@ -2672,7 +2672,7 @@ dependencies = [\n[[package]]\nname = \"rita\"\n-version = \"0.5.55\"\n+version = \"0.5.56\"\ndependencies = [\n\"actix\",\n\"actix-web\",\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/Cargo.toml",
"new_path": "rita/Cargo.toml",
"diff": "[package]\nname = \"rita\"\n-version = \"0.5.55\"\n+version = \"0.5.56\"\nauthors = [\"Justin <justin@althea.net>\", \"Jehan <jehan.tremback@gmail.com>\", \"Ben <wangben3@gmail.com>\"]\nbuild = \"build.rs\"\nedition = \"2018\"\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/dashboard/own_info.rs",
"new_path": "rita/src/rita_common/dashboard/own_info.rs",
"diff": "@@ -6,7 +6,7 @@ use failure::Error;\nuse num256::{Int256, Uint256};\nuse settings::RitaCommonSettings;\n-pub static READABLE_VERSION: &str = \"Beta 14 RC9\";\n+pub static READABLE_VERSION: &str = \"Beta 14 RC10\";\n#[derive(Serialize)]\npub struct OwnInfo {\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Bump for Beta 14 RC10 |
20,244 | 23.06.2020 08:00:40 | 14,400 | 0d0625f1c52574a7861d1bddfede709ba6d0f5ba | Default for new RunningLatencyStats fields
Required to migrate the operator tools database | [
{
"change_type": "MODIFY",
"old_path": "althea_types/src/monitoring.rs",
"new_path": "althea_types/src/monitoring.rs",
"diff": "@@ -29,8 +29,10 @@ pub struct RunningLatencyStats {\n#[serde(skip_serializing, skip_deserializing)]\nlast_changed: Option<Instant>,\n/// the front of the latency history ring buffer\n+ #[serde(default)]\nfront: usize,\n/// A history of the last few values we have seen, used to compute the median\n+ #[serde(default)]\nhistory: Vec<f32>,\n}\n@@ -70,6 +72,14 @@ impl RunningLatencyStats {\n}\n}\npub fn add_sample(&mut self, sample: f32) {\n+ // handles when 'default' was miscalled, this should be safe to remove\n+ // TODO remove operator tools fixing hack\n+ if self.history.is_empty() {\n+ let mut new = Vec::with_capacity(LATENCY_HISTORY);\n+ new.extend_from_slice(&[0.0; LATENCY_HISTORY]);\n+ self.history = new;\n+ }\n+\nmatch self.count.checked_add(1) {\nSome(val) => self.count = val,\nNone => self.reset(),\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Default for new RunningLatencyStats fields
Required to migrate the operator tools database |
20,244 | 23.06.2020 14:52:03 | 14,400 | 63d58f8237ee0f9994de6ed9959dfd6aae349023 | Add settings flag for new wyre flow
Turns out wyre isn't ready for people to actually use their
'soon to be mandatory' new flow. So I've made it remotely configurable | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/localization.rs",
"new_path": "rita/src/rita_client/dashboard/localization.rs",
"diff": "@@ -21,6 +21,7 @@ pub struct LocalizationReturn {\npub wyre_account_id: String,\npub display_currency_symbol: bool,\npub support_number: String,\n+ pub wyre_reservation_flow: bool,\n}\nimpl From<LocalizationSettings> for LocalizationReturn {\n@@ -34,6 +35,7 @@ impl From<LocalizationSettings> for LocalizationReturn {\n.format()\n.mode(Mode::National)\n.to_string(),\n+ wyre_reservation_flow: input.wyre_reservation_flow,\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "settings/src/localization.rs",
"new_path": "settings/src/localization.rs",
"diff": "@@ -12,6 +12,12 @@ fn default_display_currency_symbol() -> bool {\ntrue\n}\n+// disable the wyre reservation flow as it is half baked\n+// as of this release\n+fn default_wyre_reservation_flow() -> bool {\n+ false\n+}\n+\nfn default_support_number() -> PhoneNumber {\n\"+18664ALTHEA\".parse().unwrap()\n}\n@@ -35,6 +41,11 @@ pub struct LocalizationSettings {\n/// a locally relevant one if possible.\n#[serde(default = \"default_support_number\")]\npub support_number: PhoneNumber,\n+ /// If we use the wyre hosted debit card widget flow or the reservation flow, the reservation\n+ /// flow calls out to the operator tools to get a reservation link whereas the pre-reservation flow\n+ /// is simply a link to the wyre widget\n+ #[serde(default = \"default_wyre_reservation_flow\")]\n+ pub wyre_reservation_flow: bool,\n}\nimpl Default for LocalizationSettings {\n@@ -44,6 +55,7 @@ impl Default for LocalizationSettings {\nwyre_account_id: default_wyre_account_id(),\ndisplay_currency_symbol: default_display_currency_symbol(),\nsupport_number: default_support_number(),\n+ wyre_reservation_flow: default_wyre_reservation_flow(),\n}\n}\n}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Add settings flag for new wyre flow
Turns out wyre isn't ready for people to actually use their
'soon to be mandatory' new flow. So I've made it remotely configurable |
20,244 | 02.07.2020 11:07:44 | 14,400 | 652f70c79d3b9f2ca4be36d1082d2ef5fe223d45 | Add interfaces parsing for Babel | [
{
"change_type": "MODIFY",
"old_path": "babel_monitor/src/lib.rs",
"new_path": "babel_monitor/src/lib.rs",
"diff": "@@ -98,6 +98,14 @@ where\n}\n}\n+#[derive(Debug, Clone, Serialize, Deserialize)]\n+pub struct Interface {\n+ pub name: String,\n+ pub up: bool,\n+ pub ipv6: Option<IpAddr>,\n+ pub ipv4: Option<IpAddr>,\n+}\n+\n#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct Route {\npub id: String,\n@@ -276,6 +284,18 @@ fn validate_preamble(preamble: String) -> Result<(), Error> {\n}\n}\n+pub fn get_interfaces(\n+ stream: TcpStream,\n+) -> impl Future<Item = (TcpStream, Vec<Interface>), Error = Error> {\n+ run_command(stream, \"dump\").then(|output| {\n+ if let Err(e) = output {\n+ return Err(e);\n+ }\n+ let (stream, babel_output) = output.unwrap();\n+ Ok((stream, parse_interfaces_sync(babel_output)?))\n+ })\n+}\n+\npub fn get_local_fee(stream: TcpStream) -> impl Future<Item = (TcpStream, u32), Error = Error> {\nrun_command(stream, \"dump\").then(|output| {\nif let Err(e) = output {\n@@ -388,6 +408,39 @@ pub fn parse_neighs(\n})\n}\n+fn parse_interfaces_sync(output: String) -> Result<Vec<Interface>, Error> {\n+ let mut vector: Vec<Interface> = Vec::new();\n+ let mut found_interface = false;\n+ for entry in output.split('\\n') {\n+ if entry.contains(\"add interface\") {\n+ found_interface = true;\n+ let interface = Interface {\n+ name: match find_babel_val(\"interface\", entry) {\n+ Ok(val) => val,\n+ Err(_) => continue,\n+ },\n+ up: match find_and_parse_babel_val(\"up\", entry) {\n+ Ok(val) => val,\n+ Err(_) => continue,\n+ },\n+ ipv4: match find_and_parse_babel_val(\"ipv4\", entry) {\n+ Ok(val) => Some(val),\n+ Err(_) => None,\n+ },\n+ ipv6: match find_and_parse_babel_val(\"ipv6\", entry) {\n+ Ok(val) => Some(val),\n+ Err(_) => None,\n+ },\n+ };\n+ vector.push(interface);\n+ }\n+ }\n+ if vector.is_empty() && found_interface {\n+ bail!(\"All Babel Interface parsing failed!\")\n+ }\n+ Ok(vector)\n+}\n+\nfn parse_neighs_sync(output: String) -> Result<Vec<Neighbor>, Error> {\nlet mut vector: Vec<Neighbor> = Vec::with_capacity(5);\nlet mut found_neigh = false;\n@@ -601,6 +654,8 @@ metric factor 1900\\n\\\nadd interface lo up false\\n\\\nadd interface wlan0 up true ipv6 fe80::1a8b:ec1:8542:1bd8 ipv4 10.28.119.131\\n\\\nadd interface wg0 up true ipv6 fe80::2cee:2fff:7380:8354 ipv4 10.0.236.201\\n\\\n+add interface wg44 up false\\n\\\n+add interface wg43 up true ipv6 fe80::d1fd:cb7a:e760:2ec0\\n\\\nadd neighbour 14f19a8 address fe80::2cee:2fff:648:8796 if wg0 reach ffff rxcost 256 txcost 256 rtt \\\n26.723 rttcost 912 cost 1168\\n\\\nadd neighbour 14f0640 address fe80::e841:e384:491e:8eb9 if wlan0 reach 9ff7 rxcost 512 txcost 256 \\\n@@ -706,6 +761,24 @@ ok\\n\";\nassert_eq!(route.price, 3072);\n}\n+ #[test]\n+ fn interfaces_parse() {\n+ let interfaces = parse_interfaces_sync(TABLE.to_string()).unwrap();\n+ assert_eq!(interfaces.len(), 5);\n+\n+ let iface = interfaces.get(0).unwrap();\n+ assert!(!iface.up);\n+ let iface = interfaces.get(2).unwrap();\n+ assert_eq!(iface.ipv4, Some(\"10.0.236.201\".parse().unwrap()));\n+ let iface = interfaces.get(3).unwrap();\n+ assert!(iface.ipv4.is_none());\n+ assert!(iface.ipv6.is_none());\n+ assert!(!iface.up);\n+ let iface = interfaces.get(4).unwrap();\n+ assert!(iface.up);\n+ assert!(iface.ipv6.is_some());\n+ }\n+\n#[test]\nfn local_fee_parse() {\nassert_eq!(get_local_fee_sync(TABLE.to_string()).unwrap(), 1024);\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Add interfaces parsing for Babel |
20,244 | 02.07.2020 11:37:02 | 14,400 | b29a92a5ba9af66805324f8b5c52dc81fe2ee279 | Break out TunnelManager GC into it's own file
Trying to slowly break down this monolithic file | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/rita_loop/slow_loop.rs",
"new_path": "rita/src/rita_common/rita_loop/slow_loop.rs",
"diff": "@@ -2,7 +2,8 @@ use crate::rita_common::simulated_txfee_manager::SimulatedTxFeeManager;\nuse crate::rita_common::simulated_txfee_manager::Tick as TxFeeTick;\nuse crate::rita_common::token_bridge::Tick as TokenBridgeTick;\nuse crate::rita_common::token_bridge::TokenBridge;\n-use crate::rita_common::tunnel_manager::{TriggerGC, TunnelManager};\n+use crate::rita_common::tunnel_manager::gc::TriggerGC;\n+use crate::rita_common::tunnel_manager::TunnelManager;\nuse crate::SETTING;\nuse actix::{\nActor, ActorContext, Addr, Arbiter, AsyncContext, Context, Handler, Message, Supervised,\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "rita/src/rita_common/tunnel_manager/gc.rs",
"diff": "+use super::Tunnel;\n+use super::TunnelManager;\n+use crate::KI;\n+use actix::{Context, Handler, Message};\n+use althea_types::Identity;\n+use failure::Error;\n+use std::collections::HashMap;\n+use std::time::Duration;\n+\n+/// A message type for deleting all tunnels we haven't heard from for more than the duration.\n+pub struct TriggerGC {\n+ /// if we do not receive a hello within this many seconds we attempt to gc the tunnel\n+ /// this garbage collection can be avoided if the tunnel has seen a handshake within\n+ /// tunnel_handshake_timeout time\n+ pub tunnel_timeout: Duration,\n+ /// The backup value that prevents us from deleting an active tunnel. We check the last\n+ /// handshake on the tunnel and if it's within this amount of time we don't GC it.\n+ pub tunnel_handshake_timeout: Duration,\n+}\n+\n+impl Message for TriggerGC {\n+ type Result = Result<(), Error>;\n+}\n+\n+impl Handler<TriggerGC> for TunnelManager {\n+ type Result = Result<(), Error>;\n+ fn handle(&mut self, msg: TriggerGC, _ctx: &mut Context<Self>) -> Self::Result {\n+ let mut good: HashMap<Identity, Vec<Tunnel>> = HashMap::new();\n+ let mut timed_out: HashMap<Identity, Vec<Tunnel>> = HashMap::new();\n+ // Split entries into good and timed out rebuilding the double hashmap structure\n+ // as you can tell this is totally copy based and uses 2n ram to prevent borrow\n+ // checker issues, we should consider a method that does modify in place\n+ for (_identity, tunnels) in self.tunnels.iter() {\n+ for tunnel in tunnels.iter() {\n+ if tunnel.last_contact.elapsed() < msg.tunnel_timeout\n+ || check_handshake_time(msg.tunnel_handshake_timeout, &tunnel.iface_name)\n+ {\n+ insert_into_tunnel_list(tunnel, &mut good);\n+ } else {\n+ insert_into_tunnel_list(tunnel, &mut timed_out)\n+ }\n+ }\n+ }\n+\n+ for (id, tunnels) in timed_out.iter() {\n+ for tunnel in tunnels {\n+ info!(\"TriggerGC: removing tunnel: {} {}\", id, tunnel);\n+ }\n+ }\n+\n+ // Please keep in mind it makes more sense to update the tunnel map *before* yielding the\n+ // actual interfaces and ports from timed_out.\n+ //\n+ // The difference is leaking interfaces on del_interface() failure vs. Rita thinking\n+ // it has freed ports/interfaces which are still there/claimed.\n+ //\n+ // The former would be a mere performance bug while inconsistent-with-reality Rita state\n+ // would lead to nasty bugs in case del_interface() goes wrong for whatever reason.\n+ self.tunnels = good;\n+\n+ for (_ident, tunnels) in timed_out {\n+ for tunnel in tunnels {\n+ match tunnel.light_client_details {\n+ None => {\n+ // In the same spirit, we return the port to the free port pool only after tunnel\n+ // deletion goes well.\n+ tunnel.unmonitor(0);\n+ }\n+ Some(_) => {\n+ tunnel.close_light_client_tunnel();\n+ }\n+ }\n+ }\n+ }\n+\n+ Ok(())\n+ }\n+}\n+\n+/// A simple helper function to reduce the number of if/else statements in tunnel GC\n+fn insert_into_tunnel_list(input: &Tunnel, tunnels_list: &mut HashMap<Identity, Vec<Tunnel>>) {\n+ let identity = &input.neigh_id.global;\n+ let input = input.clone();\n+ if tunnels_list.contains_key(identity) {\n+ tunnels_list.get_mut(identity).unwrap().push(input);\n+ } else {\n+ tunnels_list.insert(*identity, Vec::new());\n+ tunnels_list.get_mut(identity).unwrap().push(input);\n+ }\n+}\n+\n+/// This function checks the handshake time of a tunnel when compared to the handshake timeout,\n+/// it returns true if we fail to get the handshake time (erring on the side of caution) and only\n+/// false if all last tunnel handshakes are older than the allowed time limit\n+fn check_handshake_time(handshake_timeout: Duration, ifname: &str) -> bool {\n+ let res = KI.get_last_handshake_time(ifname);\n+ match res {\n+ Ok(handshakes) => {\n+ for (_key, time) in handshakes {\n+ match time.elapsed() {\n+ Ok(elapsed) => {\n+ if elapsed < handshake_timeout {\n+ return true;\n+ }\n+ }\n+ Err(_e) => {\n+ // handshake in the future, possible system clock change\n+ return true;\n+ }\n+ }\n+ }\n+ false\n+ }\n+ Err(e) => {\n+ error!(\"Could not get tunnel handshake with {:?}\", e);\n+ true\n+ }\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/tunnel_manager/mod.rs",
"new_path": "rita/src/rita_common/tunnel_manager/mod.rs",
"diff": "//! up tunnels if they respond, likewise if someone calls us their hello goes through network_endpoints\n//! then into TunnelManager to open a tunnel for them.\n+pub mod gc;\npub mod id_callback;\npub mod shaping;\n@@ -474,117 +475,6 @@ impl Handler<GetTunnels> for TunnelManager {\n}\n}\n-/// A message type for deleting all tunnels we haven't heard from for more than the duration.\n-pub struct TriggerGC {\n- /// if we do not receive a hello within this many seconds we attempt to gc the tunnel\n- /// this garbage collection can be avoided if the tunnel has seen a handshake within\n- /// tunnel_handshake_timeout time\n- pub tunnel_timeout: Duration,\n- /// The backup value that prevents us from deleting an active tunnel. We check the last\n- /// handshake on the tunnel and if it's within this amount of time we don't GC it.\n- pub tunnel_handshake_timeout: Duration,\n-}\n-\n-impl Message for TriggerGC {\n- type Result = Result<(), Error>;\n-}\n-\n-impl Handler<TriggerGC> for TunnelManager {\n- type Result = Result<(), Error>;\n- fn handle(&mut self, msg: TriggerGC, _ctx: &mut Context<Self>) -> Self::Result {\n- let mut good: HashMap<Identity, Vec<Tunnel>> = HashMap::new();\n- let mut timed_out: HashMap<Identity, Vec<Tunnel>> = HashMap::new();\n- // Split entries into good and timed out rebuilding the double hashmap structure\n- // as you can tell this is totally copy based and uses 2n ram to prevent borrow\n- // checker issues, we should consider a method that does modify in place\n- for (_identity, tunnels) in self.tunnels.iter() {\n- for tunnel in tunnels.iter() {\n- if tunnel.last_contact.elapsed() < msg.tunnel_timeout\n- || check_handshake_time(msg.tunnel_handshake_timeout, &tunnel.iface_name)\n- {\n- insert_into_tunnel_list(tunnel, &mut good);\n- } else {\n- insert_into_tunnel_list(tunnel, &mut timed_out)\n- }\n- }\n- }\n-\n- for (id, tunnels) in timed_out.iter() {\n- for tunnel in tunnels {\n- info!(\"TriggerGC: removing tunnel: {} {}\", id, tunnel);\n- }\n- }\n-\n- // Please keep in mind it makes more sense to update the tunnel map *before* yielding the\n- // actual interfaces and ports from timed_out.\n- //\n- // The difference is leaking interfaces on del_interface() failure vs. Rita thinking\n- // it has freed ports/interfaces which are still there/claimed.\n- //\n- // The former would be a mere performance bug while inconsistent-with-reality Rita state\n- // would lead to nasty bugs in case del_interface() goes wrong for whatever reason.\n- self.tunnels = good;\n-\n- for (_ident, tunnels) in timed_out {\n- for tunnel in tunnels {\n- match tunnel.light_client_details {\n- None => {\n- // In the same spirit, we return the port to the free port pool only after tunnel\n- // deletion goes well.\n- tunnel.unmonitor(0);\n- }\n- Some(_) => {\n- tunnel.close_light_client_tunnel();\n- }\n- }\n- }\n- }\n-\n- Ok(())\n- }\n-}\n-\n-/// A simple helper function to reduce the number of if/else statements in tunnel GC\n-fn insert_into_tunnel_list(input: &Tunnel, tunnels_list: &mut HashMap<Identity, Vec<Tunnel>>) {\n- let identity = &input.neigh_id.global;\n- let input = input.clone();\n- if tunnels_list.contains_key(identity) {\n- tunnels_list.get_mut(identity).unwrap().push(input);\n- } else {\n- tunnels_list.insert(*identity, Vec::new());\n- tunnels_list.get_mut(identity).unwrap().push(input);\n- }\n-}\n-\n-/// This function checks the handshake time of a tunnel when compared to the handshake timeout,\n-/// it returns true if we fail to get the handshake time (erring on the side of caution) and only\n-/// false if all last tunnel handshakes are older than the allowed time limit\n-fn check_handshake_time(handshake_timeout: Duration, ifname: &str) -> bool {\n- let res = KI.get_last_handshake_time(ifname);\n- match res {\n- Ok(handshakes) => {\n- for (_key, time) in handshakes {\n- match time.elapsed() {\n- Ok(elapsed) => {\n- if elapsed < handshake_timeout {\n- return true;\n- }\n- }\n- Err(_e) => {\n- // handshake in the future, possible system clock change\n- return true;\n- }\n- }\n- }\n- false\n- }\n- Err(e) => {\n- error!(\"Could not get tunnel handshake with {:?}\", e);\n- true\n- }\n- }\n-}\n-\npub struct PeersToContact {\npub peers: HashMap<IpAddr, Peer>,\n}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Break out TunnelManager GC into it's own file
Trying to slowly break down this monolithic file |
20,244 | 02.07.2020 14:24:22 | 14,400 | 3b1baecab407e61107c14ee04f0c5c98f86b5a0a | Remove tunnels babel marks as down
This adds a new tunnel GC condition. If babel has marked the tunnel
as down, we should garbage collect it during our normal GC runs in
the ideal case this will result in the tunnel being recreated right
away | [
{
"change_type": "MODIFY",
"old_path": "babel_monitor/src/lib.rs",
"new_path": "babel_monitor/src/lib.rs",
"diff": "@@ -284,7 +284,7 @@ fn validate_preamble(preamble: String) -> Result<(), Error> {\n}\n}\n-pub fn get_interfaces(\n+pub fn parse_interfaces(\nstream: TcpStream,\n) -> impl Future<Item = (TcpStream, Vec<Interface>), Error = Error> {\nrun_command(stream, \"dump\").then(|output| {\n@@ -296,6 +296,39 @@ pub fn get_interfaces(\n})\n}\n+fn parse_interfaces_sync(output: String) -> Result<Vec<Interface>, Error> {\n+ let mut vector: Vec<Interface> = Vec::new();\n+ let mut found_interface = false;\n+ for entry in output.split('\\n') {\n+ if entry.contains(\"add interface\") {\n+ found_interface = true;\n+ let interface = Interface {\n+ name: match find_babel_val(\"interface\", entry) {\n+ Ok(val) => val,\n+ Err(_) => continue,\n+ },\n+ up: match find_and_parse_babel_val(\"up\", entry) {\n+ Ok(val) => val,\n+ Err(_) => continue,\n+ },\n+ ipv4: match find_and_parse_babel_val(\"ipv4\", entry) {\n+ Ok(val) => Some(val),\n+ Err(_) => None,\n+ },\n+ ipv6: match find_and_parse_babel_val(\"ipv6\", entry) {\n+ Ok(val) => Some(val),\n+ Err(_) => None,\n+ },\n+ };\n+ vector.push(interface);\n+ }\n+ }\n+ if vector.is_empty() && found_interface {\n+ bail!(\"All Babel Interface parsing failed!\")\n+ }\n+ Ok(vector)\n+}\n+\npub fn get_local_fee(stream: TcpStream) -> impl Future<Item = (TcpStream, u32), Error = Error> {\nrun_command(stream, \"dump\").then(|output| {\nif let Err(e) = output {\n@@ -408,39 +441,6 @@ pub fn parse_neighs(\n})\n}\n-fn parse_interfaces_sync(output: String) -> Result<Vec<Interface>, Error> {\n- let mut vector: Vec<Interface> = Vec::new();\n- let mut found_interface = false;\n- for entry in output.split('\\n') {\n- if entry.contains(\"add interface\") {\n- found_interface = true;\n- let interface = Interface {\n- name: match find_babel_val(\"interface\", entry) {\n- Ok(val) => val,\n- Err(_) => continue,\n- },\n- up: match find_and_parse_babel_val(\"up\", entry) {\n- Ok(val) => val,\n- Err(_) => continue,\n- },\n- ipv4: match find_and_parse_babel_val(\"ipv4\", entry) {\n- Ok(val) => Some(val),\n- Err(_) => None,\n- },\n- ipv6: match find_and_parse_babel_val(\"ipv6\", entry) {\n- Ok(val) => Some(val),\n- Err(_) => None,\n- },\n- };\n- vector.push(interface);\n- }\n- }\n- if vector.is_empty() && found_interface {\n- bail!(\"All Babel Interface parsing failed!\")\n- }\n- Ok(vector)\n-}\n-\nfn parse_neighs_sync(output: String) -> Result<Vec<Neighbor>, Error> {\nlet mut vector: Vec<Neighbor> = Vec::with_capacity(5);\nlet mut found_neigh = false;\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/rita_loop/slow_loop.rs",
"new_path": "rita/src/rita_common/rita_loop/slow_loop.rs",
"diff": "@@ -10,6 +10,7 @@ use actix::{\nSystemService,\n};\nuse babel_monitor::open_babel_stream;\n+use babel_monitor::parse_interfaces;\nuse babel_monitor::set_local_fee;\nuse babel_monitor::set_metric_factor;\nuse babel_monitor::start_connection;\n@@ -82,13 +83,33 @@ impl Handler<Tick> for RitaSlowLoop {\ntype Result = Result<(), Error>;\nfn handle(&mut self, _: Tick, _ctx: &mut Context<Self>) -> Self::Result {\ntrace!(\"Common Slow tick!\");\n+ let babel_port = SETTING.get_network().babel_port;\nSimulatedTxFeeManager::from_registry().do_send(TxFeeTick);\n+ Arbiter::spawn(\n+ open_babel_stream(babel_port)\n+ .from_err()\n+ .and_then(move |stream| {\n+ start_connection(stream).and_then(move |stream| {\n+ parse_interfaces(stream).and_then(move |(_stream, babel_interfaces)| {\n+ trace!(\"Sending tunnel GC\");\nTunnelManager::from_registry().do_send(TriggerGC {\ntunnel_timeout: TUNNEL_TIMEOUT,\ntunnel_handshake_timeout: TUNNEL_HANDSHAKE_TIMEOUT,\n+ babel_interfaces,\n});\n+ Ok(())\n+ })\n+ })\n+ })\n+ .then(|ret| {\n+ if let Err(e) = ret {\n+ error!(\"Tunnel Garbage collection failed with {:?}\", e)\n+ }\n+ Ok(())\n+ }),\n+ );\nTokenBridge::from_registry().do_send(TokenBridgeTick());\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/tunnel_manager/gc.rs",
"new_path": "rita/src/rita_common/tunnel_manager/gc.rs",
"diff": "@@ -3,6 +3,7 @@ use super::TunnelManager;\nuse crate::KI;\nuse actix::{Context, Handler, Message};\nuse althea_types::Identity;\n+use babel_monitor::Interface;\nuse failure::Error;\nuse std::collections::HashMap;\nuse std::time::Duration;\n@@ -16,6 +17,10 @@ pub struct TriggerGC {\n/// The backup value that prevents us from deleting an active tunnel. We check the last\n/// handshake on the tunnel and if it's within this amount of time we don't GC it.\npub tunnel_handshake_timeout: Duration,\n+ /// a vector of babel interfaces, if we find an interface that babel doesn't classify as\n+ /// 'up' we will gc it for recreation via the normal hello/ihu process, this prevents us\n+ /// from having tunnels that don't work for babel peers\n+ pub babel_interfaces: Vec<Interface>,\n}\nimpl Message for TriggerGC {\n@@ -25,24 +30,29 @@ impl Message for TriggerGC {\nimpl Handler<TriggerGC> for TunnelManager {\ntype Result = Result<(), Error>;\nfn handle(&mut self, msg: TriggerGC, _ctx: &mut Context<Self>) -> Self::Result {\n+ let interfaces = into_interfaces_hashmap(msg.babel_interfaces);\n+ trace!(\"Starting tunnel gc {:?}\", interfaces);\nlet mut good: HashMap<Identity, Vec<Tunnel>> = HashMap::new();\n- let mut timed_out: HashMap<Identity, Vec<Tunnel>> = HashMap::new();\n+ let mut to_delete: HashMap<Identity, Vec<Tunnel>> = HashMap::new();\n// Split entries into good and timed out rebuilding the double hashmap structure\n// as you can tell this is totally copy based and uses 2n ram to prevent borrow\n// checker issues, we should consider a method that does modify in place\nfor (_identity, tunnels) in self.tunnels.iter() {\nfor tunnel in tunnels.iter() {\n- if tunnel.last_contact.elapsed() < msg.tunnel_timeout\n- || check_handshake_time(msg.tunnel_handshake_timeout, &tunnel.iface_name)\n+ // we keep tunnels that have not timed out or have a recent handshake and are marked as\n+ // up in babel.\n+ if (tunnel.last_contact.elapsed() < msg.tunnel_timeout\n+ || check_handshake_time(msg.tunnel_handshake_timeout, &tunnel.iface_name))\n+ && tunnel_up(&interfaces, &tunnel.iface_name)\n{\ninsert_into_tunnel_list(tunnel, &mut good);\n} else {\n- insert_into_tunnel_list(tunnel, &mut timed_out)\n+ insert_into_tunnel_list(tunnel, &mut to_delete)\n}\n}\n}\n- for (id, tunnels) in timed_out.iter() {\n+ for (id, tunnels) in to_delete.iter() {\nfor tunnel in tunnels {\ninfo!(\"TriggerGC: removing tunnel: {} {}\", id, tunnel);\n}\n@@ -58,7 +68,7 @@ impl Handler<TriggerGC> for TunnelManager {\n// would lead to nasty bugs in case del_interface() goes wrong for whatever reason.\nself.tunnels = good;\n- for (_ident, tunnels) in timed_out {\n+ for (_ident, tunnels) in to_delete {\nfor tunnel in tunnels {\nmatch tunnel.light_client_details {\nNone => {\n@@ -117,3 +127,32 @@ fn check_handshake_time(handshake_timeout: Duration, ifname: &str) -> bool {\n}\n}\n}\n+\n+/// sorts the interfaces vector into a hashmap of interface name to up status\n+fn into_interfaces_hashmap(interfaces: Vec<Interface>) -> HashMap<String, bool> {\n+ let mut ret = HashMap::new();\n+ for interface in interfaces {\n+ ret.insert(interface.name, interface.up);\n+ }\n+ ret\n+}\n+\n+/// Searches the list of Babel tunnels for a given tunnel, if the tunnel is found\n+/// and it is down (not up in this case) we return false, indicating that this tunnel\n+/// needs to be deleted. If we do not find the tunnel return true. Because it is possible\n+/// that during a tunnel monitor failure we may encounter such a tunnel. We log this case\n+/// for later inspection to determine if this ever actually happens.\n+fn tunnel_up(interfaces: &HashMap<String, bool>, tunnel_name: &str) -> bool {\n+ trace!(\"Checking if {} is up\", tunnel_name);\n+ if let Some(up) = interfaces.get(tunnel_name) {\n+ if !up {\n+ warn!(\"Found Babel interface that's not up, removing!\");\n+ false\n+ } else {\n+ true\n+ }\n+ } else {\n+ error!(\"Could not find interface in Babel, did monitor fail?\");\n+ true\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/tunnel_manager/mod.rs",
"new_path": "rita/src/rita_common/tunnel_manager/mod.rs",
"diff": "@@ -222,7 +222,7 @@ impl Tunnel {\n})\n.then(move |res| {\n// Errors here seem very very rare, I've only ever seen it happen\n- // twice myself and I couldn't reproduce it, nontheless it's a pretty\n+ // twice myself and I couldn't reproduce it, nonetheless it's a pretty\n// bad situation so we will retry\nif let Err(e) = res {\nwarn!(\"Tunnel monitor failed with {:?}, retrying in 1 second\", e);\n@@ -386,7 +386,7 @@ impl Handler<TunnelUnMonitorFailure> for TunnelManager {\ntunnel_to_retry.unmonitor(retry_count + 1);\n} else {\nerror!(\n- \"Unmonitoring tunnel has failed! Babel will now listen on a non-existant tunnel\"\n+ \"Unmonitoring tunnel has failed! Babel will now listen on a non-existent tunnel\"\n);\n}\n}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Remove tunnels babel marks as down
This adds a new tunnel GC condition. If babel has marked the tunnel
as down, we should garbage collect it during our normal GC runs in
the ideal case this will result in the tunnel being recreated right
away |
20,244 | 18.07.2020 10:50:26 | 14,400 | aa88c093e5cb503efca5cab59c23e6faf1dad157 | B side of Beta 15 phased changes
This completes several struct migrations started in Beta 14 that are
no longer needed now that everyone is updated | [
{
"change_type": "MODIFY",
"old_path": "althea_types/src/contact_info.rs",
"new_path": "althea_types/src/contact_info.rs",
"diff": "@@ -7,8 +7,7 @@ use crate::ExitRegistrationDetails;\nuse lettre::EmailAddress;\nuse phonenumber::PhoneNumber;\n-/// Struct for storing user contact details, being phased out in favor\n-/// of ContactType in Beta 15\n+/// Struct for submitting contact details to exits\n#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]\npub struct ContactDetails {\npub phone: Option<String>,\n"
},
{
"change_type": "MODIFY",
"old_path": "althea_types/src/interop.rs",
"new_path": "althea_types/src/interop.rs",
"diff": "-use crate::{\n- contact_info::{ContactDetails, ContactType},\n- wg_key::WgKey,\n- BillingDetails, InstallationDetails,\n-};\n+use crate::{contact_info::ContactType, wg_key::WgKey, BillingDetails, InstallationDetails};\nuse arrayvec::ArrayString;\nuse babel_monitor::Neighbor;\nuse babel_monitor::Route;\n@@ -446,10 +442,6 @@ pub struct OperatorUpdateMessage {\n/// An action the operator wants to take to affect this router, examples may include reset\n/// password or change the wifi ssid\npub operator_action: Option<OperatorAction>,\n- /// being phased out, see shaper settings TODO Remove in Beta 15\n- pub max_shaper_speed: Option<usize>,\n- /// being phased out, see shaper settings TODO Remove in Beta 15\n- pub min_shaper_speed: Option<usize>,\n/// settings for the device bandwidth shaper\n#[serde(default = \"default_shaper_settings\")]\npub shaper_settings: ShaperSettings,\n@@ -496,8 +488,6 @@ pub struct OperatorCheckinMessage {\n/// we don't need instant updates of it. Arguably the phone number and email\n/// values for heartbeats should come in through here.\npub neighbor_info: Option<Vec<NeighborStatus>>,\n- /// Legacy contact_info with less validation beta 13 only\n- pub contact_details: Option<ContactDetails>,\n/// The user contact details, stored in exit client details but used throughout\n/// for various reasons.\n/// see the type definition for more details about how this type restricts values\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/client.rs",
"new_path": "rita/src/client.rs",
"diff": "@@ -124,7 +124,6 @@ use althea_kernel_interface::KernelInterface;\nuse althea_kernel_interface::LinuxCommandRunner;\n#[cfg(test)]\nuse althea_kernel_interface::TestCommandRunner;\n-use althea_types::ContactStorage;\n#[cfg(test)]\nlazy_static! {\n@@ -203,26 +202,7 @@ fn wait_for_settings(settings_file: &str) -> RitaSettingsStruct {\n}\n}\n-/// Migrates from the old contact details structure to the new one, returns true\n-/// if a migration has occurred.\n-pub fn migrate_contact_info() -> bool {\n- let mut exit_client = SETTING.get_exit_client_mut();\n- let reg_details = exit_client.reg_details.clone();\n- if let Some(reg_details) = reg_details {\n- // only migrate if it has not already been done, otherwise we might\n- // overwrite changed details\n- if exit_client.contact_info.is_none() {\n- let contact_info: Option<ContactStorage> = ContactStorage::convert(reg_details);\n- exit_client.contact_info = contact_info;\n- return true;\n- }\n- }\n- false\n-}\n-\nfn main() {\n- migrate_contact_info();\n-\n// On Linux static builds we need to probe ssl certs path to be able to\n// do TLS stuff.\nopenssl_probe::init_ssl_cert_env_vars();\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/dashboard/exits.rs",
"new_path": "rita/src/rita_client/dashboard/exits.rs",
"diff": "//! The Exit info endpoint gathers infromation about exit status and presents it to the dashbaord.\n-use crate::migrate_contact_info;\nuse crate::rita_client::exit_manager::exit_setup_request;\nuse crate::rita_common::dashboard::Dashboard;\nuse crate::ARGS;\n@@ -212,14 +211,6 @@ pub fn register_to_exit(path: Path<String>) -> Box<dyn Future<Item = HttpRespons\ndebug!(\"Attempting to register on exit {:?}\", exit_name);\n- // before beta 14 contact info was set directly into the config via the settings merge endpoint\n- // so what can happen is if a user has the beta 13 or before dashboard in their browser cache and\n- // goes to register to an exit it slips in the registration details into the config without us knowing\n- // and without performing a migration. We could intercept that at the settings endpoint but it's easier\n- // to just re-run the migration here and check to see if we have old style contact details set that we\n- // have no already migrated.\n- migrate_contact_info_and_hide_operator_info();\n-\nBox::new(exit_setup_request(exit_name, None).then(|res| {\nlet mut ret = HashMap::new();\nmatch res {\n@@ -244,9 +235,6 @@ pub fn verify_on_exit_with_code(\nlet (exit_name, code) = path.into_inner();\ndebug!(\"/exits/{}/verify/{} hit\", exit_name, code);\n- // same as register_to_exit() but I'm actually 99% sure it's not actually needed here.\n- migrate_contact_info_and_hide_operator_info();\n-\nBox::new(exit_setup_request(exit_name, Some(code)).then(|res| {\nlet mut ret = HashMap::new();\nmatch res {\n@@ -264,16 +252,3 @@ pub fn verify_on_exit_with_code(\n}\n}))\n}\n-\n-/// We need to do a migration in this file if and only if the user has used the\n-/// old dashboard to set their email or phone number since reboot. In that case\n-/// they probably have an old version of the dash cached and are not seeing the\n-/// new operator setup screen. Since we don't want the customer eventually seeing\n-/// it we should hide it\n-pub fn migrate_contact_info_and_hide_operator_info() {\n- let res = migrate_contact_info();\n- if res {\n- let mut operator = SETTING.get_operator_mut();\n- operator.display_operator_setup = false;\n- }\n-}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/operator_update/mod.rs",
"new_path": "rita/src/rita_client/operator_update/mod.rs",
"diff": "@@ -147,7 +147,6 @@ fn checkin() {\noperator_address,\nsystem_chain,\nneighbor_info: Some(neighbor_info),\n- contact_details: None,\ncontact_info,\ninstall_details,\nbilling_details,\n"
},
{
"change_type": "MODIFY",
"old_path": "settings/src/client.rs",
"new_path": "settings/src/client.rs",
"diff": "@@ -6,7 +6,7 @@ use crate::operator::OperatorSettings;\nuse crate::payment::PaymentSettings;\nuse crate::spawn_watch_thread;\nuse crate::RitaCommonSettings;\n-use althea_types::{ContactStorage, ExitRegistrationDetails, ExitState, Identity};\n+use althea_types::{ContactStorage, ExitState, Identity};\nuse config::Config;\nuse failure::Error;\nuse owning_ref::{RwLockReadGuardRef, RwLockWriteGuardRefMut};\n@@ -49,8 +49,6 @@ pub struct ExitClientSettings {\npub contact_info: Option<ContactStorage>,\n/// This controls which interfaces will be proxied over the exit tunnel\npub lan_nics: HashSet<String>,\n- /// legacy contact details storage, to be phased out in beta 15 after everyone has migrated\n- pub reg_details: Option<ExitRegistrationDetails>,\n/// Specifies if the user would like to receive low balance messages from the exit\n#[serde(default = \"default_balance_notification\")]\npub low_balance_notification: bool,\n@@ -62,7 +60,6 @@ impl Default for ExitClientSettings {\nexits: HashMap::new(),\ncurrent_exit: None,\nwg_listen_port: 59999,\n- reg_details: None,\ncontact_info: None,\nlan_nics: HashSet::new(),\nlow_balance_notification: true,\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | B side of Beta 15 phased changes
This completes several struct migrations started in Beta 14 that are
no longer needed now that everyone is updated |
20,244 | 21.07.2020 11:04:06 | 14,400 | 09f93fe4a349547a9c4f0bfbef14748a7ad13de9 | Async auto-bridge
This moves the auto-bridge library to async/await. Still requires testing | [
{
"change_type": "MODIFY",
"old_path": "auto_bridge/Cargo.toml",
"new_path": "auto_bridge/Cargo.toml",
"diff": "[package]\nname = \"auto-bridge\"\nversion = \"0.1.5\"\n-authors = [\"Jehan <jehan.tremback@gmail.com>\"]\n+authors = [\"Jehan <jehan.tremback@gmail.com>, Justin <justin@althea.net>\"]\nedition = \"2018\"\n[dependencies]\n-web30 = { git = \"https://github.com/althea-mesh/web30\", branch = \"master\" }\n-actix = \"0.7\"\n-futures = \"0.1\"\n+web30 = { git = \"https://github.com/althea-mesh/web30\", rev = \"ced518b6a3f82756e46bf061f5eb547695cbe868\" }\n+futures = \"0.3\"\nfailure = \"0.1\"\nnum256 = \"0.2\"\nclarity = \"0.1\"\n-futures-timer = \"0.1\"\nrand = \"0.7\"\n-num = \"0.2\"\n+num = \"0.3\"\nlog = \"0.4\"\n+async-std = \"1.6\"\n+\n+[dev-dependencies]\n+actix = \"0.9\"\n"
},
{
"change_type": "MODIFY",
"old_path": "auto_bridge/src/lib.rs",
"new_path": "auto_bridge/src/lib.rs",
"diff": "#[macro_use]\nextern crate log;\n+use async_std::future::timeout as future_timeout;\nuse clarity::abi::encode_call;\nuse clarity::{Address, PrivateKey};\nuse failure::bail;\nuse failure::Error;\n-use futures::Future;\n-use futures_timer::FutureExt;\nuse num::Bounded;\nuse num256::Uint256;\nuse std::time::Duration;\n@@ -53,43 +52,43 @@ impl TokenBridge {\n}\n/// This just sends some Eth. Returns the tx hash.\n- pub fn eth_transfer(\n+ pub async fn eth_transfer(\n&self,\nto: Address,\namount: Uint256,\ntimeout: u64,\n- ) -> Box<dyn Future<Item = (), Error = Error>> {\n+ ) -> Result<(), Error> {\nlet web3 = self.eth_web3.clone();\nlet own_address = self.own_address;\nlet secret = self.secret;\n- Box::new(\n- web3.send_transaction(to, Vec::new(), amount, own_address, secret, vec![])\n- .and_then(move |tx_hash| {\n- web3.wait_for_transaction(tx_hash.into())\n- .timeout(Duration::from_secs(timeout));\n- Ok(())\n- }),\n+ let tx_hash = web3\n+ .send_transaction(to, Vec::new(), amount, own_address, secret, vec![])\n+ .await?;\n+\n+ future_timeout(\n+ Duration::from_secs(timeout),\n+ web3.wait_for_transaction(tx_hash.into()),\n)\n+ .await??;\n+ Ok(())\n}\n/// Price of ETH in Dai\n- pub fn eth_to_dai_price(\n- &self,\n- amount: Uint256,\n- ) -> Box<dyn Future<Item = Uint256, Error = Error>> {\n+ pub async fn eth_to_dai_price(&self, amount: Uint256) -> Result<Uint256, Error> {\nlet web3 = self.eth_web3.clone();\nlet uniswap_address = self.uniswap_address;\nlet own_address = self.own_address;\n- Box::new(\n- web3.contract_call(\n+ let tokens_bought = web3\n+ .contract_call(\nuniswap_address,\n\"getEthToTokenInputPrice(uint256)\",\n&[amount.into()],\nown_address,\n)\n- .and_then(move |tokens_bought| {\n+ .await?;\n+\nOk(Uint256::from_bytes_be(match tokens_bought.get(0..32) {\nSome(val) => val,\nNone => bail!(\n@@ -97,27 +96,23 @@ impl TokenBridge {\ntokens_bought\n),\n}))\n- }),\n- )\n}\n/// Price of Dai in Eth\n- pub fn dai_to_eth_price(\n- &self,\n- amount: Uint256,\n- ) -> Box<dyn Future<Item = Uint256, Error = Error>> {\n+ pub async fn dai_to_eth_price(&self, amount: Uint256) -> Result<Uint256, Error> {\nlet web3 = self.eth_web3.clone();\nlet uniswap_address = self.uniswap_address;\nlet own_address = self.own_address;\n- Box::new(\n- web3.contract_call(\n+ let eth_bought = web3\n+ .contract_call(\nuniswap_address,\n\"getTokenToEthInputPrice(uint256)\",\n&[amount.into()],\nown_address,\n)\n- .and_then(move |eth_bought| {\n+ .await?;\n+\nOk(Uint256::from_bytes_be(match eth_bought.get(0..32) {\nSome(val) => val,\nNone => bail!(\n@@ -125,27 +120,24 @@ impl TokenBridge {\neth_bought\n),\n}))\n- }),\n- )\n}\n/// Sell `eth_amount` ETH for Dai.\n/// This function will error out if it takes longer than 'timeout' and the transaction is guaranteed not\n/// to be accepted on the blockchain after this time.\n- pub fn eth_to_dai_swap(\n+ pub async fn eth_to_dai_swap(\n&self,\neth_amount: Uint256,\ntimeout: u64,\n- ) -> Box<dyn Future<Item = Uint256, Error = Error>> {\n+ ) -> Result<Uint256, Error> {\nlet uniswap_address = self.uniswap_address;\nlet own_address = self.own_address;\nlet secret = self.secret;\nlet web3 = self.eth_web3.clone();\n- Box::new(\n- web3.eth_get_latest_block()\n- .join(self.eth_to_dai_price(eth_amount.clone()))\n- .and_then(move |(block, expected_dai)| {\n+ let block = web3.eth_get_latest_block().await?;\n+ let expected_dai = self.eth_to_dai_price(eth_amount.clone()).await?;\n+\n// Equivalent to `amount * (1 - 0.025)` without using decimals\nlet expected_dai = (expected_dai / 40u64.into()) * 39u64.into();\nlet deadline = block.timestamp + timeout.into();\n@@ -154,6 +146,8 @@ impl TokenBridge {\n&[expected_dai.into(), deadline.into()],\n);\n+ let _tx = future_timeout(\n+ Duration::from_secs(timeout),\nweb3.send_transaction(\nuniswap_address,\npayload,\n@@ -161,8 +155,12 @@ impl TokenBridge {\nown_address,\nsecret,\nvec![SendTxOption::GasLimit(80_000u64.into())],\n+ ),\n)\n- .join(\n+ .await??;\n+\n+ let response = future_timeout(\n+ Duration::from_secs(timeout),\nweb3.wait_for_event_alt(\nuniswap_address,\n\"TokenPurchase(address,uint256,uint256)\",\n@@ -170,32 +168,30 @@ impl TokenBridge {\nNone,\nNone,\n|_| true,\n+ ),\n)\n- .timeout(Duration::from_secs(timeout)),\n- )\n- .and_then(move |(_tx, response)| {\n+ .await??;\n+\nlet transfered_dai = Uint256::from_bytes_be(&response.topics[3]);\nOk(transfered_dai)\n- })\n- }),\n- )\n}\n/// Checks if the uniswap contract has been approved to spend dai from our account.\n- pub fn check_if_uniswap_dai_approved(&self) -> Box<dyn Future<Item = bool, Error = Error>> {\n+ pub async fn check_if_uniswap_dai_approved(&self) -> Result<bool, Error> {\nlet web3 = self.eth_web3.clone();\nlet uniswap_address = self.uniswap_address;\nlet dai_address = self.foreign_dai_contract_address;\nlet own_address = self.own_address;\n- Box::new(\n- web3.contract_call(\n+ let allowance = web3\n+ .contract_call(\ndai_address,\n\"allowance(address,address)\",\n&[own_address.into(), uniswap_address.into()],\nown_address,\n)\n- .and_then(move |allowance| {\n+ .await?;\n+\nlet allowance = Uint256::from_bytes_be(match allowance.get(0..32) {\nSome(val) => val,\nNone => bail!(\n@@ -207,16 +203,11 @@ impl TokenBridge {\n// Check if the allowance remaining is greater than half of a Uint256- it's as good\n// a test as any.\nOk(allowance > (Uint256::max_value() / 2u32.into()))\n- }),\n- )\n}\n/// Sends transaction to the DAI contract to approve uniswap transactions, this future will not\n/// resolve until the process is either successful for the timeout finishes\n- pub fn approve_uniswap_dai_transfers(\n- &self,\n- timeout: Duration,\n- ) -> Box<dyn Future<Item = (), Error = Error>> {\n+ pub async fn approve_uniswap_dai_transfers(&self, timeout: Duration) -> Result<(), Error> {\nlet dai_address = self.foreign_dai_contract_address;\nlet own_address = self.own_address;\nlet uniswap_address = self.uniswap_address;\n@@ -228,7 +219,8 @@ impl TokenBridge {\n&[uniswap_address.into(), Uint256::max_value().into()],\n);\n- Box::new(\n+ let _res = future_timeout(\n+ timeout,\nweb3.send_transaction(\ndai_address,\npayload,\n@@ -236,52 +228,48 @@ impl TokenBridge {\nown_address,\nsecret,\nvec![],\n+ ),\n)\n- .join(web3.wait_for_event_alt(\n+ .await??;\n+\n+ let _res = future_timeout(\n+ timeout,\n+ web3.wait_for_event_alt(\ndai_address,\n\"Approval(address,address,uint256)\",\nSome(vec![own_address.into()]),\nSome(vec![uniswap_address.into()]),\nNone,\n|_| true,\n- ))\n- .timeout(timeout)\n- .and_then(move |_| Ok(())),\n+ ),\n)\n+ .await??;\n+\n+ Ok(())\n}\n/// Sell `dai_amount` Dai for ETH\n/// This function will error out if it takes longer than 'timeout' and the transaction is guaranteed not\n/// to be accepted on the blockchain after this time.\n- pub fn dai_to_eth_swap(\n+ pub async fn dai_to_eth_swap(\n&self,\ndai_amount: Uint256,\ntimeout: u64,\n- ) -> Box<dyn Future<Item = Uint256, Error = Error>> {\n+ ) -> Result<Uint256, Error> {\nlet uniswap_address = self.uniswap_address;\nlet own_address = self.own_address;\nlet secret = self.secret;\nlet web3 = self.eth_web3.clone();\n- let salf = self.clone();\n- Box::new(\n- self.check_if_uniswap_dai_approved()\n- .and_then({\n- let salf = self.clone();\n- move |is_approved| {\n+ let is_approved = self.check_if_uniswap_dai_approved().await?;\ntrace!(\"uniswap approved {}\", is_approved);\n- if is_approved {\n- Box::new(futures::future::ok(()))\n- as Box<dyn Future<Item = (), Error = Error>>\n- } else {\n- salf.approve_uniswap_dai_transfers(Duration::from_secs(600))\n- }\n+ if !is_approved {\n+ self.approve_uniswap_dai_transfers(Duration::from_secs(600))\n+ .await?;\n}\n- })\n- .and_then(move |_| {\n- web3.eth_get_latest_block()\n- .join(salf.dai_to_eth_price(dai_amount.clone()))\n- .and_then(move |(block, expected_eth)| {\n+\n+ let block = web3.eth_get_latest_block().await?;\n+ let expected_eth = self.dai_to_eth_price(dai_amount.clone()).await?;\n// Equivalent to `amount * (1 - 0.025)` without using decimals\nlet expected_eth = (expected_eth / 40u64.into()) * 39u64.into();\nlet deadline = block.timestamp + timeout.into();\n@@ -290,6 +278,8 @@ impl TokenBridge {\n&[dai_amount.into(), expected_eth.into(), deadline.into()],\n);\n+ let _tx = future_timeout(\n+ Duration::from_secs(timeout),\nweb3.send_transaction(\nuniswap_address,\npayload,\n@@ -297,8 +287,12 @@ impl TokenBridge {\nown_address,\nsecret,\nvec![SendTxOption::GasLimit(80_000u64.into())],\n+ ),\n)\n- .join(\n+ .await?;\n+\n+ let response = future_timeout(\n+ Duration::from_secs(timeout),\nweb3.wait_for_event_alt(\nuniswap_address,\n\"EthPurchase(address,uint256,uint256)\",\n@@ -306,34 +300,30 @@ impl TokenBridge {\nNone,\nNone,\n|_| true,\n+ ),\n)\n- .timeout(Duration::from_secs(timeout)),\n- )\n- .and_then(move |(_tx, response)| {\n+ .await??;\n+\nlet transfered_eth = Uint256::from_bytes_be(&response.topics[3]);\nOk(transfered_eth)\n- })\n- })\n- }),\n- )\n}\n/// Bridge `dai_amount` dai to xdai\n- pub fn dai_to_xdai_bridge(\n+ pub async fn dai_to_xdai_bridge(\n&self,\ndai_amount: Uint256,\ntimeout: u64,\n- ) -> Box<dyn Future<Item = Uint256, Error = Error>> {\n+ ) -> Result<Uint256, Error> {\nlet eth_web3 = self.eth_web3.clone();\nlet foreign_dai_contract_address = self.foreign_dai_contract_address;\nlet xdai_foreign_bridge_address = self.xdai_foreign_bridge_address;\nlet own_address = self.own_address;\nlet secret = self.secret;\n- // You basically just send it some coins\n- // We have no idea when this has succeeded since the events are not indexed\n- Box::new(\n- eth_web3\n+ // You basically just send it some coins 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.send_transaction(\nforeign_dai_contract_address,\nencode_call(\n@@ -348,20 +338,19 @@ impl TokenBridge {\nsecret,\nvec![SendTxOption::GasLimit(80_000u64.into())],\n)\n- .and_then(move |tx_hash| {\n- eth_web3\n- .wait_for_transaction(tx_hash.into())\n- .timeout(Duration::from_secs(timeout));\n- Ok(dai_amount)\n- }),\n+ .await?;\n+\n+ future_timeout(\n+ Duration::from_secs(timeout),\n+ eth_web3.wait_for_transaction(tx_hash.into()),\n)\n+ .await??;\n+\n+ Ok(dai_amount)\n}\n/// Bridge `xdai_amount` xdai to dai\n- pub fn xdai_to_dai_bridge(\n- &self,\n- xdai_amount: Uint256,\n- ) -> Box<dyn Future<Item = Uint256, Error = Error>> {\n+ pub async fn xdai_to_dai_bridge(&self, xdai_amount: Uint256) -> Result<Uint256, Error> {\nlet xdai_web3 = self.xdai_web3.clone();\nlet xdai_home_bridge_address = self.xdai_home_bridge_address;\n@@ -369,8 +358,10 @@ impl TokenBridge {\nlet own_address = self.own_address;\nlet secret = self.secret;\n- // You basically just send it some coins\n- Box::new(xdai_web3.send_transaction(\n+ // You basically just send it some coins to the contract address on the Xdai side\n+ // and it will show up on the Eth side in the same address\n+ xdai_web3\n+ .send_transaction(\nxdai_home_bridge_address,\nVec::new(),\nxdai_amount,\n@@ -380,24 +371,23 @@ impl TokenBridge {\nSendTxOption::GasPrice(10_000_000_000u128.into()),\nSendTxOption::NetworkId(100u64),\n],\n- ))\n+ )\n+ .await\n}\n- pub fn get_dai_balance(\n- &self,\n- address: Address,\n- ) -> Box<dyn Future<Item = Uint256, Error = Error>> {\n+ pub async fn get_dai_balance(&self, address: Address) -> Result<Uint256, Error> {\nlet web3 = self.eth_web3.clone();\nlet dai_address = self.foreign_dai_contract_address;\nlet own_address = self.own_address;\n- Box::new(\n- web3.contract_call(\n+ let balance = web3\n+ .contract_call(\ndai_address,\n\"balanceOf(address)\",\n&[address.into()],\nown_address,\n)\n- .and_then(|balance| {\n+ .await?;\n+\nOk(Uint256::from_bytes_be(match balance.get(0..32) {\nSome(val) => val,\nNone => bail!(\n@@ -405,8 +395,6 @@ impl TokenBridge {\nbalance\n),\n}))\n- }),\n- )\n}\n}\n@@ -463,25 +451,17 @@ mod tests {\n\"https://dai.althea.org\".into(),\n);\n- actix::spawn(\n- token_bridge\n- .check_if_uniswap_dai_approved()\n- .and_then(move |is_approved| {\n+ actix::spawn(async move {\n+ let is_approved = token_bridge.check_if_uniswap_dai_approved().await.unwrap();\nassert!(is_approved);\n- unapproved_token_bridge\n+ let is_approved = unapproved_token_bridge\n.check_if_uniswap_dai_approved()\n- .and_then(move |is_approved| {\n- assert!(!is_approved);\n- Ok(())\n- })\n- })\n- .then(|res| {\n- res.unwrap();\n+ .await\n+ .unwrap();\n+ assert!(is_approved);\nactix::System::current().stop();\n- Box::new(futures::future::ok(()))\n- }),\n- );\n- system.run();\n+ });\n+ system.run().unwrap();\n}\n#[test]\n@@ -491,18 +471,19 @@ mod tests {\nlet token_bridge = new_token_bridge();\n- actix::spawn(\n- token_bridge\n+ actix::spawn(async move {\n+ let one_cent_in_eth = token_bridge\n.dai_to_eth_price(eth_to_wei(0.01f64))\n- .and_then(move |one_cent_in_eth| token_bridge.eth_to_dai_swap(one_cent_in_eth, 600))\n- .then(|res| {\n- res.unwrap();\n+ .await\n+ .unwrap();\n+ token_bridge\n+ .eth_to_dai_swap(one_cent_in_eth, 600)\n+ .await\n+ .unwrap();\nactix::System::current().stop();\n- Box::new(futures::future::ok(()))\n- }),\n- );\n+ });\n- system.run();\n+ system.run().unwrap();\n}\n#[test]\n@@ -511,18 +492,19 @@ mod tests {\nlet system = actix::System::new(\"test\");\nlet token_bridge = new_token_bridge();\n- actix::spawn(\n+ actix::spawn(async move {\ntoken_bridge\n.approve_uniswap_dai_transfers(Duration::from_secs(600))\n- .and_then(move |_| token_bridge.dai_to_eth_swap(eth_to_wei(0.01f64), 600))\n- .then(|res| {\n- res.unwrap();\n+ .await\n+ .unwrap();\n+ token_bridge\n+ .dai_to_eth_swap(eth_to_wei(0.01f64), 600)\n+ .await\n+ .unwrap();\nactix::System::current().stop();\n- Box::new(futures::future::ok(()))\n- }),\n- );\n+ });\n- system.run();\n+ system.run().unwrap();\n}\n#[test]\n@@ -532,19 +514,17 @@ mod tests {\nlet token_bridge = new_token_bridge();\n- actix::spawn(\n- token_bridge\n+ actix::spawn(async move {\n// All we can really do here is test that it doesn't throw. Check your balances in\n// 5-10 minutes to see if the money got transferred.\n+ token_bridge\n.dai_to_xdai_bridge(eth_to_wei(0.01f64), 600)\n- .then(|res| {\n- res.unwrap();\n+ .await\n+ .unwrap();\nactix::System::current().stop();\n- Box::new(futures::future::ok(()))\n- }),\n- );\n+ });\n- system.run();\n+ system.run().unwrap();\n}\n#[test]\n@@ -554,18 +534,16 @@ mod tests {\nlet token_bridge = new_token_bridge();\n- actix::spawn(\n- token_bridge\n+ actix::spawn(async move {\n// All we can really do here is test that it doesn't throw. Check your balances in\n// 5-10 minutes to see if the money got transferred.\n+ token_bridge\n.xdai_to_dai_bridge(eth_to_wei(0.01f64))\n- .then(|res| {\n- res.unwrap();\n+ .await\n+ .unwrap();\nactix::System::current().stop();\n- Box::new(futures::future::ok(()))\n- }),\n- );\n+ });\n- system.run();\n+ system.run().unwrap();\n}\n}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Async auto-bridge
This moves the auto-bridge library to async/await. Still requires testing |
20,244 | 21.07.2020 13:39:14 | 14,400 | 55c6b0785e1f4332cd6fbb2910dacbc987ea4839 | Remove withdraw_eth endpoint
The withdraw_eth endpoint was not actually being called by the dashboard
or anywhere as far as I'm aware. The supported way to withrdaw all your
eth is to use the withdraw_all endpoint, which cleans up the eth on it's
way out leaving both the xdai and eth addresses empty. | [
{
"change_type": "MODIFY",
"old_path": "rita/src/client.rs",
"new_path": "rita/src/client.rs",
"diff": "@@ -342,11 +342,6 @@ fn start_client_dashboard() {\n.route(\"/wifi_settings\", Method::GET, get_wifi_config)\n.route(\"/withdraw/{address}/{amount}\", Method::POST, withdraw)\n.route(\"/withdraw_all/{address}\", Method::POST, withdraw_all)\n- .route(\n- \"/withdraw_eth/{address}/{amount}\",\n- Method::POST,\n- withdraw_eth,\n- )\n.route(\n\"/auto_price/enabled/{status}\",\nMethod::POST,\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/exit.rs",
"new_path": "rita/src/exit.rs",
"diff": "@@ -281,11 +281,6 @@ fn start_rita_exit_dashboard() {\n.route(\"/debts/reset\", Method::POST, reset_debt)\n.route(\"/withdraw/{address}/{amount}\", Method::POST, withdraw)\n.route(\"/withdraw_all/{address}\", Method::POST, withdraw_all)\n- .route(\n- \"/withdraw_eth/{address}/{amount}\",\n- Method::POST,\n- withdraw_eth,\n- )\n.route(\"/nickname/get/\", Method::GET, get_nickname)\n.route(\"/nickname/set/\", Method::POST, set_nickname)\n.route(\"/crash_actors\", Method::POST, crash_actors)\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/dashboard/wallet.rs",
"new_path": "rita/src/rita_common/dashboard/wallet.rs",
"diff": "@@ -2,12 +2,8 @@ use crate::rita_common::blockchain_oracle::trigger_update_nonce;\nuse crate::rita_common::blockchain_oracle::BlockchainOracle;\nuse crate::rita_common::blockchain_oracle::ZeroWindowStart;\nuse crate::rita_common::rita_loop::get_web3_server;\n-use crate::rita_common::token_bridge::eth_equal;\n-use crate::rita_common::token_bridge::GetBridge;\nuse crate::rita_common::token_bridge::TokenBridge;\nuse crate::rita_common::token_bridge::Withdraw;\n-use crate::rita_common::token_bridge::DAI_WEI_CENT;\n-use crate::rita_common::token_bridge::ETH_TRANSFER_TIMEOUT;\nuse crate::SETTING;\nuse ::actix::SystemService;\nuse ::actix_web::http::StatusCode;\n@@ -92,77 +88,6 @@ pub fn withdraw_all(path: Path<Address>) -> Box<dyn Future<Item = HttpResponse,\n}\n}\n-pub fn withdraw_eth(\n- path: Path<(Address, Uint256)>,\n-) -> Box<dyn Future<Item = HttpResponse, Error = Error>> {\n- let to = path.0;\n- let withdraw_amount = path.1.clone();\n- debug!(\"/withdraw_eth/{:#x}/{} hit\", to, withdraw_amount);\n- let payment_settings = SETTING.get_payment();\n- let our_address = payment_settings.eth_address.unwrap();\n- drop(payment_settings);\n-\n- Box::new(\n- TokenBridge::from_registry()\n- .send(GetBridge())\n- .then(move |bridge| {\n- if let Err(e) = bridge {\n- return Box::new(future::ok(\n- HttpResponse::new(StatusCode::from_u16(500u16).unwrap())\n- .into_builder()\n- .json(format!(\"Failed to get bridge {:?}\", e)),\n- ))\n- as Box<dyn Future<Item = HttpResponse, Error = Error>>;\n- }\n- // first layer is the actix failure we just handled, second is the Result from\n- // the actix endpoint which can never fail you could fix this by messing with the ReturnMessage\n- // trait and implementing it for this tuple rather than using the generic Result impl\n- let (bridge, reserve_amount) = bridge.unwrap().unwrap();\n- Box::new(\n- bridge\n- .eth_web3\n- .eth_get_balance(our_address)\n- .join(bridge.dai_to_eth_price(DAI_WEI_CENT.into()))\n- .then(move |res| {\n- if let Err(e) = res {\n- return Box::new(future::ok(\n- HttpResponse::new(StatusCode::from_u16(500u16).unwrap())\n- .into_builder()\n- .json(format!(\"Failed to get balance or price {:?}\", e)),\n- ))\n- as Box<dyn Future<Item = HttpResponse, Error = Error>>;\n- }\n- let (our_eth_balance, wei_per_cent) = res.unwrap();\n- let reserve_amount_eth = eth_equal(reserve_amount, wei_per_cent);\n- if our_eth_balance - reserve_amount_eth > withdraw_amount {\n- Box::new(\n- bridge\n- .eth_transfer(to, withdraw_amount, ETH_TRANSFER_TIMEOUT)\n- .then(|res| {\n- if let Err(e) = res {\n- Ok(HttpResponse::new(\n- StatusCode::from_u16(500u16).unwrap(),\n- )\n- .into_builder()\n- .json(format!(\"Transfer error {:?}\", e)))\n- } else {\n- Ok(HttpResponse::Ok().json(\"Success!\".to_string()))\n- }\n- }),\n- )\n- } else {\n- Box::new(future::ok(\n- HttpResponse::new(StatusCode::from_u16(400u16).unwrap())\n- .into_builder()\n- .json(\"Insufficient balance\".to_string()),\n- ))\n- }\n- }),\n- )\n- }),\n- )\n-}\n-\n/// Withdraw for eth compatible chains\nfn eth_compatable_withdraw(\naddress: Address,\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/token_bridge/mod.rs",
"new_path": "rita/src/rita_common/token_bridge/mod.rs",
"diff": "//! through uniswap into DAI and then from there it is bridged over to the Xdai proof of authority chains.\n//! Support for Cosmos chains using a DAI-pegged native currency is next on the list.\n//!\n-//! Essentially the goal is to allow uers to deposit a popular and easy to aquire coin like Ethereum and then\n+//! Essentially the goal is to allow users to deposit a popular and easy to acquire coin like Ethereum and then\n//! actually transact in a stablecoin on a fast blockchain, eg not Ethereum. Withdraws are also transparently\n//! converted back to Ethereum to allow easy exchange by the user.\n//!\n//! This entire module works on the premise we call the conveyor belt model. It's difficult to track\n//! money through this entire process exactly, in fact there are some edge cases where it's simply not\n//! possible to reliably say if a task has completed or not. With that in mind we simply always progress\n-//! the the process for Eth -> DAI -> XDAI unless we explicilty have a withdraw in progress. So if we find\n+//! the the process for Eth -> DAI -> XDAI unless we explicitly have a withdraw in progress. So if we find\n//! some DAI in our address it will always be converted to XDAI even if we didn't convert that DAI from Eth\n//! in the first place.\n//!\n-//! For the withdraw process we create a withdraw request object which does a best effort sheparding of the\n+//! For the withdraw process we create a withdraw request object which does a best effort shepherding of the\n//! requested withdraw amount back to Eth and into the users hands. If this fails then the withdraw will timeout\n//! and the money will not be lost but instead moved back into XDAI by the normal conveyor belt operation\n//!\n@@ -748,24 +748,6 @@ impl Handler<GetBridgeStatus> for TokenBridge {\n}\n}\n-/// used to get the bridge object and manipulate eth elsewhere, returns\n-/// the reserve amount in eth and the TokenBridge struct\n-#[derive(Debug, Eq, PartialEq, Clone, Serialize)]\n-pub struct GetBridge();\n-\n-impl Message for GetBridge {\n- type Result = Result<(TokenBridgeCore, Uint256), Error>;\n-}\n-\n-impl Handler<GetBridge> for TokenBridge {\n- type Result = Result<(TokenBridgeCore, Uint256), Error>;\n- fn handle(&mut self, _msg: GetBridge, _ctx: &mut Context<Self>) -> Self::Result {\n- let bridge = self.bridge.clone();\n- let reserve_amount = eth_to_wei(self.reserve_amount.into());\n- Ok((bridge, reserve_amount))\n- }\n-}\n-\n/// Used to indicate that the source addresses should be reloaded from the config\n#[derive(Debug, Eq, PartialEq, Clone, Serialize, Copy)]\npub struct ReloadAddresses();\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Remove withdraw_eth endpoint
The withdraw_eth endpoint was not actually being called by the dashboard
or anywhere as far as I'm aware. The supported way to withrdaw all your
eth is to use the withdraw_all endpoint, which cleans up the eth on it's
way out leaving both the xdai and eth addresses empty. |
20,244 | 22.07.2020 09:15:30 | 14,400 | 5b4f9fe4f554f4f7e14511c24d142415227f30d3 | Convert simulated txfee to Async/Await
This converts the simulated txfee module to async/await and also
updates the various external referneces to use locked ref getters
and setters | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_client/operator_fee_manager/mod.rs",
"new_path": "rita/src/rita_client/operator_fee_manager/mod.rs",
"diff": "use crate::rita_common::payment_controller::TRANSACTION_SUBMISSON_TIMEOUT;\nuse crate::rita_common::rita_loop::get_web3_server;\n-use crate::rita_common::simulated_txfee_manager::AddTxToTotal;\n-use crate::rita_common::simulated_txfee_manager::SimulatedTxFeeManager;\n+use crate::rita_common::simulated_txfee_manager::add_tx_to_total;\nuse crate::rita_common::usage_tracker::UpdatePayments;\nuse crate::rita_common::usage_tracker::UsageTracker;\nuse crate::SETTING;\n@@ -176,7 +175,7 @@ impl Handler<Tick> for OperatorFeeManager {\ntxid: Some(txid),\n},\n});\n- SimulatedTxFeeManager::from_registry().do_send(AddTxToTotal(amount_to_pay));\n+ add_tx_to_total(amount_to_pay);\nOperatorFeeManager::from_registry().do_send(SuccessfulPayment {\ntimestamp: payment_send_time,\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/debt_keeper/mod.rs",
"new_path": "rita/src/rita_common/debt_keeper/mod.rs",
"diff": "use crate::rita_common::payment_controller;\nuse crate::rita_common::payment_controller::PaymentController;\nuse crate::rita_common::payment_validator::PAYMENT_TIMEOUT;\n-use crate::rita_common::simulated_txfee_manager::AddTxToTotal;\n-use crate::rita_common::simulated_txfee_manager::SimulatedTxFeeManager;\n+use crate::rita_common::simulated_txfee_manager::add_tx_to_total;\nuse crate::rita_common::tunnel_manager::TunnelAction;\nuse crate::rita_common::tunnel_manager::TunnelChange;\nuse crate::rita_common::tunnel_manager::TunnelManager;\n@@ -226,7 +225,7 @@ impl Handler<PaymentSucceeded> for DebtKeeper {\ntype Result = Result<(), Error>;\nfn handle(&mut self, msg: PaymentSucceeded, _: &mut Context<Self>) -> Self::Result {\n- SimulatedTxFeeManager::from_registry().do_send(AddTxToTotal(msg.amount.clone()));\n+ add_tx_to_total(msg.amount.clone());\nself.payment_succeeded(&msg.to, msg.amount)\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/simulated_txfee_manager/mod.rs",
"new_path": "rita/src/rita_common/simulated_txfee_manager/mod.rs",
"diff": "use crate::rita_common::payment_controller::TRANSACTION_SUBMISSON_TIMEOUT;\nuse crate::rita_common::rita_loop::get_web3_server;\n-use crate::rita_common::usage_tracker::UpdatePayments;\n-use crate::rita_common::usage_tracker::UsageTracker;\n+use crate::rita_common::usage_tracker::update_payments;\nuse crate::SETTING;\n-use actix::{Actor, Arbiter, Context, Handler, Message, Supervised, SystemService};\nuse althea_types::Identity;\nuse althea_types::PaymentTx;\n+use async_web30::client::Web3;\nuse clarity::Transaction;\n-use futures01::future::Future;\nuse num256::Uint256;\nuse num_traits::Signed;\nuse num_traits::Zero;\nuse settings::RitaCommonSettings;\n-use web30::client::Web3;\n+use std::sync::Arc;\n+use std::sync::RwLock;\n-pub struct SimulatedTxFeeManager {\n- amount_owed: Uint256,\n-}\n-\n-impl Actor for SimulatedTxFeeManager {\n- type Context = Context<Self>;\n-}\n-impl Supervised for SimulatedTxFeeManager {}\n-impl SystemService for SimulatedTxFeeManager {\n- fn service_started(&mut self, _ctx: &mut Context<Self>) {\n- info!(\"SimulatedTxFeeManager started\");\n- }\n-}\n-\n-impl Default for SimulatedTxFeeManager {\n- fn default() -> SimulatedTxFeeManager {\n- SimulatedTxFeeManager::new()\n- }\n-}\n-\n-impl SimulatedTxFeeManager {\n- fn new() -> SimulatedTxFeeManager {\n- SimulatedTxFeeManager {\n- amount_owed: Uint256::zero(),\n- }\n- }\n-}\n-\n-struct SuccessfulPayment(Uint256);\n-impl Message for SuccessfulPayment {\n- type Result = ();\n-}\n-\n-impl Handler<SuccessfulPayment> for SimulatedTxFeeManager {\n- type Result = ();\n-\n- fn handle(&mut self, msg: SuccessfulPayment, _: &mut Context<Self>) -> Self::Result {\n- let payment_amount = msg.0;\n- if payment_amount <= self.amount_owed {\n- self.amount_owed = self.amount_owed.clone() - payment_amount;\n- } else {\n- // I don't think this can ever happen unless successful\n- // payment gets called outside of this actor, or more than one\n- // instance of this actor exists, System service prevents the later\n- // and the lack of 'pub' prevents the former\n- error!(\"Maintainer fee overpayment!\")\n- }\n- }\n+lazy_static! {\n+ static ref AMOUNT_OWED: Arc<RwLock<Uint256>> = Arc::new(RwLock::new(Uint256::zero()));\n}\n// this is sent when a transaction is successful in another module and it registers\n// some amount to be paid as part of the fee\n-pub struct AddTxToTotal(pub Uint256);\n-impl Message for AddTxToTotal {\n- type Result = ();\n-}\n-\n-impl Handler<AddTxToTotal> for SimulatedTxFeeManager {\n- type Result = ();\n-\n- fn handle(&mut self, msg: AddTxToTotal, _: &mut Context<Self>) -> Self::Result {\n- let to_add = msg.0 / SETTING.get_payment().simulated_transaction_fee.into();\n+pub fn add_tx_to_total(amount: Uint256) {\n+ let to_add = amount / SETTING.get_payment().simulated_transaction_fee.into();\n+ let mut amount_owed = AMOUNT_OWED.write().unwrap();\ninfo!(\n\"Simulated txfee total is {} with {} to add\",\n- self.amount_owed, to_add\n+ amount_owed, to_add\n);\n- self.amount_owed += to_add;\n- }\n+ *amount_owed += to_add;\n}\n-/// Very basic loop for simulated txfee payments\n-pub struct Tick;\n-impl Message for Tick {\n- type Result = ();\n-}\n-\n-impl Handler<Tick> for SimulatedTxFeeManager {\n- type Result = ();\n-\n- fn handle(&mut self, _msg: Tick, _: &mut Context<Self>) -> Self::Result {\n+pub async fn tick_simulated_tx() {\nlet payment_settings = SETTING.get_payment();\nlet eth_private_key = payment_settings.eth_private_key;\nlet our_id = match SETTING.get_identity() {\n@@ -107,7 +43,7 @@ impl Handler<Tick> for SimulatedTxFeeManager {\nlet pay_threshold = payment_settings.pay_threshold.clone();\nlet simulated_transaction_fee_address = payment_settings.simulated_transaction_fee_address;\nlet simulated_transaction_fee = payment_settings.simulated_transaction_fee;\n- let amount_to_pay = self.amount_owed.clone();\n+ let amount_to_pay = AMOUNT_OWED.read().unwrap().clone();\nlet should_pay = amount_to_pay > pay_threshold.abs().to_uint256().unwrap();\nlet net_version = payment_settings.net_version;\ndrop(payment_settings);\n@@ -161,24 +97,31 @@ impl Handler<Tick> for SimulatedTxFeeManager {\n// in theory this may fail, for now there is no handler and\n// we will just underpay when that occurs\n- Arbiter::spawn(transaction_status.then(move |res| match res {\n+ match transaction_status.await {\nOk(txid) => {\ninfo!(\"Successfully paid the simulated txfee {:#066x}!\", txid);\n- UsageTracker::from_registry().do_send(UpdatePayments {\n- payment: PaymentTx {\n+ update_payments(PaymentTx {\nto: txfee_identity,\nfrom: our_id,\namount: amount_to_pay.clone(),\ntxid: Some(txid),\n- },\n});\n- SimulatedTxFeeManager::from_registry().do_send(SuccessfulPayment(amount_to_pay));\n- Ok(())\n+\n+ // update the billing now that the payment has gone through\n+ let mut amount_owed = AMOUNT_OWED.write().unwrap();\n+ let payment_amount = amount_to_pay;\n+ if payment_amount <= *amount_owed {\n+ *amount_owed = amount_owed.clone() - payment_amount;\n+ } else {\n+ // I don't think this can ever happen unless successful\n+ // payment gets called outside of this actor, or more than one\n+ // instance of this actor exists, System service prevents the later\n+ // and the lack of 'pub' prevents the former\n+ error!(\"Maintainer fee overpayment!\")\n+ }\n}\nErr(e) => {\nwarn!(\"Failed to pay simulated txfee! {:?}\", e);\n- Ok(())\n- }\n- }));\n}\n+ };\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/usage_tracker/mod.rs",
"new_path": "rita/src/rita_common/usage_tracker/mod.rs",
"diff": "@@ -29,6 +29,8 @@ use std::io::Read;\nuse std::io::Seek;\nuse std::io::SeekFrom;\nuse std::io::Write;\n+use std::sync::Arc;\n+use std::sync::RwLock;\nuse std::time::SystemTime;\nuse std::time::UNIX_EPOCH;\n@@ -37,6 +39,14 @@ const MAX_ENTRIES: usize = 8760;\n/// Save every 4 hours\nconst SAVE_FREQENCY: u64 = 4;\n+lazy_static! {\n+/// This is used to allow non-actix workers to add payments to the queue. An alternative to this would be\n+/// to move all storage for this actor into this locked ref format and this should be done in Beta 16 or\n+/// later, for now (Beta 15) we want to reduce the amount of changes. So instead these values will be\n+/// read off any time this actor is triggered by another payment message\n+ static ref PAYMENT_UPDATE_QUEUE: Arc<RwLock<Vec<PaymentTx>>> = Arc::new(RwLock::new(Vec::new()));\n+}\n+\n/// In an effort to converge this module between the three possible bw tracking\n/// use cases this enum is used to identify which sort of usage we are tracking\n#[derive(Clone, Copy, Debug, Serialize, Deserialize)]\n@@ -255,7 +265,7 @@ fn get_current_hour() -> Result<u64, Error> {\nOk(seconds.as_secs() / (60 * 60))\n}\n-/// The messauge used to update the current usage hour from each traffic\n+/// The message used to update the current usage hour from each traffic\n/// watcher module\n#[derive(Clone, Copy, Debug)]\npub struct UpdateUsage {\n@@ -326,6 +336,11 @@ fn process_usage_update(current_hour: u64, msg: UpdateUsage, data: &mut UsageTra\n}\n}\n+pub fn update_payments(payment: PaymentTx) {\n+ let mut payments = PAYMENT_UPDATE_QUEUE.write().unwrap();\n+ payments.push(payment);\n+}\n+\npub struct UpdatePayments {\npub payment: PaymentTx,\n}\n@@ -337,6 +352,16 @@ impl Message for UpdatePayments {\nimpl Handler<UpdatePayments> for UsageTracker {\ntype Result = Result<(), Error>;\nfn handle(&mut self, msg: UpdatePayments, _: &mut Context<Self>) -> Self::Result {\n+ let mut queue = PAYMENT_UPDATE_QUEUE.write().unwrap();\n+ for item in *queue {\n+ let _res = handle_payments(&mut self, item);\n+ }\n+ *queue = Vec::new();\n+ handle_payments(&mut self, msg.payment)\n+ }\n+}\n+\n+fn handle_payments(history: &mut UsageTracker, payment: PaymentTx) -> Result<(), Error> {\nlet current_hour = match get_current_hour() {\nOk(hour) => hour,\nErr(e) => {\n@@ -344,9 +369,9 @@ impl Handler<UpdatePayments> for UsageTracker {\nreturn Ok(());\n}\n};\n- let formatted_payment = to_formatted_payment_tx(msg.payment);\n- match self.payments.front_mut() {\n- None => self.payments.push_front(PaymentHour {\n+ let formatted_payment = to_formatted_payment_tx(payment);\n+ match history.payments.front_mut() {\n+ None => history.payments.push_front(PaymentHour {\nindex: current_hour,\npayments: vec![formatted_payment],\n}),\n@@ -354,24 +379,23 @@ impl Handler<UpdatePayments> for UsageTracker {\nif entry.index == current_hour {\nentry.payments.push(formatted_payment);\n} else {\n- self.payments.push_front(PaymentHour {\n+ history.payments.push_front(PaymentHour {\nindex: current_hour,\npayments: vec![formatted_payment],\n})\n}\n}\n}\n- while self.payments.len() > MAX_ENTRIES {\n- let _discarded_entry = self.payments.pop_back();\n+ while history.payments.len() > MAX_ENTRIES {\n+ let _discarded_entry = history.payments.pop_back();\n}\n- if (current_hour - SAVE_FREQENCY) > self.last_save_hour {\n- self.last_save_hour = current_hour;\n- let res = self.save();\n+ if (current_hour - SAVE_FREQENCY) > history.last_save_hour {\n+ history.last_save_hour = current_hour;\n+ let res = history.save();\ninfo!(\"Saving usage data: {:?}\", res);\n}\nOk(())\n}\n-}\npub struct GetUsage {\npub kind: UsageType,\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Convert simulated txfee to Async/Await
This converts the simulated txfee module to async/await and also
updates the various external referneces to use locked ref getters
and setters |
20,244 | 22.07.2020 13:00:46 | 14,400 | 7655a07890cb4f28b945bbc98b81f0bb50029599 | Use OpenSSL instead of RustTLS
Ring still doesn't work on mips | [
{
"change_type": "MODIFY",
"old_path": "Cargo.lock",
"new_path": "Cargo.lock",
"diff": "@@ -379,7 +379,6 @@ dependencies = [\n\"openssl\",\n\"pin-project\",\n\"regex\",\n- \"rustls\",\n\"serde 1.0.110\",\n\"serde_json\",\n\"serde_urlencoded 0.6.1\",\n@@ -3223,21 +3222,6 @@ dependencies = [\n\"quick-error\",\n]\n-[[package]]\n-name = \"ring\"\n-version = \"0.16.12\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"1ba5a8ec64ee89a76c98c549af81ff14813df09c3e6dc4766c3856da48597a0c\"\n-dependencies = [\n- \"cc\",\n- \"lazy_static\",\n- \"libc\",\n- \"spin\",\n- \"untrusted\",\n- \"web-sys\",\n- \"winapi 0.3.8\",\n-]\n-\n[[package]]\nname = \"rita\"\nversion = \"0.5.56\"\n@@ -3349,19 +3333,6 @@ dependencies = [\n\"semver\",\n]\n-[[package]]\n-name = \"rustls\"\n-version = \"0.16.0\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"b25a18b1bf7387f0145e7f8324e700805aade3842dd3db2e74e4cdeb4677c09e\"\n-dependencies = [\n- \"base64 0.10.1\",\n- \"log\",\n- \"ring\",\n- \"sct\",\n- \"webpki\",\n-]\n-\n[[package]]\nname = \"ryu\"\nversion = \"1.0.4\"\n@@ -3411,16 +3382,6 @@ version = \"1.1.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd\"\n-[[package]]\n-name = \"sct\"\n-version = \"0.6.0\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c\"\n-dependencies = [\n- \"ring\",\n- \"untrusted\",\n-]\n-\n[[package]]\nname = \"secp256k1\"\nversion = \"0.17.2\"\n@@ -3708,12 +3669,6 @@ dependencies = [\n\"serde 1.0.110\",\n]\n-[[package]]\n-name = \"spin\"\n-version = \"0.5.2\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d\"\n-\n[[package]]\nname = \"stable_deref_trait\"\nversion = \"1.1.1\"\n@@ -4328,12 +4283,6 @@ version = \"0.2.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c\"\n-[[package]]\n-name = \"untrusted\"\n-version = \"0.7.1\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a\"\n-\n[[package]]\nname = \"url\"\nversion = \"1.7.2\"\n@@ -4557,16 +4506,6 @@ dependencies = [\n\"tokio 0.2.21\",\n]\n-[[package]]\n-name = \"webpki\"\n-version = \"0.21.2\"\n-source = \"registry+https://github.com/rust-lang/crates.io-index\"\n-checksum = \"f1f50e1972865d6b1adb54167d1c8ed48606004c2c9d0ea5f1eeb34d95e863ef\"\n-dependencies = [\n- \"ring\",\n- \"untrusted\",\n-]\n-\n[[package]]\nname = \"wepoll-sys-stjepang\"\nversion = \"1.0.6\"\n"
},
{
"change_type": "MODIFY",
"old_path": "rita/Cargo.toml",
"new_path": "rita/Cargo.toml",
"diff": "@@ -31,7 +31,7 @@ web30 = {git = \"https://github.com/althea-net/web30\", branch = \"master\"}\n# these will be kept here for quite some time until the switch is completed.\nasync-web30 = {package=\"web30\", git = \"https://github.com/althea-net/web30\", rev = \"ced518b6a3f82756e46bf061f5eb547695cbe868\" }\nactix-async = {package=\"actix\", version = \"0.9\"}\n-actix-web-async = {package=\"actix-web\", version = \"2.0\", default_features = false, features= [\"rust-tls\"] }\n+actix-web-async = {package=\"actix-web\", version = \"2.0\", default_features = false, features= [\"openssl\"] }\nactix = \"0.7\"\nactix-web = { version = \"0.7\", default_features = false, features= [\"ssl\"] }\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Use OpenSSL instead of RustTLS
Ring still doesn't work on mips |
20,244 | 22.07.2020 13:01:18 | 14,400 | 3eaaefee5ee2b8dad6a5db45af3981d43301b392 | don't log every failed attempt to find a babel val | [
{
"change_type": "MODIFY",
"old_path": "babel_monitor/src/lib.rs",
"new_path": "babel_monitor/src/lib.rs",
"diff": "@@ -78,7 +78,7 @@ fn find_babel_val(val: &str, line: &str) -> Result<String, Error> {\n}\n}\n}\n- warn!(\"find_babel_val warn! Can not find {} in {}\", val, line);\n+ trace!(\"find_babel_val warn! Can not find {} in {}\", val, line);\nErr(VariableNotFound(String::from(val), String::from(line)).into())\n}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | don't log every failed attempt to find a babel val |
20,244 | 22.07.2020 19:19:58 | 14,400 | dbdb58333bf0ec7cb4da1c2664aa8dffd807e40a | Simplify token bridge state machine
The token bridge state machine doesn't require much of it's old structure
as it's now impossible for multiple instances futures to be running at once | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/token_bridge/mod.rs",
"new_path": "rita/src/rita_common/token_bridge/mod.rs",
"diff": "//! State::Ready:\n//! If there is a Dai balance, send it thru the bridge into xdai (this rescues stuck funds in Dai)\n//!\n-//! Change to State::Depositing.\n-//!\n//! If there is an `eth_balance` that is greater than the `minimum_to_exchange` amount,\n//! subtract the `reserve` amount and send it through uniswap into DAI. If not Change to State::Ready\n//! Future waits on Uniswap, and upon successful swap, sends dai thru the bridge into xdai.\n//! When the money is out of the Dai account and in the bridge, or if uniswap times out, change\n//! to State::Ready.\n//!\n-//! State::Depositing:\n-//! do nothing\n+//! State::WithdrawRequest { to, amount, timestamp}:\n+//! Performs the initial send to the bridge, then progresses to State::Withdrawing, this is required\n+//! in order to ensure that we only send the funds for a given withdraw once\n//!\n//! State::Withdrawing { to, amount, timestamp}:\n//! If the timestamp is expired, switch the state back into State::Ready.\n//!\n//! Future waits on Uniswap and upon successful swap, sends eth to \"to\" address. Another future\n//! waits on this transfer to complete. When it is complete, the state switches back to State::Ready\n-//!\n-//! WithdrawEvent:\n-//! State::Ready:\n-//! Send amount into bridge, switch to State::Withdrawing.\n-//!\n-//! State::Withdrawing { to, amount, timestamp}:\n-//! Nothing happens\nuse crate::SETTING;\nuse althea_types::SystemChain;\n@@ -97,13 +89,7 @@ pub fn eth_equal(dai_in_wei: Uint256, wei_per_cent: Uint256) -> Uint256 {\n#[derive(Clone, Debug, Eq, PartialEq)]\npub enum State {\n- Ready {\n- /// used to ensure that only the future chain that started an operation can end it\n- former_state: Option<Box<State>>,\n- },\n- Depositing {\n- timestamp: Instant,\n- },\n+ Ready,\nWithdrawRequest {\namount: Uint256,\nto: Address,\n@@ -121,11 +107,7 @@ pub enum State {\nimpl Display for State {\nfn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\nmatch self {\n- State::Ready {\n- former_state: Some(_),\n- } => write!(f, \"Ready{{Some()}}\"),\n- State::Ready { former_state: None } => write!(f, \"Ready{{None}}\"),\n- State::Depositing { .. } => write!(f, \"Depositing\"),\n+ State::Ready => write!(f, \"Ready\"),\nState::WithdrawRequest {\namount: a,\nto: t,\n@@ -155,6 +137,7 @@ impl Display for State {\n/// contains details fo the various inner workings of the actual contract and bridge calls\n/// rather than the logic. This struct was previously combined with TokenBridgeAmounts but\n/// we want to reload the amounts regularly without interfering with the state.\n+#[derive(Clone, Debug, Eq, PartialEq)]\npub struct TokenBridgeState {\nstate: State,\ndetailed_state: DetailedBridgeState,\n@@ -174,7 +157,7 @@ pub struct TokenBridgeAmounts {\n}\npub async fn tick_token_bridge() {\n- let bridge = BRIDGE.read().unwrap();\n+ let bridge: TokenBridgeState = BRIDGE.read().unwrap().clone();\nlet amounts = { get_amounts() };\nassert!(amounts.minimum_to_exchange > amounts.reserve_amount);\nlet payment_settings = SETTING.get_payment();\n@@ -185,8 +168,9 @@ pub async fn tick_token_bridge() {\n}\ndrop(payment_settings);\n+ trace!(\"Launching bridge future\");\nmatch system_chain {\n- SystemChain::Xdai => xdai_bridge(bridge.state.clone()).await,\n+ SystemChain::Xdai => state_change(xdai_bridge(bridge.state.clone()).await),\nSystemChain::Ethereum => eth_bridge().await,\nSystemChain::Rinkeby => {}\n}\n@@ -209,7 +193,7 @@ fn token_bridge_core_from_settings(payment_settings: &PaymentSettings) -> TokenB\nimpl Default for TokenBridgeState {\nfn default() -> TokenBridgeState {\nTokenBridgeState {\n- state: State::Ready { former_state: None },\n+ state: State::Ready,\ndetailed_state: DetailedBridgeState::NoOp {\neth_balance: Uint256::zero(),\nwei_per_dollar: Uint256::zero(),\n@@ -326,7 +310,7 @@ async fn eth_bridge() {\n}\n/// The logic for the Eth -> Xdai bridge operation\n-async fn xdai_bridge(state: State) {\n+async fn xdai_bridge(state: State) -> State {\nlet amounts = { get_amounts() };\nlet minimum_stranded_dai_transfer = amounts.minimum_stranded_dai_transfer;\nlet reserve_amount = amounts.reserve_amount;\n@@ -338,11 +322,6 @@ async fn xdai_bridge(state: State) {\n\"Ticking in bridge State::Ready. Eth Address: {}\",\nbridge.own_address\n);\n- // Go into State::Depositing right away to prevent multiple attempts\n- let state = State::Depositing {\n- timestamp: Instant::now(),\n- };\n- state_change(state.clone());\nlet res = rescue_dai(\nbridge.clone(),\nbridge.own_address,\n@@ -357,20 +336,14 @@ async fn xdai_bridge(state: State) {\nOk(val) => val,\nErr(e) => {\nwarn!(\"Failed to get eth price with {:?}\", e);\n- state_change(State::Ready {\n- former_state: Some(Box::new(state)),\n- });\n- return;\n+ return State::Ready;\n}\n};\nlet eth_balance = match bridge.eth_web3.eth_get_balance(bridge.own_address).await {\nOk(val) => val,\nErr(e) => {\nwarn!(\"Failed to get eth balance {:?}\", e);\n- state_change(State::Ready {\n- former_state: Some(Box::new(state)),\n- });\n- return;\n+ return State::Ready;\n}\n};\n// These statements convert the reserve_amount and minimum_to_exchange\n@@ -394,10 +367,7 @@ async fn xdai_bridge(state: State) {\nOk(val) => val,\nErr(e) => {\nwarn!(\"Failed to swap dai with {:?}\", e);\n- state_change(State::Ready {\n- former_state: Some(Box::new(state)),\n- });\n- return;\n+ return State::Ready;\n}\n};\ndetailed_state_change(DetailedBridgeState::DaiToXdai {\n@@ -414,33 +384,7 @@ async fn xdai_bridge(state: State) {\n});\n// we don't have a lot of eth, we shouldn't do anything\n}\n- // It goes back into State::Ready once the dai\n- // is in the bridge or if failed. This prevents multiple simultaneous\n- // attempts to bridge the same Dai.\n- state_change(State::Ready {\n- former_state: Some(Box::new(state)),\n- });\n- }\n- State::Depositing { timestamp } => {\n- info!(\"Tried to tick in bridge State::Depositing\");\n- // if the do_send at the end of state depositing fails we can get stuck here\n- // at the time time we don't want to submit multiple eth transactions for each\n- // step above, especially if they take a long time (note the timeouts are in the 10's of minutes)\n- // so we often 'tick' in depositing because there's a background future we don't want to interrupt\n- // if that future fails it's state change do_send a few lines up from here we're screwed and the bridge\n- // forever sits in this no-op state. This is a rescue setup for that situation where we check that enough\n- // time has elapsed. The theoretical max here is the uniswap timeout plus the eth transfer timeout\n- let now = Instant::now();\n- if now\n- > timestamp\n- + Duration::from_secs(UNISWAP_TIMEOUT)\n- + Duration::from_secs(ETH_TRANSFER_TIMEOUT)\n- {\n- warn!(\"Rescued stuck bridge\");\n- state_change(State::Ready {\n- former_state: Some(Box::new(State::Depositing { timestamp })),\n- });\n- }\n+ State::Ready\n}\nState::WithdrawRequest {\nto,\n@@ -453,16 +397,16 @@ async fn xdai_bridge(state: State) {\ndetailed_state_change(DetailedBridgeState::XdaiToDai {\namount: amount.clone(),\n});\n- state_change(State::Withdrawing {\n+ State::Withdrawing {\nto,\namount,\ntimestamp: Instant::now(),\nwithdraw_all,\n- });\n+ }\n}\nErr(e) => {\nerror!(\"Error in State::Deposit WithdrawRequest handler: {:?}\", e);\n- state_change(State::Ready { former_state: None });\n+ State::Ready\n}\n},\nState::Withdrawing {\n@@ -472,43 +416,42 @@ async fn xdai_bridge(state: State) {\nwithdraw_all,\n} => {\ninfo!(\"Ticking in bridge State:Withdrawing\");\n+ let our_withdrawing_state = State::Withdrawing {\n+ to,\n+ amount: amount.clone(),\n+ timestamp,\n+ withdraw_all,\n+ };\nif is_timed_out(timestamp) {\nerror!(\"Withdraw timed out!\");\ndetailed_state_change(DetailedBridgeState::NoOp {\neth_balance: Uint256::zero(),\nwei_per_dollar: Uint256::zero(),\n});\n- state_change(State::Ready {\n- former_state: Some(Box::new(State::Withdrawing {\n- to,\n- amount,\n- timestamp,\n- withdraw_all,\n- })),\n- });\n+ State::Ready\n} else {\nlet our_dai_balance = match bridge.get_dai_balance(bridge.own_address).await {\nOk(val) => val,\n- Err(_e) => return,\n+ Err(_e) => return our_withdrawing_state,\n};\nlet our_eth_balance =\nmatch bridge.eth_web3.eth_get_balance(bridge.own_address).await {\nOk(val) => val,\n- Err(_e) => return,\n+ Err(_e) => return our_withdrawing_state,\n};\nlet wei_per_dollar = match bridge.dai_to_eth_price(eth_to_wei(1u8.into())).await {\nOk(val) => val,\n- Err(_e) => return,\n+ Err(_e) => return our_withdrawing_state,\n};\n// todo why don't we compute this from the above? be careful if you're attempting this, the conversion\n// is fraught with ways to screw it up. Pull out the many units tricks from your physics class\nlet wei_per_cent = match bridge.dai_to_eth_price(DAI_WEI_CENT.into()).await {\nOk(val) => val,\n- Err(_e) => return,\n+ Err(_e) => return our_withdrawing_state,\n};\nlet eth_gas_price = match bridge.eth_web3.eth_gas_price().await {\nOk(val) => val,\n- Err(_e) => return,\n+ Err(_e) => return our_withdrawing_state,\n};\ninfo!(\n@@ -552,6 +495,7 @@ async fn xdai_bridge(state: State) {\n// Then it converts to eth\nlet _amount_actually_exchanged =\nbridge.dai_to_eth_swap(amount, UNISWAP_TIMEOUT);\n+ our_withdrawing_state\n// all other steps are done and the eth is sitting and waiting\n} else if our_eth_balance >= transferred_eth {\ninfo!(\"Converted dai back to eth!\");\n@@ -578,18 +522,14 @@ async fn xdai_bridge(state: State) {\nif res.is_ok() {\ninfo!(\"Issued an eth transfer for withdraw! Now complete!\");\n// we only exit the withdraw state on success or timeout\n- state_change(State::Ready {\n- former_state: Some(Box::new(State::Withdrawing {\n- to,\n- amount,\n- timestamp,\n- withdraw_all,\n- })),\n- });\n+ State::Ready\n+ } else {\n+ our_withdrawing_state\n}\n} else {\ninfo!(\"withdraw is waiting on bridge\");\ndetailed_state_change(DetailedBridgeState::XdaiToDai { amount });\n+ our_withdrawing_state\n}\n}\n}\n@@ -621,7 +561,7 @@ pub fn withdraw(msg: Withdraw) -> Result<(), Error> {\nif let SystemChain::Xdai = system_chain {\nmatch bridge.state.clone() {\n- State::Withdrawing { .. } => {\n+ State::Withdrawing { .. } | State::WithdrawRequest { .. } => {\n// Cannot start a withdraw when one is in progress\nbail!(\"Cannot start a withdraw when one is in progress\")\n}\n@@ -644,24 +584,7 @@ fn state_change(msg: State) {\ntrace!(\"Changing state to {}\", msg);\nlet new_state = msg;\nlet mut bridge = BRIDGE.write().unwrap();\n- // since multiple futures from this system may be in flight at once we face a race\n- // condition, the solution we have used is to put some state into the ready message\n- // the ready message contains the state that it expects to find the system in before\n- // it becomes ready again. If for example the state is depositing and it sees a message\n- // ready(depositing) we know it's the right state change. If we are in withdraw and we\n- // see ready(depositing) we know that it's a stray in flight future that's trying to\n- // modify the state machine incorrectly\n- // TODO this may not be needed after async refactor\n- if let State::Ready {\n- former_state: Some(f),\n- } = new_state.clone()\n- {\n- trace!(\"checking if we should change the state\");\n- if bridge.state != *f {\n- trace!(\"{} != {}\", bridge.state, *f);\n- return;\n- }\n- }\n+ trace!(\"Got bridge write lock\");\nbridge.state = new_state;\n}\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Simplify token bridge state machine
The token bridge state machine doesn't require much of it's old structure
as it's now impossible for multiple instances futures to be running at once |
20,244 | 22.07.2020 19:30:54 | 14,400 | bc14f705c28cc695148f4749a6d070b26b8d8490 | Retry WithdrawRequest for the same amount of time as a withdraw | [
{
"change_type": "MODIFY",
"old_path": "rita/src/rita_common/token_bridge/mod.rs",
"new_path": "rita/src/rita_common/token_bridge/mod.rs",
"diff": "@@ -389,7 +389,7 @@ async fn xdai_bridge(state: State) -> State {\nState::WithdrawRequest {\nto,\namount,\n- timestamp: _timestamp,\n+ timestamp,\nwithdraw_all,\n} => match bridge.xdai_to_dai_bridge(amount.clone()).await {\nOk(_amount_bridged) => {\n@@ -406,7 +406,22 @@ async fn xdai_bridge(state: State) -> State {\n}\nErr(e) => {\nerror!(\"Error in State::Deposit WithdrawRequest handler: {:?}\", e);\n+\n+ if is_timed_out(timestamp) {\n+ error!(\"Withdraw timed out!\");\n+ detailed_state_change(DetailedBridgeState::NoOp {\n+ eth_balance: Uint256::zero(),\n+ wei_per_dollar: Uint256::zero(),\n+ });\nState::Ready\n+ } else {\n+ State::WithdrawRequest {\n+ to,\n+ amount,\n+ timestamp,\n+ withdraw_all,\n+ }\n+ }\n}\n},\nState::Withdrawing {\n@@ -548,7 +563,7 @@ pub fn withdraw(msg: Withdraw) -> Result<(), Error> {\nlet payment_settings = SETTING.get_payment();\nlet system_chain = payment_settings.system_chain;\ndrop(payment_settings);\n- let bridge = BRIDGE.read().unwrap();\n+ let bridge = BRIDGE.read().unwrap().clone();\nlet to = msg.to;\nlet amount = msg.amount.clone();\n@@ -560,7 +575,7 @@ pub fn withdraw(msg: Withdraw) -> Result<(), Error> {\n);\nif let SystemChain::Xdai = system_chain {\n- match bridge.state.clone() {\n+ match bridge.state {\nState::Withdrawing { .. } | State::WithdrawRequest { .. } => {\n// Cannot start a withdraw when one is in progress\nbail!(\"Cannot start a withdraw when one is in progress\")\n"
}
] | Rust | Apache License 2.0 | althea-net/althea_rs | Retry WithdrawRequest for the same amount of time as a withdraw |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.