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