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

Function get_ephemeral_range

library/python/port_manager/__init__.py:246–263  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

244
245
246def get_ephemeral_range():
247 if platform.system() == 'Linux':
248 filename = "/proc/sys/net/ipv4/ip_local_port_range"
249 if os.path.exists(filename):
250 with open(filename) as afile:
251 data = afile.read(1024) # fix for musl
252 port_range = tuple(map(int, data.strip().split()))
253 if len(port_range) == 2:
254 return port_range
255 else:
256 logger.warning("Bad ip_local_port_range format: '%s'. Going to use IANA suggestion", data)
257 elif platform.system() == 'Darwin':
258 first = _sysctlbyname_uint("net.inet.ip.portrange.first")
259 last = _sysctlbyname_uint("net.inet.ip.portrange.last")
260 if first and last:
261 return first, last
262 # IANA suggestion
263 return (1 << 15) + (1 << 14), UI16MAXVAL
264
265
266def _sysctlbyname_uint(name):

Callers 1

get_valid_port_rangeFunction · 0.85

Calls 9

mapClass · 0.85
lenFunction · 0.85
_sysctlbyname_uintFunction · 0.85
systemMethod · 0.80
warningMethod · 0.80
openFunction · 0.50
tupleClass · 0.50
readMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected