aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWitchspace <witchspace81@gmail.com>2010-12-22 14:08:00 +0100
committerWitchspace <witchspace81@gmail.com>2010-12-22 14:08:00 +0100
commit5f88e8887a31db68493334fc8e5652c5dd9cbf89 (patch)
treecc723c7d3424b54e06a7f50d96cd7af417e97d65
parent2d96276e243c93add0b0d292ae9f05a54508b6e7 (diff)
downloadbitcoin-5f88e8887a31db68493334fc8e5652c5dd9cbf89.tar.xz
add -nolisten command line option
-rw-r--r--init.cpp14
-rw-r--r--net.cpp8
-rw-r--r--util.cpp2
-rw-r--r--util.h1
4 files changed, 17 insertions, 8 deletions
diff --git a/init.cpp b/init.cpp
index 61ca4d2bd5..cfb5d8e330 100644
--- a/init.cpp
+++ b/init.cpp
@@ -181,7 +181,8 @@ bool AppInit2(int argc, char* argv[])
" -rpcpassword=<pw>\t " + _("Password for JSON-RPC connections\n") +
" -rpcport=<port> \t\t " + _("Listen for JSON-RPC connections on <port>\n") +
" -rpcallowip=<ip> \t\t " + _("Allow JSON-RPC connections from specified IP address\n") +
- " -rpcconnect=<ip> \t " + _("Send commands to node running on <ip>\n");
+ " -rpcconnect=<ip> \t " + _("Send commands to node running on <ip>\n") +
+ " -nolisten \t " + _("Don't accept connections from outside");
#ifdef USE_SSL
strUsage += string() +
@@ -211,6 +212,8 @@ bool AppInit2(int argc, char* argv[])
fPrintToDebugger = GetBoolArg("-printtodebugger");
fTestNet = GetBoolArg("-testnet");
+
+ fNoListen = GetBoolArg("-nolisten");
if (fCommandLine)
{
@@ -290,10 +293,13 @@ bool AppInit2(int argc, char* argv[])
// Bind to the port early so we can tell if another instance is already running.
string strErrors;
- if (!BindListenPort(strErrors))
+ if (!fNoListen)
{
- wxMessageBox(strErrors, "Bitcoin");
- return false;
+ if (!BindListenPort(strErrors))
+ {
+ wxMessageBox(strErrors, "Bitcoin");
+ return false;
+ }
}
//
diff --git a/net.cpp b/net.cpp
index da7661962e..a626acd376 100644
--- a/net.cpp
+++ b/net.cpp
@@ -643,7 +643,9 @@ void ThreadSocketHandler2(void* parg)
FD_ZERO(&fdsetSend);
FD_ZERO(&fdsetError);
SOCKET hSocketMax = 0;
- FD_SET(hListenSocket, &fdsetRecv);
+
+ if(hListenSocket != INVALID_SOCKET)
+ FD_SET(hListenSocket, &fdsetRecv);
hSocketMax = max(hSocketMax, hListenSocket);
CRITICAL_BLOCK(cs_vNodes)
{
@@ -680,7 +682,7 @@ void ThreadSocketHandler2(void* parg)
//
// Accept new connections
//
- if (FD_ISSET(hListenSocket, &fdsetRecv))
+ if (hListenSocket != INVALID_SOCKET && FD_ISSET(hListenSocket, &fdsetRecv))
{
struct sockaddr_in sockaddr;
socklen_t len = sizeof(sockaddr);
@@ -1344,7 +1346,7 @@ void StartNode(void* parg)
#endif
printf("addrLocalHost = %s\n", addrLocalHost.ToString().c_str());
- if (fUseProxy || mapArgs.count("-connect"))
+ if (fUseProxy || mapArgs.count("-connect") || fNoListen)
{
// Proxies can't take incoming connections
addrLocalHost.ip = CAddress("0.0.0.0").ip;
diff --git a/util.cpp b/util.cpp
index 42256a9d0c..694f913045 100644
--- a/util.cpp
+++ b/util.cpp
@@ -17,7 +17,7 @@ bool fDaemon = false;
bool fCommandLine = false;
string strMiscWarning;
bool fTestNet = false;
-
+bool fNoListen = false;
diff --git a/util.h b/util.h
index f57e401067..c69bf1ce17 100644
--- a/util.h
+++ b/util.h
@@ -146,6 +146,7 @@ extern bool fDaemon;
extern bool fCommandLine;
extern string strMiscWarning;
extern bool fTestNet;
+extern bool fNoListen;
void RandAddSeed();
void RandAddSeedPerfmon();