Documentation ¶
Overview ¶
Package control implements a low-level client for the Tor control spec version 1.
The primary entrypoint is the Conn struct, instantiated with NewConn. This is the low-level layer to the control port of an already-running Tor instance. Most developers will prefer the tor package adjacent to this one for a higher level abstraction over the process and this connection.
Some of this code is lifted from https://github.com/yawning/bulb with thanks.
Index ¶
- Constants
- Variables
- type AddOnionRequest
- type AddOnionResponse
- type AddrMapEvent
- type BandwidthEvent
- type BuildTimeoutSetEvent
- type CellStatsEvent
- type CircuitBandwidthEvent
- type CircuitEvent
- type CircuitMinorEvent
- type ClientsSeenEvent
- type ConfChangedEvent
- type Conn
- func (c *Conn) AddEventListener(ch chan<- Event, events ...EventCode) error
- func (c *Conn) AddOnion(req *AddOnionRequest) (*AddOnionResponse, error)
- func (c *Conn) AttachStream(streamID string, circuitID string, hopNum int) error
- func (c *Conn) Authenticate(password string) error
- func (c *Conn) Close() error
- func (c *Conn) CloseCircuit(circuitID string, flags []string) error
- func (c *Conn) CloseStream(streamID string, reason string) error
- func (c *Conn) DelOnion(serviceID string) error
- func (c *Conn) DropGuards() error
- func (c *Conn) EventWait(ctx context.Context, events []EventCode, predicate func(Event) (bool, error)) (Event, error)
- func (c *Conn) ExtendCircuit(circuitID string, path []string, purpose string) (string, error)
- func (c *Conn) GetConf(keys ...string) ([]*KeyVal, error)
- func (c *Conn) GetHiddenServiceDescriptorAsync(address string, server string) error
- func (c *Conn) GetInfo(keys ...string) ([]*KeyVal, error)
- func (c *Conn) HandleEvents(ctx context.Context) error
- func (c *Conn) HandleNextEvent() error
- func (c *Conn) LoadConf(conf string) error
- func (c *Conn) MapAddresses(addresses ...*KeyVal) ([]*KeyVal, error)
- func (c *Conn) PostDescriptor(descriptor string, purpose string, cache string) error
- func (c *Conn) PostHiddenServiceDescriptorAsync(desc string, servers []string, address string) error
- func (c *Conn) ProtocolInfo() (*ProtocolInfo, error)
- func (c *Conn) Quit() error
- func (c *Conn) ReadResponse() (*Response, error)
- func (c *Conn) RedirectStream(streamID string, address string, port int) error
- func (c *Conn) RemoveEventListener(ch chan<- Event, events ...EventCode) error
- func (c *Conn) ResetConf(entries ...*KeyVal) error
- func (c *Conn) ResolveAsync(address string, reverse bool) error
- func (c *Conn) SaveConf(force bool) error
- func (c *Conn) SendRequest(format string, args ...interface{}) (*Response, error)
- func (c *Conn) SetCircuitPurpose(circuitID string, purpose string) error
- func (c *Conn) SetConf(entries ...*KeyVal) error
- func (c *Conn) Signal(signal string) error
- func (c *Conn) TakeOwnership() error
- func (c *Conn) UseFeatures(features ...string) error
- type ConnBandwidthEvent
- type DescChangedEvent
- type ED25519Key
- type Event
- type EventCode
- type GenKey
- type GuardEvent
- type HSDescContentEvent
- type HSDescEvent
- type Key
- type KeyAlgo
- type KeyType
- type KeyVal
- type LogEvent
- type NetworkLivenessEvent
- type NetworkStatusEvent
- type NewConsensusEvent
- type NewDescEvent
- type ORConnEvent
- type ProtocolInfo
- type RSAKey
- type Response
- type SignalEvent
- type StatusEvent
- type StreamBandwidthEvent
- type StreamEvent
- type TokenBucketEmptyEvent
- type TransportLaunchedEvent
- type UnrecognizedEvent
Constants ¶
const ( StatusOk = 250 StatusOkUnnecessary = 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 ErrEventWaitSynchronousResponseOccurred = errors.New("Synchronous event occurred during EventWait")
ErrEventWaitSynchronousResponseOccurred is returned from EventWait (see docs)
Functions ¶
This section is empty.
Types ¶
type AddOnionRequest ¶
type AddOnionRequest struct { // Key is the key to use or GenKey if Tor should generate it. Key Key // Flags are ADD_ONION flags. Flags []string // MaxStreams is ADD_ONION MaxStreams. MaxStreams int // Ports are ADD_ONION Port values. Key is virtual port, Val is target // port (or can be empty to use virtual port). Ports []*KeyVal // ClientAuths are ADD_ONION ClientAuth values. If value is empty string, // Tor will generate the password. ClientAuths map[string]string }
AddOnionRequest is a set of request params for AddOnion.
type AddOnionResponse ¶
type AddOnionResponse struct { // ServiceID is the ADD_ONION response ServiceID value. ServiceID string // Key is the ADD_ONION response PrivateKey value. Key Key // ClientAuths are the ADD_ONION response ClientAuth values. ClientAuths map[string]string // RawResponse is the raw ADD_ONION response. RawResponse *Response }
AddOnionResponse is the response for AddOnion.
type AddrMapEvent ¶
type AddrMapEvent struct { Raw string Address string NewAddress string ErrorCode string // Zero if no expire Expires time.Time // Sans double quotes Cached string }
AddrMapEvent is ADDRMAP in spec.
func ParseAddrMapEvent ¶
func ParseAddrMapEvent(raw string) *AddrMapEvent
ParseAddrMapEvent parses the event.
type BandwidthEvent ¶
BandwidthEvent is BW in spec.
func ParseBandwidthEvent ¶
func ParseBandwidthEvent(raw string) *BandwidthEvent
ParseBandwidthEvent parses the event.
type BuildTimeoutSetEvent ¶
type BuildTimeoutSetEvent struct { Raw string Type string TotalTimes int Timeout time.Duration Xm int Alpha float32 Quantile float32 TimeoutRate float32 CloseTimeout time.Duration CloseRate float32 }
BuildTimeoutSetEvent is BUILDTIMEOUT_SET in spec.
func ParseBuildTimeoutSetEvent ¶
func ParseBuildTimeoutSetEvent(raw string) *BuildTimeoutSetEvent
ParseBuildTimeoutSetEvent parses the event.
func (*BuildTimeoutSetEvent) Code ¶
func (*BuildTimeoutSetEvent) Code() EventCode
Code implements Event.Code
type CellStatsEvent ¶
type CellStatsEvent struct { Raw string CircuitID string InboundQueueID string InboundConnID string InboundAdded map[string]int InboundRemoved map[string]int InboundTime map[string]int OutboundQueueID string OutboundConnID string OutboundAdded map[string]int OutboundRemoved map[string]int OutboundTime map[string]int }
CellStatsEvent is CELL_STATS in spec.
func ParseCellStatsEvent ¶
func ParseCellStatsEvent(raw string) *CellStatsEvent
ParseCellStatsEvent parses the event.
type CircuitBandwidthEvent ¶
type CircuitBandwidthEvent struct { Raw string CircuitID string BytesRead int64 BytesWritten int64 Time time.Time }
CircuitBandwidthEvent is CIRC_BW in spec.
func ParseCircuitBandwidthEvent ¶
func ParseCircuitBandwidthEvent(raw string) *CircuitBandwidthEvent
ParseCircuitBandwidthEvent parses the event.
func (*CircuitBandwidthEvent) Code ¶
func (*CircuitBandwidthEvent) Code() EventCode
Code implements Event.Code
type CircuitEvent ¶
type CircuitEvent struct { Raw string CircuitID string Status string Path []string BuildFlags []string Purpose string HSState string RendQuery string TimeCreated time.Time Reason string RemoteReason string SocksUsername string SocksPassword string }
CircuitEvent is CIRC in spec.
func ParseCircuitEvent ¶
func ParseCircuitEvent(raw string) *CircuitEvent
ParseCircuitEvent parses the event.
type CircuitMinorEvent ¶
type CircuitMinorEvent struct { Raw string CircuitID string Event string Path []string BuildFlags []string Purpose string HSState string RendQuery string TimeCreated time.Time OldPurpose string OldHSState string }
CircuitMinorEvent is CIRC_MINOR in spec.
func ParseCircuitMinorEvent ¶
func ParseCircuitMinorEvent(raw string) *CircuitMinorEvent
ParseCircuitMinorEvent parses the event.
func (*CircuitMinorEvent) Code ¶
func (*CircuitMinorEvent) Code() EventCode
Code implements Event.Code
type ClientsSeenEvent ¶
type ClientsSeenEvent struct { Raw string TimeStarted time.Time CountrySummary map[string]int IPVersions map[string]int }
ClientsSeenEvent is CLIENTS_SEEN in spec.
func ParseClientsSeenEvent ¶
func ParseClientsSeenEvent(raw string) *ClientsSeenEvent
ParseClientsSeenEvent parses the event.
func (*ClientsSeenEvent) Code ¶
func (*ClientsSeenEvent) Code() EventCode
Code implements Event.Code
type ConfChangedEvent ¶
type ConfChangedEvent struct {
Raw []string
}
ConfChangedEvent is CONF_CHANGED in spec.
func ParseConfChangedEvent ¶
func ParseConfChangedEvent(raw []string) *ConfChangedEvent
ParseConfChangedEvent parses the event.
func (*ConfChangedEvent) Code ¶
func (*ConfChangedEvent) Code() EventCode
Code implements Event.Code
type Conn ¶
type Conn struct { // DebugWriter is the writer that debug logs for this library (not Tor // itself) will be written to. If nil, no debug logs are generated/written. DebugWriter io.Writer // True if Authenticate has been called successfully. Authenticated bool // contains filtered or unexported fields }
Conn is the connection to the Tor control port.
func (*Conn) AddEventListener ¶
AddEventListener adds the given channel as an event listener for the given events. Then Tor is notified about which events should be listened to. Callers are expected to call RemoveEventListener for the channel and all event codes used here before closing the channel. If no events are provided, this is essentially a no-op. The EventCodeUnrecognized event code can be used to listen for unrecognized events.
func (*Conn) AddOnion ¶
func (c *Conn) AddOnion(req *AddOnionRequest) (*AddOnionResponse, error)
AddOnion invokes ADD_ONION and returns its response.
func (*Conn) AttachStream ¶
AttachStream invokes ATTACHSTREAM.
func (*Conn) Authenticate ¶
Authenticate authenticates with the Tor instance using the "best" possible authentication method if not already authenticated and sets the Authenticated field. The password argument is optional, and will only be used if the "SAFECOOKIE" and "NULL" authentication methods are not available and "HASHEDPASSWORD" is.
func (*Conn) Close ¶
Close sends a QUIT and closes the underlying Tor connection. This does not error if the QUIT is not accepted but does relay any error that occurs while closing the underlying connection.
func (*Conn) CloseCircuit ¶
CloseCircuit invokes CLOSECIRCUIT.
func (*Conn) CloseStream ¶
CloseStream invokes CLOSESTREAM.
func (*Conn) EventWait ¶
func (c *Conn) EventWait( ctx context.Context, events []EventCode, predicate func(Event) (bool, error), ) (Event, error)
EventWait waits for the predicate to be satisified or a non-event message to come through. If a non-event comes through, the error ErrEventWaitSynchronousResponseOccurred is returned. If there is an error in the predicate or if the context completes or there is an error internally handling the event, the error is returned. Otherwise, the event that true was returned from the predicate for is returned.
func (*Conn) ExtendCircuit ¶
ExtendCircuit invokes EXTENDCIRCUIT and returns the circuit ID on success.
func (*Conn) GetHiddenServiceDescriptorAsync ¶
GetHiddenServiceDescriptorAsync invokes HSFETCH.
func (*Conn) HandleEvents ¶
HandleEvents loops until the context is closed dispatching async events. Can dispatch events even after context is done and of course during synchronous request. This will always end with an error, either from ctx.Done() or from an error reading/handling the event.
func (*Conn) HandleNextEvent ¶
HandleNextEvent attempts to read and handle the next event. It will return on first message seen, event or not. Otherwise it will wait until there is a message read.
func (*Conn) MapAddresses ¶
MapAddresses invokes MAPADDRESS and returns mapped addresses.
func (*Conn) PostDescriptor ¶
PostDescriptor invokes POSTDESCRIPTOR.
func (*Conn) PostHiddenServiceDescriptorAsync ¶
func (c *Conn) PostHiddenServiceDescriptorAsync(desc string, servers []string, address string) error
PostHiddenServiceDescriptorAsync invokes HSPOST.
func (*Conn) ProtocolInfo ¶
func (c *Conn) ProtocolInfo() (*ProtocolInfo, error)
ProtocolInfo invokes PROTOCOLINFO on first invocation and returns a cached result on all others.
func (*Conn) ReadResponse ¶
ReadResponse returns the next response object.
func (*Conn) RedirectStream ¶
RedirectStream invokes REDIRECTSTREAM.
func (*Conn) RemoveEventListener ¶
RemoveEventListener removes the given channel from being sent to by the given event codes. It is not an error to remove a channel from events AddEventListener was not called for. Tor is notified about events which may no longer be listened to. If no events are provided, this is essentially a no-op.
func (*Conn) ResolveAsync ¶
ResolveAsync invokes RESOLVE.
func (*Conn) SendRequest ¶
SendRequest sends a synchronous request to Tor and awaits the response. If the response errors, the error result will be set, but the response will be set also. This is usually not directly used by callers, but instead called by higher-level methods.
func (*Conn) SetCircuitPurpose ¶
SetCircuitPurpose invokes SETCIRCUITPURPOSE.
func (*Conn) TakeOwnership ¶
TakeOwnership invokes TAKEOWNERSHIP.
func (*Conn) UseFeatures ¶
UseFeatures invokes USEFEATURE.
type ConnBandwidthEvent ¶
type ConnBandwidthEvent struct { Raw string ConnID string ConnType string BytesRead int64 BytesWritten int64 }
ConnBandwidthEvent is CONN_BW in spec.
func ParseConnBandwidthEvent ¶
func ParseConnBandwidthEvent(raw string) *ConnBandwidthEvent
ParseConnBandwidthEvent parses the event.
func (*ConnBandwidthEvent) Code ¶
func (*ConnBandwidthEvent) Code() EventCode
Code implements Event.Code
type DescChangedEvent ¶
type DescChangedEvent struct {
Raw string
}
DescChangedEvent is DESCCHANGED in spec.
func ParseDescChangedEvent ¶
func ParseDescChangedEvent(raw string) *DescChangedEvent
ParseDescChangedEvent parses the event.
func (*DescChangedEvent) Code ¶
func (*DescChangedEvent) Code() EventCode
Code implements Event.Code
type ED25519Key ¶
ED25519Key is a Key for AddOnion that is a ed25519 key (i.e. v3).
func ED25519KeyFromBlob ¶
func ED25519KeyFromBlob(blob string) (*ED25519Key, error)
ED25519KeyFromBlob creates a ED25519Key for the given response blob.
type Event ¶
type Event interface {
Code() EventCode
}
Event is the base interface for all known asynchronous events.
func ParseEvent ¶
ParseEvent returns an Event for the given code and data info. Raw is the raw single line if it is a single-line event (even if it has newlines), dataArray is the array of lines for multi-line events. Only one of the two needs to be set. The response is never nil, but may be UnrecognizedEvent. Format errors are ignored per the Tor spec.
type EventCode ¶
type EventCode string
EventCode represents an asynchronous event code (ref control spec 4.1).
const ( EventCodeAddrMap EventCode = "ADDRMAP" EventCodeBandwidth EventCode = "BW" EventCodeBuildTimeoutSet EventCode = "BUILDTIMEOUT_SET" EventCodeCellStats EventCode = "CELL_STATS" EventCodeCircuit EventCode = "CIRC" EventCodeCircuitBandwidth EventCode = "CIRC_BW" EventCodeCircuitMinor EventCode = "CIRC_MINOR" EventCodeClientsSeen EventCode = "CLIENTS_SEEN" EventCodeConfChanged EventCode = "CONF_CHANGED" EventCodeConnBandwidth EventCode = "CONN_BW" EventCodeDescChanged EventCode = "DESCCHANGED" EventCodeGuard EventCode = "GUARD" EventCodeHSDesc EventCode = "HS_DESC" EventCodeHSDescContent EventCode = "HS_DESC_CONTENT" EventCodeLogDebug EventCode = "DEBUG" EventCodeLogErr EventCode = "ERR" EventCodeLogInfo EventCode = "INFO" EventCodeLogNotice EventCode = "NOTICE" EventCodeLogWarn EventCode = "WARN" EventCodeNetworkLiveness EventCode = "NETWORK_LIVENESS" EventCodeNetworkStatus EventCode = "NS" EventCodeNewConsensus EventCode = "NEWCONSENSUS" EventCodeNewDesc EventCode = "NEWDESC" EventCodeORConn EventCode = "ORCONN" EventCodeSignal EventCode = "SIGNAL" EventCodeStatusClient EventCode = "STATUS_CLIENT" EventCodeStatusGeneral EventCode = "STATUS_GENERAL" EventCodeStatusServer EventCode = "STATUS_SERVER" EventCodeStream EventCode = "STREAM" EventCodeStreamBandwidth EventCode = "STREAM_BW" EventCodeTokenBucketEmpty EventCode = "TB_EMPTY" EventCodeTransportLaunched EventCode = "TRANSPORT_LAUNCHED" )
Event codes
var EventCodeUnrecognized EventCode = "<unrecognized>"
EventCodeUnrecognized is a special event code that is only used with AddEventListener and RemoveEventListener to listen for events that are unrecognized by this library (i.e. UnrecognizedEvent).
func EventCodes ¶
func EventCodes() []EventCode
EventCodes returns a new slice of all event codes that are recognized (i.e. does not include EventCodeUnrecognized).
type GenKey ¶
type GenKey KeyAlgo
GenKey is a Key for AddOnion that asks Tor to generate a key for the given algorithm.
func GenKeyFromBlob ¶
GenKeyFromBlob creates a GenKey for the given response blob which is a KeyAlgo.
type GuardEvent ¶
GuardEvent is GUARD in spec.
func ParseGuardEvent ¶
func ParseGuardEvent(raw string) *GuardEvent
ParseGuardEvent parses the event.
type HSDescContentEvent ¶
type HSDescContentEvent struct { Raw string Address string DescID string HSDir string Descriptor string }
HSDescContentEvent is HS_DESC_CONTENT in spec.
func ParseHSDescContentEvent ¶
func ParseHSDescContentEvent(raw string) *HSDescContentEvent
ParseHSDescContentEvent parses the event.
func (*HSDescContentEvent) Code ¶
func (*HSDescContentEvent) Code() EventCode
Code implements Event.Code
type HSDescEvent ¶
type HSDescEvent struct { Raw string Action string Address string AuthType string HSDir string DescID string Reason string Replica int HSDirIndex string }
HSDescEvent is HS_DESC in spec.
func ParseHSDescEvent ¶
func ParseHSDescEvent(raw string) *HSDescEvent
ParseHSDescEvent parses the event.
type Key ¶
type Key interface { // Type is the KeyType for AddOnion. Type() KeyType // Blob is the serialized key for AddOnion. Blob() string }
Key is a type of key to use for AddOnion. Implementations include GenKey, RSAKey, and ED25519Key.
func KeyFromString ¶
KeyFromString creates a Key for AddOnion based on a response string.
type KeyVal ¶
type KeyVal struct { // Key is the always-present key Key string // Val is the value. If it's an empty string and nils are accepted/supported // where this is used, it means nil unless ValSetAndEmpty is true. Val string // ValSetAndEmpty is true when Val is an empty string, the associated // command supports nils, and Val should NOT be treated as nil. False // otherwise. ValSetAndEmpty bool }
KeyVal is a simple key-value struct. In cases where Val can be nil, an empty string represents that unless ValSetAndEmpty is true.
func KeyVals ¶
KeyVals creates multiple new key-value pairs from the given strings. The provided set of strings must have a length that is a multiple of 2.
type LogEvent ¶
LogEvent is DEBUG, ERR, INFO, NOTICE, and WARN in spec.
func ParseLogEvent ¶
ParseLogEvent parses the event.
type NetworkLivenessEvent ¶
type NetworkLivenessEvent struct {
Raw string
}
NetworkLivenessEvent is NETWORK_LIVENESS in spec.
func ParseNetworkLivenessEvent ¶
func ParseNetworkLivenessEvent(raw string) *NetworkLivenessEvent
ParseNetworkLivenessEvent parses the event.
func (*NetworkLivenessEvent) Code ¶
func (*NetworkLivenessEvent) Code() EventCode
Code implements Event.Code
type NetworkStatusEvent ¶
type NetworkStatusEvent struct {
Raw string
}
NetworkStatusEvent is NS in spec.
func ParseNetworkStatusEvent ¶
func ParseNetworkStatusEvent(raw string) *NetworkStatusEvent
ParseNetworkStatusEvent parses the event.
func (*NetworkStatusEvent) Code ¶
func (*NetworkStatusEvent) Code() EventCode
Code implements Event.Code
type NewConsensusEvent ¶
type NewConsensusEvent struct {
Raw string
}
NewConsensusEvent is NEWCONSENSUS in spec.
func ParseNewConsensusEvent ¶
func ParseNewConsensusEvent(raw string) *NewConsensusEvent
ParseNewConsensusEvent parses the event.
func (*NewConsensusEvent) Code ¶
func (*NewConsensusEvent) Code() EventCode
Code implements Event.Code
type NewDescEvent ¶
NewDescEvent is NEWDESC in spec.
func ParseNewDescEvent ¶
func ParseNewDescEvent(raw string) *NewDescEvent
ParseNewDescEvent parses the event.
type ORConnEvent ¶
type ORConnEvent struct { Raw string Target string Status string Reason string NumCircuits int ConnID string }
ORConnEvent is ORCONN in spec.
func ParseORConnEvent ¶
func ParseORConnEvent(raw string) *ORConnEvent
ParseORConnEvent parses the event.
type ProtocolInfo ¶
type ProtocolInfo struct { AuthMethods []string CookieFile string TorVersion string RawResponse *Response }
ProtocolInfo is the protocol info result of Conn.ProtocolInfo.
func (*ProtocolInfo) HasAuthMethod ¶
func (p *ProtocolInfo) HasAuthMethod(authMethod string) bool
HasAuthMethod checks if ProtocolInfo contains the requested auth method.
type RSAKey ¶
type RSAKey struct{ *rsa.PrivateKey }
RSAKey is a Key for AddOnion that is a RSA-1024 key (i.e. v2).
func RSA1024KeyFromBlob ¶
RSA1024KeyFromBlob creates a RSAKey for the given response blob.
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 asynchronous event.
func (*Response) DataWithReply ¶
DataWithReply returns a combination of Data and Reply to give a full set of the lines of the response.
type SignalEvent ¶
type SignalEvent struct {
Raw string
}
SignalEvent is SIGNAL in spec.
func ParseSignalEvent ¶
func ParseSignalEvent(raw string) *SignalEvent
ParseSignalEvent parses the event.
type StatusEvent ¶
type StatusEvent struct { Raw string Type EventCode Severity string Action string Arguments map[string]string }
StatusEvent is STATUS_CLIENT, STATUS_GENERAL, and STATUS_SERVER in spec.
func ParseStatusEvent ¶
func ParseStatusEvent(typ EventCode, raw string) *StatusEvent
ParseStatusEvent parses the event.
type StreamBandwidthEvent ¶
StreamBandwidthEvent is STREAM_BW in spec.
func ParseStreamBandwidthEvent ¶
func ParseStreamBandwidthEvent(raw string) *StreamBandwidthEvent
ParseStreamBandwidthEvent parses the event.
func (*StreamBandwidthEvent) Code ¶
func (*StreamBandwidthEvent) Code() EventCode
Code implements Event.Code
type StreamEvent ¶
type StreamEvent struct { Raw string StreamID string Status string CircuitID string TargetAddress string TargetPort int Reason string RemoteReason string Source string SourceAddress string SourcePort int Purpose string }
StreamEvent is STREAM in spec.
func ParseStreamEvent ¶
func ParseStreamEvent(raw string) *StreamEvent
ParseStreamEvent parses the event.
type TokenBucketEmptyEvent ¶
type TokenBucketEmptyEvent struct { Raw string BucketName string ConnID string ReadBucketEmpty time.Duration WriteBucketEmpty time.Duration LastRefil time.Duration }
TokenBucketEmptyEvent is TB_EMPTY in spec.
func ParseTokenBucketEmptyEvent ¶
func ParseTokenBucketEmptyEvent(raw string) *TokenBucketEmptyEvent
ParseTokenBucketEmptyEvent parses the event.
func (*TokenBucketEmptyEvent) Code ¶
func (*TokenBucketEmptyEvent) Code() EventCode
Code implements Event.Code
type TransportLaunchedEvent ¶
TransportLaunchedEvent is TRANSPORT_LAUNCHED in spec.
func ParseTransportLaunchedEvent ¶
func ParseTransportLaunchedEvent(raw string) *TransportLaunchedEvent
ParseTransportLaunchedEvent parses the event.
func (*TransportLaunchedEvent) Code ¶
func (*TransportLaunchedEvent) Code() EventCode
Code implements Event.Code
type UnrecognizedEvent ¶
UnrecognizedEvent is any unrecognized event code.
func ParseUnrecognizedEvent ¶
func ParseUnrecognizedEvent(eventCode EventCode, rawSingleLine string, rawMultiLine []string) *UnrecognizedEvent
ParseUnrecognizedEvent creates an unrecognized event with the given values.
func (*UnrecognizedEvent) Code ¶
func (u *UnrecognizedEvent) Code() EventCode
Code implements Event.Code