Stuff

Interesting and not so interesting stuff

Twunnel: A HTTP/SOCKS5 Tunnel for Twisted

Twunnel is a HTTP/SOCKS5 tunnel for Twisted.

Twunnel supports:

  • HTTP
  • HTTP + Basic authentication
  • SOCKS5

The Twunnel project page: https://github.com/jvansteirteghem/twunnel

Examples

1
2
3
4
5
6
7
8
9
10
import twunnel

protocolFactory = ..

configuration = \
{
}

tunnel = twunnel.Tunnel(configuration)
tunnel.connect("www.google.com", 80, protocolFactory)
1
2
3
4
5
6
7
8
9
10
11
12
13
from twisted.internet import ssl
import twunnel

protocolFactory = ..

configuration = \
{
}

contextFactory = ssl.ClientContextFactory()

tunnel = twunnel.Tunnel(configuration)
tunnel.connect("www.google.com", 443, protocolFactory, contextFactory)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import twunnel

protocolFactory = ..

configuration = \
{
    "PROXY_SERVERS":
    [
        {
            "TYPE": "HTTP",
            "ADDRESS": "127.0.0.1",
            "PORT": 8080,
            "AUTHENTICATION":
            {
                "USERNAME": "1",
                "PASSWORD": "2"
            }
        }
    ]
}

tunnel = twunnel.Tunnel(configuration)
tunnel.connect("www.google.com", 80, protocolFactory)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import twunnel

protocolFactory = ..

configuration = \
{
    "PROXY_SERVERS":
    [
        {
            "TYPE": "SOCKS5",
            "ADDRESS": "127.0.0.1",
            "PORT": 1080
        }
    ]
}

tunnel = twunnel.Tunnel(configuration)
tunnel.connect("www.google.com", 80, protocolFactory)
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
import twunnel

protocolFactory = ..

configuration = \
{
    "PROXY_SERVERS":
    [
        {
            "TYPE": "HTTP",
            "ADDRESS": "127.0.0.1",
            "PORT": 8080,
            "AUTHENTICATION":
            {
                "USERNAME": "1",
                "PASSWORD": "2"
            }
        },
        {
            "TYPE": "SOCKS5",
            "ADDRESS": "127.0.0.1",
            "PORT": 1080
        }
    ]
}

tunnel = twunnel.Tunnel(configuration)
tunnel.connect("www.google.com", 80, protocolFactory)