refactor: tr_address cleanup (#3422)

* refactor: remove tr_address_compare()

* refactor: remove tr_address_to_string()

* refactor: remove NUM_TR_AF_INET_TYPES

* refactor: replace tr_sessionGetPublicAddress with tr_session::getPublicAddress()

* refactor: tr_peerIo() takes tr_address by value

* refactor: replace tr_sessionIsAddressBlocked with tr_session::isAddressBlocked()

* refactor: tr_peerMgrAddIncoming now takes tr_address by value

* refactor: replace tr_address_is_valid_for_peers() with tr_address.isValidForPeers()

* refactor: tr_netOpenPeerSocket takes tr_address by value

* refactor: remove tr_generateAllowedSet()

* refactor: setup_sockaddr takes a tr_address by value

* refactor: tr_netBindTCP() takes a tr_address by value

* refactor: tr_dhtAddNode() takes a tr_address by value

* refactor: remove tr_address_from_string()

* refactor: rename tr_address.isValidForPeers() to .isValidPeerAddress()

* refactor: replace tr_address_from_sockaddr_storage() with tr_address::fromSockaddrStorage()

* refactor: minor cleanup to tr_address::readable()
This commit is contained in:
Charles Kerr
2022-07-08 13:23:41 -05:00
committed by GitHub
parent 745adf8332
commit 9a44eeaa27
23 changed files with 217 additions and 432 deletions

View File

@@ -33,8 +33,7 @@ using namespace std::literals;
bool tr_addressIsIP(char const* str)
{
tr_address tmp;
return tr_address_from_string(&tmp, str);
return tr_address::fromString(str).has_value();
}
char const* tr_webGetResponseStr(long code)
@@ -271,16 +270,15 @@ std::string_view getSiteName(std::string_view host)
return host;
}
// psl needs a zero-terminated hostname
auto const szhost = tr_urlbuf{ host };
// is it an IP?
auto addr = tr_address{};
if (tr_address_from_string(&addr, std::data(szhost)))
if (auto const addr = tr_address::fromString(host); addr)
{
return host;
}
// psl needs a zero-terminated hostname
auto const szhost = tr_urlbuf{ host };
// is it a registered name?
if (isAsciiNonUpperCase(host))
{