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
19f653df
Unverified
Commit
19f653df
authored
Aug 29, 2020
by
Brian May
Committed by
GitHub
Aug 29, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #513 from drjbarker/python2-compat
Fix python2 server compatibility
parents
d9e5ccc1
ec5fb683
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
5 deletions
+26
-5
assembler.py
sshuttle/assembler.py
+5
-2
client.py
sshuttle/client.py
+2
-2
server.py
sshuttle/server.py
+19
-1
No files found.
sshuttle/assembler.py
View file @
19f653df
...
@@ -7,8 +7,11 @@ z = zlib.decompressobj()
...
@@ -7,8 +7,11 @@ z = zlib.decompressobj()
while
1
:
while
1
:
name
=
sys
.
stdin
.
readline
()
.
strip
()
name
=
sys
.
stdin
.
readline
()
.
strip
()
if
name
:
if
name
:
# python2 compat: in python2 sys.stdin.readline().strip() -> str
# in python3 sys.stdin.readline().strip() -> bytes
# (see #481)
if
sys
.
version_info
>=
(
3
,
0
):
name
=
name
.
decode
(
"ASCII"
)
name
=
name
.
decode
(
"ASCII"
)
nbytes
=
int
(
sys
.
stdin
.
readline
())
nbytes
=
int
(
sys
.
stdin
.
readline
())
if
verbosity
>=
2
:
if
verbosity
>=
2
:
sys
.
stderr
.
write
(
'server: assembling
%
r (
%
d bytes)
\n
'
sys
.
stderr
.
write
(
'server: assembling
%
r (
%
d bytes)
\n
'
...
...
sshuttle/client.py
View file @
19f653df
...
@@ -299,8 +299,8 @@ class FirewallClient:
...
@@ -299,8 +299,8 @@ class FirewallClient:
raise
Fatal
(
'
%
r expected STARTED, got
%
r'
%
(
self
.
argv
,
line
))
raise
Fatal
(
'
%
r expected STARTED, got
%
r'
%
(
self
.
argv
,
line
))
def
sethostip
(
self
,
hostname
,
ip
):
def
sethostip
(
self
,
hostname
,
ip
):
assert
(
not
re
.
search
(
rb
'[^-
\
w
\
.]'
,
hostname
))
assert
(
not
re
.
search
(
br
'[^-
\
w
\
.]'
,
hostname
))
assert
(
not
re
.
search
(
rb
'[^0-9.]'
,
ip
))
assert
(
not
re
.
search
(
br
'[^0-9.]'
,
ip
))
self
.
pfile
.
write
(
b
'HOST
%
s,
%
s
\n
'
%
(
hostname
,
ip
))
self
.
pfile
.
write
(
b
'HOST
%
s,
%
s
\n
'
%
(
hostname
,
ip
))
self
.
pfile
.
flush
()
self
.
pfile
.
flush
()
...
...
sshuttle/server.py
View file @
19f653df
...
@@ -6,7 +6,25 @@ import time
...
@@ -6,7 +6,25 @@ import time
import
sys
import
sys
import
os
import
os
import
platform
import
platform
from
shutil
import
which
if
sys
.
version_info
>=
(
3
,
0
):
from
shutil
import
which
else
:
# python2 compat: shutil.which is not available so we provide our
# own which command
def
which
(
file
,
mode
=
os
.
F_OK
|
os
.
X_OK
,
path
=
None
):
if
path
is
not
None
:
search_paths
=
[
path
]
elif
"PATH"
in
os
.
environ
:
search_paths
=
os
.
environ
[
"PATH"
]
.
split
(
os
.
pathsep
)
else
:
search_paths
=
os
.
defpath
.
split
(
os
.
pathsep
)
for
p
in
search_paths
:
filepath
=
os
.
path
.
join
(
p
,
file
)
if
os
.
path
.
exists
(
filepath
)
and
os
.
access
(
filepath
,
mode
):
return
filepath
return
None
import
sshuttle.ssnet
as
ssnet
import
sshuttle.ssnet
as
ssnet
import
sshuttle.helpers
as
helpers
import
sshuttle.helpers
as
helpers
...
...
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