Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH v3] Support escaping network-sandbox through SOCKSv5 proxy
Date: Mon, 26 Jan 2015 01:23:43
Message-Id: 54C5971A.5020504@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH v3] Support escaping network-sandbox through SOCKSv5 proxy by "Michał Górny"
1 On 01/25/2015 02:34 PM, Michał Górny wrote:
2 > diff --git a/bin/socks5-server.py b/bin/socks5-server.py
3 > new file mode 100644
4 > index 0000000..45cf76b
5 > --- /dev/null
6 > +++ b/bin/socks5-server.py
7 > @@ -0,0 +1,233 @@
8 > +#!/usr/bin/env python
9 > +# SOCKSv5 proxy server for network-sandbox
10 > +# Copyright 2015 Gentoo Foundation
11 > +# Distributed under the terms of the GNU General Public License v2
12 > +
13 > +import asyncore
14 > +import errno
15 > +import os
16 > +import socket
17 > +import struct
18 > +import sys
19 > +
20 > +
21 > +if sys.hexversion < 0x03000000:
22 > + from io import BlockingIOError
23 > +
24 > +
25 > +class ProxyConnection(asyncore.dispatcher_with_send):
26 > + _addr = None
27 > + _connected = False
28 > + _family = socket.AF_INET
29 > + _proxy_conn = None
30
31 You've defined these as class variables, but they should be instance
32 variables (initialized in the constructor). Since the class is a
33 singleton, it works either way, but it's poor style to use class
34 variables like this.
35
36 > +class ProxyHandler(asyncore.dispatcher_with_send):
37 > + _my_buf = b''
38 > + _my_conn = None
39 > + _my_state = 0
40 > + _my_addr = None
41
42 These class variables should also be changed to instance variables.
43 --
44 Thanks,
45 Zac

Replies