This file is indexed.

/usr/share/pyshared/txsocksx/http.py is in python-txsocksx 1.13.0.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Copyright (c) Aaron Gallagher <_@habnab.it>
# See COPYING for details.

"""``twisted.web.client`` adapters for SOCKS4/4a and SOCKS5 connections.

This requires Twisted 12.1 or greater to use.

"""


from twisted.web.client import Agent, SchemeNotSupported

from txsocksx.client import SOCKS4ClientEndpoint, SOCKS5ClientEndpoint
from txsocksx.tls import TLSWrapClientEndpoint


class _SOCKSAgent(Agent):
    endpointFactory = None
    _tlsWrapper = TLSWrapClientEndpoint

    def __init__(self, *a, **kw):
        self.proxyEndpoint = kw.pop('proxyEndpoint')
        self.endpointArgs = kw.pop('endpointArgs', {})
        super(_SOCKSAgent, self).__init__(*a, **kw)

    def _getEndpoint(self, scheme, host, port):
        if scheme not in ('http', 'https'):
            raise SchemeNotSupported('unsupported scheme', scheme)
        endpoint = self.endpointFactory(
            host, port, self.proxyEndpoint, **self.endpointArgs)
        if scheme == 'https':
            endpoint = self._tlsWrapper(
                self._wrapContextFactory(host, port), endpoint)
        return endpoint

class SOCKS4Agent(_SOCKSAgent):
    """An `Agent`__ which connects over SOCKS4.

    See |SOCKS5Agent| for details.

    __ http://twistedmatrix.com/documents/current/api/twisted.web.client.Agent.html
    .. |SOCKS5Agent| replace:: ``SOCKS5Agent``

    """

    endpointFactory = SOCKS4ClientEndpoint

class SOCKS5Agent(_SOCKSAgent):
    """An ``Agent`` which connects over SOCKS5.

    :param proxyEndpoint: The same as *proxyEndpoint* for
        |SOCKS5ClientEndpoint|: the endpoint of the SOCKS5 proxy server. This
        argument must be passed as a keyword argument.
    :param endpointArgs: A dict of keyword arguments which will be passed when
        constructing the |SOCKS5ClientEndpoint|. For example, this could be
        ``{'methods': {'anonymous': ()}}``.

    The rest of the parameters, methods, and overall behavior is identical to
    `Agent`__. The ``connectTimeout`` and ``bindAddress`` arguments will be
    ignored and should be specified when constructing the *proxyEndpoint*.

    __ http://twistedmatrix.com/documents/current/api/twisted.web.client.Agent.html
    .. |SOCKS5ClientEndpoint| replace:: ``SOCKS5ClientEndpoint``

    """

    endpointFactory = SOCKS5ClientEndpoint