summaryrefslogtreecommitdiffstats
path: root/ssnet.py
diff options
context:
space:
mode:
authorAvery Pennarun <apenwarr@gmail.com>2011-02-02 02:32:46 -0800
committerAvery Pennarun <apenwarr@gmail.com>2011-02-02 02:32:46 -0800
commita81972b2b5a828ef42b15e77cea6ce46d762888f (patch)
tree4c103088040419fd6838f5f844e8333855d9062a /ssnet.py
parenta238f7636c90e516a3e45345cb92ccc3172ae269 (diff)
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.
Diffstat (limited to 'ssnet.py')
-rw-r--r--ssnet.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/ssnet.py b/ssnet.py
index 554d870..2145431 100644
--- a/ssnet.py
+++ b/ssnet.py
@@ -1,6 +1,8 @@
import struct, socket, errno, select
if not globals().get('skip_imports'):
from helpers import *
+
+MAX_CHANNEL = 65535
# these don't exist in the socket module in python 2.3!
SHUT_RD = 0
@@ -300,7 +302,7 @@ class Mux(Handler):
# channel 0 is special, so we never allocate it
for timeout in xrange(1024):
self.chani += 1
- if self.chani > 65535:
+ if self.chani > MAX_CHANNEL:
self.chani = 1
if not self.channels.get(self.chani):
return self.chani