Documentation
¶
Overview ¶
Package control implements part of the 'Tor control protocol (Version 1)'. See https://gitweb.torproject.org/torspec.git/tree/control-spec.txt.
Index ¶
- Constants
- type Cmd
- type Conn
- func (c Conn) Auth(passwd string) (err error)
- func (c Conn) AuthCookie(cookie []byte) (err error)
- func (c Conn) GetInfo(key string) (*Reply, error)
- func (c Conn) Receive() (*Reply, error)
- func (c Conn) ReceiveSync() (*Reply, error)
- func (c Conn) ReceiveToChan() error
- func (c Conn) Resolve(addr string) error
- func (c Conn) Send(cmd Cmd) (*Reply, error)
- func (c Conn) SetEvents(keys []string) error
- func (c Conn) Signal(s string) error
- type Demux
- type Handler
- type Reply
- type ReplyLine
Constants ¶
const ( StatusOK = 250 StatusOperationUnnecessary = 251 StatusResourceExhausted = 451 StatusProtocolSyntaxError = 500 StatusUnrecognizedCommand = 510 StatusUnimplementedCommand = 511 StatusArgumentSyntaxError = 512 StatusUnrecognizedArgument = 513 StatusAuthenticationRequired = 514 StatusBadAuthentication = 515 StatusUnspecifiedError = 550 StatusInternalError = 551 StatusUnrecognizedEntity = 552 StatusInvalidConfigurationValue = 553 StatusInvalidDescriptor = 554 StatusUnmanagedEntity = 555 StatusAsyncEventNotification = 650 )
Status codes of replies from the onion router.
const ( SignalReload = "RELOAD" // Reload config items. SignalShutdown = "SHUTDOWN" // Controlled shutdown. SignalDump = "DUMP" // Dump log information about open connections and circuits. SignalDebug = "DEBUG" // Switch all open logs to loglevel debug. SignalHalt = "HALT" // Immediate shutdown: clean up and exit now. SignalClearDNSCache = "CLEARDNSCACHE" // Forget the client-side cached IPs for all hostnames. SignalNewNym = "NEWNYM" // Switch to clean circuits, so new application requests don't share any circuits with old ones. SignalHeartbeat = "HEARTBEAT" // Dump an unscheduled Heartbeat message to log. )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
type Cmd struct { Keyword string Arguments []string // optional list of arguments; may be nil Data string // will be dot escaped by Send }
Cmd represents a command send from the client to the server.
type Conn ¶
Conn represents a Tor Control Protocol connection to a Tor server.
func Client ¶
Client returns a new Tor Control Protocol connection using conn as the underlying transport.
func Dial ¶
Dial connects to the given network address using net.Dial and then starts and returns a new Tor Control Protocol connection.
func (Conn) Auth ¶
Auth authenticates a connection using the hashed password mechanism. Pass an empty string to authenticate without password.
func (Conn) AuthCookie ¶
AuthCookie authenticates a connection using the control auth cookie.
func (Conn) Receive ¶
Receive reads and returns a single reply from the Tor server. It makes no distinction between synchronous and asynchronous replies.
func (Conn) ReceiveSync ¶
ReceiveSync reads replies from the Tor server. It returns the first synchronous reply; replies read before that are send to the connections Replies channel. ReceiveSync blocks until the replies are read from that channel.
func (Conn) ReceiveToChan ¶
ReceiveToChan reads a single reply from the Tor server and sends it to the connections Replies channel. ReceiveToChan blocks until the reply is read from the channel.
type Demux ¶
type Demux struct {
// contains filtered or unexported fields
}
Demux is a simple demultiplexer for asynchronous replies. It matches the type of a reply against a list of registered events and calls the corresponding Handler function.
type Handler ¶
type Handler func(r *Reply)
A Handler can be registered to handle asynchronous replies send by an Tor router. It is customary for Handler to communicate back using channels.
type Reply ¶
type Reply struct { Status int // the StatusCode of the reply Text string // ReplyText of the EndReplyLine Lines []ReplyLine // MidReplyLines and DataReplyLines }
Reply represents a reply send from the server to the client.