Merge pull request #6462
7b79cbd
limit total length of user agent comments (Pavol Rusnak)557f8ea
implement uacomment config parameter which can add comments to user agent as per BIP-0014 (Pavol Rusnak)
This commit is contained in:
commit
c384800027
5 changed files with 16 additions and 4 deletions
|
@ -1020,6 +1020,13 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
|
|
||||||
RegisterNodeSignals(GetNodeSignals());
|
RegisterNodeSignals(GetNodeSignals());
|
||||||
|
|
||||||
|
// format user agent, check total size
|
||||||
|
strSubVersion = FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, mapMultiArgs.count("-uacomment") ? mapMultiArgs["-uacomment"] : std::vector<string>());
|
||||||
|
if (strSubVersion.size() > MAX_SUBVERSION_LENGTH) {
|
||||||
|
return InitError(strprintf("Total length of network version string %i exceeds maximum of %i characters. Reduce the number and/or size of uacomments.",
|
||||||
|
strSubVersion.size(), MAX_SUBVERSION_LENGTH));
|
||||||
|
}
|
||||||
|
|
||||||
if (mapArgs.count("-onlynet")) {
|
if (mapArgs.count("-onlynet")) {
|
||||||
std::set<enum Network> nets;
|
std::set<enum Network> nets;
|
||||||
BOOST_FOREACH(const std::string& snet, mapMultiArgs["-onlynet"]) {
|
BOOST_FOREACH(const std::string& snet, mapMultiArgs["-onlynet"]) {
|
||||||
|
|
|
@ -3898,7 +3898,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||||
if (!vRecv.empty())
|
if (!vRecv.empty())
|
||||||
vRecv >> addrFrom >> nNonce;
|
vRecv >> addrFrom >> nNonce;
|
||||||
if (!vRecv.empty()) {
|
if (!vRecv.empty()) {
|
||||||
vRecv >> LIMITED_STRING(pfrom->strSubVer, 256);
|
vRecv >> LIMITED_STRING(pfrom->strSubVer, MAX_SUBVERSION_LENGTH);
|
||||||
pfrom->cleanSubVer = SanitizeString(pfrom->strSubVer);
|
pfrom->cleanSubVer = SanitizeString(pfrom->strSubVer);
|
||||||
}
|
}
|
||||||
if (!vRecv.empty())
|
if (!vRecv.empty())
|
||||||
|
|
|
@ -83,6 +83,7 @@ CAddrMan addrman;
|
||||||
int nMaxConnections = DEFAULT_MAX_PEER_CONNECTIONS;
|
int nMaxConnections = DEFAULT_MAX_PEER_CONNECTIONS;
|
||||||
int nWhiteConnections = 0;
|
int nWhiteConnections = 0;
|
||||||
bool fAddressesInitialized = false;
|
bool fAddressesInitialized = false;
|
||||||
|
std::string strSubVersion;
|
||||||
|
|
||||||
vector<CNode*> vNodes;
|
vector<CNode*> vNodes;
|
||||||
CCriticalSection cs_vNodes;
|
CCriticalSection cs_vNodes;
|
||||||
|
@ -445,7 +446,7 @@ void CNode::PushVersion()
|
||||||
else
|
else
|
||||||
LogPrint("net", "send version message: version %d, blocks=%d, us=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString(), id);
|
LogPrint("net", "send version message: version %d, blocks=%d, us=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString(), id);
|
||||||
PushMessage("version", PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe,
|
PushMessage("version", PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe,
|
||||||
nLocalHostNonce, FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector<string>()), nBestHeight, true);
|
nLocalHostNonce, strSubVersion, nBestHeight, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,8 @@ static const unsigned int MAX_INV_SZ = 50000;
|
||||||
static const unsigned int MAX_ADDR_TO_SEND = 1000;
|
static const unsigned int MAX_ADDR_TO_SEND = 1000;
|
||||||
/** Maximum length of incoming protocol messages (no message over 2 MiB is currently acceptable). */
|
/** Maximum length of incoming protocol messages (no message over 2 MiB is currently acceptable). */
|
||||||
static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 2 * 1024 * 1024;
|
static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 2 * 1024 * 1024;
|
||||||
|
/** Maximum length of strSubVer in `version` message */
|
||||||
|
static const unsigned int MAX_SUBVERSION_LENGTH = 256;
|
||||||
/** -listen default */
|
/** -listen default */
|
||||||
static const bool DEFAULT_LISTEN = true;
|
static const bool DEFAULT_LISTEN = true;
|
||||||
/** -upnp default */
|
/** -upnp default */
|
||||||
|
@ -168,6 +170,9 @@ extern CCriticalSection cs_vAddedNodes;
|
||||||
extern NodeId nLastNodeId;
|
extern NodeId nLastNodeId;
|
||||||
extern CCriticalSection cs_nLastNodeId;
|
extern CCriticalSection cs_nLastNodeId;
|
||||||
|
|
||||||
|
/** Subversion as sent to the P2P network in `version` messages */
|
||||||
|
extern std::string strSubVersion;
|
||||||
|
|
||||||
struct LocalServiceInfo {
|
struct LocalServiceInfo {
|
||||||
int nScore;
|
int nScore;
|
||||||
int nPort;
|
int nPort;
|
||||||
|
|
|
@ -443,8 +443,7 @@ UniValue getnetworkinfo(const UniValue& params, bool fHelp)
|
||||||
|
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue obj(UniValue::VOBJ);
|
||||||
obj.push_back(Pair("version", CLIENT_VERSION));
|
obj.push_back(Pair("version", CLIENT_VERSION));
|
||||||
obj.push_back(Pair("subversion",
|
obj.push_back(Pair("subversion", strSubVersion));
|
||||||
FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector<string>())));
|
|
||||||
obj.push_back(Pair("protocolversion",PROTOCOL_VERSION));
|
obj.push_back(Pair("protocolversion",PROTOCOL_VERSION));
|
||||||
obj.push_back(Pair("localservices", strprintf("%016x", nLocalServices)));
|
obj.push_back(Pair("localservices", strprintf("%016x", nLocalServices)));
|
||||||
obj.push_back(Pair("timeoffset", GetTimeOffset()));
|
obj.push_back(Pair("timeoffset", GetTimeOffset()));
|
||||||
|
|
Loading…
Reference in a new issue