Browse Source

add -nolisten command line option

miguelfreitas
Witchspace 14 years ago
parent
commit
5f88e8887a
  1. 8
      init.cpp
  2. 6
      net.cpp
  3. 2
      util.cpp
  4. 1
      util.h

8
init.cpp

@ -181,7 +181,8 @@ bool AppInit2(int argc, char* argv[])
" -rpcpassword=<pw>\t " + _("Password for JSON-RPC connections\n") + " -rpcpassword=<pw>\t " + _("Password for JSON-RPC connections\n") +
" -rpcport=<port> \t\t " + _("Listen for JSON-RPC connections on <port>\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") + " -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 #ifdef USE_SSL
strUsage += string() + strUsage += string() +
@ -212,6 +213,8 @@ bool AppInit2(int argc, char* argv[])
fTestNet = GetBoolArg("-testnet"); fTestNet = GetBoolArg("-testnet");
fNoListen = GetBoolArg("-nolisten");
if (fCommandLine) if (fCommandLine)
{ {
int ret = CommandLineRPC(argc, argv); int ret = CommandLineRPC(argc, argv);
@ -290,11 +293,14 @@ bool AppInit2(int argc, char* argv[])
// Bind to the port early so we can tell if another instance is already running. // Bind to the port early so we can tell if another instance is already running.
string strErrors; string strErrors;
if (!fNoListen)
{
if (!BindListenPort(strErrors)) if (!BindListenPort(strErrors))
{ {
wxMessageBox(strErrors, "Bitcoin"); wxMessageBox(strErrors, "Bitcoin");
return false; return false;
} }
}
// //
// Load data files // Load data files

6
net.cpp

@ -643,6 +643,8 @@ void ThreadSocketHandler2(void* parg)
FD_ZERO(&fdsetSend); FD_ZERO(&fdsetSend);
FD_ZERO(&fdsetError); FD_ZERO(&fdsetError);
SOCKET hSocketMax = 0; SOCKET hSocketMax = 0;
if(hListenSocket != INVALID_SOCKET)
FD_SET(hListenSocket, &fdsetRecv); FD_SET(hListenSocket, &fdsetRecv);
hSocketMax = max(hSocketMax, hListenSocket); hSocketMax = max(hSocketMax, hListenSocket);
CRITICAL_BLOCK(cs_vNodes) CRITICAL_BLOCK(cs_vNodes)
@ -680,7 +682,7 @@ void ThreadSocketHandler2(void* parg)
// //
// Accept new connections // Accept new connections
// //
if (FD_ISSET(hListenSocket, &fdsetRecv)) if (hListenSocket != INVALID_SOCKET && FD_ISSET(hListenSocket, &fdsetRecv))
{ {
struct sockaddr_in sockaddr; struct sockaddr_in sockaddr;
socklen_t len = sizeof(sockaddr); socklen_t len = sizeof(sockaddr);
@ -1344,7 +1346,7 @@ void StartNode(void* parg)
#endif #endif
printf("addrLocalHost = %s\n", addrLocalHost.ToString().c_str()); 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 // Proxies can't take incoming connections
addrLocalHost.ip = CAddress("0.0.0.0").ip; addrLocalHost.ip = CAddress("0.0.0.0").ip;

2
util.cpp

@ -17,7 +17,7 @@ bool fDaemon = false;
bool fCommandLine = false; bool fCommandLine = false;
string strMiscWarning; string strMiscWarning;
bool fTestNet = false; bool fTestNet = false;
bool fNoListen = false;

1
util.h

@ -146,6 +146,7 @@ extern bool fDaemon;
extern bool fCommandLine; extern bool fCommandLine;
extern string strMiscWarning; extern string strMiscWarning;
extern bool fTestNet; extern bool fTestNet;
extern bool fNoListen;
void RandAddSeed(); void RandAddSeed();
void RandAddSeedPerfmon(); void RandAddSeedPerfmon();

Loading…
Cancel
Save