454 for (
auto& line : strVec)
457 if (
std::count(line.begin(), line.end(),
':') != 1)
463 if (result.
size() == line.size())
476 boost::filesystem::path p(dbPath);
477 legacy(
"database_path", boost::filesystem::absolute(p).
string());
485 if (strTemp ==
"main")
487 else if (strTemp ==
"testnet")
489 else if (strTemp ==
"devnet")
492 NETWORK_ID = beast::lexicalCastThrow<uint32_t>(strTemp);
500 PEERS_MAX = beast::lexicalCastThrow<std::size_t>(strTemp);
507 peers_in_max = beast::lexicalCastThrow<std::size_t>(strTemp);
508 if (*peers_in_max > 1000)
509 Throw<std::runtime_error>(
"Invalid value specified in [" SECTION_PEERS_IN_MAX
510 "] section; the value must be less or equal than 1000");
516 peers_out_max = beast::lexicalCastThrow<std::size_t>(strTemp);
517 if (*peers_out_max < 10 || *peers_out_max > 1000)
518 Throw<std::runtime_error>(
"Invalid value specified in [" SECTION_PEERS_OUT_MAX
519 "] section; the value must be in range 10-1000");
523 if ((peers_in_max && !peers_out_max) || (peers_out_max && !peers_in_max))
524 Throw<std::runtime_error>(
"Both sections [" SECTION_PEERS_IN_MAX
526 "and [" SECTION_PEERS_OUT_MAX
"] must be configured");
528 if (peers_in_max && peers_out_max)
537 if (boost::iequals(strTemp,
"tiny"))
539 else if (boost::iequals(strTemp,
"small"))
541 else if (boost::iequals(strTemp,
"medium"))
543 else if (boost::iequals(strTemp,
"large"))
545 else if (boost::iequals(strTemp,
"huge"))
555 ELB_SUPPORT = beast::lexicalCastThrow<bool>(strTemp);
561 SSL_VERIFY = beast::lexicalCastThrow<bool>(strTemp);
565 if (boost::iequals(strTemp,
"all"))
567 else if (boost::iequals(strTemp,
"trusted"))
569 else if (boost::iequals(strTemp,
"drop_untrusted"))
572 Throw<std::runtime_error>(
"Invalid value specified in [" SECTION_RELAY_VALIDATIONS
"] section");
577 if (boost::iequals(strTemp,
"all"))
579 else if (boost::iequals(strTemp,
"trusted"))
581 else if (boost::iequals(strTemp,
"drop_untrusted"))
584 Throw<std::runtime_error>(
"Invalid value specified in [" SECTION_RELAY_PROPOSALS
"] section");
587 if (
exists(SECTION_VALIDATION_SEED) &&
exists(SECTION_VALIDATOR_TOKEN))
588 Throw<std::runtime_error>(
"Cannot have both [" SECTION_VALIDATION_SEED
"] and [" SECTION_VALIDATOR_TOKEN
589 "] config sections");
603 if (boost::iequals(strTemp,
"full"))
605 else if (boost::iequals(strTemp,
"none"))
613 if (boost::iequals(strTemp,
"none"))
615 else if (boost::iequals(strTemp,
"full"))
618 FETCH_DEPTH = beast::lexicalCastThrow<std::uint32_t>(strTemp);
626 if (
exists(SECTION_VALIDATION_SEED) ||
exists(SECTION_VALIDATOR_TOKEN))
632 PATH_SEARCH = beast::lexicalCastThrow<int>(strTemp);
645 if (SWEEP_INTERVAL < 10 || SWEEP_INTERVAL > 600)
646 Throw<std::runtime_error>(
"Invalid " SECTION_SWEEP_INTERVAL
": must be between 10 and 600 inclusive");
651 WORKERS = beast::lexicalCastThrow<int>(strTemp);
653 if (WORKERS < 1 || WORKERS > 1024)
654 Throw<std::runtime_error>(
"Invalid " SECTION_WORKERS
": must be between 1 and 1024 inclusive.");
659 IO_WORKERS = beast::lexicalCastThrow<int>(strTemp);
661 if (IO_WORKERS < 1 || IO_WORKERS > 1024)
662 Throw<std::runtime_error>(
"Invalid " SECTION_IO_WORKERS
": must be between 1 and 1024 inclusive.");
669 if (PREFETCH_WORKERS < 1 || PREFETCH_WORKERS > 1024)
670 Throw<std::runtime_error>(
"Invalid " SECTION_PREFETCH_WORKERS
": must be between 1 and 1024 inclusive.");
674 COMPRESSION = beast::lexicalCastThrow<bool>(strTemp);
679 if (
exists(SECTION_REDUCE_RELAY))
681 auto sec =
section(SECTION_REDUCE_RELAY);
689 if (sec.exists(
"vp_base_squelch_enable") && sec.exists(
"vp_enable"))
690 Throw<std::runtime_error>(
"Invalid " SECTION_REDUCE_RELAY
691 " cannot specify both vp_base_squelch_enable and vp_enable "
693 "vp_enable was deprecated and replaced by "
694 "vp_base_squelch_enable");
696 if (sec.exists(
"vp_base_squelch_enable"))
698 else if (sec.exists(
"vp_enable"))
710 Throw<std::runtime_error>(
"Invalid " SECTION_REDUCE_RELAY
711 " vp_base_squelch_max_selected_peers must be "
712 "greater than or equal to 3");
720 Throw<std::runtime_error>(
"Invalid " SECTION_REDUCE_RELAY
721 ", tx_min_peers must be greater than or equal to 10"
722 ", tx_relay_percentage must be greater than or equal to 10 "
723 "and less than or equal to 100");
735 Throw<std::runtime_error>(
"Invalid " SECTION_SERVER_DOMAIN
736 ": the domain name does not appear to meet the requirements.");
742 if (
exists(SECTION_OVERLAY))
744 auto const sec =
section(SECTION_OVERLAY);
750 if (
auto val = sec.get(
"max_unknown_time"))
755 Throw<std::runtime_error>(
"Invalid value 'max_unknown_time' in " SECTION_OVERLAY
756 ": must be of the form '<number>' representing seconds.");
760 Throw<std::runtime_error>(
"Invalid value 'max_unknown_time' in " SECTION_OVERLAY
761 ": the time must be between 300 and 1800 seconds, inclusive.");
765 if (
auto val = sec.get(
"max_diverged_time"))
770 Throw<std::runtime_error>(
"Invalid value 'max_diverged_time' in " SECTION_OVERLAY
771 ": must be of the form '<number>' representing seconds.");
776 Throw<std::runtime_error>(
"Invalid value 'max_diverged_time' in " SECTION_OVERLAY
777 ": the time must be between 60 and 900 seconds, inclusive.");
784 boost::regex
const re(
"^\\s*(\\d+)\\s*(minutes|hours|days|weeks)\\s*(\\s+.*)?$");
786 if (!boost::regex_match(strTemp,
match, re))
787 Throw<std::runtime_error>(
"Invalid " SECTION_AMENDMENT_MAJORITY_TIME
788 ", must be: [0-9]+ [minutes|hours|days|weeks]");
792 if (boost::iequals(
match[2],
"minutes"))
794 else if (boost::iequals(
match[2],
"hours"))
796 else if (boost::iequals(
match[2],
"days"))
798 else if (boost::iequals(
match[2],
"weeks"))
802 Throw<std::runtime_error>(
"Invalid " SECTION_AMENDMENT_MAJORITY_TIME
803 ", the minimum amount of time an amendment must hold a "
804 "majority is 15 minutes");
821 boost::filesystem::path validatorsFile;
825 validatorsFile = strTemp;
827 if (validatorsFile.empty())
828 Throw<std::runtime_error>(
"Invalid path specified in [" SECTION_VALIDATORS_FILE
"]");
830 if (!validatorsFile.is_absolute() && !
CONFIG_DIR.empty())
833 if (!boost::filesystem::exists(validatorsFile))
834 Throw<std::runtime_error>(
835 "The file specified in [" SECTION_VALIDATORS_FILE
838 validatorsFile.string());
841 !boost::filesystem::is_regular_file(validatorsFile) && !boost::filesystem::is_symlink(validatorsFile))
842 Throw<std::runtime_error>(
843 "Invalid file specified in [" SECTION_VALIDATORS_FILE
"]: " + validatorsFile.string());
849 if (!validatorsFile.empty())
851 if (!boost::filesystem::exists(validatorsFile))
852 validatorsFile.clear();
854 !boost::filesystem::is_regular_file(validatorsFile) &&
855 !boost::filesystem::is_symlink(validatorsFile))
856 validatorsFile.clear();
860 if (!validatorsFile.empty() && boost::filesystem::exists(validatorsFile) &&
861 (boost::filesystem::is_regular_file(validatorsFile) || boost::filesystem::is_symlink(validatorsFile)))
863 boost::system::error_code ec;
867 Throw<std::runtime_error>(
868 "Failed to read '" + validatorsFile.string() +
"'." +
std::to_string(ec.value()) +
": " +
887 section(SECTION_VALIDATOR_LIST_SITES).
append(*valSiteEntries);
894 auto valListThreshold =
getIniFileSection(iniFile, SECTION_VALIDATOR_LIST_THRESHOLD);
896 if (valListThreshold)
897 section(SECTION_VALIDATOR_LIST_THRESHOLD).
append(*valListThreshold);
899 if (!entries && !valKeyEntries && !valListKeys)
900 Throw<std::runtime_error>(
901 "The file specified in [" SECTION_VALIDATORS_FILE
903 "does not contain a [" SECTION_VALIDATORS
905 "[" SECTION_VALIDATOR_KEYS
907 "[" SECTION_VALIDATOR_LIST_KEYS
910 validatorsFile.string());
914 auto const& listThreshold =
section(SECTION_VALIDATOR_LIST_THRESHOLD);
915 if (listThreshold.lines().empty())
917 else if (listThreshold.values().size() == 1)
919 auto strTemp = listThreshold.values()[0];
920 auto const listThreshold = beast::lexicalCastThrow<std::size_t>(strTemp);
921 if (listThreshold == 0)
923 else if (listThreshold >
section(SECTION_VALIDATOR_LIST_KEYS).values().size())
925 Throw<std::runtime_error>(
926 "Value in config section "
927 "[" SECTION_VALIDATOR_LIST_THRESHOLD
"] exceeds the number of configured list keys");
929 return listThreshold;
933 Throw<std::runtime_error>(
935 "[" SECTION_VALIDATOR_LIST_THRESHOLD
"] should contain single value only");
942 if (!
section(SECTION_VALIDATOR_LIST_SITES).lines().empty() &&
943 section(SECTION_VALIDATOR_LIST_KEYS).lines().empty())
945 Throw<std::runtime_error>(
"[" +
std::string(SECTION_VALIDATOR_LIST_KEYS) +
"] config section is missing");
950 auto const part =
section(
"features");
951 for (
auto const& s : part.values())
956 Throw<std::runtime_error>(
"Unknown feature: " + s +
" in config file.");
972 Throw<std::runtime_error>(
973 "The minimum number of required peers (network_quorum) exceeds "
974 "the maximum number of allowed peers (peers_max)");