Skip to content

Commit 09c1ae1

Browse files
committed
torcontrol improvements and fixes
- Force AUTHCOOKIE size to be 32 bytes: This provides protection against an attack where a process pretends to be Tor and uses the cookie authentication method to nab arbitrary files such as the wallet - torcontrol logging - fix cookie auth - add HASHEDPASSWORD auth, fix fd leak when fwrite() fails - better error reporting when cookie file is not ok - better init/shutdown flow - stop advertizing service when disconnected from tor control port - COOKIE->SAFECOOKIE auth
1 parent 2f796e5 commit 09c1ae1

File tree

5 files changed

+206
-84
lines changed

5 files changed

+206
-84
lines changed

src/init.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ void Interrupt(boost::thread_group& threadGroup)
160160
InterruptHTTPRPC();
161161
InterruptRPC();
162162
InterruptREST();
163+
InterruptTorControl();
163164
threadGroup.interrupt_all();
164165
}
165166

@@ -362,6 +363,7 @@ std::string HelpMessage(HelpMessageMode mode)
362363
strUsage += HelpMessageOpt("-seednode=<ip>", _("Connect to a node to retrieve peer addresses, and disconnect"));
363364
strUsage += HelpMessageOpt("-timeout=<n>", strprintf(_("Specify connection timeout in milliseconds (minimum: 1, default: %d)"), DEFAULT_CONNECT_TIMEOUT));
364365
strUsage += HelpMessageOpt("-torcontrol=<ip>:<port>", strprintf(_("Tor control port to use if onion listening enabled (default: %s)"), DEFAULT_TOR_CONTROL));
366+
strUsage += HelpMessageOpt("-torpassword=<pass>", _("Tor control port password (default: empty)"));
365367
#ifdef USE_UPNP
366368
#if USE_UPNP
367369
strUsage += HelpMessageOpt("-upnp", _("Use UPnP to map the listening port (default: 1 when listening and no -proxy)"));

src/net.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,14 @@ bool AddLocal(const CNetAddr &addr, int nScore)
263263
return AddLocal(CService(addr, GetListenPort()), nScore);
264264
}
265265

266+
bool RemoveLocal(const CService& addr)
267+
{
268+
LOCK(cs_mapLocalHost);
269+
LogPrintf("RemoveLocal(%s)\n", addr.ToString());
270+
mapLocalHost.erase(addr);
271+
return true;
272+
}
273+
266274
/** Make a particular network entirely off-limits (no automatic connects to it) */
267275
void SetLimited(enum Network net, bool fLimited)
268276
{

src/net.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ bool IsLimited(enum Network net);
128128
bool IsLimited(const CNetAddr& addr);
129129
bool AddLocal(const CService& addr, int nScore = LOCAL_NONE);
130130
bool AddLocal(const CNetAddr& addr, int nScore = LOCAL_NONE);
131+
bool RemoveLocal(const CService& addr);
131132
bool SeenLocal(const CService& addr);
132133
bool IsLocal(const CService& addr);
133134
bool GetLocal(CService &addr, const CNetAddr *paddrPeer = NULL);

0 commit comments

Comments
 (0)