* Re: [gentoo-portage-dev] [PATCH v2] Support escaping network-sandbox through SOCKSv5 proxy
@ 2015-01-25 21:47 99% ` Zac Medico
0 siblings, 0 replies; 1+ results
From: Zac Medico @ 2015-01-25 21:47 UTC (permalink / raw
To: gentoo-portage-dev
On 01/25/2015 06:00 AM, Michał Górny wrote:
> diff --git a/bin/socks5-server.py b/bin/socks5-server.py
> new file mode 100644
> index 0000000..c079018
> --- /dev/null
> +++ b/bin/socks5-server.py
> @@ -0,0 +1,218 @@
> +#!/usr/bin/env python
> +# SOCKSv5 proxy server for network-sandbox
> +# Copyright 2015 Gentoo Foundation
> +# Distributed under the terms of the GNU General Public License v2
> +
> +import asyncore
> +import errno
> +import socket
> +import struct
> +import sys
> +
> +
> +class ProxyConnection(asyncore.dispatcher_with_send):
> + _addr = None
> + _connected = False
> + _family = socket.AF_INET
> + _proxy_conn = None
> +
> + def __init__(self, proxy_conn):
> + self._proxy_conn = proxy_conn
> + asyncore.dispatcher_with_send.__init__(self)
> + self.create_socket(self._family, socket.SOCK_STREAM)
> +
> + def start_connection(self, host, port):
> + try:
> + self.connect((host, port))
> + except:
> + self.handle_error()
> +
> + def handle_read(self):
> + buf = self.recv(4096)
> + self._proxy_conn.send(buf)
The self.recv calls should probably handle BlockingIOError, since the
docs say it can be raised "even though select.select() or select.poll()
has reported the socket ready for reading".
--
Thanks,
Zac
^ permalink raw reply [relevance 99%]
Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2015-01-25 14:00 [gentoo-portage-dev] [PATCH v2] Support escaping network-sandbox through SOCKSv5 proxy Michał Górny
2015-01-25 21:47 99% ` Zac Medico
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox