MCPcopy Create free account
hub / github.com/catboost/catboost / GetEphemeralRange

Function GetEphemeralRange

library/cpp/testing/common/network.cpp:64–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62 };
63
64 std::pair<ui16, ui16> GetEphemeralRange() {
65 // IANA suggestion
66 std::pair<ui16, ui16> pair{(1 << 15) + (1 << 14), (1 << 16) - 1};
67 #ifdef _linux_
68 if (NFs::Exists("/proc/sys/net/ipv4/ip_local_port_range")) {
69 TIFStream fileStream("/proc/sys/net/ipv4/ip_local_port_range");
70 fileStream >> pair.first >> pair.second;
71 }
72 #endif
73 #ifdef _darwin_
74 ui32 first, last;
75 size_t size;
76 sysctlbyname("net.inet.ip.portrange.first", &first, &size, NULL, 0);
77 sysctlbyname("net.inet.ip.portrange.last", &last, &size, NULL, 0);
78 pair.first = first;
79 pair.second = last;
80 #endif
81 return pair;
82 }
83
84 TVector<std::pair<ui16, ui16>> GetPortRanges() {
85 TString givenRange = GetEnv("VALID_PORT_RANGE");

Callers 1

GetPortRangesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected