mirror of
https://github.com/sshuttle/sshuttle.git
synced 2025-04-21 09:48:51 +02:00
parent
ce5187100c
commit
02fa49627f
@ -4,13 +4,15 @@ import imp
|
|||||||
|
|
||||||
z = zlib.decompressobj()
|
z = zlib.decompressobj()
|
||||||
while 1:
|
while 1:
|
||||||
name = sys.stdin.readline().strip()
|
name = stdin.readline().strip()
|
||||||
if name:
|
if name:
|
||||||
nbytes = int(sys.stdin.readline())
|
name = name.decode("ASCII")
|
||||||
|
|
||||||
|
nbytes = int(stdin.readline())
|
||||||
if verbosity >= 2:
|
if verbosity >= 2:
|
||||||
sys.stderr.write('server: assembling %r (%d bytes)\n'
|
sys.stderr.write('server: assembling %r (%d bytes)\n'
|
||||||
% (name, nbytes))
|
% (name, nbytes))
|
||||||
content = z.decompress(sys.stdin.read(nbytes))
|
content = z.decompress(stdin.read(nbytes))
|
||||||
|
|
||||||
module = imp.new_module(name)
|
module = imp.new_module(name)
|
||||||
parent, _, parent_name = name.rpartition(".")
|
parent, _, parent_name = name.rpartition(".")
|
||||||
|
@ -17,22 +17,23 @@ from sshuttle.helpers import log, debug1, debug2, debug3, Fatal, \
|
|||||||
|
|
||||||
|
|
||||||
def _ipmatch(ipstr):
|
def _ipmatch(ipstr):
|
||||||
if ipstr == 'default':
|
if ipstr == b'default':
|
||||||
ipstr = '0.0.0.0/0'
|
ipstr = b'0.0.0.0/0'
|
||||||
m = re.match(r'^(\d+(\.\d+(\.\d+(\.\d+)?)?)?)(?:/(\d+))?$', ipstr)
|
m = re.match(b'^(\d+(\.\d+(\.\d+(\.\d+)?)?)?)(?:/(\d+))?$', ipstr)
|
||||||
if m:
|
if m:
|
||||||
g = m.groups()
|
g = m.groups()
|
||||||
ips = g[0]
|
ips = g[0]
|
||||||
width = int(g[4] or 32)
|
width = int(g[4] or 32)
|
||||||
if g[1] is None:
|
if g[1] is None:
|
||||||
ips += '.0.0.0'
|
ips += b'.0.0.0'
|
||||||
width = min(width, 8)
|
width = min(width, 8)
|
||||||
elif g[2] is None:
|
elif g[2] is None:
|
||||||
ips += '.0.0'
|
ips += b'.0.0'
|
||||||
width = min(width, 16)
|
width = min(width, 16)
|
||||||
elif g[3] is None:
|
elif g[3] is None:
|
||||||
ips += '.0'
|
ips += b'.0'
|
||||||
width = min(width, 24)
|
width = min(width, 24)
|
||||||
|
ips = ips.decode("ASCII")
|
||||||
return (struct.unpack('!I', socket.inet_aton(ips))[0], width)
|
return (struct.unpack('!I', socket.inet_aton(ips))[0], width)
|
||||||
|
|
||||||
|
|
||||||
@ -61,7 +62,7 @@ def _list_routes():
|
|||||||
p = ssubprocess.Popen(argv, stdout=ssubprocess.PIPE)
|
p = ssubprocess.Popen(argv, stdout=ssubprocess.PIPE)
|
||||||
routes = []
|
routes = []
|
||||||
for line in p.stdout:
|
for line in p.stdout:
|
||||||
cols = re.split(r'\s+', line)
|
cols = re.split(b'\s+', line)
|
||||||
ipw = _ipmatch(cols[0])
|
ipw = _ipmatch(cols[0])
|
||||||
if not ipw:
|
if not ipw:
|
||||||
continue # some lines won't be parseable; never mind
|
continue # some lines won't be parseable; never mind
|
||||||
@ -239,9 +240,9 @@ def main(latency_control):
|
|||||||
socket.fromfd(sys.stdout.fileno(),
|
socket.fromfd(sys.stdout.fileno(),
|
||||||
socket.AF_INET, socket.SOCK_STREAM))
|
socket.AF_INET, socket.SOCK_STREAM))
|
||||||
handlers.append(mux)
|
handlers.append(mux)
|
||||||
routepkt = ''
|
routepkt = b''
|
||||||
for r in routes:
|
for r in routes:
|
||||||
routepkt += '%d,%s,%d\n' % r
|
routepkt += b'%d,%s,%d\n' % (r[0], r[1].encode("ASCII"), r[2])
|
||||||
mux.send(0, ssnet.CMD_ROUTES, routepkt)
|
mux.send(0, ssnet.CMD_ROUTES, routepkt)
|
||||||
|
|
||||||
hw = Hostwatch()
|
hw = Hostwatch()
|
||||||
@ -270,7 +271,7 @@ def main(latency_control):
|
|||||||
mux.got_host_req = got_host_req
|
mux.got_host_req = got_host_req
|
||||||
|
|
||||||
def new_channel(channel, data):
|
def new_channel(channel, data):
|
||||||
(family, dstip, dstport) = data.split(',', 2)
|
(family, dstip, dstport) = data.split(b',', 2)
|
||||||
family = int(family)
|
family = int(family)
|
||||||
dstport = int(dstport)
|
dstport = int(dstport)
|
||||||
outwrap = ssnet.connect_dst(family, dstip, dstport)
|
outwrap = ssnet.connect_dst(family, dstip, dstport)
|
||||||
|
@ -91,7 +91,8 @@ def connect(ssh_cmd, rhostport, python, stderr, options):
|
|||||||
pyscript = r"""
|
pyscript = r"""
|
||||||
import sys;
|
import sys;
|
||||||
verbosity=%d;
|
verbosity=%d;
|
||||||
exec(compile(sys.stdin.read(%d), "assembler.py", "exec"))
|
stdin=getattr(sys.stdin,"buffer",sys.stdin);
|
||||||
|
exec(compile(stdin.read(%d), "assembler.py", "exec"))
|
||||||
""" % (helpers.verbose or 0, len(content))
|
""" % (helpers.verbose or 0, len(content))
|
||||||
pyscript = re.sub(r'\s+', ' ', pyscript.strip())
|
pyscript = re.sub(r'\s+', ' ', pyscript.strip())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user