456 for (
auto& line : strVec)
459 if (
std::count(line.begin(), line.end(),
':') != 1)
465 if (result.
size() == line.size())
478 boost::filesystem::path p(dbPath);
479 legacy(
"database_path", boost::filesystem::absolute(p).
string());
487 if (strTemp ==
"main")
489 else if (strTemp ==
"testnet")
491 else if (strTemp ==
"devnet")
494 NETWORK_ID = beast::lexicalCastThrow<uint32_t>(strTemp);
502 PEERS_MAX = beast::lexicalCastThrow<std::size_t>(strTemp);
509 peers_in_max = beast::lexicalCastThrow<std::size_t>(strTemp);
510 if (*peers_in_max > 1000)
511 Throw<std::runtime_error>(
"Invalid value specified in [" SECTION_PEERS_IN_MAX
512 "] section; the value must be less or equal than 1000");
518 peers_out_max = beast::lexicalCastThrow<std::size_t>(strTemp);
519 if (*peers_out_max < 10 || *peers_out_max > 1000)
520 Throw<std::runtime_error>(
"Invalid value specified in [" SECTION_PEERS_OUT_MAX
521 "] section; the value must be in range 10-1000");
525 if ((peers_in_max && !peers_out_max) || (peers_out_max && !peers_in_max))
526 Throw<std::runtime_error>(
"Both sections [" SECTION_PEERS_IN_MAX
528 "and [" SECTION_PEERS_OUT_MAX
"] must be configured");
530 if (peers_in_max && peers_out_max)
539 if (boost::iequals(strTemp,
"tiny"))
541 else if (boost::iequals(strTemp,
"small"))
543 else if (boost::iequals(strTemp,
"medium"))
545 else if (boost::iequals(strTemp,
"large"))
547 else if (boost::iequals(strTemp,
"huge"))
557 ELB_SUPPORT = beast::lexicalCastThrow<bool>(strTemp);
563 SSL_VERIFY = beast::lexicalCastThrow<bool>(strTemp);
567 if (boost::iequals(strTemp,
"all"))
569 else if (boost::iequals(strTemp,
"trusted"))
571 else if (boost::iequals(strTemp,
"drop_untrusted"))
574 Throw<std::runtime_error>(
"Invalid value specified in [" SECTION_RELAY_VALIDATIONS
"] section");
579 if (boost::iequals(strTemp,
"all"))
581 else if (boost::iequals(strTemp,
"trusted"))
583 else if (boost::iequals(strTemp,
"drop_untrusted"))
586 Throw<std::runtime_error>(
"Invalid value specified in [" SECTION_RELAY_PROPOSALS
"] section");
589 if (
exists(SECTION_VALIDATION_SEED) &&
exists(SECTION_VALIDATOR_TOKEN))
590 Throw<std::runtime_error>(
"Cannot have both [" SECTION_VALIDATION_SEED
"] and [" SECTION_VALIDATOR_TOKEN
591 "] config sections");
605 if (boost::iequals(strTemp,
"full"))
607 else if (boost::iequals(strTemp,
"none"))
615 if (boost::iequals(strTemp,
"none"))
617 else if (boost::iequals(strTemp,
"full"))
620 FETCH_DEPTH = beast::lexicalCastThrow<std::uint32_t>(strTemp);
628 if (
exists(SECTION_VALIDATION_SEED) ||
exists(SECTION_VALIDATOR_TOKEN))
634 PATH_SEARCH = beast::lexicalCastThrow<int>(strTemp);
647 if (SWEEP_INTERVAL < 10 || SWEEP_INTERVAL > 600)
648 Throw<std::runtime_error>(
"Invalid " SECTION_SWEEP_INTERVAL
": must be between 10 and 600 inclusive");
653 WORKERS = beast::lexicalCastThrow<int>(strTemp);
655 if (WORKERS < 1 || WORKERS > 1024)
656 Throw<std::runtime_error>(
"Invalid " SECTION_WORKERS
": must be between 1 and 1024 inclusive.");
661 IO_WORKERS = beast::lexicalCastThrow<int>(strTemp);
663 if (IO_WORKERS < 1 || IO_WORKERS > 1024)
664 Throw<std::runtime_error>(
"Invalid " SECTION_IO_WORKERS
": must be between 1 and 1024 inclusive.");
671 if (PREFETCH_WORKERS < 1 || PREFETCH_WORKERS > 1024)
672 Throw<std::runtime_error>(
"Invalid " SECTION_PREFETCH_WORKERS
": must be between 1 and 1024 inclusive.");
676 COMPRESSION = beast::lexicalCastThrow<bool>(strTemp);
681 if (
exists(SECTION_REDUCE_RELAY))
683 auto sec =
section(SECTION_REDUCE_RELAY);
691 if (sec.exists(
"vp_base_squelch_enable") && sec.exists(
"vp_enable"))
692 Throw<std::runtime_error>(
"Invalid " SECTION_REDUCE_RELAY
693 " cannot specify both vp_base_squelch_enable and vp_enable "
695 "vp_enable was deprecated and replaced by "
696 "vp_base_squelch_enable");
698 if (sec.exists(
"vp_base_squelch_enable"))
700 else if (sec.exists(
"vp_enable"))
712 Throw<std::runtime_error>(
"Invalid " SECTION_REDUCE_RELAY
713 " vp_base_squelch_max_selected_peers must be "
714 "greater than or equal to 3");
722 Throw<std::runtime_error>(
"Invalid " SECTION_REDUCE_RELAY
723 ", tx_min_peers must be greater than or equal to 10"
724 ", tx_relay_percentage must be greater than or equal to 10 "
725 "and less than or equal to 100");
737 Throw<std::runtime_error>(
"Invalid " SECTION_SERVER_DOMAIN
738 ": the domain name does not appear to meet the requirements.");
744 if (
exists(SECTION_OVERLAY))
746 auto const sec =
section(SECTION_OVERLAY);
752 if (
auto val = sec.get(
"max_unknown_time"))
757 Throw<std::runtime_error>(
"Invalid value 'max_unknown_time' in " SECTION_OVERLAY
758 ": must be of the form '<number>' representing seconds.");
762 Throw<std::runtime_error>(
"Invalid value 'max_unknown_time' in " SECTION_OVERLAY
763 ": the time must be between 300 and 1800 seconds, inclusive.");
767 if (
auto val = sec.get(
"max_diverged_time"))
772 Throw<std::runtime_error>(
"Invalid value 'max_diverged_time' in " SECTION_OVERLAY
773 ": must be of the form '<number>' representing seconds.");
778 Throw<std::runtime_error>(
"Invalid value 'max_diverged_time' in " SECTION_OVERLAY
779 ": the time must be between 60 and 900 seconds, inclusive.");
786 boost::regex
const re(
"^\\s*(\\d+)\\s*(minutes|hours|days|weeks)\\s*(\\s+.*)?$");
788 if (!boost::regex_match(strTemp,
match, re))
789 Throw<std::runtime_error>(
"Invalid " SECTION_AMENDMENT_MAJORITY_TIME
790 ", must be: [0-9]+ [minutes|hours|days|weeks]");
794 if (boost::iequals(
match[2],
"minutes"))
796 else if (boost::iequals(
match[2],
"hours"))
798 else if (boost::iequals(
match[2],
"days"))
800 else if (boost::iequals(
match[2],
"weeks"))
804 Throw<std::runtime_error>(
"Invalid " SECTION_AMENDMENT_MAJORITY_TIME
805 ", the minimum amount of time an amendment must hold a "
806 "majority is 15 minutes");
823 boost::filesystem::path validatorsFile;
827 validatorsFile = strTemp;
829 if (validatorsFile.empty())
830 Throw<std::runtime_error>(
"Invalid path specified in [" SECTION_VALIDATORS_FILE
"]");
832 if (!validatorsFile.is_absolute() && !
CONFIG_DIR.empty())
835 if (!boost::filesystem::exists(validatorsFile))
836 Throw<std::runtime_error>(
837 "The file specified in [" SECTION_VALIDATORS_FILE
840 validatorsFile.string());
843 !boost::filesystem::is_regular_file(validatorsFile) && !boost::filesystem::is_symlink(validatorsFile))
844 Throw<std::runtime_error>(
845 "Invalid file specified in [" SECTION_VALIDATORS_FILE
"]: " + validatorsFile.string());
851 if (!validatorsFile.empty())
853 if (!boost::filesystem::exists(validatorsFile))
854 validatorsFile.clear();
856 !boost::filesystem::is_regular_file(validatorsFile) &&
857 !boost::filesystem::is_symlink(validatorsFile))
858 validatorsFile.clear();
862 if (!validatorsFile.empty() && boost::filesystem::exists(validatorsFile) &&
863 (boost::filesystem::is_regular_file(validatorsFile) || boost::filesystem::is_symlink(validatorsFile)))
865 boost::system::error_code ec;
869 Throw<std::runtime_error>(
870 "Failed to read '" + validatorsFile.string() +
"'." +
std::to_string(ec.value()) +
": " +
889 section(SECTION_VALIDATOR_LIST_SITES).
append(*valSiteEntries);
896 auto valListThreshold =
getIniFileSection(iniFile, SECTION_VALIDATOR_LIST_THRESHOLD);
898 if (valListThreshold)
899 section(SECTION_VALIDATOR_LIST_THRESHOLD).
append(*valListThreshold);
901 if (!entries && !valKeyEntries && !valListKeys)
902 Throw<std::runtime_error>(
903 "The file specified in [" SECTION_VALIDATORS_FILE
905 "does not contain a [" SECTION_VALIDATORS
907 "[" SECTION_VALIDATOR_KEYS
909 "[" SECTION_VALIDATOR_LIST_KEYS
912 validatorsFile.string());
916 auto const& listThreshold =
section(SECTION_VALIDATOR_LIST_THRESHOLD);
917 if (listThreshold.lines().empty())
919 else if (listThreshold.values().size() == 1)
921 auto strTemp = listThreshold.values()[0];
922 auto const listThreshold = beast::lexicalCastThrow<std::size_t>(strTemp);
923 if (listThreshold == 0)
925 else if (listThreshold >
section(SECTION_VALIDATOR_LIST_KEYS).values().size())
927 Throw<std::runtime_error>(
928 "Value in config section "
929 "[" SECTION_VALIDATOR_LIST_THRESHOLD
"] exceeds the number of configured list keys");
931 return listThreshold;
935 Throw<std::runtime_error>(
937 "[" SECTION_VALIDATOR_LIST_THRESHOLD
"] should contain single value only");
944 if (!
section(SECTION_VALIDATOR_LIST_SITES).lines().empty() &&
945 section(SECTION_VALIDATOR_LIST_KEYS).lines().empty())
947 Throw<std::runtime_error>(
"[" +
std::string(SECTION_VALIDATOR_LIST_KEYS) +
"] config section is missing");
952 auto const part =
section(
"features");
953 for (
auto const& s : part.values())
958 Throw<std::runtime_error>(
"Unknown feature: " + s +
" in config file.");
974 Throw<std::runtime_error>(
975 "The minimum number of required peers (network_quorum) exceeds "
976 "the maximum number of allowed peers (peers_max)");