File Coverage

blib/lib/Linux/WireGuard.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Linux::WireGuard;
2              
3 2     2   769 use strict;
  2         11  
  2         45  
4 2     2   11 use warnings;
  2         3  
  2         45  
5              
6             =encoding utf-8
7              
8             =head1 NAME
9              
10             Linux::WireGuard - L in Perl
11              
12             =head1 SYNOPSIS
13              
14             my @names = Linux::WireGuard::list_device_names();
15              
16             my %device = map { $_ => Linux::WireGuard::get_device($_) } @names;
17              
18             =head1 DESCRIPTION
19              
20             Linux::WireGuard provides an interface to WireGuard via
21             L.
22              
23             NB: Although WireGuard itself is cross-platform, the embedded C
24             library is Linux-specific.
25              
26             =cut
27              
28             #----------------------------------------------------------------------
29              
30 2     2   7 use XSLoader;
  2         17  
  2         110  
31              
32             our $VERSION = '0.01_90';
33              
34             XSLoader::load( __PACKAGE__, $VERSION );
35              
36             #----------------------------------------------------------------------
37              
38             =head1 FUNCTIONS
39              
40             =head2 @names = list_device_names()
41              
42             Returns a list of strings.
43              
44             =head2 $dev_hr = get_device( $NAME )
45              
46             Returns a reference to a hash that describes the $NAME’d device:
47              
48             =over
49              
50             =item * C
51              
52             =item * C
53              
54             =item * C and C (raw strings, or undef)
55              
56             =item * C (can be undef)
57              
58             =item * C (can be undef)
59              
60             =item * C - reference to an array of hash references. Each hash is:
61              
62             =over
63              
64             =item * C and C (raw strings, or undef)
65              
66             =item * C - Raw sockaddr data (a string), or undef. To parse
67             the sockaddr, use L’s C to determine the
68             address family, then C for Socket::AF_INET or
69             C for Socket::AF_INET6.
70              
71             =item * C and C
72              
73             =item * C (can be undef)
74              
75             =item * C and C
76              
77             =item * C - reference to an array of hash references. Each hash is:
78              
79             =over
80              
81             =item * C - Socket::AF_INET or Socket::AF_INET6
82              
83             =item * C - A packed IPv4 or IPv6 address. Unpack with L’s
84             C or C.
85              
86             =item * C
87              
88             =back
89              
90             =back
91              
92             =back
93              
94             =head2 $bin = generate_private_key()
95              
96             Returns a newly-generated private key (raw string).
97              
98             =head2 $bin = generate_public_key( $PRIVATE_KEY )
99              
100             Takes a private key and returns its public key. (Both raw strings.)
101              
102             =head2 $bin = generate_preshared_key()
103              
104             Returns a newly-generated preshared key (raw string).
105              
106             =head1 TODO
107              
108             The interface is incomplete. It would be nice for it to be complete.
109              
110             =head1 LICENSE & COPYRIGHT
111              
112             Copyright 2022 Gasper Software Consulting. All rights reserved.
113              
114             Linux::WireGuard is licensed under the same terms as Perl itself (cf.
115             L); B, the embedded C wireguard library has its
116             own copyright terms. Use of Linux::WireGuard I imply acceptance of
117             that embedded C library’s own copyright terms. See this distribution’s
118             F for details.
119              
120             =cut
121              
122             1;