1 |
On Thu, 12 Jan 2017 09:36:36 -0800 |
2 |
Zac Medico <zmedico@g.o> wrote: |
3 |
|
4 |
> Use the idna codec to decode the destination address that is read |
5 |
> from the client. This fixes a "TypeError: must be str, not bytes" |
6 |
> exception raised from getaddrinfo with Python 3.4.5. |
7 |
> |
8 |
> X-Gentoo-Bug: 604474 |
9 |
> X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=604474 |
10 |
> --- |
11 |
> bin/socks5-server.py | 5 +++++ |
12 |
> 1 file changed, 5 insertions(+) |
13 |
> |
14 |
> diff --git a/bin/socks5-server.py b/bin/socks5-server.py |
15 |
> index cfe3ece..d46cf53 100644 |
16 |
> --- a/bin/socks5-server.py |
17 |
> +++ b/bin/socks5-server.py |
18 |
> @@ -83,6 +83,11 @@ class Socks5Server(object): |
19 |
> data = yield from |
20 |
> reader.readexactly(1) addr_len, = struct.unpack('!B', data) |
21 |
> addr = yield from |
22 |
> reader.readexactly(addr_len) |
23 |
> + try: |
24 |
> + addr = addr.decode('idna') |
25 |
> + except UnicodeDecodeError: |
26 |
> + rpl = 0x04 # host |
27 |
> unreachable + |
28 |
> elif atyp == 0x04: # IPv6 |
29 |
> data = yield from |
30 |
> reader.readexactly(16) addr = socket.inet_ntop(socket.AF_INET6, data) |
31 |
|
32 |
|
33 |
looks good |
34 |
-- |
35 |
Brian Dolbec <dolsen> |