aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-05-14 17:15:58 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2012-05-14 17:52:45 +0200
commit0f1707de678a23b8600510be366289071203fc6e (patch)
tree86ad8eddb178c01da5d65983030ccceab30220d6 /src
parent0071a540d40f8e7cf75eb555f007ab61473a3a81 (diff)
-onlynet instead of -blocknet
Diffstat (limited to 'src')
-rw-r--r--src/init.cpp16
-rw-r--r--src/net.cpp11
-rw-r--r--src/net.h1
3 files changed, 21 insertions, 7 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 0d3679657b..f1599ed3a5 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -204,7 +204,7 @@ std::string HelpMessage()
" -connect=<ip> " + _("Connect only to the specified node") + "\n" +
" -seednode=<ip> " + _("Connect to a node to retrieve peer addresses, and disconnect") + "\n" +
" -externalip=<ip> " + _("Specify your own public address") + "\n" +
- " -blocknet=<net> " + _("Do not connect to addresses in network <net> (IPv4 or IPv6)") + "\n" +
+ " -onlynet=<net> " + _("Only connect to nodes in network <net> (IPv4 or IPv6)") + "\n" +
" -discover " + _("Try to discover public IP address (default: 1)") + "\n" +
" -irc " + _("Find peers using internet relay chat (default: 0)") + "\n" +
" -listen " + _("Accept connections from outside (default: 1)") + "\n" +
@@ -572,12 +572,18 @@ bool AppInit2()
SoftSetBoolArg("-discover", false);
}
- if (mapArgs.count("-blocknet")) {
- BOOST_FOREACH(std::string snet, mapMultiArgs["-blocknet"]) {
+ if (mapArgs.count("-onlynet")) {
+ std::set<enum Network> nets;
+ BOOST_FOREACH(std::string snet, mapMultiArgs["-onlynet"]) {
enum Network net = ParseNetwork(snet);
if (net == NET_UNROUTABLE)
- return InitError(strprintf(_("Unknown network specified in -blocknet: '%s'"), snet.c_str()));
- SetLimited(net);
+ return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet.c_str()));
+ nets.insert(net);
+ }
+ for (int n = 0; n < NET_MAX; n++) {
+ enum Network net = (enum Network)n;
+ if (!nets.count(net))
+ SetLimited(net);
}
}
diff --git a/src/net.cpp b/src/net.cpp
index 88578cdcb3..e48b300953 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -245,14 +245,21 @@ bool AddLocal(const CNetAddr &addr, int nScore)
/** Make a particular network entirely off-limits (no automatic connects to it) */
void SetLimited(enum Network net, bool fLimited)
{
+ if (net == NET_UNROUTABLE)
+ return;
LOCK(cs_mapLocalHost);
vfLimited[net] = fLimited;
}
-bool IsLimited(const CNetAddr& addr)
+bool IsLimited(enum Network net)
{
LOCK(cs_mapLocalHost);
- return vfLimited[addr.GetNetwork()];
+ return vfLimited[net];
+}
+
+bool IsLimited(const CNetAddr &addr)
+{
+ return IsLimited(addr.GetNetwork());
}
/** vote for a local address */
diff --git a/src/net.h b/src/net.h
index 3755c765d3..cb90ef6e72 100644
--- a/src/net.h
+++ b/src/net.h
@@ -57,6 +57,7 @@ enum
};
void SetLimited(enum Network net, bool fLimited = true);
+bool IsLimited(enum Network net);
bool IsLimited(const CNetAddr& addr);
bool AddLocal(const CService& addr, int nScore = LOCAL_NONE);
bool AddLocal(const CNetAddr& addr, int nScore = LOCAL_NONE);