Documentation
¶
Index ¶
- type CircuitReceiver
- type Link
- func (l *Link) ClaimCircID(id uint32) bool
- func (l *Link) Close() error
- func (l *Link) LinkDone() <-chan struct{}
- func (l *Link) RegisterCircuit(circID uint32) (*CircuitReceiver, error)
- func (l *Link) ReleaseCircID(id uint32)
- func (l *Link) SetDeadline(t time.Time) error
- func (l *Link) StartReadLoop()
- func (l *Link) UnregisterCircuit(circID uint32)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CircuitReceiver ¶ added in v0.1.5
type CircuitReceiver struct {
Cells chan cell.Cell
Done <-chan struct{}
// contains filtered or unexported fields
}
CircuitReceiver receives raw cells routed to a circuit by the link read loop.
type Link ¶
type Link struct {
Version uint16
Reader *cell.Reader
Writer *cell.Writer
// RelayIdentityEd25519 is the relay's Ed25519 identity key from CERTS validation.
RelayIdentityEd25519 []byte
// RelayAddr is the relay's IP:port we connected to.
RelayAddr string
// CircIDs tracks allocated circuit IDs on this link to prevent collisions.
CircIDs map[uint32]bool
// contains filtered or unexported fields
}
Link represents an established Tor link connection.
func Handshake ¶
Handshake connects to a Tor relay and performs the full link handshake. Returns a ready Link or an error.
func HandshakeWithPinning ¶ added in v0.1.6
HandshakeWithPinning connects to a Tor relay and performs the full link handshake. If expectedEd25519 is non-nil, the relay's Ed25519 identity key from the CERTS cell is compared using constant-time comparison; a mismatch returns an error.
func NewTestLink ¶ added in v0.1.5
NewTestLink creates a Link suitable for testing with the given cell reader and writer. It initializes the circuits map and done channel so that RegisterCircuit, StartReadLoop, etc. work correctly.
func (*Link) ClaimCircID ¶
ClaimCircID registers a circuit ID on this link. Returns false if already in use.
func (*Link) LinkDone ¶ added in v0.1.5
func (l *Link) LinkDone() <-chan struct{}
LinkDone returns the link's done channel for detecting link death. Returns nil if the link has no done channel (e.g., test links).
func (*Link) RegisterCircuit ¶ added in v0.1.5
func (l *Link) RegisterCircuit(circID uint32) (*CircuitReceiver, error)
RegisterCircuit creates and stores a CircuitReceiver for the given circuit ID. Returns an error if the ID is already registered or the link is dead.
func (*Link) ReleaseCircID ¶
ReleaseCircID removes a circuit ID from this link's tracking.
func (*Link) SetDeadline ¶
SetDeadline sets a deadline on the underlying connection.
func (*Link) StartReadLoop ¶ added in v0.1.5
func (l *Link) StartReadLoop()
StartReadLoop starts the background read loop goroutine (idempotent via sync.Once).
func (*Link) UnregisterCircuit ¶ added in v0.1.5
UnregisterCircuit removes a circuit from the dispatch table and signals Done. It does NOT close cr.Cells - the cells channel is only closed in cleanupAllCircuits (on link death) to avoid a race with runReadLoop sending to the channel.