#include "utils.h" #include #include #include #include #if defined(_unix_) #include #endif #if defined(_win_) #include #endif using namespace NNeh; size_t NNeh::RealStackSize(size_t len) noexcept { #if defined(NDEBUG) && !defined(_san_enabled_) return len; #else return Max(len, 64000); #endif } TString NNeh::PrintHostByRfc(const NAddr::IRemoteAddr& addr) { TStringStream ss; if (addr.Addr()->sa_family == AF_INET) { NAddr::PrintHost(ss, addr); } else if (addr.Addr()->sa_family == AF_INET6) { ss << '['; NAddr::PrintHost(ss, addr); ss << ']'; } return ss.Str(); } NAddr::IRemoteAddrPtr NNeh::GetPeerAddr(SOCKET s) { TAutoPtr addr(new NAddr::TOpaqueAddr()); if (getpeername(s, addr->MutableAddr(), addr->LenPtr()) < 0) { ythrow TSystemError() << "getpeername() failed"; } return NAddr::IRemoteAddrPtr(addr.Release()); }