From d7d24f956be302e99cea30df83ccbde3437ec4e1 Mon Sep 17 00:00:00 2001
From: vieira <vieira@yubo.be>
Date: Thu, 9 Feb 2017 01:28:53 +0000
Subject: [PATCH] Small refactoring of netstat/iproute parsing

---
 sshuttle/server.py | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/sshuttle/server.py b/sshuttle/server.py
index ab22c19..4f7b67c 100644
--- a/sshuttle/server.py
+++ b/sshuttle/server.py
@@ -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)