Add --wrap option to force channel number wrapping at a lower number.

This makes it easier to actually test what happens when channel numbers wrap
around.  The good news: it works.

However, I did find a bug where sshuttle would die if we completely ran out
of available channel numbers because so many of them were open.  This would
never realistically happen at the default of 65535 channels (we'd run out of
file descriptors first), but it's still a bug, so let's handle it by just
dropping the connection when it happens.
This commit is contained in:
Avery Pennarun
2011-02-02 02:32:46 -08:00
parent a238f7636c
commit a81972b2b5
3 changed files with 11 additions and 1 deletions

View File

@ -273,6 +273,10 @@ def _main(listener, fw, ssh_cmd, remotename, python, latency_control,
sock.close()
return
chan = mux.next_channel()
if not chan:
log('warning: too many open channels. Discarded connection.\n')
sock.close()
return
mux.send(chan, ssnet.CMD_CONNECT, '%s,%s' % dstip)
outwrap = MuxWrapper(mux, chan)
handlers.append(Proxy(SockWrapper(sock, sock), outwrap))