Skip to content

Commit

Permalink
tor: make a TORv3 hidden service instead of TORv2
Browse files Browse the repository at this point in the history
TORv2 is deprecated [1], thus whenever we create the hidden service
ourselves create a TORv3 one instead.

[1] https://blog.torproject.org/v2-deprecation-timeline
  • Loading branch information
vasild authored and furszy committed Aug 10, 2021
1 parent 6da9a14 commit ccd508a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
13 changes: 13 additions & 0 deletions doc/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,19 @@ It enforces the same rules as the legacy cold-staking opcode, but without allowi
The new opcode takes the name of `OP_CHECKCOLDSTAKEVERIFY`, and the legacy opcode (`0xd1`) is renamed to `OP_CHECKCOLDSTAKEVERIFY_LOF` (last-output-free).
Scripts with the old opcode are still accepted on the network (the restriction on the last-output is enforced after the script validation in this case), but the client creates new delegations with the new opcode, by default, after the upgrade enforcement.

P2P and network changes
-----------------------

- The Tor onion service that is automatically created by setting the
`-listenonion` configuration parameter will now be created as a Tor v3 service
instead of Tor v2. The private key that was used for Tor v2 (if any) will be
left untouched in the `onion_private_key` file in the data directory (see
`-datadir`) and can be removed if not needed. PIVX Core will no longer
attempt to read it. The private key for the Tor v3 service will be saved in a
file named `onion_v3_private_key`. To use the deprecated Tor v2 service (not
recommended), then `onion_private_key` can be copied over
`onion_v3_private_key`, e.g.
`cp -f onion_private_key onion_v3_private_key`. (#19954)

Multi-wallet support
--------------------
Expand Down
9 changes: 5 additions & 4 deletions src/torcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,10 @@ void TorController::auth_cb(TorControlConnection& _conn, const TorControlReply&
}

// Finally - now create the service
if (private_key.empty()) // No private key, generate one
private_key = "NEW:RSA1024"; // Explicitly request RSA1024 - see issue #9214
// Request hidden service, redirect port.
if (private_key.empty()) { // No private key, generate one
private_key = "NEW:ED25519-V3"; // Explicitly request key type - see issue #9214
}
// Request onion service, redirect port.
// Note that the 'virtual' port is always the default port to avoid decloaking nodes using other ports.
_conn.Command(strprintf("ADD_ONION %s Port=%i,127.0.0.1:%i", private_key, Params().GetDefaultPort(), GetListenPort()),
std::bind(&TorController::add_onion_cb, this, std::placeholders::_1, std::placeholders::_2));
Expand Down Expand Up @@ -721,7 +722,7 @@ void TorController::Reconnect()

fs::path TorController::GetPrivateKeyFile()
{
return GetDataDir() / "onion_private_key";
return GetDataDir() / "onion_v3_private_key";
}

void TorController::reconnect_cb(evutil_socket_t fd, short what, void *arg)
Expand Down

0 comments on commit ccd508a

Please sign in to comment.