2018-08-30 12:10:40 +03:00
|
|
|
// Copyright 2018 The Grin Developers
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
//! Comments for configuration + injection into output .toml
|
|
|
|
use std::collections::HashMap;
|
|
|
|
|
2018-09-03 14:09:28 +03:00
|
|
|
/// maps entries to Comments that should precede them
|
2018-08-30 12:10:40 +03:00
|
|
|
fn comments() -> HashMap<String, String> {
|
|
|
|
let mut retval = HashMap::new();
|
|
|
|
retval.insert(
|
|
|
|
"[server]".to_string(),
|
|
|
|
"
|
2018-09-05 16:37:37 +03:00
|
|
|
# Generated Server Configuration File for Grin
|
2018-08-30 12:10:40 +03:00
|
|
|
#
|
|
|
|
# When running the grin executable without specifying any command line
|
2018-09-05 16:37:37 +03:00
|
|
|
# arguments, it will look for this file in two places, in the following
|
2018-08-30 12:10:40 +03:00
|
|
|
# order:
|
|
|
|
#
|
|
|
|
# -The working directory
|
|
|
|
# -[user home]/.grin
|
|
|
|
#
|
|
|
|
|
|
|
|
#########################################
|
|
|
|
### SERVER CONFIGURATION ###
|
|
|
|
#########################################
|
|
|
|
|
|
|
|
#Server connection details
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"api_http_addr".to_string(),
|
|
|
|
"
|
2019-01-07 22:42:11 +03:00
|
|
|
#path of TLS certificate file, self-signed certificates are not supported
|
|
|
|
#tls_certificate_file = \"\"
|
|
|
|
#private key for the TLS certificate
|
|
|
|
#tls_certificate_key = \"\"
|
|
|
|
|
2018-08-30 12:10:40 +03:00
|
|
|
#the address on which services will listen, e.g. Transaction Pool
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-09-26 23:38:44 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"api_secret_path".to_string(),
|
|
|
|
"
|
|
|
|
#path of the secret token used by the API to authenticate the calls
|
|
|
|
#comment the it to disable basic auth
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"db_root".to_string(),
|
|
|
|
"
|
|
|
|
#the directory, relative to current, in which the grin blockchain
|
|
|
|
#is stored
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"chain_type".to_string(),
|
|
|
|
"
|
|
|
|
#The chain type, which defines the genesis block and the set of cuckoo
|
2018-09-05 16:37:37 +03:00
|
|
|
#parameters used for mining as well as wallet output coinbase maturity. Can be:
|
2018-08-30 12:10:40 +03:00
|
|
|
#AutomatedTesting - For CI builds and instant blockchain creation
|
|
|
|
#UserTesting - For regular user testing (cuckoo 16)
|
2018-12-21 00:04:57 +03:00
|
|
|
#Floonet - For the long term Floonet test network
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"chain_validation_mode".to_string(),
|
|
|
|
"
|
2018-09-26 23:38:44 +03:00
|
|
|
#the chain validation mode, defines how often (if at all) we
|
2018-08-30 12:10:40 +03:00
|
|
|
#want to run a full chain validation. Can be:
|
|
|
|
#\"EveryBlock\" - run full chain validation when processing each block (except during sync)
|
|
|
|
#\"Disabled\" - disable full chain validation (just run regular block validation)
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"archive_mode".to_string(),
|
|
|
|
"
|
|
|
|
#run the node in \"full archive\" mode (default is fast-sync, pruned node)
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"skip_sync_wait".to_string(),
|
|
|
|
"
|
|
|
|
#skip waiting for sync on startup, (optional param, mostly for testing)
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"run_tui".to_string(),
|
|
|
|
"
|
|
|
|
#whether to run the ncurses TUI. Ncurses must be installed and this
|
|
|
|
#will also disable logging to stdout
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"run_test_miner".to_string(),
|
|
|
|
"
|
|
|
|
#Whether to run a test miner. This is only for developer testing (chaintype
|
|
|
|
#usertesting) at cuckoo 16, and will only mine into the default wallet port.
|
|
|
|
#real mining should use the standalone grin-miner
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"[server.dandelion_config]".to_string(),
|
|
|
|
"
|
|
|
|
#########################################
|
|
|
|
### DANDELION CONFIGURATION ###
|
|
|
|
#########################################
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"relay_secs".to_string(),
|
|
|
|
"
|
|
|
|
#dandelion relay time (choose new relay peer every n secs)
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"embargo_secs".to_string(),
|
|
|
|
"
|
|
|
|
#fluff and broadcast after embargo expires if tx not seen on network
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"patience_secs".to_string(),
|
|
|
|
"
|
|
|
|
#run dandelion stem/fluff processing every n secs (stem tx aggregation in this window)
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
retval.insert(
|
|
|
|
"stem_probability".to_string(),
|
|
|
|
"
|
|
|
|
#dandelion stem probability (stem 90% of the time, fluff 10% of the time)
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"[server.p2p_config]".to_string(),
|
|
|
|
"#test miner wallet URL (burns if this doesn't exist)
|
2018-12-29 01:46:21 +03:00
|
|
|
#test_miner_wallet_url = \"http://127.0.0.1:3415\"
|
2018-08-30 12:10:40 +03:00
|
|
|
|
|
|
|
#########################################
|
|
|
|
### SERVER P2P CONFIGURATION ###
|
|
|
|
#########################################
|
|
|
|
#The P2P server details (i.e. the server that communicates with other
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"host".to_string(),
|
|
|
|
"
|
2018-10-23 15:01:19 +03:00
|
|
|
#The interface on which to listen.
|
2018-09-26 23:38:44 +03:00
|
|
|
#0.0.0.0 will listen on all interfaces, allowing others to interact
|
2018-08-30 12:10:40 +03:00
|
|
|
#127.0.0.1 will listen on the local machine only
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"port".to_string(),
|
|
|
|
"
|
|
|
|
#The port on which to listen.
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"seeding_type".to_string(),
|
|
|
|
"
|
2018-10-16 04:25:58 +03:00
|
|
|
#how to seed this server, can be None, List or DNSSeed
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-10-16 04:25:58 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"[server.p2p_config.capabilities]".to_string(),
|
|
|
|
"#If the seeding type is List, the list of peers to connect to can
|
2018-08-30 12:10:40 +03:00
|
|
|
#be specified as follows:
|
2018-12-29 01:46:21 +03:00
|
|
|
#seeds = [\"192.168.0.1:3414\",\"192.168.0.2:3414\"]
|
2018-08-30 12:10:40 +03:00
|
|
|
|
2018-09-12 06:30:24 +03:00
|
|
|
#hardcoded peer lists for allow/deny
|
2018-08-30 12:10:40 +03:00
|
|
|
#will *only* connect to peers in allow list
|
2018-12-29 01:46:21 +03:00
|
|
|
#peers_allow = [\"192.168.0.1:3414\", \"192.168.0.2:3414\"]
|
2018-08-30 12:10:40 +03:00
|
|
|
#will *never* connect to peers in deny list
|
2018-12-29 01:46:21 +03:00
|
|
|
#peers_deny = [\"192.168.0.3:3414\", \"192.168.0.4:3414\"]
|
2018-08-30 12:10:40 +03:00
|
|
|
#a list of preferred peers to connect to
|
2018-12-29 01:46:21 +03:00
|
|
|
#peers_preferred = [\"192.168.0.1:3414\",\"192.168.0.2:3414\"]
|
2018-08-30 12:10:40 +03:00
|
|
|
|
|
|
|
#how long a banned peer should stay banned
|
|
|
|
#ban_window = 10800
|
|
|
|
|
|
|
|
#maximum number of peers
|
|
|
|
#peer_max_count = 25
|
|
|
|
|
|
|
|
#preferred minimum number of peers (we'll actively keep trying to add peers
|
|
|
|
#until we get to at least this number
|
|
|
|
#peer_min_preferred_count = 8
|
|
|
|
|
2018-11-07 12:28:17 +03:00
|
|
|
# 15 = Bit flags for FULL_NODE
|
2018-10-08 15:35:48 +03:00
|
|
|
#This structure needs to be changed internally, to make it more configurable
|
2018-12-31 19:49:05 +03:00
|
|
|
|
2018-12-31 21:00:33 +03:00
|
|
|
# A preferred dandelion_peer, mainly used for testing dandelion
|
2018-12-31 19:49:05 +03:00
|
|
|
# dandelion_peer = \"10.0.0.1:13144\"
|
|
|
|
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-09-12 06:30:24 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"[server.pool_config]".to_string(),
|
|
|
|
"
|
2018-08-30 12:10:40 +03:00
|
|
|
#########################################
|
|
|
|
### MEMPOOL CONFIGURATION ###
|
|
|
|
#########################################
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"accept_fee_base".to_string(),
|
|
|
|
"
|
2018-09-26 23:38:44 +03:00
|
|
|
#base fee that's accepted into the pool
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"max_pool_size".to_string(),
|
|
|
|
"
|
2018-09-26 23:38:44 +03:00
|
|
|
#maximum number of transactions allowed in the pool
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
2018-11-05 15:51:52 +03:00
|
|
|
retval.insert(
|
|
|
|
"max_stempool_size".to_string(),
|
|
|
|
"
|
|
|
|
#maximum number of transactions allowed in the stempool
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-11-05 15:51:52 +03:00
|
|
|
);
|
|
|
|
|
2018-11-14 21:22:08 +03:00
|
|
|
retval.insert(
|
|
|
|
"mineable_max_weight".to_string(),
|
|
|
|
"
|
|
|
|
#maximum total weight of transactions that can get selected to build a block
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-11-14 21:22:08 +03:00
|
|
|
);
|
|
|
|
|
2018-08-30 12:10:40 +03:00
|
|
|
retval.insert(
|
|
|
|
"[server.stratum_mining_config]".to_string(),
|
|
|
|
"
|
|
|
|
################################################
|
|
|
|
### STRATUM MINING SERVER CONFIGURATION ###
|
|
|
|
################################################
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"enable_stratum_server".to_string(),
|
|
|
|
"
|
|
|
|
#whether stratum server is enabled
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"stratum_server_addr".to_string(),
|
|
|
|
"
|
|
|
|
#what port and address for the stratum server to listen on
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"attempt_time_per_block".to_string(),
|
|
|
|
"
|
2018-09-26 23:38:44 +03:00
|
|
|
#the amount of time, in seconds, to attempt to mine on a particular
|
2018-08-30 12:10:40 +03:00
|
|
|
#header before stopping and re-collecting transactions from the pool
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"minimum_share_difficulty".to_string(),
|
|
|
|
"
|
2018-09-26 23:38:44 +03:00
|
|
|
#the minimum acceptable share difficulty to request from miners
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"wallet_listener_url".to_string(),
|
|
|
|
"
|
|
|
|
#the wallet receiver to which coinbase rewards will be sent
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"burn_reward".to_string(),
|
|
|
|
"
|
|
|
|
#whether to ignore the reward (mostly for testing)
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"[wallet]".to_string(),
|
|
|
|
"
|
|
|
|
#########################################
|
|
|
|
### WALLET CONFIGURATION ###
|
|
|
|
#########################################
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"api_listen_interface".to_string(),
|
|
|
|
"
|
2018-09-26 23:38:44 +03:00
|
|
|
#host IP for wallet listener, change to \"0.0.0.0\" to receive grins
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"api_listen_port".to_string(),
|
|
|
|
"
|
2018-10-05 18:03:15 +03:00
|
|
|
#path of TLS certificate file, self-signed certificates are not supported
|
2018-10-02 10:49:36 +03:00
|
|
|
#tls_certificate_file = \"\"
|
2018-10-05 18:03:15 +03:00
|
|
|
#private key for the TLS certificate
|
|
|
|
#tls_certificate_key = \"\"
|
2018-10-02 10:49:36 +03:00
|
|
|
|
2019-01-30 07:21:09 +03:00
|
|
|
#port for wallet listener
|
|
|
|
"
|
|
|
|
.to_string(),
|
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"owner_api_listen_port".to_string(),
|
|
|
|
"
|
|
|
|
#port for wallet owner api
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
2018-09-26 23:38:44 +03:00
|
|
|
retval.insert(
|
|
|
|
"api_secret_path".to_string(),
|
|
|
|
"
|
|
|
|
#path of the secret token used by the API to authenticate the calls
|
|
|
|
#comment it to disable basic auth
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-09-26 23:38:44 +03:00
|
|
|
);
|
2018-08-30 12:10:40 +03:00
|
|
|
retval.insert(
|
|
|
|
"check_node_api_http_addr".to_string(),
|
|
|
|
"
|
2018-09-26 23:38:44 +03:00
|
|
|
#where the wallet should find a running node
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
2018-09-27 22:45:48 +03:00
|
|
|
retval.insert(
|
|
|
|
"node_api_secret_path".to_string(),
|
|
|
|
"
|
|
|
|
#location of the node api secret for basic auth on the Grin API
|
2019-01-07 13:00:52 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
|
|
|
);
|
|
|
|
retval.insert(
|
|
|
|
"owner_api_include_foreign".to_string(),
|
|
|
|
"
|
|
|
|
#include the foreign API endpoints on the same port as the owner
|
|
|
|
#API. Useful for networking environments like AWS ECS that make
|
|
|
|
#it difficult to access multiple ports on a single service.
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-09-27 22:45:48 +03:00
|
|
|
);
|
2018-08-30 12:10:40 +03:00
|
|
|
retval.insert(
|
|
|
|
"data_file_dir".to_string(),
|
|
|
|
"
|
2018-09-26 23:38:44 +03:00
|
|
|
#where to find wallet files (seed, data, etc)
|
2019-01-14 18:43:10 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
|
|
|
);
|
|
|
|
retval.insert(
|
|
|
|
"no_commit_cache".to_string(),
|
|
|
|
"
|
|
|
|
#If true, don't store calculated commits in the database
|
2019-01-30 07:21:09 +03:00
|
|
|
#better privacy, but at a performance cost of having to
|
2019-01-14 18:43:10 +03:00
|
|
|
#re-calculate commits every time they're used
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-11-03 11:42:41 +03:00
|
|
|
);
|
|
|
|
retval.insert(
|
|
|
|
"dark_background_color_scheme".to_string(),
|
|
|
|
"
|
|
|
|
#Whether to use the black background color scheme for command line
|
2018-12-18 14:51:44 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
|
|
|
);
|
|
|
|
retval.insert(
|
2018-12-25 03:05:24 +03:00
|
|
|
"keybase_notify_ttl".to_string(),
|
2018-12-18 14:51:44 +03:00
|
|
|
"
|
2018-12-25 03:05:24 +03:00
|
|
|
#The exploding lifetime for keybase notification on coins received.
|
|
|
|
#Unit: Minute. Default value 1440 minutes for one day.
|
|
|
|
#Refer to https://keybase.io/blog/keybase-exploding-messages for detail.
|
|
|
|
#To disable this notification, set it as 0.
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"[logging]".to_string(),
|
|
|
|
"
|
|
|
|
#########################################
|
|
|
|
### LOGGING CONFIGURATION ###
|
|
|
|
#########################################
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"log_to_stdout".to_string(),
|
|
|
|
"
|
2018-09-26 23:38:44 +03:00
|
|
|
#whether to log to stdout
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"stdout_log_level".to_string(),
|
|
|
|
"
|
2018-10-21 23:30:56 +03:00
|
|
|
#log level for stdout: Error, Warning, Info, Debug, Trace
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"log_to_file".to_string(),
|
|
|
|
"
|
2018-09-26 23:38:44 +03:00
|
|
|
#whether to log to a file
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"file_log_level".to_string(),
|
|
|
|
"
|
2018-10-21 23:30:56 +03:00
|
|
|
#log level for file: Error, Warning, Info, Debug, Trace
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"log_file_path".to_string(),
|
|
|
|
"
|
2018-09-26 23:38:44 +03:00
|
|
|
#log file path
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
retval.insert(
|
|
|
|
"log_file_append".to_string(),
|
|
|
|
"
|
2018-09-26 23:38:44 +03:00
|
|
|
#whether to append to the log file (true), or replace it on every run (false)
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-08-30 12:10:40 +03:00
|
|
|
);
|
|
|
|
|
2018-10-21 23:30:56 +03:00
|
|
|
retval.insert(
|
|
|
|
"log_max_size".to_string(),
|
|
|
|
"
|
|
|
|
#maximum log file size in bytes before performing log rotation
|
|
|
|
#comment it to disable log rotation
|
2018-12-08 02:59:40 +03:00
|
|
|
"
|
|
|
|
.to_string(),
|
2018-10-21 23:30:56 +03:00
|
|
|
);
|
|
|
|
|
2018-08-30 12:10:40 +03:00
|
|
|
retval
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_key(line: &str) -> String {
|
|
|
|
if line.contains("[") && line.contains("]") {
|
|
|
|
return line.to_owned();
|
|
|
|
} else if line.contains("=") {
|
|
|
|
return line.split("=").collect::<Vec<&str>>()[0].trim().to_owned();
|
|
|
|
} else {
|
|
|
|
return "NOT_FOUND".to_owned();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn insert_comments(orig: String) -> String {
|
|
|
|
let comments = comments();
|
|
|
|
let lines: Vec<&str> = orig.split("\n").collect();
|
|
|
|
let mut out_lines = vec![];
|
|
|
|
for l in lines {
|
|
|
|
let key = get_key(l);
|
|
|
|
if let Some(v) = comments.get(&key) {
|
|
|
|
out_lines.push(v.to_owned());
|
|
|
|
}
|
|
|
|
out_lines.push(l.to_owned());
|
|
|
|
out_lines.push("\n".to_owned());
|
|
|
|
}
|
|
|
|
let mut ret_val = String::from("");
|
|
|
|
for l in out_lines {
|
|
|
|
ret_val.push_str(&l);
|
|
|
|
}
|
|
|
|
ret_val.to_owned()
|
|
|
|
}
|