summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvieira <vieira@yubo.be>2017-11-07 22:23:44 +0000
committerBrian May <brian@linuxpenguins.xyz>2017-11-08 16:17:06 +1100
commit112931dd2c19c9b0b25551c36578fab7f50f662b (patch)
treeebedc342ab4926d351595bf0eceadf43405bce3b
parentad676029c754795522553c26b98dd96b1695744a (diff)
Changes methods that do not reference the instance to static methods
-rw-r--r--sshuttle/methods/__init__.py12
-rw-r--r--sshuttle/methods/pf.py31
-rw-r--r--sshuttle/server.py3
-rw-r--r--sshuttle/ssnet.py3
4 files changed, 31 insertions, 18 deletions
diff --git a/sshuttle/methods/__init__.py b/sshuttle/methods/__init__.py
index 6359d19..84a0453 100644
--- a/sshuttle/methods/__init__.py
+++ b/sshuttle/methods/__init__.py
@@ -35,7 +35,8 @@ class BaseMethod(object):
def set_firewall(self, firewall):
self.firewall = firewall
- def get_supported_features(self):
+ @staticmethod
+ def get_supported_features():
result = Features()
result.ipv6 = False
result.udp = False
@@ -43,10 +44,12 @@ class BaseMethod(object):
result.user = False
return result
- def get_tcp_dstip(self, sock):
+ @staticmethod
+ def get_tcp_dstip(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')
data, srcip = udp_listener.recvfrom(bufsize)
return (srcip, None, data)
@@ -77,7 +80,8 @@ class BaseMethod(object):
def restore_firewall(self, port, family, udp, user):
raise NotImplementedError()
- def firewall_command(self, line):
+ @staticmethod
+ def firewall_command(line):
return False
diff --git a/sshuttle/methods/pf.py b/sshuttle/methods/pf.py
index 2c0e575..1716e06 100644
--- a/sshuttle/methods/pf.py
+++ b/sshuttle/methods/pf.py
@@ -35,11 +35,11 @@ class Generic(object):
class pf_addr(Structure):
class _pfa(Union):
- _fields_ = [("v4", c_uint32), # struct in_addr
- ("v6", c_uint32 * 4), # struct in6_addr
- ("addr8", c_uint8 * 16),
- ("addr16", c_uint16 * 8),
- ("addr32", c_uint32 * 4)]
+ _fields_ = [("v4", c_uint32), # struct in_addr
+ ("v6", c_uint32 * 4), # struct in6_addr
+ ("addr8", c_uint8 * 16),
+ ("addr16", c_uint16 * 8),
+ ("addr32", c_uint32 * 4)]
_fields_ = [("pfa", _pfa)]
_anonymous_ = ("pfa",)
@@ -66,7 +66,8 @@ class Generic(object):
pfctl('-e')
_pf_context['started_by_sshuttle'] += 1
- def disable(self, anchor):
+ @staticmethod
+ def disable(anchor):
pfctl('-a %s -F all' % anchor)
if _pf_context['started_by_sshuttle'] == 1:
pfctl('-d')
@@ -98,11 +99,13 @@ class Generic(object):
port = socket.ntohs(self._get_natlook_port(pnl.rdxport))
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.dxport = socket.htons(dst_port)
- def _get_natlook_port(self, xport):
+ @staticmethod
+ def _get_natlook_port(xport):
return xport
def add_anchors(self, anchor, status=None):
@@ -129,18 +132,22 @@ class Generic(object):
'I', self.PF_CHANGE_ADD_TAIL), 4) # action = PF_CHANGE_ADD_TAIL
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'
- def _lo_addr(self, family):
+ @staticmethod
+ def _lo_addr(family):
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)
debug3("rules:\n" + rules.decode("ASCII"))
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]
diff --git a/sshuttle/server.py b/sshuttle/server.py
index a3a38cd..e40e76b 100644
--- a/sshuttle/server.py
+++ b/sshuttle/server.py
@@ -175,7 +175,8 @@ class DnsProxy(Handler):
self.to_nameserver = self._addrinfo(peer, port)
self.try_send()
- def _addrinfo(self, peer, port):
+ @staticmethod
+ def _addrinfo(peer, port):
if int(port) == 0:
port = 53
family, _, _, _, sockaddr = socket.getaddrinfo(peer, port)[0]
diff --git a/sshuttle/ssnet.py b/sshuttle/ssnet.py
index 5c3639c..f506d6a 100644
--- a/sshuttle/ssnet.py
+++ b/sshuttle/ssnet.py
@@ -200,7 +200,8 @@ class SockWrapper:
_, e = sys.exc_info()[:2]
self.seterr('nowrite: %s' % e)
- def too_full(self):
+ @staticmethod
+ def too_full():
return False # fullness is determined by the socket's select() state
def uwrite(self, buf):