auto-nets: retrieve routes only if using auto-nets

There's a known issue that makes sshuttle crash if there are too
many routes on the remote host (that don't fit in 64KB). This patch
requests the routes only if auto-nets is specified on the command
line.
This commit is contained in:
Vasil Kolev 2019-01-27 12:55:21 +02:00 committed by Brian May
parent 0e99adc5d1
commit 8e35f049e2
3 changed files with 15 additions and 7 deletions

View File

@ -35,4 +35,5 @@ sshuttle.helpers.verbose = verbosity
import sshuttle.cmdline_options as options import sshuttle.cmdline_options as options
from sshuttle.server import main from sshuttle.server import main
main(options.latency_control, options.auto_hosts, options.to_nameserver) main(options.latency_control, options.auto_hosts, options.to_nameserver,
options.auto_nets)

View File

@ -453,7 +453,8 @@ def _main(tcp_listener, udp_listener, fw, ssh_cmd, remotename,
stderr=ssyslog._p and ssyslog._p.stdin, stderr=ssyslog._p and ssyslog._p.stdin,
options=dict(latency_control=latency_control, options=dict(latency_control=latency_control,
auto_hosts=auto_hosts, auto_hosts=auto_hosts,
to_nameserver=to_nameserver)) to_nameserver=to_nameserver,
auto_nets=auto_nets))
except socket.error as e: except socket.error as e:
if e.args[0] == errno.EPIPE: if e.args[0] == errno.EPIPE:
raise Fatal("failed to establish ssh session (1)") raise Fatal("failed to establish ssh session (1)")

View File

@ -279,7 +279,7 @@ class UdpProxy(Handler):
self.mux.send(self.chan, ssnet.CMD_UDP_DATA, hdr + data) self.mux.send(self.chan, ssnet.CMD_UDP_DATA, hdr + data)
def main(latency_control, auto_hosts, to_nameserver): def main(latency_control, auto_hosts, to_nameserver, auto_nets):
debug1('Starting server with Python version %s\n' debug1('Starting server with Python version %s\n'
% platform.python_version()) % platform.python_version())
@ -289,10 +289,6 @@ def main(latency_control, auto_hosts, to_nameserver):
helpers.logprefix = 'server: ' helpers.logprefix = 'server: '
debug1('latency control setting = %r\n' % latency_control) debug1('latency control setting = %r\n' % latency_control)
routes = list(list_routes())
debug1('available routes:\n')
for r in routes:
debug1(' %d/%s/%d\n' % r)
# synchronization header # synchronization header
sys.stdout.write('\0\0SSHUTTLE0001') sys.stdout.write('\0\0SSHUTTLE0001')
@ -304,6 +300,16 @@ def main(latency_control, auto_hosts, to_nameserver):
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)
debug1('auto-nets:' + str(auto_nets) + '\n')
if auto_nets:
routes = list(list_routes())
debug1('available routes:\n')
for r in routes:
debug1(' %d/%s/%d\n' % r)
else:
routes = []
routepkt = '' routepkt = ''
for r in routes: for r in routes:
routepkt += '%d,%s,%d\n' % r routepkt += '%d,%s,%d\n' % r