Fix CMasternodeConfig::read (#1322)

CService fails to initialize correctly on Windows for whatever reason,
replacing this functionality with SplitHostPort call.
This commit is contained in:
UdjinM6 2017-02-06 01:29:23 +04:00 committed by GitHub
parent 8de792291a
commit 56971f8da1

View File

@ -1,8 +1,7 @@
#include "net.h" #include "netbase.h"
#include "masternodeconfig.h" #include "masternodeconfig.h"
#include "util.h" #include "util.h"
#include "ui_interface.h"
#include "chainparams.h" #include "chainparams.h"
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
@ -56,16 +55,26 @@ bool CMasternodeConfig::read(std::string& strErr) {
} }
} }
int port = 0;
std::string hostname = "";
SplitHostPort(ip, port, hostname);
if(port == 0 || hostname == "") {
strErr = _("Failed to parse host:port string") + "\n"+
strprintf(_("Line: %d"), linenumber) + "\n\"" + line + "\"";
streamConfig.close();
return false;
}
int mainnetDefaultPort = Params(CBaseChainParams::MAIN).GetDefaultPort(); int mainnetDefaultPort = Params(CBaseChainParams::MAIN).GetDefaultPort();
if(Params().NetworkIDString() == CBaseChainParams::MAIN) { if(Params().NetworkIDString() == CBaseChainParams::MAIN) {
if(CService(ip).GetPort() != mainnetDefaultPort) { if(port != mainnetDefaultPort) {
strErr = _("Invalid port detected in masternode.conf") + "\n" + strErr = _("Invalid port detected in masternode.conf") + "\n" +
strprintf(_("Port: %d"), port) + "\n" +
strprintf(_("Line: %d"), linenumber) + "\n\"" + line + "\"" + "\n" + strprintf(_("Line: %d"), linenumber) + "\n\"" + line + "\"" + "\n" +
strprintf(_("(must be %d for mainnet)"), mainnetDefaultPort); strprintf(_("(must be %d for mainnet)"), mainnetDefaultPort);
streamConfig.close(); streamConfig.close();
return false; return false;
} }
} else if(CService(ip).GetPort() == mainnetDefaultPort) { } else if(port == mainnetDefaultPort) {
strErr = _("Invalid port detected in masternode.conf") + "\n" + strErr = _("Invalid port detected in masternode.conf") + "\n" +
strprintf(_("Line: %d"), linenumber) + "\n\"" + line + "\"" + "\n" + strprintf(_("Line: %d"), linenumber) + "\n\"" + line + "\"" + "\n" +
strprintf(_("(%d could be used only on mainnet)"), mainnetDefaultPort); strprintf(_("(%d could be used only on mainnet)"), mainnetDefaultPort);