1 |
On Sun, 25 Jan 2015 17:23:38 -0800 |
2 |
Zac Medico <zmedico@g.o> wrote: |
3 |
|
4 |
> On 01/25/2015 02:34 PM, Michał Górny wrote: |
5 |
> > diff --git a/bin/socks5-server.py b/bin/socks5-server.py |
6 |
> > new file mode 100644 |
7 |
> > index 0000000..45cf76b |
8 |
> > --- /dev/null |
9 |
> > +++ b/bin/socks5-server.py |
10 |
> > @@ -0,0 +1,233 @@ |
11 |
> > +#!/usr/bin/env python |
12 |
> > +# SOCKSv5 proxy server for network-sandbox |
13 |
> > +# Copyright 2015 Gentoo Foundation |
14 |
> > +# Distributed under the terms of the GNU General Public License v2 |
15 |
> > + |
16 |
> > +import asyncore |
17 |
> > +import errno |
18 |
> > +import os |
19 |
> > +import socket |
20 |
> > +import struct |
21 |
> > +import sys |
22 |
> > + |
23 |
> > + |
24 |
> > +if sys.hexversion < 0x03000000: |
25 |
> > + from io import BlockingIOError |
26 |
> > + |
27 |
> > + |
28 |
> > +class ProxyConnection(asyncore.dispatcher_with_send): |
29 |
> > + _addr = None |
30 |
> > + _connected = False |
31 |
> > + _family = socket.AF_INET |
32 |
> > + _proxy_conn = None |
33 |
> |
34 |
> You've defined these as class variables, but they should be instance |
35 |
> variables (initialized in the constructor). Since the class is a |
36 |
> singleton, it works either way, but it's poor style to use class |
37 |
> variables like this. |
38 |
> |
39 |
> > +class ProxyHandler(asyncore.dispatcher_with_send): |
40 |
> > + _my_buf = b'' |
41 |
> > + _my_conn = None |
42 |
> > + _my_state = 0 |
43 |
> > + _my_addr = None |
44 |
> |
45 |
> These class variables should also be changed to instance variables. |
46 |
|
47 |
Yeah, I meant to ask you the same... Do they need to be class wide |
48 |
(multiple instances refer to the same exact variables) or just instance |
49 |
wide ones. But I hadn't looked it over in enough detail yet. |
50 |
|
51 |
And LOOSE the _my prefix. |
52 |
|
53 |
-- |
54 |
Brian Dolbec <dolsen> |