Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 637 Lines • ▼ Show 20 Lines | argsman.AddArg("-asmap=<file>", | ||||
"prefixed by the net-specific datadir location.", | "prefixed by the net-specific datadir location.", | ||||
DEFAULT_ASMAP_FILENAME), | DEFAULT_ASMAP_FILENAME), | ||||
ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); | ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); | ||||
argsman.AddArg("-bantime=<n>", | argsman.AddArg("-bantime=<n>", | ||||
strprintf("Default duration (in seconds) of manually " | strprintf("Default duration (in seconds) of manually " | ||||
"configured bans (default: %u)", | "configured bans (default: %u)", | ||||
DEFAULT_MISBEHAVING_BANTIME), | DEFAULT_MISBEHAVING_BANTIME), | ||||
ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); | ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); | ||||
argsman.AddArg("-bind=<addr>", | argsman.AddArg( | ||||
"Bind to given address and always listen on it. Use " | "-bind=<addr>[:<port>][=onion]", | ||||
"[host]:port notation for IPv6", | strprintf("Bind to given address and always listen on it (default: " | ||||
"0.0.0.0). Use [host]:port notation for IPv6. Append =onion " | |||||
"to tag any incoming connections to that address and port as " | |||||
"incoming Tor connections (default: 127.0.0.1:%u=onion, " | |||||
"testnet: 127.0.0.1:%u=onion, regtest: 127.0.0.1:%u=onion)", | |||||
defaultBaseParams->OnionServiceTargetPort(), | |||||
testnetBaseParams->OnionServiceTargetPort(), | |||||
regtestBaseParams->OnionServiceTargetPort()), | |||||
ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, | ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, | ||||
OptionsCategory::CONNECTION); | OptionsCategory::CONNECTION); | ||||
argsman.AddArg( | argsman.AddArg( | ||||
"-connect=<ip>", | "-connect=<ip>", | ||||
"Connect only to the specified node(s); -connect=0 disables automatic " | "Connect only to the specified node(s); -connect=0 disables automatic " | ||||
"connections (the rules for this peer are the same as for -addnode)", | "connections (the rules for this peer are the same as for -addnode)", | ||||
ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, | ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, | ||||
OptionsCategory::CONNECTION); | OptionsCategory::CONNECTION); | ||||
argsman.AddArg( | argsman.AddArg( | ||||
"-discover", | "-discover", | ||||
▲ Show 20 Lines • Show All 2,313 Lines • ▼ Show 20 Lines | //// debug print | ||||
} | } | ||||
if (tip_info && ::pindexBestHeader) { | if (tip_info && ::pindexBestHeader) { | ||||
tip_info->header_height = ::pindexBestHeader->nHeight; | tip_info->header_height = ::pindexBestHeader->nHeight; | ||||
tip_info->header_time = ::pindexBestHeader->GetBlockTime(); | tip_info->header_time = ::pindexBestHeader->GetBlockTime(); | ||||
} | } | ||||
} | } | ||||
LogPrintf("nBestHeight = %d\n", chain_active_height); | LogPrintf("nBestHeight = %d\n", chain_active_height); | ||||
if (args.GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION)) { | |||||
StartTorControl(DefaultOnionServiceTarget()); | |||||
} | |||||
Discover(); | Discover(); | ||||
// Map ports with UPnP | // Map ports with UPnP | ||||
if (args.GetBoolArg("-upnp", DEFAULT_UPNP)) { | if (args.GetBoolArg("-upnp", DEFAULT_UPNP)) { | ||||
StartMapPort(); | StartMapPort(); | ||||
} | } | ||||
CConnman::Options connOptions; | CConnman::Options connOptions; | ||||
Show All 15 Lines | #endif | ||||
connOptions.nReceiveFloodSize = | connOptions.nReceiveFloodSize = | ||||
1000 * args.GetArg("-maxreceivebuffer", DEFAULT_MAXRECEIVEBUFFER); | 1000 * args.GetArg("-maxreceivebuffer", DEFAULT_MAXRECEIVEBUFFER); | ||||
connOptions.m_added_nodes = args.GetArgs("-addnode"); | connOptions.m_added_nodes = args.GetArgs("-addnode"); | ||||
connOptions.nMaxOutboundTimeframe = nMaxOutboundTimeframe; | connOptions.nMaxOutboundTimeframe = nMaxOutboundTimeframe; | ||||
connOptions.nMaxOutboundLimit = nMaxOutboundLimit; | connOptions.nMaxOutboundLimit = nMaxOutboundLimit; | ||||
connOptions.m_peer_connect_timeout = peer_connect_timeout; | connOptions.m_peer_connect_timeout = peer_connect_timeout; | ||||
for (const std::string &strBind : args.GetArgs("-bind")) { | for (const std::string &bind_arg : args.GetArgs("-bind")) { | ||||
CService addrBind; | CService bind_addr; | ||||
if (!Lookup(strBind, addrBind, GetListenPort(), false)) { | const size_t index = bind_arg.rfind('='); | ||||
return InitError(ResolveErrMsg("bind", strBind)); | if (index == std::string::npos) { | ||||
if (Lookup(bind_arg, bind_addr, GetListenPort(), false)) { | |||||
connOptions.vBinds.push_back(bind_addr); | |||||
continue; | |||||
} | |||||
} else { | |||||
const std::string network_type = bind_arg.substr(index + 1); | |||||
if (network_type == "onion") { | |||||
const std::string truncated_bind_arg = | |||||
bind_arg.substr(0, index); | |||||
if (Lookup(truncated_bind_arg, bind_addr, | |||||
BaseParams().OnionServiceTargetPort(), false)) { | |||||
connOptions.onion_binds.push_back(bind_addr); | |||||
continue; | |||||
} | |||||
} | |||||
} | |||||
return InitError(ResolveErrMsg("bind", bind_arg)); | |||||
} | |||||
if (connOptions.onion_binds.empty()) { | |||||
connOptions.onion_binds.push_back(DefaultOnionServiceTarget()); | |||||
} | |||||
if (args.GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION)) { | |||||
const auto bind_addr = connOptions.onion_binds.front(); | |||||
if (connOptions.onion_binds.size() > 1) { | |||||
InitWarning(strprintf( | |||||
_("More than one onion bind address is provided. Using %s for " | |||||
"the automatically created Tor onion service."), | |||||
bind_addr.ToStringIPPort())); | |||||
} | } | ||||
connOptions.vBinds.push_back(addrBind); | StartTorControl(bind_addr); | ||||
} | } | ||||
for (const std::string &strBind : args.GetArgs("-whitebind")) { | for (const std::string &strBind : args.GetArgs("-whitebind")) { | ||||
NetWhitebindPermissions whitebind; | NetWhitebindPermissions whitebind; | ||||
bilingual_str error; | bilingual_str error; | ||||
if (!NetWhitebindPermissions::TryParse(strBind, whitebind, error)) { | if (!NetWhitebindPermissions::TryParse(strBind, whitebind, error)) { | ||||
return InitError(error); | return InitError(error); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines |