Changed settings format file from JSON to Toml.

This commit is contained in:
Revertron
2021-03-06 22:40:19 +01:00
parent c5d20d2e00
commit ac915a1e92
5 changed files with 21 additions and 26 deletions
+1
View File
@@ -12,6 +12,7 @@ repository = "https://github.com/Revertron/Alfis"
[dependencies] [dependencies]
getopts = "0.2.21" getopts = "0.2.21"
log = "0.4.14" log = "0.4.14"
toml = "0.5.8"
simple_logger = "1.11.0" simple_logger = "1.11.0"
rust-crypto = "^0.2" rust-crypto = "^0.2"
num_cpus = "1.13.0" num_cpus = "1.13.0"
-20
View File
@@ -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"
]
}
}
+16
View File
@@ -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"]
+1 -1
View File
@@ -36,7 +36,7 @@ use alfis::dns::protocol::DnsRecord;
use alfis::blockchain::filter::BlockchainFilter; use alfis::blockchain::filter::BlockchainFilter;
const KEYSTORE_DIFFICULTY: usize = 24; 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_MAIN: &str = "alfis::Main";
const LOG_TARGET_UI: &str = "alfis::UI"; const LOG_TARGET_UI: &str = "alfis::UI";
+3 -5
View File
@@ -26,12 +26,10 @@ impl Settings {
Ok(mut file) => { Ok(mut file) => {
let mut text = String::new(); let mut text = String::new();
file.read_to_string(&mut text).unwrap(); file.read_to_string(&mut text).unwrap();
let loaded = serde_json::from_str(&text); if let Ok(settings) = toml::from_str(&text) {
return if loaded.is_ok() { return Some(settings);
Some(loaded.unwrap())
} else {
None
} }
None
}, },
Err(..) => None Err(..) => None
} }