I’m not sure if this will be solved by libevent, it could be, in any case there needs to be an issue for this: currently CNetAddr (and to a lesser extent, CService) farm out address parsing to the OS, which causes it (at the discretion of the OS) to accept incomplete as well as otherwise invalid addresses. @EthanHeilman perfectly illustrates this in #7291:
0BOOST_CHECK(CNetAddr("1.1.1").ToString() == "1.1.0.1");
1BOOST_CHECK(CNetAddr("1.1").ToString() == "1.0.0.1");
2BOOST_CHECK(CNetAddr("1111").ToString() == "0.0.4.87");
Parsing incomplete addresses as they were complete ones causes confusion when specifying ban masks. For example a user may think that 1.1.1
, as it is accepted, maps to 1.1.1.0/24
. Mapping to 1.1.0.1 is just strange. It should simply reject these.
Also, CNetaddr is not supposed to accept a port! but parses this as IPv6 any addr:
0BOOST_CHECK(CNetAddr("250.2.2.2:7777").ToString() == "::");
1BOOST_CHECK(CNetAddr("1.1.1.1:1").ToString() == CNetAddr("2.2.2:1").ToString());
These cases too should result an address address that is not valid (!IsValid()
).