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

Represents a remote IP address with IPv4/IPv6 designation. More...

#include <capture.hpp>

Public Member Functions

std::string to_string () const
 Returns a string representation of the remote address.
 
bool defined () const
 Checks if the address is defined.
 
void validate (const std::string &title) const
 Validates the IP address format.
 
Json::Value to_json () const
 Serializes the object to a JSON value.
 
void from_json (const Json::Value &root, const std::string &title)
 Deserializes the object from a JSON value.
 

Public Attributes

std::string address
 
bool ipv6 = false
 

Detailed Description

Represents a remote IP address with IPv4/IPv6 designation.

This class encapsulates an IP address string along with a flag indicating whether it's an IPv6 address. It provides methods for validation, serialization, and checking if the address is defined.

Definition at line 54 of file capture.hpp.

Member Function Documentation

◆ defined()

bool openvpn::TunBuilderCapture::RemoteAddress::defined ( ) const
inline

Checks if the address is defined.

An address is considered defined if its string representation is not empty.

Returns
true if the address is defined, false otherwise.

Definition at line 79 of file capture.hpp.

Here is the caller graph for this function:

◆ from_json()

void openvpn::TunBuilderCapture::RemoteAddress::from_json ( const Json::Value &  root,
const std::string &  title 
)
inline

Deserializes the object from a JSON value.

Populates the object's fields from the given JSON object.

Warning
If input is not a valid JSON dictionary, the method will return without processing and without raising any errors. This silent behavior may cause unexpected results.
Parameters
rootThe JSON value to deserialize from.
titleA context string used in error messages if deserialization fails.

Definition at line 116 of file capture.hpp.

◆ to_json()

Json::Value openvpn::TunBuilderCapture::RemoteAddress::to_json ( ) const
inline

Serializes the object to a JSON value.

Creates a JSON object with "address" and "ipv6" fields.

Returns
A Json::Value object representing this remote address.

Definition at line 101 of file capture.hpp.

Here is the caller graph for this function:

◆ to_string()

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

Returns a string representation of the remote address.

Formats the address as a string, appending " [IPv6]" suffix if the address is IPv6.

Returns
Formatted string representation of the address.

Definition at line 66 of file capture.hpp.

Here is the caller graph for this function:

◆ validate()

void openvpn::TunBuilderCapture::RemoteAddress::validate ( const std::string &  title) const
inline

Validates the IP address format.

Uses the IP::Addr class to validate that the address string represents a valid IPv4 or IPv6 address based on the ipv6 flag.

Parameters
titleA context string used in error messages if validation fails.

Definition at line 90 of file capture.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ address

std::string openvpn::TunBuilderCapture::RemoteAddress::address

Definition at line 57 of file capture.hpp.

◆ ipv6

bool openvpn::TunBuilderCapture::RemoteAddress::ipv6 = false

Definition at line 58 of file capture.hpp.


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