Back to Site
Loading...
Searching...
No Matches
librats::CircuitService Class Referenceabstract

#include <circuit_service.h>

Inheritance diagram for librats::CircuitService:
[legend]

Public Member Functions

virtual ~CircuitService ()=default
virtual std::optional< PeerRoute > adopt_circuit (const PeerId &carrier, std::unique_ptr< Link > link, ConnRole role, bool connected)=0
 Adopt link as a connection carried by the peer carrier, on the reactor that owns the carrier's own connection.
virtual void wake_circuit (PeerRoute route, uint32_t events)=0
 Deliver poll-equivalent events (PollIn / PollOut / PollErr, see core/io_poller.h) to a circuit connection — the events a socket-backed link would have got from the poller.
virtual void close_circuit (PeerRoute route, CloseReason reason)=0
 Tear a circuit connection down.
virtual std::optional< PeerRoute > dial_relayed (const PeerId &carrier, uint64_t cid, ForwardedCircuit circuit)=0
 Dial the far end through carrier, the relay. The connection is Outbound.
virtual std::optional< PeerRoute > expect_relayed (const PeerId &carrier, uint64_t cid, ForwardedCircuit circuit)=0
 Accept the dial that will come through carrier, the relay, as an Inbound connection — under the same admission gate as adopt_circuit.
virtual bool forward_datagrams (const PeerId &dialer, const PeerId &responder, uint64_t cid, std::shared_ptr< std::atomic< uint64_t > > bytes, uint64_t rate, uint64_t burst)=0
 As the relay: forward the packets of cid between dialer and responder, counting their bytes into bytes, at most rate bytes a second each way with bursts of burst (0: no rate; how it is held is UdpMux's, "Relayed connections").
virtual void stop_forwarding (uint64_t cid)=0

Detailed Description

Definition at line 62 of file circuit_service.h.

Constructor & Destructor Documentation

◆ ~CircuitService()

virtual librats::CircuitService::~CircuitService ( )
virtualdefault

Member Function Documentation

◆ adopt_circuit()

virtual std::optional< PeerRoute > librats::CircuitService::adopt_circuit ( const PeerId & carrier,
std::unique_ptr< Link > link,
ConnRole role,
bool connected )
pure virtual

Adopt link as a connection carried by the peer carrier, on the reactor that owns the carrier's own connection.

Parameters
roleOutbound for a circuit we opened, Inbound for one opened to us. It is what the secure handshake and the peer table's duplicate resolution read, so it must say who asked.
connectedwhether the far end is already there. An inbound circuit is (the opener would not have sent it otherwise); an outbound one is not until its acceptance arrives, and until then the connection waits in Connecting for a PollOut.
Returns
the new connection's route, or nullopt when the carrier is no longer a peer, or when an inbound circuit would push this node past its peer limit. Nothing is started in that case and link is released.

Implemented in librats::Node.

◆ close_circuit()

virtual void librats::CircuitService::close_circuit ( PeerRoute route,
CloseReason reason )
pure virtual

Tear a circuit connection down.

Thread-safe; a no-op for a route that is already gone.

Implemented in librats::Node.

◆ dial_relayed()

virtual std::optional< PeerRoute > librats::CircuitService::dial_relayed ( const PeerId & carrier,
uint64_t cid,
ForwardedCircuit circuit )
pure virtual

Dial the far end through carrier, the relay. The connection is Outbound.

Implemented in librats::Node.

◆ expect_relayed()

virtual std::optional< PeerRoute > librats::CircuitService::expect_relayed ( const PeerId & carrier,
uint64_t cid,
ForwardedCircuit circuit )
pure virtual

Accept the dial that will come through carrier, the relay, as an Inbound connection — under the same admission gate as adopt_circuit.

Implemented in librats::Node.

◆ forward_datagrams()

virtual bool librats::CircuitService::forward_datagrams ( const PeerId & dialer,
const PeerId & responder,
uint64_t cid,
std::shared_ptr< std::atomic< uint64_t > > bytes,
uint64_t rate,
uint64_t burst )
pure virtual

As the relay: forward the packets of cid between dialer and responder, counting their bytes into bytes, at most rate bytes a second each way with bursts of burst (0: no rate; how it is held is UdpMux's, "Relayed connections").

False when the two are not both datagram peers on one socket — the circuit must then be a byte stream.

Implemented in librats::Node.

◆ stop_forwarding()

virtual void librats::CircuitService::stop_forwarding ( uint64_t cid)
pure virtual

Implemented in librats::Node.

◆ wake_circuit()

virtual void librats::CircuitService::wake_circuit ( PeerRoute route,
uint32_t events )
pure virtual

Deliver poll-equivalent events (PollIn / PollOut / PollErr, see core/io_poller.h) to a circuit connection — the events a socket-backed link would have got from the poller.

Thread-safe, and a no-op for a route that is already gone.

Implemented in librats::Node.


The documentation for this class was generated from the following file: