From 623b987813acfc985ecca591e96ac0b84f5333e3 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Fri, 4 May 2012 16:55:19 +0200 Subject: Add -noproxy to circumvent proxy for some network --- src/init.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/init.cpp') diff --git a/src/init.cpp b/src/init.cpp index 60927f20b..03b47b3ef 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -180,6 +180,7 @@ bool AppInit2(int argc, char* argv[]) " -timeout= \t " + _("Specify connection timeout (in milliseconds)") + "\n" + " -proxy= \t " + _("Connect through socks proxy") + "\n" + " -socks= \t " + _("Select the version of socks proxy to use (4 or 5, 5 is default)") + "\n" + + " -noproxy= \t " + _("Do not use proxy for connections to network net (ipv4 or ipv6)") + "\n" + " -dns \t " + _("Allow DNS lookups for -addnode, -seednode and -connect") + "\n" + " -proxydns \t " + _("Pass DNS requests to (SOCKS5) proxy") + "\n" + " -port= \t\t " + _("Listen for connections on (default: 8333 or testnet: 18333)") + "\n" + @@ -532,6 +533,18 @@ bool AppInit2(int argc, char* argv[]) } } + if (mapArgs.count("-noproxy")) + { + BOOST_FOREACH(std::string snet, mapMultiArgs["-noproxy"]) { + enum Network net = ParseNetwork(snet); + if (net == NET_UNROUTABLE) { + ThreadSafeMessageBox(_("Unknown network specified in -noproxy"), _("Bitcoin"), wxOK | wxMODAL); + return false; + } + SetNoProxy(net); + } + } + if (mapArgs.count("-connect")) SoftSetBoolArg("-dnsseed", false); -- cgit v1.2.3 From 457754d2c24f7e53c55f4b68155a5fa702552327 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Fri, 4 May 2012 16:46:22 +0200 Subject: Add -blocknet to prevent connections to a given network --- src/init.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/init.cpp') diff --git a/src/init.cpp b/src/init.cpp index 03b47b3ef..202d51367 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -189,6 +189,7 @@ bool AppInit2(int argc, char* argv[]) " -connect= \t\t " + _("Connect only to the specified node") + "\n" + " -seednode= \t\t " + _("Connect to a node to retrieve peer addresses, and disconnect") + "\n" + " -externalip= \t " + _("Specify your own public address") + "\n" + + " -blocknet= \t " + _("Do not connect to addresses in network net (ipv4, ipv6)") + "\n" + " -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" + @@ -560,6 +561,17 @@ bool AppInit2(int argc, char* argv[]) SoftSetBoolArg("-discover", false); } + if (mapArgs.count("-blocknet")) { + BOOST_FOREACH(std::string snet, mapMultiArgs["-blocknet"]) { + enum Network net = ParseNetwork(snet); + if (net == NET_UNROUTABLE) { + ThreadSafeMessageBox(_("Unknown network specified in -blocknet"), _("Bitcoin"), wxOK | wxMODAL); + return false; + } + SetLimited(net); + } + } + fNameLookup = GetBoolArg("-dns"); fProxyNameLookup = GetBoolArg("-proxydns"); if (fProxyNameLookup) -- cgit v1.2.3 From 8f10a2889089af1b2ac64802360494b54c8c7ff1 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Fri, 11 May 2012 15:28:59 +0200 Subject: Separate listening sockets, -bind= --- src/init.cpp | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'src/init.cpp') diff --git a/src/init.cpp b/src/init.cpp index 202d51367..877b1d471 100644 --- a/src/init.cpp +++ b/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= \t " + _("Bind to given address. Use [host]:port notation for IPv6") + "\n" + #ifdef QT_GUI " -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(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")) -- cgit v1.2.3