Skip to content

Commit

Permalink
Back-merge develop into master (Release v5.0.0-beta) (#883)
Browse files Browse the repository at this point in the history
* Remove segwits segments from block template 馃コ

* Disabling Segwit components (no pre-segwit)

* Remove segwit switch from code 馃

* Reenable version bit calculations

* Enabling Chainparams genesis block and merkle root checks

* Update randomized authentication for proxy connections

* Adds copyrights to torcontroller
Resolves #867

* Tor Hidden Services v3 (#872)

* Initi v3 tor hidden services

* Support hidden services (V3) for new nodes

* Remove my laziness

* Remove more logs

* Add i2p support (#873)

* add i2p support

if using i2p wrapped daemon.

it would be nice to eventually add i2pd as an option as well.

* fix shmypo

* Update zeromq to 4.3.1 (#874) (#875)

This is related to the BTC issue
bitcoin/bitcoin#15188
and CVE https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-6250

* Improve header parsing and correction for block parsing with older nodes #865 (#870)

* Update randomized authentication for proxy connections

* Adds copyrights to torcontroller
Resolves #867

* Tor Hidden Services v3 (#872)

* Initi v3 tor hidden services

* Support hidden services (V3) for new nodes

* Remove my laziness

* Remove more logs

* Add i2p support (#873)

* add i2p support

if using i2p wrapped daemon.

it would be nice to eventually add i2pd as an option as well.

* fix init/for bench

* add chain to interfaces

* add optional header

* close def

* add walletinit to makefile

* add chain header to init

* add int chain

* update rpc util

* move rawtx to node/tx

* remove header dup

* add zmq headers

* remove zmqrpc hdr

* remove unused boost deps

* add zmqrpc

* add zmq rpc to makefile

* zmqheader

* add zmqrpc to automake

* update walletiinitinterface header

* updates to node txs

* Update init.cpp

* updates

* Update strencodings.h

* add assumptions to compat

* update banman

* update addrdb

* update addrman

* update getcheaphash

* add chain interface

* update net_processing header

* updates to node interface

* updates to zmq notification interface

* update zmq abstract notifier

* update net header

* move handlers to header

* update cclientUIinterface

* clean up, remove regtest

* update logging

* update logger on http server

* isbindany

* vaddednodes

* remove dupe

* close())

* SetLimited -> SetReachable

* add argument

* add arg

* add arg

* update to net

* fixes

* update w header parsing

* update validation header

ugh

* fixes

* fix torcontrol

* loginstance

* +}-(

hue

* pita

* remove arg

* update rest api

* update blockchain rpc header

* cblockindex updates

* more cblockindex

* Fix testnet chain parameters

* Refactor POW a bit for more readability

* Include Blocksignatures as part of our generated blocks
(also being transferred)

* Fix pub-/privkey prefixes for testnet

* [WIP] Bugfix block submission (#877)

* Remove segwits segments from block template 馃コ

* Disabling Segwit components (no pre-segwit)

* Remove segwit switch from code 馃

* Reenable version bit calculations

* Enabling Chainparams genesis block and merkle root checks

* Improve header parsing and correction for block parsing with older nodes #865 (#870)

* Update randomized authentication for proxy connections

* Adds copyrights to torcontroller
Resolves #867

* Tor Hidden Services v3 (#872)

* Initi v3 tor hidden services

* Support hidden services (V3) for new nodes

* Remove my laziness

* Remove more logs

* Add i2p support (#873)

* add i2p support

if using i2p wrapped daemon.

it would be nice to eventually add i2pd as an option as well.

* Fix testnet chain parameters

* Refactor POW a bit for more readability

* Include Blocksignatures as part of our generated blocks
(also being transferred)

* Fix pub-/privkey prefixes for testnet

* Develop (#878)

* Update randomized authentication for proxy connections

* Adds copyrights to torcontroller
Resolves #867

* Tor Hidden Services v3 (#872)

* Initi v3 tor hidden services

* Support hidden services (V3) for new nodes

* Remove my laziness

* Remove more logs

* Add i2p support (#873)

* add i2p support

if using i2p wrapped daemon.

it would be nice to eventually add i2pd as an option as well.

* fix shmypo

* Update zeromq to 4.3.1 (#874) (#875)

This is related to the BTC issue
bitcoin/bitcoin#15188
and CVE https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-6250

* [WIP] Bugfix block submission (#877)

* Remove segwits segments from block template 馃コ

* Disabling Segwit components (no pre-segwit)

* Remove segwit switch from code 馃

* Reenable version bit calculations

* Enabling Chainparams genesis block and merkle root checks

* Improve header parsing and correction for block parsing with older nodes #865 (#870)

* Update randomized authentication for proxy connections

* Adds copyrights to torcontroller
Resolves #867

* Tor Hidden Services v3 (#872)

* Initi v3 tor hidden services

* Support hidden services (V3) for new nodes

* Remove my laziness

* Remove more logs

* Add i2p support (#873)

* add i2p support

if using i2p wrapped daemon.

it would be nice to eventually add i2pd as an option as well.

* Fix testnet chain parameters

* Refactor POW a bit for more readability

* Include Blocksignatures as part of our generated blocks
(also being transferred)

* Fix pub-/privkey prefixes for testnet

* add isbindany back to netaddress header

* update blockchain rpc

* update blockchain rpc header

* fix blockchain rpc header

* Move versionbits info out of versionbits.o

* Remove previous invalidation schemes and replace them with our ones

* Transfer methods into cpp file rather than inline methods

* Enabling full mining capabilities

* Fix compiling issues

* Revert "Merge branch 'bench_tests' into develop"

This reverts commit 3969482, reversing
changes made to 33ce10b.

* Revert "Merge branch 'bench_tests' into develop"

This reverts commit efc7e3b, reversing
changes made to b508db7.

* Fix linking issues for wallet signing

* Update README.md

* Remove the useless rest of a merge conflict 馃檳
  • Loading branch information
marpme authored and justinvforvendetta committed Feb 28, 2019
1 parent 9bd6f12 commit 96e1b3c
Show file tree
Hide file tree
Showing 24 changed files with 564 additions and 274 deletions.
2 changes: 1 addition & 1 deletion doc/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ These are the dependencies currently used by Verge Core. You can find instructio
| Qt | [5.7.1](https://download.qt.io/official_releases/qt/) | 4.7+ | No | | |
| XCB | | | | | [Yes](/depends/packages/qt.mk#L94) (Linux only) |
| xkbcommon | | | | | [Yes](/depends/packages/qt.mk#L93) (Linux only) |
| ZeroMQ | [4.3.1](https://github.com/zeromq/libzmq/releases) | | No | | |
| ZeroMQ | [4.2.3](https://github.com/zeromq/libzmq/releases) | | No | | |
| zlib | [1.2.11](http://zlib.net/) | | | | No |
37 changes: 20 additions & 17 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ static CBlock CreateGenesisBlock(const char* pszTimestamp, uint32_t nTime, uint3
* transaction cannot be spent since it did not originally exist in the
* database.
*/
static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion)
static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, bool isTestnet = false)
{
const char* pszTimestamp = "Name: Dogecoin Dark";
const char* pszTimestamp = isTestnet ? "VERGE TESTNET" : "Name: Dogecoin Dark";
return CreateGenesisBlock(pszTimestamp, nTime, nNonce, nBits, nVersion);
}

Expand Down Expand Up @@ -121,10 +121,10 @@ class CMainParams : public CChainParams {
nPruneAfterHeight = 100000;

genesis = CreateGenesisBlock(1412878964, 1473191, 0x1e0fffff, 1);
consensus.hashGenesisBlock = genesis.GetPoWHash(ALGO_SCRYPT);
//printf("%s", genesis.ToString().c_str());
//assert(genesis.hashMerkleRoot == uint256S("0x1c83275d9151711eec3aec37d829837cc3c2730b2bdfd00ec5e8e5dce675fd00"));
//assert(consensus.hashGenesisBlock == uint256S("0x00000fc63692467faeb20cdb3b53200dc601d75bdfa1001463304cc790d77278"));
consensus.hashGenesisBlock = genesis.GetHash();

assert(genesis.hashMerkleRoot == uint256S("0x1c83275d9151711eec3aec37d829837cc3c2730b2bdfd00ec5e8e5dce675fd00"));
assert(consensus.hashGenesisBlock == uint256S("0x00000fc63692467faeb20cdb3b53200dc601d75bdfa1001463304cc790d77278"));

// Note that of those which support the service bits prefix, most only support a subset of
// possible options.
Expand Down Expand Up @@ -259,6 +259,9 @@ class CTestNetParams : public CChainParams {
// KeyNote: we'll leave testnet as is for now
strNetworkID = "test";
consensus.nSubsidyHalvingInterval = 210000;
consensus.MULTI_ALGO_SWITCH_BLOCK = 340000;
consensus.STEALTH_TX_SWITCH_BLOCK = 1824150;

consensus.BIP34Height = 0;
consensus.BIP65Height = 0; // 00000000007f6655f22f98e72ed80d8b06dc761d5da09df0fa1dc4be4f861eb6
consensus.BIP66Height = 0; // 000000002104c8c45e99a8853285a3b592602a3ccde2b832481da85e9e4ba182
Expand Down Expand Up @@ -289,18 +292,18 @@ class CTestNetParams : public CChainParams {
// By default assume that the signatures in ancestors of this block are valid.
consensus.defaultAssumeValid = uint256S("0x65b4e101cacf3e1e4f3a9237e3a74ffd1186e595d8b78fa8ea22c21ef5bf9347"); //also genesis

pchMessageStart[0] = 0x0b;
pchMessageStart[1] = 0x11;
pchMessageStart[2] = 0x09;
pchMessageStart[3] = 0x07;
pchMessageStart[0] = 0xcd;
pchMessageStart[1] = 0xf2;
pchMessageStart[2] = 0xc0;
pchMessageStart[3] = 0xef;
nDefaultPort = 21104;
nPruneAfterHeight = 1000;

genesis = CreateGenesisBlock(1462058066, 2, 0x1e0fffff, 1);
genesis = CreateGenesisBlock(1462058066, 2, 0x1e0fffff, 1, true);
consensus.hashGenesisBlock = genesis.GetHash();
// printf("%s", genesis.ToString().c_str());
//assert(consensus.hashGenesisBlock == uint256S("0x65b4e101cacf3e1e4f3a9237e3a74ffd1186e595d8b78fa8ea22c21ef5bf9347"));
//assert(genesis.hashMerkleRoot == uint256S("0x768cc22f70bbcc4de26f83aca1b4ea2a7e25f0d100497ba47c7ff2d9b696414c"));

assert(consensus.hashGenesisBlock == uint256S("0x65b4e101cacf3e1e4f3a9237e3a74ffd1186e595d8b78fa8ea22c21ef5bf9347"));
assert(genesis.hashMerkleRoot == uint256S("0x768cc22f70bbcc4de26f83aca1b4ea2a7e25f0d100497ba47c7ff2d9b696414c"));

vFixedSeeds.clear();
vSeeds.clear();
Expand All @@ -310,9 +313,9 @@ class CTestNetParams : public CChainParams {
vSeeds.emplace_back("seed.testnet.bitcoin.sprovoost.nl");
vSeeds.emplace_back("testnet-seed.bluematt.me"); // Just a static list of stable node(s), only supports x9

base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,239);
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,115);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,198);
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,243); // 128 + PUBKEY_ADDRESS_TEST
base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};

Expand Down
8 changes: 6 additions & 2 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
// -promiscuousmempoolflags is used.
// TODO: replace this with a call to main to assess validity of a mempool
// transaction (which in most cases can be a no-op).
fIncludeWitness = IsWitnessEnabled(pindexPrev, chainparams.GetConsensus()) && fMineWitnessTx;
// fIncludeWitness = IsWitnessEnabled(pindexPrev, chainparams.GetConsensus()) && fMineWitnessTx;

int nPackagesSelected = 0;
int nDescendantsUpdated = 0;
Expand All @@ -179,13 +179,17 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc

// Create coinbase transaction.
CMutableTransaction coinbaseTx;
// vin emtpy
coinbaseTx.vin.resize(1);
coinbaseTx.vin[0].prevout.SetNull();
// vout to miner with subsidy
coinbaseTx.vout.resize(1);
coinbaseTx.vout[0].scriptPubKey = scriptPubKeyIn;
coinbaseTx.vout[0].nValue = nFees + GetBlockSubsidy(nHeight, chainparams.GetConsensus());

coinbaseTx.vin[0].scriptSig = CScript() << nHeight << OP_0;
pblock->vtx[0] = MakeTransactionRef(std::move(coinbaseTx));

pblocktemplate->vchCoinbaseCommitment = GenerateCoinbaseCommitment(*pblock, pindexPrev, chainparams.GetConsensus());
pblocktemplate->vTxFees[0] = -nFees;

Expand All @@ -196,7 +200,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev);
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, algo, chainparams.GetConsensus());
pblock->nNonce = 0;
pblocktemplate->vTxSigOpsCost[0] = WITNESS_SCALE_FACTOR * GetLegacySigOpCount(*pblock->vtx[0]);
pblocktemplate->vTxSigOpsCost[0] = GetLegacySigOpCount(*pblock->vtx[0]);

CValidationState state;
if (!TestBlockValidity(state, chainparams, *pblock, pindexPrev, false, false)) {
Expand Down
2 changes: 1 addition & 1 deletion src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ bool AddLocal(const CService& addr, int nScore)
return false;

bool isTorActived = !gArgs.GetBoolArg("-without-tor", false);
if(isTorActived && !addr.IsTor())
if((isTorActived && !addr.IsTor()) && (isTorActived && !addr.IsTorV3()))
return false;

LogPrintf("AddLocal(%s,%i)\n", addr.ToString(), nScore);
Expand Down
79 changes: 67 additions & 12 deletions src/netaddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

static const unsigned char pchIPv4[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };
static const unsigned char pchOnionCat[] = {0xFD,0x87,0xD8,0x7E,0xEB,0x43};
static const unsigned char pchGarliCat[] = {0xFD,0x60,0xDB,0x4D,0xDD,0xB5};

// 0xFD + sha256("bitcoin")[0:5]
static const unsigned char g_internal_prefix[] = { 0xFD, 0x6B, 0x88, 0xC0, 0x87, 0x24 };
Expand Down Expand Up @@ -56,15 +57,37 @@ bool CNetAddr::SetInternal(const std::string &name)

bool CNetAddr::SetSpecial(const std::string &strName)
{
if (strName.size()>6 && strName.substr(strName.size() - 6, 6) == ".onion") {
if (strName.size() > 6 && strName.substr(strName.size() - 6, 6) == ".onion") {
std::vector<unsigned char> vchAddr = DecodeBase32(strName.substr(0, strName.size() - 6).c_str());
if (vchAddr.size() != 16-sizeof(pchOnionCat))
// 16' length - v2 tor addresses
if (vchAddr.size() == 16 - sizeof(pchOnionCat)){
memcpy(ip, pchOnionCat, sizeof(pchOnionCat));
for (unsigned int i = 0; i < 16 - sizeof(pchOnionCat); i++)
ip[i + sizeof(pchOnionCat)] = vchAddr[i];
usesTorV3 = false;
return true;
}

// 56' length - v3 tor addressess
std::vector<unsigned char> vchAddrV3 = DecodeBase32(strName.substr(0, strName.size() - 6).c_str());
if (vchAddrV3.size() == 41 - sizeof(pchOnionCat)){
memcpy(ip, pchOnionCat, sizeof(pchOnionCat));
for (unsigned int i = 0; i < 41 - sizeof(pchOnionCat); i++)
ip[i + sizeof(pchOnionCat)] = vchAddrV3[i];
usesTorV3 = true;
return true;
}

}
if (strName.size()>11 && strName.substr(strName.size() - 11, 11) == ".oc.b32.i2p") {
std::vector<unsigned char> vchAddr = DecodeBase32(strName.substr(0, strName.size() - 11).c_str());
if (vchAddr.size() != 16-sizeof(pchGarliCat))
return false;
memcpy(ip, pchOnionCat, sizeof(pchOnionCat));
for (unsigned int i=0; i<16-sizeof(pchOnionCat); i++)
ip[i + sizeof(pchOnionCat)] = vchAddr[i];
memcpy(ip, pchOnionCat, sizeof(pchGarliCat));
for (unsigned int i=0; i<16-sizeof(pchGarliCat); i++)
ip[i + sizeof(pchGarliCat)] = vchAddr[i];
return true;
}
}
return false;
}

Expand All @@ -91,7 +114,7 @@ bool CNetAddr::IsIPv4() const

bool CNetAddr::IsIPv6() const
{
return (!IsIPv4() && !IsTor() && !IsInternal());
return (!IsIPv4() && !IsTor() && !IsI2P() && !IsTorV3() && !IsInternal());
}

bool CNetAddr::IsRFC1918() const
Expand Down Expand Up @@ -169,7 +192,17 @@ bool CNetAddr::IsRFC4843() const

bool CNetAddr::IsTor() const
{
return (memcmp(ip, pchOnionCat, sizeof(pchOnionCat)) == 0);
return !usesTorV3 && (memcmp(ip, pchOnionCat, sizeof(pchOnionCat)) == 0);
}

bool CNetAddr::IsTorV3() const
{
return usesTorV3 && (memcmp(ip, pchOnionCat, sizeof(pchOnionCat)) == 0);
}

bool CNetAddr::IsI2P() const
{
return (memcmp(ip, pchGarliCat, sizeof(pchGarliCat)) == 0);
}

bool CNetAddr::IsLocal() const
Expand Down Expand Up @@ -227,7 +260,7 @@ bool CNetAddr::IsValid() const

bool CNetAddr::IsRoutable() const
{
return IsValid() && !(IsRFC1918() || IsRFC2544() || IsRFC3927() || IsRFC4862() || IsRFC6598() || IsRFC5737() || (IsRFC4193() && !IsTor()) || IsRFC4843() || IsLocal() || IsInternal());
return IsValid() && !(IsRFC1918() || IsRFC2544() || IsRFC3927() || IsRFC4862() || IsRFC6598() || IsRFC5737() || (IsRFC4193() && (!IsI2P() && !IsTor() && !IsTorV3())) || IsRFC4843() || IsLocal() || IsInternal());
}

bool CNetAddr::IsInternal() const
Expand All @@ -246,8 +279,11 @@ enum Network CNetAddr::GetNetwork() const
if (IsIPv4())
return NET_IPV4;

if (IsTor())
if (IsTor() || IsTorV3())
return NET_TOR;

if (IsI2P())
return NET_I2P;

return NET_IPV6;
}
Expand All @@ -256,6 +292,13 @@ std::string CNetAddr::ToStringIP() const
{
if (IsTor())
return EncodeBase32(&ip[6], 10) + ".onion";

if (IsI2P())
return EncodeBase32(&ip[6], 10) + ".oc.b32.i2p";

if (IsTorV3())
return EncodeBase32(&ip[6], 35) + ".onion";

if (IsInternal())
return EncodeBase32(ip + sizeof(g_internal_prefix), sizeof(ip) - sizeof(g_internal_prefix)) + ".internal";
CService serv(*this, 0);
Expand Down Expand Up @@ -354,11 +397,17 @@ std::vector<unsigned char> CNetAddr::GetGroup() const
vchRet.push_back(GetByte(2) ^ 0xFF);
return vchRet;
}
else if (IsTor())
else if (IsTor() || IsTorV3())
{
nClass = NET_TOR;
nStartByte = 6;
nBits = 4;
}
else if (IsI2P())
{
nClass = NET_I2P;
nStartByte = 6;
nBits = 4;
}
// for he.net, use /36 groups
else if (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x04 && GetByte(12) == 0x70)
Expand Down Expand Up @@ -440,6 +489,11 @@ int CNetAddr::GetReachabilityFrom(const CNetAddr *paddrPartner) const
case NET_IPV4: return REACH_IPV4; // Tor users can connect to IPv4 as well
case NET_TOR: return REACH_PRIVATE;
}
case NET_I2P:
switch(ourNet) {
default: return REACH_DEFAULT;
case NET_I2P: return REACH_PRIVATE;
}
case NET_TEREDO:
switch(ourNet) {
default: return REACH_DEFAULT;
Expand All @@ -455,6 +509,7 @@ int CNetAddr::GetReachabilityFrom(const CNetAddr *paddrPartner) const
case NET_TEREDO: return REACH_TEREDO;
case NET_IPV6: return REACH_IPV6_WEAK;
case NET_IPV4: return REACH_IPV4;
case NET_I2P: return REACH_PRIVATE; // assume connections from unroutable addresses are
case NET_TOR: return REACH_PRIVATE; // either from Tor, or don't care about our address
}
}
Expand Down Expand Up @@ -562,7 +617,7 @@ std::string CService::ToStringPort() const

std::string CService::ToStringIPPort() const
{
if (IsIPv4() || IsTor() || IsInternal()) {
if (IsIPv4() || IsTor() || IsI2P() || IsTorV3() || IsInternal()) {
return ToStringIP() + ":" + ToStringPort();
} else {
return "[" + ToStringIP() + "]:" + ToStringPort();
Expand Down
39 changes: 34 additions & 5 deletions src/netaddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <compat.h>
#include <serialize.h>
#include <span.h>
#include <version.h>

#include <stdint.h>
#include <string>
Expand All @@ -24,6 +25,7 @@ enum Network
NET_IPV4,
NET_IPV6,
NET_TOR,
NET_I2P,
NET_INTERNAL,

NET_MAX,
Expand All @@ -33,7 +35,8 @@ enum Network
class CNetAddr
{
protected:
unsigned char ip[16]; // in network byte order
unsigned char ip[41]; // in network byte order
bool usesTorV3 = false;
uint32_t scopeId; // for scoped/link-local ipv6 addresses

public:
Expand All @@ -55,9 +58,9 @@ class CNetAddr
*/
bool SetInternal(const std::string& name);

bool SetSpecial(const std::string &strName); // for Tor addresses
bool SetSpecial(const std::string &strName); // for Tor & i2p addresses
bool IsIPv4() const; // IPv4 mapped address (::FFFF:0:0/96, 0.0.0.0/0)
bool IsIPv6() const; // IPv6 address (not mapped IPv4, not Tor)
bool IsIPv6() const; // IPv6 address (not mapped IPv4, not Tor/i2p)
bool IsRFC1918() const; // IPv4 private networks (10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12)
bool IsRFC2544() const; // IPv4 inter-network communications (192.18.0.0/15)
bool IsRFC6598() const; // IPv4 ISP-level NAT (100.64.0.0/10)
Expand All @@ -72,6 +75,8 @@ class CNetAddr
bool IsRFC6052() const; // IPv6 well-known prefix (64:FF9B::/96)
bool IsRFC6145() const; // IPv6 IPv4-translated address (::FFFF:0:0:0/96)
bool IsTor() const;
bool IsI2P() const;
bool IsTorV3() const;
bool IsLocal() const;
bool IsRoutable() const;
bool IsInternal() const;
Expand All @@ -96,7 +101,19 @@ class CNetAddr

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
READWRITE(ip);
if(s.GetVersion() > TORV3_SERVICES_VERSION) {
READWRITE(ip);
} else { // backwards compatibility
if(ser_action.ForRead()){
unsigned char compatibleIP[16];
READWRITE(compatibleIP);
memcpy(CNetAddr::ip, compatibleIP, sizeof(compatibleIP));
} else {
unsigned char compatibleIP[16];
memcpy(compatibleIP, CNetAddr::ip, sizeof(compatibleIP));
READWRITE(compatibleIP);
}
}
}

friend class CSubNet;
Expand Down Expand Up @@ -168,7 +185,19 @@ class CService : public CNetAddr

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
READWRITE(ip);
if(s.GetVersion() >= TORV3_SERVICES_VERSION) {
READWRITE(ip);
} else {
if(ser_action.ForRead()){
unsigned char compatibleIP[16];
READWRITE(compatibleIP);
memcpy(CNetAddr::ip, compatibleIP, sizeof(compatibleIP));
} else {
unsigned char compatibleIP[16]; // backwards compatibility
memcpy(compatibleIP, CNetAddr::ip, sizeof(compatibleIP));
READWRITE(compatibleIP);
}
}
READWRITE(WrapBigEndian(port));
}
};
Expand Down

0 comments on commit 96e1b3c

Please sign in to comment.