txtorcon.socks Module

SOCKS5 Errors

SocksError

class txtorcon.socks.SocksError(message='', code=None)

Bases: exceptions.Exception

message = ''
code = None

GeneralServerFailureError

class txtorcon.socks.GeneralServerFailureError(message='', code=None)

Bases: txtorcon.socks.SocksError

code = 1
message = 'general SOCKS server failure'

ConnectionNotAllowedError

class txtorcon.socks.ConnectionNotAllowedError(message='', code=None)

Bases: txtorcon.socks.SocksError

code = 2
message = 'connection not allowed by ruleset'

NetworkUnreachableError

class txtorcon.socks.NetworkUnreachableError(message='', code=None)

Bases: txtorcon.socks.SocksError

code = 3
message = 'Network unreachable'

HostUnreachableError

class txtorcon.socks.HostUnreachableError(message='', code=None)

Bases: txtorcon.socks.SocksError

code = 4
message = 'Host unreachable'

ConnectionRefusedError

class txtorcon.socks.ConnectionRefusedError(message='', code=None)

Bases: txtorcon.socks.SocksError

code = 5
message = 'Connection refused'

TtlExpiredError

class txtorcon.socks.TtlExpiredError(message='', code=None)

Bases: txtorcon.socks.SocksError

code = 6
message = 'TTL expired'

CommandNotSupportedError

class txtorcon.socks.CommandNotSupportedError(message='', code=None)

Bases: txtorcon.socks.SocksError

code = 7
message = 'Command not supported'

AddressTypeNotSupportedError

class txtorcon.socks.AddressTypeNotSupportedError(message='', code=None)

Bases: txtorcon.socks.SocksError

code = 8
message = 'Address type not supported'

Note

The following sections present low-level APIs. If you are able to work with txtorcon.Tor‘s corresponding high-level APIs, you should do so.

resolve

txtorcon.socks.resolve(*args, **kwargs)

This is easier to use via txtorcon.Tor.dns_resolve()

Parameters:
  • tor_endpoint – the Tor SOCKS endpoint to use.
  • hostname – the hostname to look up.

resolve_ptr

txtorcon.socks.resolve_ptr(*args, **kwargs)

This is easier to use via txtorcon.Tor.dns_resolve_ptr()

Parameters:
  • tor_endpoint – the Tor SOCKS endpoint to use.
  • ip – the IP address to look up.

TorSocksEndpoint

class txtorcon.socks.TorSocksEndpoint(socks_endpoint, host, port, tls=False)

Bases: object

Represents an endpoint which will talk to a Tor SOCKS port.

These should usually not be instantiated directly, instead use txtorcon.TorConfig.socks_endpoint().

connect(*args, **kwargs)