OpenVPN 3 Core Library
Loading...
Searching...
No Matches
openvpn::ServerProber Class Reference

#include <serverprober.hpp>

Inheritance diagram for openvpn::ServerProber:
[legend]
Collaboration diagram for openvpn::ServerProber:
[legend]

Classes

struct  NotifyCallback
 
struct  Pending
 
struct  RecvCtx
 
struct  Result
 One responding server, with its measured latency and advertised parameters. More...
 
struct  Target
 

Public Types

using UDPSocket = openvpn_io::ip::udp::socket
 
using UDPEndpoint = openvpn_io::ip::udp::endpoint
 

Public Member Functions

 ServerProber (openvpn_io::io_context &io_context_arg, RemoteList::Ptr remote_list_arg, ProtoContext::ProtoConfig::Ptr proto_config_arg, SocketProtect *socket_protect_arg, SessionStats::Ptr stats_arg, const Time::Duration &probe_window_arg)
 
 ~ServerProber ()
 Cancels any in-flight probe; see stop().
 
void start (NotifyCallback *cb)
 Begin probing. cb->server_probe_done() fires exactly once, when the probe window elapses (or immediately if there is nothing to probe).
 
void stop ()
 Cancel probing without invoking the callback. Sockets stay open (transferable).
 
std::unique_ptr< UDPSocketrelease_socket (const IP::Addr::Version v)
 Hand off the probe socket for an address family so it can be adopted as the connection socket (source port preserved, no rebind).
 

Private Member Functions

void gather_targets (std::vector< Target > &targets)
 Collect every resolved UDP endpoint from the remote list.
 
UDPSocketsocket_for (const UDPEndpoint &target)
 Lazily open (and socket_protect) the per-family socket, arming its receive.
 
void send_probe (const Target &t)
 Wrap and send one SERVER_PROBE, recording the endpoint as pending.
 
void queue_recv (const bool v4)
 
void handle_reply (const UDPEndpoint &sender, BufferAllocated &buf)
 Unwrap a PROBE_REPLY and record a Result, ignoring anything unsolicited.
 
void finish ()
 

Private Attributes

openvpn_io::io_context & io_context
 
RemoteList::Ptr remote_list
 
ProtoContext::ProtoConfig::Ptr proto_config
 
SocketProtectsocket_protect
 
SessionStats::Ptr stats
 
Time::Duration probe_window
 
AsioTimer timer
 
ProtoContext::ProbeWrap probe_wrap
 
std::unique_ptr< UDPSocketsock_v4
 
std::unique_ptr< UDPSocketsock_v6
 
std::map< UDPEndpoint, Pendingpending
 
std::vector< Resultresults
 
NotifyCallbacknotify_callback = nullptr
 
bool halt = false
 
bool finished = false
 

Detailed Description

Definition at line 51 of file serverprober.hpp.

Member Typedef Documentation

◆ UDPEndpoint

using openvpn::ServerProber::UDPEndpoint = openvpn_io::ip::udp::endpoint

Definition at line 55 of file serverprober.hpp.

◆ UDPSocket

using openvpn::ServerProber::UDPSocket = openvpn_io::ip::udp::socket

Definition at line 54 of file serverprober.hpp.

Constructor & Destructor Documentation

◆ ServerProber()

openvpn::ServerProber::ServerProber ( openvpn_io::io_context &  io_context_arg,
RemoteList::Ptr  remote_list_arg,
ProtoContext::ProtoConfig::Ptr  proto_config_arg,
SocketProtect socket_protect_arg,
SessionStats::Ptr  stats_arg,
const Time::Duration &  probe_window_arg 
)
inline

Construct a prober for the already-resolved remotes in remote_list_arg, wrapping probes with the control-channel protection from proto_config_arg. Opens no socket and sends nothing; call start() to probe.

Definition at line 77 of file serverprober.hpp.

◆ ~ServerProber()

openvpn::ServerProber::~ServerProber ( )
inline

Cancels any in-flight probe; see stop().

Definition at line 95 of file serverprober.hpp.

Member Function Documentation

◆ finish()

void openvpn::ServerProber::finish ( )
inlineprivate

Close the probe window and hand the replies to the callback, once. No-op if stopped – an already-expired timer's handler can still reach us.

Definition at line 331 of file serverprober.hpp.

Here is the caller graph for this function:

◆ gather_targets()

void openvpn::ServerProber::gather_targets ( std::vector< Target > &  targets)
inlineprivate

Collect every resolved UDP endpoint from the remote list.

Definition at line 184 of file serverprober.hpp.

Here is the caller graph for this function:

◆ handle_reply()

void openvpn::ServerProber::handle_reply ( const UDPEndpoint sender,
BufferAllocated buf 
)
inlineprivate

Unwrap a PROBE_REPLY and record a Result, ignoring anything unsolicited.

Definition at line 300 of file serverprober.hpp.

◆ queue_recv()

void openvpn::ServerProber::queue_recv ( const bool  v4)
inlineprivate

Arm the next receive on the v4 or v6 socket; re-armed after every datagram until halt, or until that socket is released (it is then gone).

Definition at line 265 of file serverprober.hpp.

Here is the caller graph for this function:

◆ release_socket()

std::unique_ptr< UDPSocket > openvpn::ServerProber::release_socket ( const IP::Addr::Version  v)
inline

Hand off the probe socket for an address family so it can be adopted as the connection socket (source port preserved, no rebind).

The adopting transport must be its only reader, so anything we still have armed on it is cancelled. Nothing of ours re-arms behind that: queue_recv() looks the socket up by family, and it is gone once moved out.

Returns
the socket, or nullptr if none was opened for that family

Definition at line 150 of file serverprober.hpp.

◆ send_probe()

void openvpn::ServerProber::send_probe ( const Target t)
inlineprivate

Wrap and send one SERVER_PROBE, recording the endpoint as pending.

Definition at line 234 of file serverprober.hpp.

Here is the caller graph for this function:

◆ socket_for()

UDPSocket * openvpn::ServerProber::socket_for ( const UDPEndpoint target)
inlineprivate

Lazily open (and socket_protect) the per-family socket, arming its receive.

Definition at line 207 of file serverprober.hpp.

Here is the caller graph for this function:

◆ start()

void openvpn::ServerProber::start ( NotifyCallback cb)
inline

Begin probing. cb->server_probe_done() fires exactly once, when the probe window elapses (or immediately if there is nothing to probe).

Definition at line 104 of file serverprober.hpp.

◆ stop()

void openvpn::ServerProber::stop ( )
inline

Cancel probing without invoking the callback. Sockets stay open (transferable).

Definition at line 127 of file serverprober.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ finished

bool openvpn::ServerProber::finished = false
private

Definition at line 362 of file serverprober.hpp.

◆ halt

bool openvpn::ServerProber::halt = false
private

Definition at line 361 of file serverprober.hpp.

◆ io_context

openvpn_io::io_context& openvpn::ServerProber::io_context
private

Definition at line 344 of file serverprober.hpp.

◆ notify_callback

NotifyCallback* openvpn::ServerProber::notify_callback = nullptr
private

Definition at line 360 of file serverprober.hpp.

◆ pending

std::map<UDPEndpoint, Pending> openvpn::ServerProber::pending
private

Definition at line 357 of file serverprober.hpp.

◆ probe_window

Time::Duration openvpn::ServerProber::probe_window
private

Definition at line 349 of file serverprober.hpp.

◆ probe_wrap

ProtoContext::ProbeWrap openvpn::ServerProber::probe_wrap
private

Definition at line 352 of file serverprober.hpp.

◆ proto_config

ProtoContext::ProtoConfig::Ptr openvpn::ServerProber::proto_config
private

Definition at line 346 of file serverprober.hpp.

◆ remote_list

RemoteList::Ptr openvpn::ServerProber::remote_list
private

Definition at line 345 of file serverprober.hpp.

◆ results

std::vector<Result> openvpn::ServerProber::results
private

Definition at line 358 of file serverprober.hpp.

◆ sock_v4

std::unique_ptr<UDPSocket> openvpn::ServerProber::sock_v4
private

Definition at line 354 of file serverprober.hpp.

◆ sock_v6

std::unique_ptr<UDPSocket> openvpn::ServerProber::sock_v6
private

Definition at line 355 of file serverprober.hpp.

◆ socket_protect

SocketProtect* openvpn::ServerProber::socket_protect
private

Definition at line 347 of file serverprober.hpp.

◆ stats

SessionStats::Ptr openvpn::ServerProber::stats
private

Definition at line 348 of file serverprober.hpp.

◆ timer

AsioTimer openvpn::ServerProber::timer
private

Definition at line 351 of file serverprober.hpp.


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