mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
Separate listening sockets, -bind=<addr>
This commit is contained in:
36
src/init.cpp
36
src/init.cpp
@@ -119,6 +119,18 @@ bool AppInit(int argc, char* argv[])
|
||||
return fRet;
|
||||
}
|
||||
|
||||
bool static Bind(const CService &addr) {
|
||||
if (IsLimited(addr))
|
||||
return false;
|
||||
std::string strError;
|
||||
if (!BindListenPort(addr, strError))
|
||||
{
|
||||
ThreadSafeMessageBox(strError, _("Bitcoin"), wxOK | wxMODAL);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AppInit2(int argc, char* argv[])
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
@@ -193,6 +205,7 @@ bool AppInit2(int argc, char* argv[])
|
||||
" -discover \t " + _("Try to discover public IP address (default: 1)") + "\n" +
|
||||
" -irc \t " + _("Find peers using internet relay chat (default: 0)") + "\n" +
|
||||
" -listen \t " + _("Accept connections from outside (default: 1)") + "\n" +
|
||||
" -bind=<addr> \t " + _("Bind to given address. Use [host]:port notation for IPv6") + "\n" +
|
||||
#ifdef QT_GUI
|
||||
" -lang=<lang> \t\t " + _("Set language, for example \"de_DE\" (default: system locale)") + "\n" +
|
||||
#endif
|
||||
@@ -548,7 +561,11 @@ bool AppInit2(int argc, char* argv[])
|
||||
|
||||
if (mapArgs.count("-connect"))
|
||||
SoftSetBoolArg("-dnsseed", false);
|
||||
|
||||
|
||||
// even in Tor mode, if -bind is specified, you really want -listen
|
||||
if (mapArgs.count("-bind"))
|
||||
SoftSetBoolArg("-listen", true);
|
||||
|
||||
bool fTor = (fUseProxy && addrProxy.GetPort() == 9050);
|
||||
if (fTor)
|
||||
{
|
||||
@@ -588,14 +605,23 @@ bool AppInit2(int argc, char* argv[])
|
||||
const char* pszP2SH = "/P2SH/";
|
||||
COINBASE_FLAGS << std::vector<unsigned char>(pszP2SH, pszP2SH+strlen(pszP2SH));
|
||||
|
||||
bool fBound = false;
|
||||
if (!fNoListen)
|
||||
{
|
||||
std::string strError;
|
||||
if (!BindListenPort(strError))
|
||||
{
|
||||
ThreadSafeMessageBox(strError, _("Bitcoin"), wxOK | wxMODAL);
|
||||
return false;
|
||||
if (mapArgs.count("-bind")) {
|
||||
BOOST_FOREACH(std::string strBind, mapMultiArgs["-bind"]) {
|
||||
fBound |= Bind(CService(strBind, GetDefaultPort(), false));
|
||||
}
|
||||
} else {
|
||||
struct in_addr inaddr_any = {s_addr: INADDR_ANY};
|
||||
fBound |= Bind(CService(inaddr_any, GetDefaultPort()));
|
||||
#ifdef USE_IPV6
|
||||
fBound |= Bind(CService(in6addr_any, GetDefaultPort()));
|
||||
#endif
|
||||
}
|
||||
if (!fBound)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mapArgs.count("-externalip"))
|
||||
|
||||
Reference in New Issue
Block a user