diff options
author | and42 <and42@yandex-team.ru> | 2022-02-10 16:47:12 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:12 +0300 |
commit | 984590e9d9d7c0f912885d93ae78be402ae7b4f4 (patch) | |
tree | 339adc63bce23800021202ae4a8328a843dc447a /util/network/endpoint.h | |
parent | 4fc9a1a64db469cc94894abfec740aa5c9e9789b (diff) | |
download | ydb-984590e9d9d7c0f912885d93ae78be402ae7b4f4.tar.gz |
Restoring authorship annotation for <and42@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/network/endpoint.h')
-rw-r--r-- | util/network/endpoint.h | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/util/network/endpoint.h b/util/network/endpoint.h index fd98d331af..a3e59b4925 100644 --- a/util/network/endpoint.h +++ b/util/network/endpoint.h @@ -1,61 +1,61 @@ -#pragma once - -#include "address.h" - -#include <util/str_stl.h> - -//some equivalent boost::asio::ip::endpoint (easy for using pair ip:port) -class TEndpoint { -public: +#pragma once + +#include "address.h" + +#include <util/str_stl.h> + +//some equivalent boost::asio::ip::endpoint (easy for using pair ip:port) +class TEndpoint { +public: using TAddrRef = NAddr::IRemoteAddrRef; - - TEndpoint(const TAddrRef& addr); - TEndpoint(); - + + TEndpoint(const TAddrRef& addr); + TEndpoint(); + inline const TAddrRef& Addr() const noexcept { - return Addr_; - } - inline const sockaddr* SockAddr() const { - return Addr_->Addr(); - } - inline socklen_t SockAddrLen() const { - return Addr_->Len(); - } - - inline bool IsIpV4() const { - return Addr_->Addr()->sa_family == AF_INET; - } - inline bool IsIpV6() const { - return Addr_->Addr()->sa_family == AF_INET6; - } + return Addr_; + } + inline const sockaddr* SockAddr() const { + return Addr_->Addr(); + } + inline socklen_t SockAddrLen() const { + return Addr_->Len(); + } + + inline bool IsIpV4() const { + return Addr_->Addr()->sa_family == AF_INET; + } + inline bool IsIpV6() const { + return Addr_->Addr()->sa_family == AF_INET6; + } inline bool IsUnix() const { return Addr_->Addr()->sa_family == AF_UNIX; } - + inline TString IpToString() const { - return NAddr::PrintHost(*Addr_); - } - - void SetPort(ui16 port); + return NAddr::PrintHost(*Addr_); + } + + void SetPort(ui16 port); ui16 Port() const noexcept; - - size_t Hash() const; - -private: - TAddrRef Addr_; -}; - + + size_t Hash() const; + +private: + TAddrRef Addr_; +}; + template <> -struct THash<TEndpoint> { +struct THash<TEndpoint> { inline size_t operator()(const TEndpoint& ep) const { - return ep.Hash(); - } -}; - + return ep.Hash(); + } +}; + inline bool operator==(const TEndpoint& l, const TEndpoint& r) { - try { + try { return NAddr::IsSame(*l.Addr(), *r.Addr()) && l.Port() == r.Port(); - } catch (...) { - return false; - } -} + } catch (...) { + return false; + } +} |