File Coverage

lib/Wireguard/WGmeta/Cli/Commands/Apply.pm
Criterion Covered Total %
statement 15 35 42.8
branch 0 4 0.0
condition n/a
subroutine 5 8 62.5
pod 2 2 100.0
total 22 49 44.9


line stmt bran cond sub pod time code
1             package Wireguard::WGmeta::Cli::Commands::Apply;
2 1     1   6 use strict;
  1         3  
  1         45  
3 1     1   5 use warnings FATAL => 'all';
  1         2  
  1         32  
4              
5 1     1   5 use experimental 'signatures';
  1         1  
  1         6  
6              
7 1     1   98 use parent 'Wireguard::WGmeta::Cli::Commands::Command';
  1         3  
  1         4  
8              
9 1     1   66 use Wireguard::WGmeta::Wrapper::Bridge;
  1         2  
  1         269  
10              
11              
12 0     0 1   sub entry_point($self) {
  0            
  0            
13 0 0         if ($self->_retrieve_or_die($self->{input_args}, 0) eq 'help') {
14 0           $self->cmd_help();
15             }
16 0           $self->check_privileges();
17 0           $self->_run_command();
18             }
19              
20 0     0     sub _run_command($self) {
  0            
  0            
21 0           my $interface = $self->_retrieve_or_die($self->{input_args}, 0);
22              
23             # please note that there ar potential problems with this commend as mentioned here: https://github.com/WireGuard/wireguard-tools/pull/3
24 0           my $cmd_line = "su -c 'wg syncconf $interface <(wg-quick strip $interface)'";
25 0 0         unless (defined $ENV{WGmeta_NO_WG}) {
26 0           run_external($cmd_line);
27             } else {
28 0           print "Faked apply \n";
29             }
30             }
31              
32 0     0 1   sub cmd_help($self) {
  0            
  0            
33 0           print "Usage: wg-meta apply \n";
34 0           exit;
35             }
36              
37             1;