OpenVPN 3 Core Library
Loading...
Searching...
No Matches
unittests::TunBuilderMock Class Reference
Inheritance diagram for unittests::TunBuilderMock:
[legend]
Collaboration diagram for unittests::TunBuilderMock:
[legend]

Public Member Functions

 TunBuilderMock (bool ipv6)
 
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_set_remote_address (const std::string &address, bool ipv6) override
 Callback to set the address of the remote server.
 
bool containsIP (std::string ipaddr)
 
bool containsIP (openvpn::IP::Addr ipaddr)
 
- 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 bool tun_builder_set_layer (int layer)
 Optional callback that indicates OSI layer to be used.
 
virtual bool tun_builder_add_address (const std::string &address, int prefix_length, const std::string &gateway, bool ipv6, bool net30)
 Callback to add a network address to the VPN interface.
 
virtual bool tun_builder_set_route_metric_default (int metric)
 Optional callback to set default value for route metric.
 
virtual bool tun_builder_reroute_gw (bool ipv4, bool ipv6, unsigned int flags)
 Callback to reroute the default gateway to the VPN interface.
 
virtual bool tun_builder_exclude_route (const std::string &address, int prefix_length, int metric, bool ipv6)
 Callback to exclude route from VPN interface.
 
virtual bool tun_builder_set_dns_options (const DnsOptions &dns)
 Callback to set DNS related options to VPN interface.
 
virtual bool tun_builder_set_mtu (int mtu)
 Callback to set the MTU of the VPN interface.
 
virtual bool tun_builder_set_session_name (const std::string &name)
 Sets the session name for the TunBuilder.
 
virtual bool tun_builder_add_proxy_bypass (const std::string &bypass_host)
 Callback to add a host which should bypass the proxy.
 
virtual bool tun_builder_set_proxy_auto_config_url (const std::string &url)
 Callback to set the proxy "Auto Config URL".
 
virtual bool tun_builder_set_proxy_http (const std::string &host, int port)
 Callback to set the HTTP proxy.
 
virtual bool tun_builder_set_proxy_https (const std::string &host, int port)
 Set the HTTPS proxy for the TunBuilder session.
 
virtual bool tun_builder_add_wins_server (const std::string &address)
 Callback to add a Windows WINS server to the VPN interface.
 
virtual bool tun_builder_set_allow_family (int af, bool allow)
 Indicates whether traffic of a certain address family (AF_INET or AF_INET6) should be blocked or allowed.
 
virtual bool tun_builder_set_allow_local_dns (bool allow)
 Optional callback that indicates whether local DNS traffic should be blocked or allowed to prevent DNS queries from leaking while the tunnel is connected.
 
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 Attributes

bool is_ipv6
 
std::vector< std::string > addresses
 
std::vector< std::string > routes
 
std::vector< openvpn::IP::RouteroutesAddr
 

Detailed Description

Definition at line 35 of file test_route_emulation.cpp.

Constructor & Destructor Documentation

◆ TunBuilderMock()

unittests::TunBuilderMock::TunBuilderMock ( bool  ipv6)
inline

Definition at line 39 of file test_route_emulation.cpp.

Member Function Documentation

◆ containsIP() [1/2]

bool unittests::TunBuilderMock::containsIP ( openvpn::IP::Addr  ipaddr)
inline

Definition at line 70 of file test_route_emulation.cpp.

◆ containsIP() [2/2]

bool unittests::TunBuilderMock::containsIP ( std::string  ipaddr)
inline

Definition at line 65 of file test_route_emulation.cpp.

Here is the caller graph for this function:

◆ tun_builder_add_route()

bool unittests::TunBuilderMock::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 44 of file test_route_emulation.cpp.

◆ tun_builder_set_remote_address()

bool unittests::TunBuilderMock::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 55 of file test_route_emulation.cpp.

Member Data Documentation

◆ addresses

std::vector<std::string> unittests::TunBuilderMock::addresses

Definition at line 61 of file test_route_emulation.cpp.

◆ is_ipv6

bool unittests::TunBuilderMock::is_ipv6

Definition at line 38 of file test_route_emulation.cpp.

◆ routes

std::vector<std::string> unittests::TunBuilderMock::routes

Definition at line 62 of file test_route_emulation.cpp.

◆ routesAddr

std::vector<openvpn::IP::Route> unittests::TunBuilderMock::routesAddr

Definition at line 63 of file test_route_emulation.cpp.


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