1
1
mirror of https://github.com/sshuttle/sshuttle.git synced 2025-05-03 23:54:41 +02:00

Rename TCP specific commands to clarify they are TCP specific.

This commit is contained in:
Brian May 2011-06-06 10:39:50 +10:00
parent 94566b5efc
commit 08bd1dca46
2 changed files with 16 additions and 16 deletions

View File

@ -214,7 +214,7 @@ def onaccept(listener, mux, handlers):
log('warning: too many open channels. Discarded connection.\n') log('warning: too many open channels. Discarded connection.\n')
sock.close() sock.close()
return return
mux.send(chan, ssnet.CMD_CONNECT, '%s,%s' % dstip) mux.send(chan, ssnet.CMD_TCP_CONNECT, '%s,%s' % dstip)
outwrap = MuxWrapper(mux, chan) outwrap = MuxWrapper(mux, chan)
handlers.append(Proxy(SockWrapper(sock, sock), outwrap)) handlers.append(Proxy(SockWrapper(sock, sock), outwrap))
expire_connections(time.time(), mux) expire_connections(time.time(), mux)

View File

@ -16,10 +16,10 @@ HDR_LEN = 8
CMD_EXIT = 0x4200 CMD_EXIT = 0x4200
CMD_PING = 0x4201 CMD_PING = 0x4201
CMD_PONG = 0x4202 CMD_PONG = 0x4202
CMD_CONNECT = 0x4203 CMD_TCP_CONNECT = 0x4203
CMD_STOP_SENDING = 0x4204 CMD_TCP_STOP_SENDING = 0x4204
CMD_EOF = 0x4205 CMD_TCP_EOF = 0x4205
CMD_DATA = 0x4206 CMD_TCP_DATA = 0x4206
CMD_ROUTES = 0x4207 CMD_ROUTES = 0x4207
CMD_HOST_REQ = 0x4208 CMD_HOST_REQ = 0x4208
CMD_HOST_LIST = 0x4209 CMD_HOST_LIST = 0x4209
@ -30,10 +30,10 @@ cmd_to_name = {
CMD_EXIT: 'EXIT', CMD_EXIT: 'EXIT',
CMD_PING: 'PING', CMD_PING: 'PING',
CMD_PONG: 'PONG', CMD_PONG: 'PONG',
CMD_CONNECT: 'CONNECT', CMD_TCP_CONNECT: 'TCP_CONNECT',
CMD_STOP_SENDING: 'STOP_SENDING', CMD_TCP_STOP_SENDING: 'TCP_STOP_SENDING',
CMD_EOF: 'EOF', CMD_TCP_EOF: 'TCP_EOF',
CMD_DATA: 'DATA', CMD_TCP_DATA: 'TCP_DATA',
CMD_ROUTES: 'ROUTES', CMD_ROUTES: 'ROUTES',
CMD_HOST_REQ: 'HOST_REQ', CMD_HOST_REQ: 'HOST_REQ',
CMD_HOST_LIST: 'HOST_LIST', CMD_HOST_LIST: 'HOST_LIST',
@ -374,7 +374,7 @@ class Mux(Handler):
self.fullness = 0 self.fullness = 0
elif cmd == CMD_EXIT: elif cmd == CMD_EXIT:
self.ok = False self.ok = False
elif cmd == CMD_CONNECT: elif cmd == CMD_TCP_CONNECT:
assert(not self.channels.get(channel)) assert(not self.channels.get(channel))
if self.new_channel: if self.new_channel:
self.new_channel(channel, data) self.new_channel(channel, data)
@ -478,13 +478,13 @@ class MuxWrapper(SockWrapper):
def noread(self): def noread(self):
if not self.shut_read: if not self.shut_read:
self.shut_read = True self.shut_read = True
self.mux.send(self.channel, CMD_STOP_SENDING, '') self.mux.send(self.channel, CMD_TCP_STOP_SENDING, '')
self.maybe_close() self.maybe_close()
def nowrite(self): def nowrite(self):
if not self.shut_write: if not self.shut_write:
self.shut_write = True self.shut_write = True
self.mux.send(self.channel, CMD_EOF, '') self.mux.send(self.channel, CMD_TCP_EOF, '')
self.maybe_close() self.maybe_close()
def maybe_close(self): def maybe_close(self):
@ -501,7 +501,7 @@ class MuxWrapper(SockWrapper):
return 0 # too much already enqueued return 0 # too much already enqueued
if len(buf) > 2048: if len(buf) > 2048:
buf = buf[:2048] buf = buf[:2048]
self.mux.send(self.channel, CMD_DATA, buf) self.mux.send(self.channel, CMD_TCP_DATA, buf)
return len(buf) return len(buf)
def uread(self): def uread(self):
@ -511,11 +511,11 @@ class MuxWrapper(SockWrapper):
return None # no data available right now return None # no data available right now
def got_packet(self, cmd, data): def got_packet(self, cmd, data):
if cmd == CMD_EOF: if cmd == CMD_TCP_EOF:
self.noread() self.noread()
elif cmd == CMD_STOP_SENDING: elif cmd == CMD_TCP_STOP_SENDING:
self.nowrite() self.nowrite()
elif cmd == CMD_DATA: elif cmd == CMD_TCP_DATA:
self.buf.append(data) self.buf.append(data)
else: else:
raise Exception('unknown command %d (%d bytes)' raise Exception('unknown command %d (%d bytes)'