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

Function _list_routes

sshuttle/server.py:96–114  ·  view source on GitHub ↗
(argv, extract_route)

Source from the content-addressed store, hash-verified

94
95
96def _list_routes(argv, extract_route):
97 # FIXME: IPv4 only
98 p = ssubprocess.Popen(argv, stdout=ssubprocess.PIPE, env=get_env())
99 routes = []
100 for line in p.stdout:
101 if not line.strip():
102 continue
103 ipw, mask = extract_route(line.decode("ASCII"))
104 if not ipw:
105 continue
106 width = min(ipw[1], mask)
107 ip = ipw[0] & _shl(_shl(1, width) - 1, 32 - width)
108 routes.append(
109 (socket.AF_INET, socket.inet_ntoa(struct.pack('!I', ip)), width))
110 rv = p.wait()
111 if rv != 0:
112 log('WARNING: %r returned %d' % (argv, rv))
113
114 return routes
115
116
117def list_routes():

Callers 1

list_routesFunction · 0.85

Calls 3

get_envFunction · 0.90
logFunction · 0.90
_shlFunction · 0.85

Tested by

no test coverage detected