2
0
mirror of https://github.com/Revertron/Alfis synced 2024-11-03 15:40:19 +00:00

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

View File

@ -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"

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
alfis.toml Normal file
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"]

View File

@ -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";

View File

@ -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
}