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
d7d24f95
Commit
d7d24f95
authored
Feb 09, 2017
by
vieira
Committed by
Brian May
Feb 10, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small refactoring of netstat/iproute parsing
parent
809fad53
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
8 deletions
+6
-8
server.py
sshuttle/server.py
+6
-8
No files found.
sshuttle/server.py
View file @
d7d24f95
...
...
@@ -66,23 +66,19 @@ def _shl(n, bits):
def
_route_netstat
(
line
):
cols
=
re
.
split
(
r'\s+'
,
line
.
decode
(
"ASCII"
)
)
cols
=
line
.
split
(
None
)
ipw
=
_ipmatch
(
cols
[
0
])
if
not
ipw
:
return
None
,
None
# some lines won't be parseable; never mind
maskw
=
_ipmatch
(
cols
[
2
])
# linux only
mask
=
_maskbits
(
maskw
)
# returns 32 if maskw is null
return
ipw
,
mask
def
_route_iproute
(
line
):
ipm
=
line
.
decode
(
"ASCII"
)
.
split
(
None
,
1
)[
0
]
if
ipm
==
'default'
:
ipm
=
line
.
split
(
None
,
1
)[
0
]
if
'/'
not
in
ipm
:
return
None
,
None
ip
,
mask
=
ipm
.
split
(
'/'
)
ipw
=
_ipmatch
(
ip
)
if
not
ipw
:
return
None
,
None
# some lines won't be parseable; never mind
return
ipw
,
int
(
mask
)
...
...
@@ -95,7 +91,9 @@ def _list_routes(argv, extract_route):
p
=
ssubprocess
.
Popen
(
argv
,
stdout
=
ssubprocess
.
PIPE
,
env
=
env
)
routes
=
[]
for
line
in
p
.
stdout
:
ipw
,
mask
=
extract_route
(
line
)
if
not
line
.
strip
():
continue
ipw
,
mask
=
extract_route
(
line
.
decode
(
"ASCII"
))
if
not
ipw
:
continue
width
=
min
(
ipw
[
1
],
mask
)
...
...
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