OpenVPN 3 Core Library
|
#include <capture.hpp>
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 > |
![]() | |
typedef RCPtr< RC > | Ptr |
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 RouteAddress * | vpn_ipv4 () const |
const RouteAddress * | vpn_ipv6 () const |
const RouteAddress * | vpn_ip (const IP::Addr::Version v) const |
void | validate () const |
std::string | to_string () const |
![]() | |
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. | |
![]() | |
RC () noexcept=default | |
RC (const RC &)=delete | |
virtual | ~RC ()=default |
RC & | operator= (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< RouteAddress > | tunnel_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< Route > | add_routes |
std::vector< Route > | exclude_routes |
DnsOptions | dns_options |
std::vector< ProxyBypass > | proxy_bypass |
ProxyAutoConfigURL | proxy_auto_config_url |
ProxyHostPort | http_proxy |
ProxyHostPort | https_proxy |
std::vector< WINSServer > | wins_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 constexpr bool | is_thread_safe () |
Delegates call to RCImpl and returns the result. | |
Definition at line 41 of file capture.hpp.
Definition at line 44 of file capture.hpp.
|
inlinestaticprivate |
|
inline |
|
inline |
|
inline |
|
inlineoverridevirtual |
Callback to add a network address to the VPN interface.
This method may be called multiple times within a single TunBuilder session.
address | The network address to add. |
prefix_length | The prefix length of the network address. |
gateway | An optional gateway address. |
ipv6 | A boolean indicating whether the address is IPv6. |
net30 | A boolean indicating whether to use a net30 topology. |
true
if the address was successfully added, false
otherwise Reimplemented from openvpn::TunBuilderBase.
Definition at line 378 of file capture.hpp.
|
inlineoverridevirtual |
Callback to add a host which should bypass the proxy.
This method can be called multiple times within the same TunBuilder session.
bypass_host | A string representing the host that should bypass the proxy. |
true
if the bypass host was successfully added, false
otherwise Reimplemented from openvpn::TunBuilderBase.
Definition at line 462 of file capture.hpp.
|
inlineoverridevirtual |
Callback to add a route to the VPN interface.
This method may be called multiple times per TunBuilder session.
address | The address to add the route for. |
prefix_length | The prefix length associated with the route. |
metric | The metric for the route. It is optional and should be ignored if it is less than 0. |
ipv6 | Boolean indicating whether the address is IPv6. |
true
if the route was successfully added, false
otherwise Reimplemented from openvpn::TunBuilderBase.
Definition at line 408 of file capture.hpp.
|
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.
tun_builder_reroute_gw()
.address | The IPv4 address of the WINS server to be added. |
true
if the WINS server was successfully added, false
otherwise Reimplemented from openvpn::TunBuilderBase.
Definition at line 490 of file capture.hpp.
|
inlineoverridevirtual |
Callback to exclude route from VPN interface.
This method may be called more than once per TunBuilder session.
address | The IP address for the route to be excluded. |
prefix_length | The prefix length for the IP address. |
metric | The route metric. This parameter should be ignored if it is less than 0. |
ipv6 | A boolean flag indicating whether the IP address is IPv6 or not. |
true
if the route was successfully excluded, false
otherwise Reimplemented from openvpn::TunBuilderBase.
Definition at line 419 of file capture.hpp.
|
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.
ipv4 | Set to true if the default route to be added should be IPv4. |
ipv6 | Set to true if the default route to be added should be IPv6. |
flags | Additional flags defined in RGWFlags (see rgwflags.hpp for details). |
true
if the rerouting was successful, false
otherwise Reimplemented from openvpn::TunBuilderBase.
Definition at line 394 of file capture.hpp.
|
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.
af | The address family (AF_INET or AF_INET6). |
allow | A boolean indicating whether the address family should be allowed. |
true
if it was successfully set, false
otherwise Reimplemented from openvpn::TunBuilderBase.
Definition at line 498 of file capture.hpp.
|
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.
allow | Determines whether to allow (true ) or block (false ) local DNS traffic. |
true
if it was successfully set, false
otherwise Reimplemented from openvpn::TunBuilderBase.
Definition at line 507 of file capture.hpp.
|
inlineoverridevirtual |
Set DNS options for use with tun builder.
Calling this invalidates any DNS related –dhcp-options previously added.
dns | The –dns options to be set |
Reimplemented from openvpn::TunBuilderBase.
Definition at line 438 of file capture.hpp.
|
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).
layer | The OSI layer to set, should be 2 (TAP), 3 (TUN) or 0. Currently only 3 (TUN) is supported. |
true
if the layer was successfully set, false
otherwise Reimplemented from openvpn::TunBuilderBase.
Definition at line 444 of file capture.hpp.
|
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.
mtu | The MTU size to set. |
true
if the MTU was successfully set, false
otherwise Reimplemented from openvpn::TunBuilderBase.
Definition at line 450 of file capture.hpp.
|
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.
url | The URL string for the proxy autoconfiguration. |
true
if the proxy auto config URL was successfully set, false
otherwise Reimplemented from openvpn::TunBuilderBase.
Definition at line 470 of file capture.hpp.
|
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.
true
if the HTTP proxy was successfully set, false
otherwise Reimplemented from openvpn::TunBuilderBase.
Definition at line 476 of file capture.hpp.
|
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.
host | The hostname of the HTTPS proxy. |
port | The port number of the HTTPS proxy. |
true
if the HTTPS proxy was successfully set, false
otherwise Reimplemented from openvpn::TunBuilderBase.
Definition at line 483 of file capture.hpp.
|
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.
address | Specifies the address of the remote server. |
ipv6 | Boolean indicating whether the given address is an IPv6 address. |
true
if the address was successfully set, false
otherwise Reimplemented from openvpn::TunBuilderBase.
Definition at line 371 of file capture.hpp.
|
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.
metric | The metric value to set for the route. |
true
if the route metric was successfully set Reimplemented from openvpn::TunBuilderBase.
Definition at line 402 of file capture.hpp.
|
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.
name | A string representing the session name. |
true
if the session name was successfully set, false
otherwise Reimplemented from openvpn::TunBuilderBase.
Definition at line 456 of file capture.hpp.
|
inline |
|
inlineprivate |
|
inlinestaticprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inline |
Definition at line 539 of file capture.hpp.
|
inline |
|
inline |
std::vector<Route> openvpn::TunBuilderCapture::add_routes |
Definition at line 674 of file capture.hpp.
bool openvpn::TunBuilderCapture::block_ipv4 = false |
Definition at line 670 of file capture.hpp.
bool openvpn::TunBuilderCapture::block_ipv6 = false |
Definition at line 671 of file capture.hpp.
bool openvpn::TunBuilderCapture::block_outside_dns = false |
Definition at line 672 of file capture.hpp.
DnsOptions openvpn::TunBuilderCapture::dns_options |
Definition at line 676 of file capture.hpp.
std::vector<Route> openvpn::TunBuilderCapture::exclude_routes |
Definition at line 675 of file capture.hpp.
ProxyHostPort openvpn::TunBuilderCapture::http_proxy |
Definition at line 680 of file capture.hpp.
ProxyHostPort openvpn::TunBuilderCapture::https_proxy |
Definition at line 681 of file capture.hpp.
Layer openvpn::TunBuilderCapture::layer {Layer::OSI_LAYER_3} |
Definition at line 664 of file capture.hpp.
int openvpn::TunBuilderCapture::mtu = 0 |
Definition at line 663 of file capture.hpp.
|
staticconstexpr |
Definition at line 685 of file capture.hpp.
ProxyAutoConfigURL openvpn::TunBuilderCapture::proxy_auto_config_url |
Definition at line 679 of file capture.hpp.
std::vector<ProxyBypass> openvpn::TunBuilderCapture::proxy_bypass |
Definition at line 678 of file capture.hpp.
RemoteAddress openvpn::TunBuilderCapture::remote_address |
Definition at line 665 of file capture.hpp.
RerouteGW openvpn::TunBuilderCapture::reroute_gw |
Definition at line 669 of file capture.hpp.
int openvpn::TunBuilderCapture::route_metric_default = -1 |
Definition at line 673 of file capture.hpp.
std::string openvpn::TunBuilderCapture::session_name |
Definition at line 662 of file capture.hpp.
int openvpn::TunBuilderCapture::tunnel_address_index_ipv4 = -1 |
Definition at line 667 of file capture.hpp.
int openvpn::TunBuilderCapture::tunnel_address_index_ipv6 = -1 |
Definition at line 668 of file capture.hpp.
std::vector<RouteAddress> openvpn::TunBuilderCapture::tunnel_addresses |
Definition at line 666 of file capture.hpp.
std::vector<WINSServer> openvpn::TunBuilderCapture::wins_servers |
Definition at line 683 of file capture.hpp.