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
112931dd
Commit
112931dd
authored
Nov 07, 2017
by
vieira
Committed by
Brian May
Nov 08, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes methods that do not reference the instance to static methods
parent
ad676029
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
18 deletions
+31
-18
__init__.py
sshuttle/methods/__init__.py
+8
-4
pf.py
sshuttle/methods/pf.py
+19
-12
server.py
sshuttle/server.py
+2
-1
ssnet.py
sshuttle/ssnet.py
+2
-1
No files found.
sshuttle/methods/__init__.py
View file @
112931dd
...
@@ -35,7 +35,8 @@ class BaseMethod(object):
...
@@ -35,7 +35,8 @@ class BaseMethod(object):
def
set_firewall
(
self
,
firewall
):
def
set_firewall
(
self
,
firewall
):
self
.
firewall
=
firewall
self
.
firewall
=
firewall
def
get_supported_features
(
self
):
@
staticmethod
def
get_supported_features
():
result
=
Features
()
result
=
Features
()
result
.
ipv6
=
False
result
.
ipv6
=
False
result
.
udp
=
False
result
.
udp
=
False
...
@@ -43,10 +44,12 @@ class BaseMethod(object):
...
@@ -43,10 +44,12 @@ class BaseMethod(object):
result
.
user
=
False
result
.
user
=
False
return
result
return
result
def
get_tcp_dstip
(
self
,
sock
):
@
staticmethod
def
get_tcp_dstip
(
sock
):
return
original_dst
(
sock
)
return
original_dst
(
sock
)
def
recv_udp
(
self
,
udp_listener
,
bufsize
):
@
staticmethod
def
recv_udp
(
udp_listener
,
bufsize
):
debug3
(
'Accept UDP using recvfrom.
\n
'
)
debug3
(
'Accept UDP using recvfrom.
\n
'
)
data
,
srcip
=
udp_listener
.
recvfrom
(
bufsize
)
data
,
srcip
=
udp_listener
.
recvfrom
(
bufsize
)
return
(
srcip
,
None
,
data
)
return
(
srcip
,
None
,
data
)
...
@@ -77,7 +80,8 @@ class BaseMethod(object):
...
@@ -77,7 +80,8 @@ class BaseMethod(object):
def
restore_firewall
(
self
,
port
,
family
,
udp
,
user
):
def
restore_firewall
(
self
,
port
,
family
,
udp
,
user
):
raise
NotImplementedError
()
raise
NotImplementedError
()
def
firewall_command
(
self
,
line
):
@
staticmethod
def
firewall_command
(
line
):
return
False
return
False
...
...
sshuttle/methods/pf.py
View file @
112931dd
...
@@ -66,7 +66,8 @@ class Generic(object):
...
@@ -66,7 +66,8 @@ class Generic(object):
pfctl
(
'-e'
)
pfctl
(
'-e'
)
_pf_context
[
'started_by_sshuttle'
]
+=
1
_pf_context
[
'started_by_sshuttle'
]
+=
1
def
disable
(
self
,
anchor
):
@
staticmethod
def
disable
(
anchor
):
pfctl
(
'-a
%
s -F all'
%
anchor
)
pfctl
(
'-a
%
s -F all'
%
anchor
)
if
_pf_context
[
'started_by_sshuttle'
]
==
1
:
if
_pf_context
[
'started_by_sshuttle'
]
==
1
:
pfctl
(
'-d'
)
pfctl
(
'-d'
)
...
@@ -98,11 +99,13 @@ class Generic(object):
...
@@ -98,11 +99,13 @@ class Generic(object):
port
=
socket
.
ntohs
(
self
.
_get_natlook_port
(
pnl
.
rdxport
))
port
=
socket
.
ntohs
(
self
.
_get_natlook_port
(
pnl
.
rdxport
))
return
(
ip
,
port
)
return
(
ip
,
port
)
def
_add_natlook_ports
(
self
,
pnl
,
src_port
,
dst_port
):
@
staticmethod
def
_add_natlook_ports
(
pnl
,
src_port
,
dst_port
):
pnl
.
sxport
=
socket
.
htons
(
src_port
)
pnl
.
sxport
=
socket
.
htons
(
src_port
)
pnl
.
dxport
=
socket
.
htons
(
dst_port
)
pnl
.
dxport
=
socket
.
htons
(
dst_port
)
def
_get_natlook_port
(
self
,
xport
):
@
staticmethod
def
_get_natlook_port
(
xport
):
return
xport
return
xport
def
add_anchors
(
self
,
anchor
,
status
=
None
):
def
add_anchors
(
self
,
anchor
,
status
=
None
):
...
@@ -129,18 +132,22 @@ class Generic(object):
...
@@ -129,18 +132,22 @@ class Generic(object):
'I'
,
self
.
PF_CHANGE_ADD_TAIL
),
4
)
# action = PF_CHANGE_ADD_TAIL
'I'
,
self
.
PF_CHANGE_ADD_TAIL
),
4
)
# action = PF_CHANGE_ADD_TAIL
ioctl
(
pf_get_dev
(),
pf
.
DIOCCHANGERULE
,
pr
)
ioctl
(
pf_get_dev
(),
pf
.
DIOCCHANGERULE
,
pr
)
def
_inet_version
(
self
,
family
):
@
staticmethod
def
_inet_version
(
family
):
return
b
'inet'
if
family
==
socket
.
AF_INET
else
b
'inet6'
return
b
'inet'
if
family
==
socket
.
AF_INET
else
b
'inet6'
def
_lo_addr
(
self
,
family
):
@
staticmethod
def
_lo_addr
(
family
):
return
b
'127.0.0.1'
if
family
==
socket
.
AF_INET
else
b
'::1'
return
b
'127.0.0.1'
if
family
==
socket
.
AF_INET
else
b
'::1'
def
add_rules
(
self
,
anchor
,
rules
):
@
staticmethod
def
add_rules
(
anchor
,
rules
):
assert
isinstance
(
rules
,
bytes
)
assert
isinstance
(
rules
,
bytes
)
debug3
(
"rules:
\n
"
+
rules
.
decode
(
"ASCII"
))
debug3
(
"rules:
\n
"
+
rules
.
decode
(
"ASCII"
))
pfctl
(
'-a
%
s -f /dev/stdin'
%
anchor
,
rules
)
pfctl
(
'-a
%
s -f /dev/stdin'
%
anchor
,
rules
)
def
has_skip_loopback
(
self
):
@
staticmethod
def
has_skip_loopback
():
return
b
'skip'
in
pfctl
(
'-s Interfaces -i lo -v'
)[
0
]
return
b
'skip'
in
pfctl
(
'-s Interfaces -i lo -v'
)[
0
]
...
...
sshuttle/server.py
View file @
112931dd
...
@@ -175,7 +175,8 @@ class DnsProxy(Handler):
...
@@ -175,7 +175,8 @@ class DnsProxy(Handler):
self
.
to_nameserver
=
self
.
_addrinfo
(
peer
,
port
)
self
.
to_nameserver
=
self
.
_addrinfo
(
peer
,
port
)
self
.
try_send
()
self
.
try_send
()
def
_addrinfo
(
self
,
peer
,
port
):
@
staticmethod
def
_addrinfo
(
peer
,
port
):
if
int
(
port
)
==
0
:
if
int
(
port
)
==
0
:
port
=
53
port
=
53
family
,
_
,
_
,
_
,
sockaddr
=
socket
.
getaddrinfo
(
peer
,
port
)[
0
]
family
,
_
,
_
,
_
,
sockaddr
=
socket
.
getaddrinfo
(
peer
,
port
)[
0
]
...
...
sshuttle/ssnet.py
View file @
112931dd
...
@@ -200,7 +200,8 @@ class SockWrapper:
...
@@ -200,7 +200,8 @@ class SockWrapper:
_
,
e
=
sys
.
exc_info
()[:
2
]
_
,
e
=
sys
.
exc_info
()[:
2
]
self
.
seterr
(
'nowrite:
%
s'
%
e
)
self
.
seterr
(
'nowrite:
%
s'
%
e
)
def
too_full
(
self
):
@
staticmethod
def
too_full
():
return
False
# fullness is determined by the socket's select() state
return
False
# fullness is determined by the socket's select() state
def
uwrite
(
self
,
buf
):
def
uwrite
(
self
,
buf
):
...
...
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