From ac915a1e9266b29f5d996901a2be4ffa09239476 Mon Sep 17 00:00:00 2001 From: Revertron Date: Sat, 6 Mar 2021 22:40:19 +0100 Subject: [PATCH] Changed settings format file from JSON to Toml. --- Cargo.toml | 1 + alfis.cfg | 20 -------------------- alfis.toml | 16 ++++++++++++++++ src/main.rs | 2 +- src/settings.rs | 8 +++----- 5 files changed, 21 insertions(+), 26 deletions(-) delete mode 100644 alfis.cfg create mode 100644 alfis.toml diff --git a/Cargo.toml b/Cargo.toml index a628a02..e37bb10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ repository = "https://github.com/Revertron/Alfis" [dependencies] getopts = "0.2.21" log = "0.4.14" +toml = "0.5.8" simple_logger = "1.11.0" rust-crypto = "^0.2" num_cpus = "1.13.0" diff --git a/alfis.cfg b/alfis.cfg deleted file mode 100644 index 686aad0..0000000 --- a/alfis.cfg +++ /dev/null @@ -1,20 +0,0 @@ -{ - "chain_name": "test", - "origin": "00000DFBFFCFADC09751E7085872F9AE6464075E626401904D8C779E215A21B1", - "version": 0, - "key_file": "default.key", - "listen": "[::]:4244", - "public": false, - "peers": [ - "test-ip4.alfis.name:4244", - "test-ip6.alfis.name:4244" - ], - "dns": { - "host": "0.0.0.0", - "port": 5300, - "forwarders": [ - "94.140.14.14:53", - "94.140.15.15:53" - ] - } -} \ No newline at end of file diff --git a/alfis.toml b/alfis.toml new file mode 100644 index 0000000..e2c8947 --- /dev/null +++ b/alfis.toml @@ -0,0 +1,16 @@ +# Settings +origin = "00000DFBFFCFADC09751E7085872F9AE6464075E626401904D8C779E215A21B1" +version = 1 +key_file = "default.key" +listen = "[::]:4244" +public = false + +# Bootstrap nodes +peers = ["test2-ip4.alfis.name:4244", "test2-ip6.alfis.name:4244"] + +# DNS server options +[dns] +host = "0.0.0.0" +port = 5300 +#AdGuard DNS servers to filter ads and trackers +forwarders = ["94.140.14.14:53", "94.140.15.15:53"] diff --git a/src/main.rs b/src/main.rs index 643570e..d48278a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,7 +36,7 @@ use alfis::dns::protocol::DnsRecord; use alfis::blockchain::filter::BlockchainFilter; const KEYSTORE_DIFFICULTY: usize = 24; -const SETTINGS_FILENAME: &str = "alfis.cfg"; +const SETTINGS_FILENAME: &str = "alfis.toml"; const LOG_TARGET_MAIN: &str = "alfis::Main"; const LOG_TARGET_UI: &str = "alfis::UI"; diff --git a/src/settings.rs b/src/settings.rs index 3fc8140..bb80c3f 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -26,12 +26,10 @@ impl Settings { Ok(mut file) => { let mut text = String::new(); file.read_to_string(&mut text).unwrap(); - let loaded = serde_json::from_str(&text); - return if loaded.is_ok() { - Some(loaded.unwrap()) - } else { - None + if let Ok(settings) = toml::from_str(&text) { + return Some(settings); } + None }, Err(..) => None }