|
17 | 17 |
|
18 | 18 |
|
19 | 19 | def _ipmatch(ipstr):
|
20 |
| - if ipstr == 'default': |
21 |
| - ipstr = '0.0.0.0/0' |
22 |
| - m = re.match(r'^(\d+(\.\d+(\.\d+(\.\d+)?)?)?)(?:/(\d+))?$', ipstr) |
| 20 | + if ipstr == b'default': |
| 21 | + ipstr = b'0.0.0.0/0' |
| 22 | + m = re.match(b'^(\d+(\.\d+(\.\d+(\.\d+)?)?)?)(?:/(\d+))?$', ipstr) |
23 | 23 | if m:
|
24 | 24 | g = m.groups()
|
25 | 25 | ips = g[0]
|
26 | 26 | width = int(g[4] or 32)
|
27 | 27 | if g[1] is None:
|
28 |
| - ips += '.0.0.0' |
| 28 | + ips += b'.0.0.0' |
29 | 29 | width = min(width, 8)
|
30 | 30 | elif g[2] is None:
|
31 |
| - ips += '.0.0' |
| 31 | + ips += b'.0.0' |
32 | 32 | width = min(width, 16)
|
33 | 33 | elif g[3] is None:
|
34 |
| - ips += '.0' |
| 34 | + ips += b'.0' |
35 | 35 | width = min(width, 24)
|
| 36 | + ips = ips.decode("ASCII") |
36 | 37 | return (struct.unpack('!I', socket.inet_aton(ips))[0], width)
|
37 | 38 |
|
38 | 39 |
|
@@ -61,7 +62,7 @@ def _list_routes():
|
61 | 62 | p = ssubprocess.Popen(argv, stdout=ssubprocess.PIPE)
|
62 | 63 | routes = []
|
63 | 64 | for line in p.stdout:
|
64 |
| - cols = re.split(r'\s+', line) |
| 65 | + cols = re.split(b'\s+', line) |
65 | 66 | ipw = _ipmatch(cols[0])
|
66 | 67 | if not ipw:
|
67 | 68 | continue # some lines won't be parseable; never mind
|
@@ -239,9 +240,9 @@ def main(latency_control):
|
239 | 240 | socket.fromfd(sys.stdout.fileno(),
|
240 | 241 | socket.AF_INET, socket.SOCK_STREAM))
|
241 | 242 | handlers.append(mux)
|
242 |
| - routepkt = '' |
| 243 | + routepkt = b'' |
243 | 244 | for r in routes:
|
244 |
| - routepkt += '%d,%s,%d\n' % r |
| 245 | + routepkt += b'%d,%s,%d\n' % (r[0], r[1].encode("ASCII"), r[2]) |
245 | 246 | mux.send(0, ssnet.CMD_ROUTES, routepkt)
|
246 | 247 |
|
247 | 248 | hw = Hostwatch()
|
@@ -270,7 +271,7 @@ def got_host_req(data):
|
270 | 271 | mux.got_host_req = got_host_req
|
271 | 272 |
|
272 | 273 | def new_channel(channel, data):
|
273 |
| - (family, dstip, dstport) = data.split(',', 2) |
| 274 | + (family, dstip, dstport) = data.split(b',', 2) |
274 | 275 | family = int(family)
|
275 | 276 | dstport = int(dstport)
|
276 | 277 | outwrap = ssnet.connect_dst(family, dstip, dstport)
|
|
0 commit comments