|
|
@ -273,11 +273,11 @@ void HandleSIGHUP(int) |
|
|
|
fReopenDebugLog = true; |
|
|
|
fReopenDebugLog = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool static Bind(const CService &addr, unsigned int flags) { |
|
|
|
bool static Bind(CConnman& connman, const CService &addr, unsigned int flags) { |
|
|
|
if (!(flags & BF_EXPLICIT) && IsLimited(addr)) |
|
|
|
if (!(flags & BF_EXPLICIT) && IsLimited(addr)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
std::string strError; |
|
|
|
std::string strError; |
|
|
|
if (!BindListenPort(addr, strError, (flags & BF_WHITELIST) != 0)) { |
|
|
|
if (!connman.BindListenPort(addr, strError, (flags & BF_WHITELIST) != 0)) { |
|
|
|
if (flags & BF_REPORT_ERROR) |
|
|
|
if (flags & BF_REPORT_ERROR) |
|
|
|
return InitError(strError); |
|
|
|
return InitError(strError); |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -1198,7 +1198,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) |
|
|
|
CService addrBind; |
|
|
|
CService addrBind; |
|
|
|
if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false)) |
|
|
|
if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false)) |
|
|
|
return InitError(ResolveErrMsg("bind", strBind)); |
|
|
|
return InitError(ResolveErrMsg("bind", strBind)); |
|
|
|
fBound |= Bind(addrBind, (BF_EXPLICIT | BF_REPORT_ERROR)); |
|
|
|
fBound |= Bind(connman, addrBind, (BF_EXPLICIT | BF_REPORT_ERROR)); |
|
|
|
} |
|
|
|
} |
|
|
|
BOOST_FOREACH(const std::string& strBind, mapMultiArgs["-whitebind"]) { |
|
|
|
BOOST_FOREACH(const std::string& strBind, mapMultiArgs["-whitebind"]) { |
|
|
|
CService addrBind; |
|
|
|
CService addrBind; |
|
|
@ -1206,14 +1206,14 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) |
|
|
|
return InitError(ResolveErrMsg("whitebind", strBind)); |
|
|
|
return InitError(ResolveErrMsg("whitebind", strBind)); |
|
|
|
if (addrBind.GetPort() == 0) |
|
|
|
if (addrBind.GetPort() == 0) |
|
|
|
return InitError(strprintf(_("Need to specify a port with -whitebind: '%s'"), strBind)); |
|
|
|
return InitError(strprintf(_("Need to specify a port with -whitebind: '%s'"), strBind)); |
|
|
|
fBound |= Bind(addrBind, (BF_EXPLICIT | BF_REPORT_ERROR | BF_WHITELIST)); |
|
|
|
fBound |= Bind(connman, addrBind, (BF_EXPLICIT | BF_REPORT_ERROR | BF_WHITELIST)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
struct in_addr inaddr_any; |
|
|
|
struct in_addr inaddr_any; |
|
|
|
inaddr_any.s_addr = INADDR_ANY; |
|
|
|
inaddr_any.s_addr = INADDR_ANY; |
|
|
|
fBound |= Bind(CService(in6addr_any, GetListenPort()), BF_NONE); |
|
|
|
fBound |= Bind(connman, CService(in6addr_any, GetListenPort()), BF_NONE); |
|
|
|
fBound |= Bind(CService(inaddr_any, GetListenPort()), !fBound ? BF_REPORT_ERROR : BF_NONE); |
|
|
|
fBound |= Bind(connman, CService(inaddr_any, GetListenPort()), !fBound ? BF_REPORT_ERROR : BF_NONE); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!fBound) |
|
|
|
if (!fBound) |
|
|
|
return InitError(_("Failed to listen on any port. Use -listen=0 if you want this.")); |
|
|
|
return InitError(_("Failed to listen on any port. Use -listen=0 if you want this.")); |
|
|
|