From 56971f8da1e038041cb02959b8d7307bcbbaffee Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Mon, 6 Feb 2017 01:29:23 +0400 Subject: [PATCH] Fix CMasternodeConfig::read (#1322) CService fails to initialize correctly on Windows for whatever reason, replacing this functionality with SplitHostPort call. --- src/masternodeconfig.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/masternodeconfig.cpp b/src/masternodeconfig.cpp index 3f85a5b5d5..5813109ff4 100644 --- a/src/masternodeconfig.cpp +++ b/src/masternodeconfig.cpp @@ -1,8 +1,7 @@ -#include "net.h" +#include "netbase.h" #include "masternodeconfig.h" #include "util.h" -#include "ui_interface.h" #include "chainparams.h" #include @@ -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);