torctrlgo

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthData

type AuthData struct {
	Password   string
	CookieData []byte
}

AuthData declares the data passed for authentication.

  • Password may be declared for AUTH_HASHEDPASSWORD authentication.
  • CookieData may be declared to pass a cookie-file's contents manually. If CookieData is nil, AUTH_COOKIE and AUTH_SAFECOOKIE authentication will read the first available cookie-file's contents automatically.

type AuthMethod

type AuthMethod string

AuthMethod declares the way of authentication on the ControlPort connection.

const (
	// AUTH_NULL No authentication is required.
	//
	// To prevent cross-protocol attacks, calling authenticate is still required, even when all methods are disabled.
	AUTH_NULL AuthMethod = "NULL"
	// AUTH_HASHEDPASSWORD A password needs to be presented.
	//
	// The password's hash is defined in the configuration.
	AUTH_HASHEDPASSWORD AuthMethod = "HASHEDPASSWORD"
	// AUTH_COOKIE A cookie-file's contents must be provided.
	//
	// The Controller needs to prove its privileges to read one of them.
	AUTH_COOKIE AuthMethod = "COOKIE"
	// AUTH_SAFECOOKIE A Challenge must be completed
	//
	// The Controller needs to prove its knowledge of a cookie-file, similar to AUTH_COOKIE.
	AUTH_SAFECOOKIE AuthMethod = "SAFECOOKIE"
)

type Cmd

type Cmd string

Cmd represents a direct command on the ControlPort protocol

Usage of Cmd outside the module itself will be mostly obsolete once all commands are implemented on the LowController API.

const (
	CMD_SETCONF                  Cmd = "SETCONF"
	CMD_RESETCONF                Cmd = "RESETCONF"
	CMD_GETCONF                  Cmd = "GETCONF"
	CMD_SETEVENTS                Cmd = "SETEVENTS"
	CMD_AUTHENTICATE             Cmd = "AUTHENTICATE"
	CMD_SAVECONF                 Cmd = "SAVECONF"
	CMD_SIGNAL                   Cmd = "SIGNAL"
	CMD_MAPADDRESS               Cmd = "MAPADDRESS"
	CMD_GETINFO                  Cmd = "GETINFO"
	CMD_EXTENDCIRCUIT            Cmd = "EXTENDCIRCUIT"
	CMD_SETCIRCUITPURPOSE        Cmd = "SETCIRCUITPURPOSE"
	CMD_SETROUTERPURPOSE         Cmd = "SETROUTERPURPOSE"
	CMD_ATTACHSTREAM             Cmd = "ATTACHSTREAM"
	CMD_POSTDESCRIPTOR           Cmd = "POSTDESCRIPTOR"
	CMD_REDIRECTSTREAM           Cmd = "REDIRECTSTREAM"
	CMD_CLOSESTREAM              Cmd = "CLOSESTREAM"
	CMD_CLOSECIRCUIT             Cmd = "CLOSECIRCUIT"
	CMD_QUIT                     Cmd = "QUIT"
	CMD_USEFEATURE               Cmd = "USEFEATURE"
	CMD_RESOLVE                  Cmd = "RESOLVE"
	CMD_PROTOCOLINFO             Cmd = "PROTOCOLINFO"
	CMD_LOADCONF                 Cmd = "LOADCONF"
	CMD_TAKEOWNERSHIP            Cmd = "TAKEOWNERSHIP"
	CMD_AUTHCHALLENGE            Cmd = "AUTHCHALLENGE"
	CMD_DROPGUARDS               Cmd = "DROPGUARDS"
	CMD_HSFETCH                  Cmd = "HSFETCH"
	CMD_ADD_ONION                Cmd = "ADD_ONION"
	CMD_DEL_ONION                Cmd = "DEL_ONION"
	CMD_HSPOST                   Cmd = "HSPOST"
	CMD_ONION_CLIENT_AUTH_ADD    Cmd = "ONION_CLIENT_AUTH_ADD"
	CMD_ONION_CLIENT_AUTH_REMOVE Cmd = "ONION_CLIENT_AUTH_REMOVE"
	CMD_ONION_CLIENT_AUTH_VIEW   Cmd = "ONION_CLIENT_AUTH_VIEW"
	CMD_DROPOWNERSHIP            Cmd = "DROPOWNERSHIP"
	CMD_DROPTIMEOUTS             Cmd = "DROPTIMEOUTS"
)

type Controller

type Controller struct {
	TorVersion    string
	TorRCPath     string
	VersionStatus string
	LowController *LowController
	// contains filtered or unexported fields
}

Controller provides a high-level API for communication over TOR's ControlPort protocol.

Certain functions may declare high concurrency-safety.

func NewController

func NewController() *Controller

func (*Controller) Authenticate

func (c *Controller) Authenticate(method AuthMethod, data AuthData) error

Authenticate the connection using the given AuthMethod and (if required) AuthData

This function is fully thread-safe, although there shouldn't be any scenario, where that's applicable

func (*Controller) HSDescAvailable

func (c *Controller) HSDescAvailable(addr string) (bool, error)

HSDescAvailable checks for the availability of the given hidden service on the hash-ring. This usually means, that the hidden service is reachable.

This function is fully thread-safe

func (*Controller) NewIdentity

func (c *Controller) NewIdentity() error

NewIdentity switches to new circuits, so that new requests don't share any circuits with old ones.

This function is fully thread-safe, although TOR might rate-limit its usage.

func (*Controller) Open

func (c *Controller) Open(addr string) error

func (*Controller) RegisterEvent

func (c *Controller) RegisterEvent(code EventCode, callback func([]ReplyLine)) error

RegisterEvent sets the callback function for the given event.

This function is fully thread-safe.

func (*Controller) UnregisterEvent

func (c *Controller) UnregisterEvent(code EventCode) error

UnregisterEvent removes the set callback function for the given event.

This function is fully thread-safe.

type ErrAuthenticationRequired

type ErrAuthenticationRequired error

type ErrBadAuthentication

type ErrBadAuthentication error

type ErrInternal

type ErrInternal error

type ErrInvalidConfigurationValue

type ErrInvalidConfigurationValue error

type ErrInvalidDescriptor

type ErrInvalidDescriptor error

type ErrOperationUnnecessary

type ErrOperationUnnecessary error

type ErrProtocolSyntaxError

type ErrProtocolSyntaxError error

type ErrResourceExhausted

type ErrResourceExhausted error

type ErrSyntaxCommandArgument

type ErrSyntaxCommandArgument error

type ErrUnimplementedCommand

type ErrUnimplementedCommand error

type ErrUnknown

type ErrUnknown error

type ErrUnmanagedEntity

type ErrUnmanagedEntity error

type ErrUnrecognizedCommand

type ErrUnrecognizedCommand error

type ErrUnrecognizedCommandArgument

type ErrUnrecognizedCommandArgument error

type ErrUnrecognizedEntity

type ErrUnrecognizedEntity error

type ErrUnspecified

type ErrUnspecified error

type EventCode

type EventCode string
const (
	EVENT_CIRC               EventCode = "CIRC"
	EVENT_STREAM             EventCode = "STREAM"
	EVENT_ORCONN             EventCode = "ORCONN"
	EVENT_BW                 EventCode = "BW"
	EVENT_DEBUG              EventCode = "DEBUG"
	EVENT_INFO               EventCode = "INFO"
	EVENT_NOTICE             EventCode = "NOTICE"
	EVENT_WARN               EventCode = "WARN"
	EVENT_ERR                EventCode = "ERR"
	EVENT_NEWDESC            EventCode = "NEWDESC"
	EVENT_ADDRMAP            EventCode = "ADDRMAP"
	EVENT_AUTHDIR_NEWDESCS   EventCode = "AUTHDIR_NEWDESCS"
	EVENT_DESCCHANGED        EventCode = "DESCCHANGED"
	EVENT_STATUS_GENERAL     EventCode = "STATUS_GENERAL"
	EVENT_STATUS_CLIENT      EventCode = "STATUS_CLIENT"
	EVENT_STATUS_SERVER      EventCode = "STATUS_SERVER"
	EVENT_GUARD              EventCode = "GUARD"
	EVENT_NS                 EventCode = "NS"
	EVENT_STREAM_BW          EventCode = "STREAM_BW"
	EVENT_CLIENTS_SEEN       EventCode = "CLIENTS_SEEN"
	EVENT_NEWCONSENSUS       EventCode = "NEWCONSENSUS"
	EVENT_BUILDTIMEOUT_SET   EventCode = "BUILDTIMEOUT_SET"
	EVENT_SIGNAL             EventCode = "SIGNAL"
	EVENT_CONF_CHANGED       EventCode = "CONF_CHANGED"
	EVENT_CIRC_MINOR         EventCode = "CIRC_MINOR"
	EVENT_TRANSPORT_LAUNCHED EventCode = "TRANSPORT_LAUNCHED"
	EVENT_CONN_BW            EventCode = "CONN_BW"
	EVENT_CIRC_BW            EventCode = "CIRC_BW"
	EVENT_CELL_STATS         EventCode = "CELL_STATS"
	EVENT_TB_EMPTY           EventCode = "TB_EMPTY"
	EVENT_HS_DESC            EventCode = "HS_DESC"
	EVENT_HS_DESC_CONTENT    EventCode = "HS_DESC_CONTENT"
	EVENT_NETWORK_LIVENESS   EventCode = "NETWORK_LIVENESS"
	EVENT_PT_LOG             EventCode = "PT_LOG"
	EVENT_PT_STATUS          EventCode = "PT_STATUS"
)

type LowController

type LowController struct {
	NotificationChan chan []ReplyLine
	// contains filtered or unexported fields
}

LowController provides a low-level API for communication over TOR's ControlPort protocol.

All exported functions are concurrency-safe. Since TOR processes commands sequentially,

func NewLowController

func NewLowController() *LowController

func (*LowController) AuthChallenge

func (c *LowController) AuthChallenge(chllngType string, clientNonce []byte) (serverHash []byte, serverNonce []byte, err error)

func (*LowController) AuthenticateBytes

func (c *LowController) AuthenticateBytes(data []byte) error

func (*LowController) AuthenticateNull

func (c *LowController) AuthenticateNull() error

func (*LowController) AuthenticateString

func (c *LowController) AuthenticateString(data string) error

func (*LowController) GetConf

func (c *LowController) GetConf(names []string) (map[string]string, error)

func (*LowController) GetInfo

func (c *LowController) GetInfo(keywords []string) (map[string]string, error)

func (*LowController) GetProtocolInfo

func (c *LowController) GetProtocolInfo(versions []string) (*ProtocolInfo, error)

func (*LowController) HSFetch

func (c *LowController) HSFetch(addressOrDescriptor string, servers []string) error

func (*LowController) Open

func (c *LowController) Open(addr string) (err error)

func (*LowController) Quit

func (c *LowController) Quit() error

func (*LowController) ResetConf

func (c *LowController) ResetConf(confs map[string]string) error

func (*LowController) Resolve

func (c *LowController) Resolve(addr string, reverse bool) error

func (*LowController) SaveConf

func (c *LowController) SaveConf(force bool) error

func (*LowController) SendSignal

func (c *LowController) SendSignal(signal Signal) error

func (*LowController) SetConf

func (c *LowController) SetConf(confs map[string]string) error

func (*LowController) SetEvents

func (c *LowController) SetEvents(codes []string) error

type ProtocolInfo

type ProtocolInfo struct {
	PIVERSION   string
	TorVersion  string
	AuthMethods []string
	CookieFiles []string
}

type ReplyLine

type ReplyLine struct {
	StatusCode uint16
	Separator  byte
	Line       []byte
}

type Signal

type Signal string
const (
	SIGNAL_RELOAD        Signal = "RELOAD"
	SIGNAL_SHUTDOWN      Signal = "SHUTDOWN"
	SIGNAL_DUMP          Signal = "DUMP"
	SIGNAL_DEBUG         Signal = "DEBUG"
	SIGNAL_HALT          Signal = "HALT"
	SIGNAL_CLEARDNSCACHE Signal = "CLEARDNSCACHE"
	SIGNAL_NEWNYM        Signal = "NEWNYM"
	SIGNAL_HEARTBEAT     Signal = "HEARTBEAT"
	SIGNAL_DORMANT       Signal = "DORMANT"
	SIGNAL_ACTIVE        Signal = "ACTIVE"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL