MCPcopy Index your code
hub / github.com/sshuttle/sshuttle / _ipmatch

Function _ipmatch

sshuttle/server.py:20–38  ·  view source on GitHub ↗
(ipstr)

Source from the content-addressed store, hash-verified

18
19
20def _ipmatch(ipstr):
21 # FIXME: IPv4 only
22 if ipstr == 'default':
23 ipstr = '0.0.0.0/0'
24 m = re.match(r'^(\d+(\.\d+(\.\d+(\.\d+)?)?)?)(?:/(\d+))?$', ipstr)
25 if m:
26 g = m.groups()
27 ips = g[0]
28 width = int(g[4] or 32)
29 if g[1] is None:
30 ips += '.0.0.0'
31 width = min(width, 8)
32 elif g[2] is None:
33 ips += '.0.0'
34 width = min(width, 16)
35 elif g[3] is None:
36 ips += '.0'
37 width = min(width, 24)
38 return (struct.unpack('!I', socket.inet_aton(ips))[0], width)
39
40
41def _ipstr(ip, width):

Callers 3

_route_netstatFunction · 0.85
_route_iprouteFunction · 0.85
_route_windowsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected