Skip to content

Commit

Permalink
Fix CMasternodeConfig::read (#1322)
Browse files Browse the repository at this point in the history
CService fails to initialize correctly on Windows for whatever reason,
replacing this functionality with SplitHostPort call.
  • Loading branch information
UdjinM6 authored Feb 5, 2017
1 parent 8de7922 commit 56971f8
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/masternodeconfig.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

#include "net.h"
#include "netbase.h"
#include "masternodeconfig.h"
#include "util.h"
#include "ui_interface.h"
#include "chainparams.h"

#include <boost/filesystem.hpp>
Expand Down Expand Up @@ -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();
if(Params().NetworkIDString() == CBaseChainParams::MAIN) {
if(CService(ip).GetPort() != mainnetDefaultPort) {
if(port != mainnetDefaultPort) {
strErr = _("Invalid port detected in masternode.conf") + "\n" +
strprintf(_("Port: %d"), port) + "\n" +
strprintf(_("Line: %d"), linenumber) + "\n\"" + line + "\"" + "\n" +
strprintf(_("(must be %d for mainnet)"), mainnetDefaultPort);
streamConfig.close();
return false;
}
} else if(CService(ip).GetPort() == mainnetDefaultPort) {
} else if(port == mainnetDefaultPort) {
strErr = _("Invalid port detected in masternode.conf") + "\n" +
strprintf(_("Line: %d"), linenumber) + "\n\"" + line + "\"" + "\n" +
strprintf(_("(%d could be used only on mainnet)"), mainnetDefaultPort);
Expand Down

0 comments on commit 56971f8

Please sign in to comment.