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
e63e1213
Commit
e63e1213
authored
Dec 13, 2015
by
Brian May
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Print PF rules used.
Also support multiline debug output better.
parent
2b235331
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
2 deletions
+28
-2
helpers.py
sshuttle/helpers.py
+9
-1
pf.py
sshuttle/methods/pf.py
+2
-1
test_helpers.py
sshuttle/tests/test_helpers.py
+16
-0
test_methods_pf.py
sshuttle/tests/test_methods_pf.py
+1
-0
No files found.
sshuttle/helpers.py
View file @
e63e1213
...
...
@@ -7,8 +7,16 @@ verbose = 0
def
log
(
s
):
global
logprefix
try
:
sys
.
stdout
.
flush
()
if
s
.
find
(
"
\n
"
)
!=
-
1
:
prefix
=
logprefix
s
=
s
.
rstrip
(
"
\n
"
)
for
line
in
s
.
split
(
"
\n
"
):
sys
.
stderr
.
write
(
prefix
+
line
+
"
\n
"
)
prefix
=
"---> "
else
:
sys
.
stderr
.
write
(
logprefix
+
s
)
sys
.
stderr
.
flush
()
except
IOError
:
...
...
sshuttle/methods/pf.py
View file @
e63e1213
...
...
@@ -7,7 +7,7 @@ import subprocess as ssubprocess
from
fcntl
import
ioctl
from
ctypes
import
c_char
,
c_uint8
,
c_uint16
,
c_uint32
,
Union
,
Structure
,
\
sizeof
,
addressof
,
memmove
from
sshuttle.helpers
import
debug1
,
debug2
,
Fatal
,
family_to_string
from
sshuttle.helpers
import
debug1
,
debug2
,
debug3
,
Fatal
,
family_to_string
from
sshuttle.methods
import
BaseMethod
...
...
@@ -215,6 +215,7 @@ class Method(BaseMethod):
rules
=
b
'
\n
'
.
join
(
tables
+
translating_rules
+
filtering_rules
)
\
+
b
'
\n
'
assert
isinstance
(
rules
,
bytes
)
debug3
(
"rules:
\n
"
+
rules
.
decode
(
"ASCII"
))
pf_status
=
pfctl
(
'-s all'
)[
0
]
if
b
'
\n
rdr-anchor "sshuttle" all
\n
'
not
in
pf_status
:
...
...
sshuttle/tests/test_helpers.py
View file @
e63e1213
...
...
@@ -11,12 +11,28 @@ import sshuttle.helpers
@
patch
(
'sshuttle.helpers.sys.stderr'
)
def
test_log
(
mock_stderr
,
mock_stdout
):
sshuttle
.
helpers
.
log
(
"message"
)
sshuttle
.
helpers
.
log
(
"message 1
\n
"
)
sshuttle
.
helpers
.
log
(
"message 2
\n
line2
\n
line3
\n
"
)
sshuttle
.
helpers
.
log
(
"message 3
\n
line2
\n
line3"
)
assert
mock_stdout
.
mock_calls
==
[
call
.
flush
(),
call
.
flush
(),
call
.
flush
(),
call
.
flush
(),
]
assert
mock_stderr
.
mock_calls
==
[
call
.
write
(
'prefix: message'
),
call
.
flush
(),
call
.
write
(
'prefix: message 1
\n
'
),
call
.
flush
(),
call
.
write
(
'prefix: message 2
\n
'
),
call
.
write
(
'---> line2
\n
'
),
call
.
write
(
'---> line3
\n
'
),
call
.
flush
(),
call
.
write
(
'prefix: message 3
\n
'
),
call
.
write
(
'---> line2
\n
'
),
call
.
write
(
'---> line3
\n
'
),
call
.
flush
(),
]
...
...
sshuttle/tests/test_methods_pf.py
View file @
e63e1213
...
...
@@ -104,6 +104,7 @@ def pfctl(args, stdin=None):
return
None
@
patch
(
'sshuttle.helpers.verbose'
,
new
=
3
)
@
patch
(
'sshuttle.methods.pf.sys.platform'
,
'darwin'
)
@
patch
(
'sshuttle.methods.pf.pfctl'
)
@
patch
(
'sshuttle.methods.pf.ioctl'
)
...
...
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