Documentation
¶
Index ¶
- Constants
- Variables
- func BuildCircuit(ctx context.Context, dialer proxy.Dialer, nodes []*directory.NodeInfo) (*TorConn, *Circuit, error)
- func BuildDirectoryCircuit(ctx context.Context, dirs []*directory.MinimalNodeInfo, dialer proxy.Dialer) (tc *TorConn, circ *Circuit, err error)
- func DownloadConsensus(dirClient *http.Client, authorityFingerprints []string) (*directory.Consensus, directory.Authorities, error)
- func DownloadMicrodescriptors(dirClient *http.Client, snis []*directory.ShortNodeInfo) ([]*directory.NodeInfo, error)
- type Circuit
- func (circ *Circuit) Close() error
- func (circ *Circuit) Dial(network, addr string) (c net.Conn, err error)
- func (circ *Circuit) DialDir(ctx context.Context) (*Stream, error)
- func (circ *Circuit) DialRendezvousRaw(cookie, payload []byte) error
- func (circ *Circuit) DialTCP(ctx context.Context, net, address string) (*Stream, error)
- func (circ *Circuit) Extend(ip net.IP, port uint16, routerid, ntorPublic []byte) error
- func (circ *Circuit) ListenRendezvousRaw(cookie []byte) (func() ([]byte, error), error)
- func (circ *Circuit) ReadRaw() ([]byte, error)
- func (circ *Circuit) WriteRaw(payload []byte) error
- type MultiplexConn
- func (c *MultiplexConn) Close() error
- func (c *MultiplexConn) LocalAddr() net.Addr
- func (c *MultiplexConn) Read(buf []byte) (int, error)
- func (c *MultiplexConn) RemoteAddr() net.Addr
- func (c *MultiplexConn) SetDeadline(t time.Time) error
- func (c *MultiplexConn) SetReadDeadline(t time.Time) error
- func (c *MultiplexConn) SetWriteDeadline(t time.Time) error
- func (c *MultiplexConn) Write(buf []byte) (int, error)
- type SingleStreamConn
- func (c *SingleStreamConn) Close() error
- func (c *SingleStreamConn) LocalAddr() net.Addr
- func (c *SingleStreamConn) Read(buf []byte) (int, error)
- func (c *SingleStreamConn) RemoteAddr() net.Addr
- func (c *SingleStreamConn) SetDeadline(t time.Time) error
- func (c *SingleStreamConn) SetReadDeadline(t time.Time) error
- func (c *SingleStreamConn) SetWriteDeadline(t time.Time) error
- func (c *SingleStreamConn) Write(buf []byte) (int, error)
- type Stream
- type TorConn
- type Torch
- func (t *Torch) Pick(weighWith func(w *directory.BandwidthWeights, n *directory.NodeInfo) int64, ...) *directory.NodeInfo
- func (t *Torch) Stop() error
- func (t *Torch) UnguardedCircuitTo(ctx context.Context, n int, dst *directory.NodeInfo) (*TorConn, *Circuit, error)
- func (t *Torch) UnguardedExitCircuit(ctx context.Context, n int) (*TorConn, *Circuit, error)
- func (t *Torch) WithDirectory(f func(*directory.Directory) interface{}) interface{}
Constants ¶
const ( HASH_LEN = 20 KEY_LEN = 16 )
const ( PAYLOAD_LEN = 509 CIRCID_LEN_v1 = 2 CIRCID_LEN_v4 = 4 )
const ( CELL_PADDING = iota CELL_CREATE CELL_CREATED CELL_RELAY CELL_DESTROY CELL_CREATE_FAST CELL_CREATED_FAST CELL_VERSIONS // variable-length CELL_NETINFO CELL_RELAY_EARLY CELL_CREATE2 CELL_CREATED2 )
const ( CELL_VPADDING = 128 + iota CELL_CERTS CELL_AUTH_CHALLENGE CELL_AUTHENTICATE CELL_AUTHORIZE )
const ( RELAY_BEGIN = 1 + iota RELAY_DATA RELAY_END RELAY_CONNECTED RELAY_SENDME RELAY_EXTEND RELAY_EXTENDED RELAY_TRUNCATE RELAY_TRUNCATED RELAY_DROP RELAY_RESOLVE RELAY_RESOLVED RELAY_BEGIN_DIR RELAY_EXTEND2 RELAY_EXTENDED2 )
const ( RELAY_ESTABLISH_INTRO = 32 + iota RELAY_ESTABLISH_RENDEZVOUS RELAY_INTRODUCE1 RELAY_INTRODUCE2 RELAY_RENDEZVOUS1 RELAY_RENDEZVOUS2 RELAY_INTRO_ESTABLISHED RELAY_RENDEZVOUS_ESTABLISHED RELAY_INTRODUCE_ACK )
const ( REASON_MISC = 1 + iota REASON_RESOLVEFAILED REASON_CONNECTREFUSED REASON_EXITPOLICY REASON_DESTROY REASON_DONE REASON_TIMEOUT REASON_NOROUTE REASON_HIBERNATING REASON_INTERNAL REASON_RESOURCELIMIT REASON_CONNRESET REASON_TORPROTOCOL REASON_NOTDIRECTORY )
const (
RELAY_PAYLOAD_LEN = PAYLOAD_LEN - 11
)
Variables ¶
var ErrStreamClosed = fmt.Errorf("stream closed")
Functions ¶
func BuildCircuit ¶
func BuildDirectoryCircuit ¶
func DownloadConsensus ¶
Types ¶
type Circuit ¶
type Circuit struct {
// contains filtered or unexported fields
}
func (*Circuit) Dial ¶
Dial implements proxy.Dialer using DialTCP and DialDir based on the hostname, returning multiplexed connections.
func (*Circuit) DialRendezvousRaw ¶
DialRendezvousRaw executes the "server" part of the rendezvous protocol. Requires len(cookie) = 20, len(payload) = 148. The Circuit should not be used for other purposes after this. On success, this circuit will be connected to the rendezvous peer and the circuit will enter raw mode.
func (*Circuit) ListenRendezvousRaw ¶
ListenRendezvousRaw executes the "client" part of the rendezvous protocol. Requires len(cookie) = 20. The returned function, accept, waits for the server to complete the rendezvous protocol and returns the 148-byte server handshake message and on success, this circuit will be connected to the rendezvous peer and the circuit will enter raw mode.
type MultiplexConn ¶
type MultiplexConn Stream
MultiplexConn wraps a Stream to provide a net.Conn interface without interereing with other streams on the same circuit. However, this means that we cannot use TCP-level deadlines, and there currently is no deadline support (soft deadlines may be implemented in the future).
func (*MultiplexConn) Close ¶
func (c *MultiplexConn) Close() error
func (*MultiplexConn) LocalAddr ¶
func (c *MultiplexConn) LocalAddr() net.Addr
func (*MultiplexConn) RemoteAddr ¶
func (c *MultiplexConn) RemoteAddr() net.Addr
func (*MultiplexConn) SetDeadline ¶
func (c *MultiplexConn) SetDeadline(t time.Time) error
func (*MultiplexConn) SetReadDeadline ¶
func (c *MultiplexConn) SetReadDeadline(t time.Time) error
func (*MultiplexConn) SetWriteDeadline ¶
func (c *MultiplexConn) SetWriteDeadline(t time.Time) error
type SingleStreamConn ¶
type SingleStreamConn struct {
// contains filtered or unexported fields
}
SingleStreamConn uses one TOR connection carrying a single circuit carrying a single stream as a net.Conn. This enables direct access to TCP-level deadlines, but incurs the overhead of torconn and circuit creation.
func (*SingleStreamConn) Close ¶
func (c *SingleStreamConn) Close() error
func (*SingleStreamConn) LocalAddr ¶
func (c *SingleStreamConn) LocalAddr() net.Addr
func (*SingleStreamConn) RemoteAddr ¶
func (c *SingleStreamConn) RemoteAddr() net.Addr
func (*SingleStreamConn) SetDeadline ¶
func (c *SingleStreamConn) SetDeadline(t time.Time) error
func (*SingleStreamConn) SetReadDeadline ¶
func (c *SingleStreamConn) SetReadDeadline(t time.Time) error
func (*SingleStreamConn) SetWriteDeadline ¶
func (c *SingleStreamConn) SetWriteDeadline(t time.Time) error
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
func (*Stream) RemoteAddr ¶
type TorConn ¶
type TorConn struct {
// contains filtered or unexported fields
}
torConn implements the TOR link protocol. Only link protocol version 4 is supported.
func DialOnionRouter ¶
type Torch ¶
func New ¶
New initializes a new TOR client, loading the consensus information. When New returns, the resulting TOR client is in a good state for selecting and establishing circuits.
func (*Torch) UnguardedCircuitTo ¶
func (*Torch) UnguardedExitCircuit ¶
func (*Torch) WithDirectory ¶
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
bufio
Package bufio implements buffered I/O. It wraps an io.Reader or io.Writer object, creating another object (Reader or Writer) that also implements the interface but provides buffering and some help for textual I/O.
|
Package bufio implements buffered I/O. It wraps an io.Reader or io.Writer object, creating another object (Reader or Writer) that also implements the interface but provides buffering and some help for textual I/O. |