diff options
author | Olle Lundberg <geek@nerd.sh> | 2014-08-14 14:28:34 +0200 |
---|---|---|
committer | Olle Lundberg <geek@nerd.sh> | 2014-08-14 15:19:06 +0200 |
commit | 83aa7335f7121f9259a41ae27cab5fb8dad09b96 (patch) | |
tree | 10ac3da15d5ac002277c80817082d6bee2b717a5 | |
parent | c0df755ead0eb54d798dd3f49b7dd86b8ad6baeb (diff) |
Move window and packet constants.
Centralise them to the common module to avoid import cycles.
Also add constants for default values and use them in the
transport class.
-rw-r--r-- | paramiko/channel.py | 10 | ||||
-rw-r--r-- | paramiko/common.py | 11 | ||||
-rw-r--r-- | paramiko/transport.py | 9 |
3 files changed, 17 insertions, 13 deletions
diff --git a/paramiko/channel.py b/paramiko/channel.py index 90761d43..d6ad1a52 100644 --- a/paramiko/channel.py +++ b/paramiko/channel.py @@ -30,7 +30,7 @@ from paramiko import util from paramiko.common import cMSG_CHANNEL_REQUEST, cMSG_CHANNEL_WINDOW_ADJUST, \ cMSG_CHANNEL_DATA, cMSG_CHANNEL_EXTENDED_DATA, DEBUG, ERROR, \ cMSG_CHANNEL_SUCCESS, cMSG_CHANNEL_FAILURE, cMSG_CHANNEL_EOF, \ - cMSG_CHANNEL_CLOSE + cMSG_CHANNEL_CLOSE, MIN_PACKET_SIZE from paramiko.message import Message from paramiko.py3compat import bytes_types from paramiko.ssh_exception import SSHException @@ -39,14 +39,6 @@ from paramiko.buffered_pipe import BufferedPipe, PipeTimeout from paramiko import pipe -# lower bound on the max packet size we'll accept from the remote host -# Minimum packet size is 32768 bytes according to -# http://www.ietf.org/rfc/rfc4254.txt -MIN_PACKET_SIZE = 2 ** 15 - -# Max windows size according to http://www.ietf.org/rfc/rfc4254.txt -MAX_WINDOW_SIZE = 2**32 -1 - class Channel (object): """ A secure tunnel across an SSH `.Transport`. A Channel is meant to behave diff --git a/paramiko/common.py b/paramiko/common.py index 18298922..93f71df0 100644 --- a/paramiko/common.py +++ b/paramiko/common.py @@ -171,3 +171,14 @@ CRITICAL = logging.CRITICAL # Common IO/select/etc sleep period, in seconds io_sleep = 0.01 + +DEFAULT_WINDOW_SIZE = 64 * 2 ** 15 +DEFAULT_MAX_PACKET_SIZE = 2 ** 15 + +# lower bound on the max packet size we'll accept from the remote host +# Minimum packet size is 32768 bytes according to +# http://www.ietf.org/rfc/rfc4254.txt +MIN_PACKET_SIZE = 2 ** 15 + +# Max windows size according to http://www.ietf.org/rfc/rfc4254.txt +MAX_WINDOW_SIZE = 2**32 -1 diff --git a/paramiko/transport.py b/paramiko/transport.py index da67408f..fb7ab113 100644 --- a/paramiko/transport.py +++ b/paramiko/transport.py @@ -31,7 +31,7 @@ from hashlib import md5, sha1 import paramiko from paramiko import util from paramiko.auth_handler import AuthHandler -from paramiko.channel import Channel, MIN_PACKET_SIZE, MAX_WINDOW_SIZE +from paramiko.channel import Channel from paramiko.common import xffffffff, cMSG_CHANNEL_OPEN, cMSG_IGNORE, \ cMSG_GLOBAL_REQUEST, DEBUG, MSG_KEXINIT, MSG_IGNORE, MSG_DISCONNECT, \ MSG_DEBUG, ERROR, WARNING, cMSG_UNIMPLEMENTED, INFO, cMSG_KEXINIT, \ @@ -42,7 +42,8 @@ from paramiko.common import xffffffff, cMSG_CHANNEL_OPEN, cMSG_IGNORE, \ MSG_CHANNEL_OPEN_SUCCESS, MSG_CHANNEL_OPEN_FAILURE, MSG_CHANNEL_OPEN, \ MSG_CHANNEL_SUCCESS, MSG_CHANNEL_FAILURE, MSG_CHANNEL_DATA, \ MSG_CHANNEL_EXTENDED_DATA, MSG_CHANNEL_WINDOW_ADJUST, MSG_CHANNEL_REQUEST, \ - MSG_CHANNEL_EOF, MSG_CHANNEL_CLOSE + MSG_CHANNEL_EOF, MSG_CHANNEL_CLOSE, MIN_PACKET_SIZE, MAX_WINDOW_SIZE, \ + DEFAULT_WINDOW_SIZE, DEFAULT_MAX_PACKET_SIZE from paramiko.compress import ZlibCompressor, ZlibDecompressor from paramiko.dsskey import DSSKey from paramiko.kex_gex import KexGex @@ -137,8 +138,8 @@ class Transport (threading.Thread): def __init__(self, sock, - default_window_size=64 * 2 ** 15, - default_max_packet_size=2 ** 15): + default_window_size=DEFAULT_WINDOW_SIZE, + default_max_packet_size=DEFAULT_MAX_PACKET_SIZE): """ Create a new SSH session over an existing socket, or socket-like object. This only creates the `.Transport` object; it doesn't begin the |