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

#include <capture.hpp>

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

Classes

class  ProxyAutoConfigURL
 
class  ProxyBypass
 
class  ProxyHostPort
 
class  RemoteAddress
 
class  RerouteGW
 
class  Route
 
class  RouteAddress
 
class  RouteBase
 
class  WINSServer
 

Public Types

using Ptr = RCPtr< TunBuilderCapture >
 
- Public Types inherited from openvpn::RC< thread_unsafe_refcount >
typedef RCPtr< RCPtr
 

Public Member Functions

bool tun_builder_set_remote_address (const std::string &address, bool ipv6) override
 Callback to set the address of the remote server.
 
bool tun_builder_add_address (const std::string &address, int prefix_length, const std::string &gateway, bool ipv6, bool net30) override
 Callback to add a network address to the VPN interface.
 
bool tun_builder_reroute_gw (bool ipv4, bool ipv6, unsigned int flags) override
 Callback to reroute the default gateway to the VPN interface.
 
bool tun_builder_set_route_metric_default (int metric) override
 Optional callback to set default value for route metric.
 
bool tun_builder_add_route (const std::string &address, int prefix_length, int metric, bool ipv6) override
 Callback to add a route to the VPN interface.
 
bool tun_builder_exclude_route (const std::string &address, int prefix_length, int metric, bool ipv6) override
 Callback to exclude route from VPN interface.
 
bool tun_builder_set_dns_options (const DnsOptions &dns) override
 Set DNS options for use with tun builder.
 
bool tun_builder_set_layer (int layer) override
 Optional callback that indicates OSI layer to be used.
 
bool tun_builder_set_mtu (int mtu) override
 Callback to set the MTU of the VPN interface.
 
bool tun_builder_set_session_name (const std::string &name) override
 Sets the session name for the TunBuilder.
 
bool tun_builder_add_proxy_bypass (const std::string &bypass_host) override
 Callback to add a host which should bypass the proxy.
 
bool tun_builder_set_proxy_auto_config_url (const std::string &url) override
 Callback to set the proxy "Auto Config URL".
 
bool tun_builder_set_proxy_http (const std::string &host, int port) override
 Callback to set the HTTP proxy.
 
bool tun_builder_set_proxy_https (const std::string &host, int port) override
 Set the HTTPS proxy for the TunBuilder session.
 
bool tun_builder_add_wins_server (const std::string &address) override
 Callback to add a Windows WINS server to the VPN interface.
 
bool tun_builder_set_allow_family (int af, bool allow) override
 Indicates whether traffic of a certain address family (AF_INET or AF_INET6) should be blocked or allowed.
 
bool tun_builder_set_allow_local_dns (bool allow) override
 Optional callback that indicates whether local DNS traffic should be blocked or allowed to prevent DNS queries from leaking while the tunnel is connected.
 
void reset_tunnel_addresses ()
 
void reset_dns_options ()
 
const RouteAddressvpn_ipv4 () const
 
const RouteAddressvpn_ipv6 () const
 
const RouteAddressvpn_ip (const IP::Addr::Version v) const
 
void validate () const
 
std::string to_string () const
 
- Public Member Functions inherited from openvpn::TunBuilderBase
virtual bool tun_builder_new ()
 Callback to construct a new TunBuilder. This function should be called first.
 
virtual int tun_builder_establish ()
 Callback to establish the VPN tunnel.
 
virtual bool tun_builder_persist ()
 Determines if the TUN interface can be persisted.
 
virtual std::vector< std::string > tun_builder_get_local_networks (bool ipv6)
 Retrieves a list of local networks to exclude from the VPN network.
 
virtual void tun_builder_establish_lite ()
 Indicates a reconnection with persisted TUN state.
 
virtual void tun_builder_teardown (bool disconnect)
 Indicates that tunnel is being torn down.
 
virtual ~TunBuilderBase ()=default
 Virtual destructor for the TunBuilderBase class.
 
- Public Member Functions inherited from openvpn::RC< thread_unsafe_refcount >
 RC () noexcept=default
 
 RC (const RC &)=delete
 
virtual ~RC ()=default
 
RCoperator= (const RC &)=delete
 
olong use_count () const noexcept
 Delegates call to RCImpl and returns the result.
 

Public Attributes

std::string session_name
 
int mtu = 0
 
Layer layer {Layer::OSI_LAYER_3}
 
RemoteAddress remote_address
 
std::vector< RouteAddresstunnel_addresses
 
int tunnel_address_index_ipv4 = -1
 
int tunnel_address_index_ipv6 = -1
 
RerouteGW reroute_gw
 
bool block_ipv4 = false
 
bool block_ipv6 = false
 
bool block_outside_dns = false
 
int route_metric_default = -1
 
std::vector< Routeadd_routes
 
std::vector< Routeexclude_routes
 
DnsOptions dns_options
 
std::vector< ProxyBypassproxy_bypass
 
ProxyAutoConfigURL proxy_auto_config_url
 
ProxyHostPort http_proxy
 
ProxyHostPort https_proxy
 
std::vector< WINSServerwins_servers
 

Static Public Attributes

static constexpr int mtu_ipv4_maximum = 65'535
 

Private Member Functions

bool validate_tunnel_index (const int index) const
 
void validate_tunnel_address_indices (const std::string &title) const
 
void validate_mtu (const std::string &title) const
 
void validate_layer (const std::string &title) const
 

Static Private Member Functions

template<typename LIST >
static void render_list (std::ostream &os, const std::string &title, const LIST &list)
 
template<typename LIST >
static void validate_list (const LIST &list, const std::string &title)
 

Additional Inherited Members

- Static Public Member Functions inherited from openvpn::RC< thread_unsafe_refcount >
static constexpr bool is_thread_safe ()
 Delegates call to RCImpl and returns the result.
 

Detailed Description

Definition at line 41 of file capture.hpp.

Member Typedef Documentation

◆ Ptr

Member Function Documentation

◆ render_list()

template<typename LIST >
static void openvpn::TunBuilderCapture::render_list ( std::ostream &  os,
const std::string &  title,
const LIST &  list 
)
inlinestaticprivate

Definition at line 689 of file capture.hpp.

Here is the caller graph for this function:

◆ reset_dns_options()

void openvpn::TunBuilderCapture::reset_dns_options ( )
inline

Definition at line 520 of file capture.hpp.

Here is the caller graph for this function:

◆ reset_tunnel_addresses()

void openvpn::TunBuilderCapture::reset_tunnel_addresses ( )
inline

Definition at line 513 of file capture.hpp.

Here is the caller graph for this function:

◆ to_string()

std::string openvpn::TunBuilderCapture::to_string ( ) const
inline

Definition at line 567 of file capture.hpp.

Here is the caller graph for this function:

◆ tun_builder_add_address()

bool openvpn::TunBuilderCapture::tun_builder_add_address ( const std::string &  address,
int  prefix_length,
const std::string &  gateway,
bool  ipv6,
bool  net30 
)
inlineoverridevirtual

Callback to add a network address to the VPN interface.

This method may be called multiple times within a single TunBuilder session.

Parameters
addressThe network address to add.
prefix_lengthThe prefix length of the network address.
gatewayAn optional gateway address.
ipv6A boolean indicating whether the address is IPv6.
net30A boolean indicating whether to use a net30 topology.
Returns
true if the address was successfully added, false otherwise

Reimplemented from openvpn::TunBuilderBase.

Definition at line 378 of file capture.hpp.

Here is the caller graph for this function:

◆ tun_builder_add_proxy_bypass()

bool openvpn::TunBuilderCapture::tun_builder_add_proxy_bypass ( const std::string &  bypass_host)
inlineoverridevirtual

Callback to add a host which should bypass the proxy.

This method can be called multiple times within the same TunBuilder session.

Parameters
bypass_hostA string representing the host that should bypass the proxy.
Returns
Returns true if the bypass host was successfully added, false otherwise

Reimplemented from openvpn::TunBuilderBase.

Definition at line 462 of file capture.hpp.

Here is the caller graph for this function:

◆ tun_builder_add_route()

bool openvpn::TunBuilderCapture::tun_builder_add_route ( const std::string &  address,
int  prefix_length,
int  metric,
bool  ipv6 
)
inlineoverridevirtual

Callback to add a route to the VPN interface.

This method may be called multiple times per TunBuilder session.

Parameters
addressThe address to add the route for.
prefix_lengthThe prefix length associated with the route.
metricThe metric for the route. It is optional and should be ignored if it is less than 0.
ipv6Boolean indicating whether the address is IPv6.
Returns
true if the route was successfully added, false otherwise

Reimplemented from openvpn::TunBuilderBase.

Definition at line 408 of file capture.hpp.

Here is the caller graph for this function:

◆ tun_builder_add_wins_server()

bool openvpn::TunBuilderCapture::tun_builder_add_wins_server ( const std::string &  address)
inlineoverridevirtual

Callback to add a Windows WINS server to the VPN interface.

This function is called to add a WINS server address to the VPN interface. WINS server addresses are always IPv4.

Note
This function may be called more than once per TunBuilder session. It is guaranteed to be called after tun_builder_reroute_gw().
Parameters
addressThe IPv4 address of the WINS server to be added.
Returns
true if the WINS server was successfully added, false otherwise

Reimplemented from openvpn::TunBuilderBase.

Definition at line 490 of file capture.hpp.

Here is the caller graph for this function:

◆ tun_builder_exclude_route()

bool openvpn::TunBuilderCapture::tun_builder_exclude_route ( const std::string &  address,
int  prefix_length,
int  metric,
bool  ipv6 
)
inlineoverridevirtual

Callback to exclude route from VPN interface.

This method may be called more than once per TunBuilder session.

Parameters
addressThe IP address for the route to be excluded.
prefix_lengthThe prefix length for the IP address.
metricThe route metric. This parameter should be ignored if it is less than 0.
ipv6A boolean flag indicating whether the IP address is IPv6 or not.
Returns
true if the route was successfully excluded, false otherwise

Reimplemented from openvpn::TunBuilderBase.

Definition at line 419 of file capture.hpp.

Here is the caller graph for this function:

◆ tun_builder_reroute_gw()

bool openvpn::TunBuilderCapture::tun_builder_reroute_gw ( bool  ipv4,
bool  ipv6,
unsigned int  flags 
)
inlineoverridevirtual

Callback to reroute the default gateway to the VPN interface.

This function is used to add the default route for either IPv4, IPv6, or both. It is called only once per TunBuilder session.

Parameters
ipv4Set to true if the default route to be added should be IPv4.
ipv6Set to true if the default route to be added should be IPv6.
flagsAdditional flags defined in RGWFlags (see rgwflags.hpp for details).
Returns
true if the rerouting was successful, false otherwise

Reimplemented from openvpn::TunBuilderBase.

Definition at line 394 of file capture.hpp.

Here is the caller graph for this function:

◆ tun_builder_set_allow_family()

bool openvpn::TunBuilderCapture::tun_builder_set_allow_family ( int  af,
bool  allow 
)
inlineoverridevirtual

Indicates whether traffic of a certain address family (AF_INET or AF_INET6) should be blocked or allowed.

This is used to prevent unencrypted packet leakage when the tunnel is IPv4-only or IPv6-only, but the local machine has connectivity with the other protocol to the internet.

This setting is controlled by the "block-ipv6" and "block-ipv6" configuration variables. If addresses are added for a family, this setting should be ignored for that family.

Remarks
See also Android's VPNService.Builder::allowFamily method.
Parameters
afThe address family (AF_INET or AF_INET6).
allowA boolean indicating whether the address family should be allowed.
Returns
true if it was successfully set, false otherwise

Reimplemented from openvpn::TunBuilderBase.

Definition at line 498 of file capture.hpp.

Here is the caller graph for this function:

◆ tun_builder_set_allow_local_dns()

bool openvpn::TunBuilderCapture::tun_builder_set_allow_local_dns ( bool  allow)
inlineoverridevirtual

Optional callback that indicates whether local DNS traffic should be blocked or allowed to prevent DNS queries from leaking while the tunnel is connected.

Note that this option is only relevant on Windows when the --dns option is used. If DNS is set via --dhcp-option, port 53 is always blocked for backwards compatibility reasons.

Parameters
allowDetermines whether to allow (true) or block (false) local DNS traffic.
Returns
true if it was successfully set, false otherwise

Reimplemented from openvpn::TunBuilderBase.

Definition at line 507 of file capture.hpp.

◆ tun_builder_set_dns_options()

bool openvpn::TunBuilderCapture::tun_builder_set_dns_options ( const DnsOptions dns)
inlineoverridevirtual

Set DNS options for use with tun builder.

Calling this invalidates any DNS related –dhcp-options previously added.

Parameters
dnsThe –dns options to be set
Returns
true unconditionally

Reimplemented from openvpn::TunBuilderBase.

Definition at line 438 of file capture.hpp.

Here is the caller graph for this function:

◆ tun_builder_set_layer()

bool openvpn::TunBuilderCapture::tun_builder_set_layer ( int  layer)
inlineoverridevirtual

Optional callback that indicates OSI layer to be used.

This function sets the OSI layer to be used. Possible values are 2 (TAP), 3 (TUN) or 0. Currently, we only support 3 (TUN).

Parameters
layerThe OSI layer to set, should be 2 (TAP), 3 (TUN) or 0. Currently only 3 (TUN) is supported.
Returns
true if the layer was successfully set, false otherwise

Reimplemented from openvpn::TunBuilderBase.

Definition at line 444 of file capture.hpp.

◆ tun_builder_set_mtu()

bool openvpn::TunBuilderCapture::tun_builder_set_mtu ( int  mtu)
inlineoverridevirtual

Callback to set the MTU of the VPN interface.

This function sets the Maximum Transmission Unit (MTU) of the virtual private network (VPN) interface. It's designed to be called not more than once per TunBuilder session.

Parameters
mtuThe MTU size to set.
Returns
Returns true if the MTU was successfully set, false otherwise

Reimplemented from openvpn::TunBuilderBase.

Definition at line 450 of file capture.hpp.

Here is the caller graph for this function:

◆ tun_builder_set_proxy_auto_config_url()

bool openvpn::TunBuilderCapture::tun_builder_set_proxy_auto_config_url ( const std::string &  url)
inlineoverridevirtual

Callback to set the proxy "Auto Config URL".

This function is a callback used to set the proxy "Auto Config URL". It is never called more than once per TunBuilder session.

Parameters
urlThe URL string for the proxy autoconfiguration.
Returns
Returns true if the proxy auto config URL was successfully set, false otherwise

Reimplemented from openvpn::TunBuilderBase.

Definition at line 470 of file capture.hpp.

Here is the caller graph for this function:

◆ tun_builder_set_proxy_http()

bool openvpn::TunBuilderCapture::tun_builder_set_proxy_http ( const std::string &  host,
int  port 
)
inlineoverridevirtual

Callback to set the HTTP proxy.

This function acts as a callback to configure the HTTP proxy settings. It is never called more than once per TunBuilder session.

Parameters
hostThe hostname or IP address of the HTTP proxy.
portThe port number of the HTTP proxy.
Returns
Returns true if the HTTP proxy was successfully set, false otherwise

Reimplemented from openvpn::TunBuilderBase.

Definition at line 476 of file capture.hpp.

Here is the caller graph for this function:

◆ tun_builder_set_proxy_https()

bool openvpn::TunBuilderCapture::tun_builder_set_proxy_https ( const std::string &  host,
int  port 
)
inlineoverridevirtual

Set the HTTPS proxy for the TunBuilder session.

This method sets the HTTPS proxy using the given host and port. It is called at most once during a TunBuilder session.

Parameters
hostThe hostname of the HTTPS proxy.
portThe port number of the HTTPS proxy.
Returns
true if the HTTPS proxy was successfully set, false otherwise

Reimplemented from openvpn::TunBuilderBase.

Definition at line 483 of file capture.hpp.

Here is the caller graph for this function:

◆ tun_builder_set_remote_address()

bool openvpn::TunBuilderCapture::tun_builder_set_remote_address ( const std::string &  address,
bool  ipv6 
)
inlineoverridevirtual

Callback to set the address of the remote server.

This function is invoked to set the remote server's address. It will not be called more than once in a single TunBuilder session.

Parameters
addressSpecifies the address of the remote server.
ipv6Boolean indicating whether the given address is an IPv6 address.
Returns
true if the address was successfully set, false otherwise

Reimplemented from openvpn::TunBuilderBase.

Definition at line 371 of file capture.hpp.

Here is the caller graph for this function:

◆ tun_builder_set_route_metric_default()

bool openvpn::TunBuilderCapture::tun_builder_set_route_metric_default ( int  metric)
inlineoverridevirtual

Optional callback to set default value for route metric.

This method is guaranteed to be called before other methods that deal with routes, such as tun_builder_add_route() and tun_builder_reroute_gw(). The route metric is ignored if its value is less than 0.

Parameters
metricThe metric value to set for the route.
Returns
true if the route metric was successfully set

Reimplemented from openvpn::TunBuilderBase.

Definition at line 402 of file capture.hpp.

◆ tun_builder_set_session_name()

bool openvpn::TunBuilderCapture::tun_builder_set_session_name ( const std::string &  name)
inlineoverridevirtual

Sets the session name for the TunBuilder.

This function is a callback that sets the session name. It is guaranteed to be called no more than once per TunBuilder session.

Parameters
nameA string representing the session name.
Returns
Returns true if the session name was successfully set, false otherwise

Reimplemented from openvpn::TunBuilderBase.

Definition at line 456 of file capture.hpp.

Here is the caller graph for this function:

◆ validate()

void openvpn::TunBuilderCapture::validate ( ) const
inline

Definition at line 552 of file capture.hpp.

Here is the caller graph for this function:

◆ validate_layer()

void openvpn::TunBuilderCapture::validate_layer ( const std::string &  title) const
inlineprivate

Definition at line 736 of file capture.hpp.

Here is the caller graph for this function:

◆ validate_list()

template<typename LIST >
static void openvpn::TunBuilderCapture::validate_list ( const LIST &  list,
const std::string &  title 
)
inlinestaticprivate

Definition at line 699 of file capture.hpp.

Here is the caller graph for this function:

◆ validate_mtu()

void openvpn::TunBuilderCapture::validate_mtu ( const std::string &  title) const
inlineprivate

Definition at line 730 of file capture.hpp.

Here is the caller graph for this function:

◆ validate_tunnel_address_indices()

void openvpn::TunBuilderCapture::validate_tunnel_address_indices ( const std::string &  title) const
inlineprivate

Definition at line 716 of file capture.hpp.

Here is the caller graph for this function:

◆ validate_tunnel_index()

bool openvpn::TunBuilderCapture::validate_tunnel_index ( const int  index) const
inlineprivate

Definition at line 709 of file capture.hpp.

Here is the caller graph for this function:

◆ vpn_ip()

const RouteAddress * openvpn::TunBuilderCapture::vpn_ip ( const IP::Addr::Version  v) const
inline

Definition at line 539 of file capture.hpp.

◆ vpn_ipv4()

const RouteAddress * openvpn::TunBuilderCapture::vpn_ipv4 ( ) const
inline

Definition at line 525 of file capture.hpp.

Here is the caller graph for this function:

◆ vpn_ipv6()

const RouteAddress * openvpn::TunBuilderCapture::vpn_ipv6 ( ) const
inline

Definition at line 532 of file capture.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ add_routes

std::vector<Route> openvpn::TunBuilderCapture::add_routes

Definition at line 674 of file capture.hpp.

◆ block_ipv4

bool openvpn::TunBuilderCapture::block_ipv4 = false

Definition at line 670 of file capture.hpp.

◆ block_ipv6

bool openvpn::TunBuilderCapture::block_ipv6 = false

Definition at line 671 of file capture.hpp.

◆ block_outside_dns

bool openvpn::TunBuilderCapture::block_outside_dns = false

Definition at line 672 of file capture.hpp.

◆ dns_options

DnsOptions openvpn::TunBuilderCapture::dns_options

Definition at line 676 of file capture.hpp.

◆ exclude_routes

std::vector<Route> openvpn::TunBuilderCapture::exclude_routes

Definition at line 675 of file capture.hpp.

◆ http_proxy

ProxyHostPort openvpn::TunBuilderCapture::http_proxy

Definition at line 680 of file capture.hpp.

◆ https_proxy

ProxyHostPort openvpn::TunBuilderCapture::https_proxy

Definition at line 681 of file capture.hpp.

◆ layer

Layer openvpn::TunBuilderCapture::layer {Layer::OSI_LAYER_3}

Definition at line 664 of file capture.hpp.

◆ mtu

int openvpn::TunBuilderCapture::mtu = 0

Definition at line 663 of file capture.hpp.

◆ mtu_ipv4_maximum

constexpr int openvpn::TunBuilderCapture::mtu_ipv4_maximum = 65'535
staticconstexpr

Definition at line 685 of file capture.hpp.

◆ proxy_auto_config_url

ProxyAutoConfigURL openvpn::TunBuilderCapture::proxy_auto_config_url

Definition at line 679 of file capture.hpp.

◆ proxy_bypass

std::vector<ProxyBypass> openvpn::TunBuilderCapture::proxy_bypass

Definition at line 678 of file capture.hpp.

◆ remote_address

RemoteAddress openvpn::TunBuilderCapture::remote_address

Definition at line 665 of file capture.hpp.

◆ reroute_gw

RerouteGW openvpn::TunBuilderCapture::reroute_gw

Definition at line 669 of file capture.hpp.

◆ route_metric_default

int openvpn::TunBuilderCapture::route_metric_default = -1

Definition at line 673 of file capture.hpp.

◆ session_name

std::string openvpn::TunBuilderCapture::session_name

Definition at line 662 of file capture.hpp.

◆ tunnel_address_index_ipv4

int openvpn::TunBuilderCapture::tunnel_address_index_ipv4 = -1

Definition at line 667 of file capture.hpp.

◆ tunnel_address_index_ipv6

int openvpn::TunBuilderCapture::tunnel_address_index_ipv6 = -1

Definition at line 668 of file capture.hpp.

◆ tunnel_addresses

std::vector<RouteAddress> openvpn::TunBuilderCapture::tunnel_addresses

Definition at line 666 of file capture.hpp.

◆ wins_servers

std::vector<WINSServer> openvpn::TunBuilderCapture::wins_servers

Definition at line 683 of file capture.hpp.


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