addrman: reset I2P ports to 0 when loading from disk

This is a temporary change to convert I2P addresses that have propagated
with port 8333 to ones with port 0.

It would cause a problem some day if indeed some bitcoin software is
listening on port 8333 only and rejects connections to port 0 and we are
still using SAM 3.1 which only supports port 0. In this case we would
replace 8333 with 0 and try to connect to such nodes.

This commit should be included in 22.0 and be reverted before 23.0 is
released.
This commit is contained in:
Vasil Dimov
2021-06-28 16:54:45 +02:00
parent 41cda9d075
commit e0a2b390c1
3 changed files with 225 additions and 0 deletions

View File

@@ -452,6 +452,8 @@ public:
RemoveInvalid();
ResetI2PPorts();
Check();
}
@@ -767,6 +769,14 @@ private:
//! Remove invalid addresses.
void RemoveInvalid() EXCLUSIVE_LOCKS_REQUIRED(cs);
/**
* Reset the ports of I2P peers to 0.
* This is needed as a temporary measure because now we enforce port 0 and
* only connect to I2P hosts if the port is 0, but in the early days some
* I2P addresses with port 8333 were rumoured and persisted into addrmans.
*/
void ResetI2PPorts() EXCLUSIVE_LOCKS_REQUIRED(cs);
friend class CAddrManTest;
};