Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sshuttle
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pub
sshuttle
Commits
08bd1dca
Commit
08bd1dca
authored
Jun 06, 2011
by
Brian May
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename TCP specific commands to clarify they are TCP specific.
parent
94566b5e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
16 deletions
+16
-16
client.py
client.py
+1
-1
ssnet.py
ssnet.py
+15
-15
No files found.
client.py
View file @
08bd1dca
...
@@ -214,7 +214,7 @@ def onaccept(listener, mux, handlers):
...
@@ -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
)
...
...
ssnet.py
View file @
08bd1dca
...
@@ -16,10 +16,10 @@ HDR_LEN = 8
...
@@ -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 = {
...
@@ -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):
...
@@ -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):
...
@@ -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):
...
@@ -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):
...
@@ -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)'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment