Documentation ¶
Overview ¶
package asaur is a Go language interface to a Tor control port.
Index ¶
- Constants
- Variables
- func GetInfo(torControlAddress string, torControlSocketType string, authentication string, ...) ([]string, error)
- func HSFetch(onion string) error
- func ParseBootstrapPhase(data []string) map[string]string
- type Conn
- func (c *Conn) AddOnion(ports []OnionPortSpec, key crypto.PrivateKey, oneshot bool) (*OnionInfo, error)
- func (c *Conn) Authenticate(password string) error
- func (c *Conn) Close() error
- func (c *Conn) Debug(enable bool)
- func (c *Conn) DeleteOnion(serviceID string) error
- func (c *Conn) Dialer(auth *proxy.Auth) (proxy.Dialer, error)
- func (c *Conn) GetClientRevisionCounter(onion string) (uint64, error)
- func (c *Conn) GetInfo(arg string) ([]string, error)
- func (c *Conn) GetServiceRevisionCounter(onion string) (uint64, error)
- func (c *Conn) Listener(port uint16, key crypto.PrivateKey) (net.Listener, error)
- func (c *Conn) NewListener(config *NewOnionConfig, vports ...uint16) (net.Listener, error)
- func (c *Conn) NewOnion(config *NewOnionConfig, dontCheckDescriptor bool) (*OnionInfo, error)
- func (c *Conn) NextEvent() (*Response, error)
- func (c *Conn) ProtocolInfo() (*ProtocolInfo, error)
- func (c *Conn) Read(p []byte) (int, error)
- func (c *Conn) ReadResponse() (*Response, error)
- func (c *Conn) RecoverListener(config *NewOnionConfig, onion string, vports ...uint16) (net.Listener, error)
- func (c *Conn) Request(fmt string, args ...interface{}) (*Response, error)
- func (c *Conn) StartAsyncReader()
- func (c *Conn) Write(p []byte) (int, error)
- type NewOnionConfig
- type OnionInfo
- type OnionPortSpec
- type OnionPrivateKey
- type ProtocolInfo
- type Response
Constants ¶
const ( StatusOk = 250 StatusOkUnneccecary = 251 StatusErrResourceExhausted = 451 StatusErrSyntaxError = 500 StatusErrUnrecognizedCmd = 510 StatusErrUnimplementedCmd = 511 StatusErrSyntaxErrorArg = 512 StatusErrUnrecognizedCmdArg = 513 StatusErrAuthenticationRequired = 514 StatusErrBadAuthentication = 515 StatusErrUnspecifiedTorError = 550 StatusErrInternalError = 551 StatusErrUnrecognizedEntity = 552 StatusErrInvalidConfigValue = 553 StatusErrInvalidDescriptor = 554 StatusErrUnmanagedEntity = 555 StatusAsyncEvent = 650 )
The various control port StatusCode constants.
Variables ¶
var ErrNoAsyncReader = errors.New("event requested without an async reader")
ErrNoAsyncReader is the error returned when the asynchronous event handling is requested, but the helper go routine has not been started.
Functions ¶
func HSFetch ¶
run HSFETCH for an onion, in order to put its onion service descriptor into the client cache unfortunately we don't actually do this, because HSFETCH doesn't support v3 yet instead we make a shortlived connection to it, which has a side effect of putting the descriptor into cache see https://trac.torproject.org/projects/tor/ticket/25417 for details
func ParseBootstrapPhase ¶
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a control port connection instance.
func (*Conn) AddOnion ¶
func (c *Conn) AddOnion(ports []OnionPortSpec, key crypto.PrivateKey, oneshot bool) (*OnionInfo, error)
[DEPRECATED] AddOnion issues an ADD_ONION command and returns the parsed response.
func (*Conn) Authenticate ¶
Authenticate authenticates with the Tor instance using the "best" possible authentication method. The password argument is entirely optional, and will only be used if the "SAFECOOKE" and "NULL" authentication methods are not available and "HASHEDPASSWORD" is.
func (*Conn) DeleteOnion ¶
DeleteOnion issues a DEL_ONION command and returns the parsed response.
func (*Conn) GetClientRevisionCounter ¶
func (*Conn) GetServiceRevisionCounter ¶
func (*Conn) NewListener ¶
[DEPRECATED] generate a random port to listen on (this is for backwards compatibility)
func (*Conn) NewOnion ¶
func (c *Conn) NewOnion(config *NewOnionConfig, dontCheckDescriptor bool) (*OnionInfo, error)
NewOnion issues an ADD_ONION command using configuration config and returns the parsed response.
func (*Conn) NextEvent ¶
NextEvent returns the next asynchronous event received, blocking if neccecary. In order to enable asynchronous event handling, StartAsyncReader must be called first.
func (*Conn) ProtocolInfo ¶
func (c *Conn) ProtocolInfo() (*ProtocolInfo, error)
ProtocolInfo issues a PROTOCOLINFO command and returns the parsed response.
func (*Conn) Read ¶
Read reads directly from the control port connection. Mixing this call with Request, ReadResponse, or asynchronous events will lead to undefined behavior.
func (*Conn) ReadResponse ¶
ReadResponse returns the next response object. Calling this simultaniously with Read, Request, or StartAsyncReader will lead to undefined behavior
func (*Conn) RecoverListener ¶
func (*Conn) Request ¶
Request sends a raw control port request and returns the response. If the async. reader is not currently running, events received while waiting for the response will be silently dropped. Calling Request simultaniously with StartAsyncReader, Read, Write, or ReadResponse will lead to undefined behavior.
func (*Conn) StartAsyncReader ¶
func (c *Conn) StartAsyncReader()
StartAsyncReader starts the asynchronous reader go routine that allows asynchronous events to be handled. It must not be called simultaniously with Read, Request, or ReadResponse or undefined behavior will occur.
type NewOnionConfig ¶
type NewOnionConfig struct { Onion string PortSpecs []OnionPortSpec PrivateKey crypto.PrivateKey DiscardPK bool Detach bool BasicAuth bool NonAnonymous bool }
NewOnionConfig is a configuration for NewOnion command.
type OnionInfo ¶
type OnionInfo struct { OnionID string PrivateKey crypto.PrivateKey RawResponse *Response }
OnionInfo is the result of the AddOnion command.
type OnionPortSpec ¶
OnionPortSpec is a Onion VirtPort/Target pair.
type OnionPrivateKey ¶
OnionPrivateKey is a unknown Onion private key (crypto.PublicKey).
type ProtocolInfo ¶
type ProtocolInfo struct { AuthMethods map[string]bool CookieFile string TorVersion string RawResponse *Response }
ProtocolInfo is the result of the ProtocolInfo command.
type Response ¶
type Response struct { // Err is the status code and string representation associated with a // response. Responses that have completed successfully will also have // Err set to indicate such. Err *textproto.Error // Reply is the text on the EndReplyLine of the response. Reply string // Data is the MidReplyLines/DataReplyLines of the response. Dot encoded // data is "decoded" and presented as a single string (terminal ".CRLF" // removed, all intervening CRs stripped). Data []string // RawLines is all of the lines of a response, without CRLFs. RawLines []string }
Response is a response to a control port command, or an asyncrhonous event.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
Package utils implements useful utilities for dealing with Tor and it's control port.
|
Package utils implements useful utilities for dealing with Tor and it's control port. |
pkcs1
Package pkcs1 implements PKCS#1 RSA key marshalling/unmarshalling, compatibile with Tor's usage.
|
Package pkcs1 implements PKCS#1 RSA key marshalling/unmarshalling, compatibile with Tor's usage. |