The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WGmeta::Wrapper::Show - Class for interfacing `wg show dump` output

SYNOPSIS

 use Wireguard::WGmeta::Wrapper::Show;
 my $wg_show = Wireguard::WGmeta::Wrapper::Show->new(<wg show dump output as string>);

DESCRIPTION

This class provides wrapper-functions around the output of Wireguard::WGmeta::Parser::Show.

EXAMPLES

 use Wireguard::WGmeta::Wrapper::Show;
 use Wireguard::WGmeta::Wrapper::Bridge;

 my ($out, $err) = get_wg_show();
 my $wg_show = Wireguard::WGmeta::Wrapper::Show->new($out);

 # get a specific interface section
 wg_show->get_interface_section('wg0', '<interface_public_key>');

METHODS

new($wg_show_dump)

Creates a new instance of the show parser

Parameters

  • $wg_show_dump Output of the (external) command wg show dump.

Returns

Instance

get_interface_list()

Returns a list with all available interface names

Parameters

Returns

A list with valid interface names.

iface_exists($interface)

Simply checks if data is available for a specific interface. Useful to check if an interface is up.

Parameters

  • $interface An interface name

Returns

If yes, returns True else False

get_interface_section($interface, $identifier)

Returns a specific section of an interface

Parameters

  • $interface A valid interface name, ideally retrieved through "get_interface_list()".

  • $identifier A valid identifier, if the requested section is a peer this is its public-key, otherwise the interface name again.

Returns

A hash of the requested section. If non-existent, empty hash.

get_section_list($interface)

Returns a sorted list of all peers belonging to given interface

Parameters

Returns

A list of peer public-keys (identifiers), if the interface does not exist -> empty list.