Branch Coverage

lib/Wireguard/WGmeta/Wrapper/Config.pm
Criterion Covered Total %
branch 84 114 73.6


line true false branch
110 0 10 if ($wg_meta_prefix eq $wg_meta_disabled_prefix)
114 1 9 defined $custom_attributes ? :
209 0 41 unless defined $value
210 0 41 unless $self->is_valid_interface($interface)
212 0 41 unless $self->is_valid_identifier($interface, $identifier)
214 6 35 if ($interface eq $identifier) { }
216 1 5 if $attr_type == 14
219 1 34 if $attr_type == 13 or $attr_type == 12
223 0 39 if (exists $self->{'parsed_config'}{$interface}{$identifier}{$attribute} and $self->{'parsed_config'}{$interface}{$identifier}{$attribute} eq $value)
228 1 38 unless $self->attr_value_is_valid($attribute, $value)
230 25 13 unless (exists $self->{'parsed_config'}{$interface}{$identifier}{$attribute})
232 23 2 unless (exists $self->{'parsed_config'}{$interface}{'int_observed_wg_meta_attrs'}{$attribute})
233 14 9 if (exists {address => {in_config_name => 'Address', type => 12, validator => sub ($input) { package Wireguard::WGmeta::Validator; BEGIN {${^WARNING_BITS} = "\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\x0f"} use feature 'array_base'; no feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval'; ; return 1; } }, alias => {in_config_name => 'Alias', type => 10, validator => sub ($input) { package Wireguard::WGmeta::Validator; BEGIN {${^WARNING_BITS} = "\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\x0f"} use feature 'array_base'; no feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval'; ; return 1; } }, allowed-ips => {in_config_name => 'AllowedIPs', type => 14, validator => sub ($input) { package Wireguard::WGmeta::Validator; BEGIN {${^WARNING_BITS} = "\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\x0f"} use feature 'array_base'; no feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval'; ; return 1; } }, checksum => {in_config_name => 'Checksum', type => 10, validator => sub ($input) { package Wireguard::WGmeta::Validator; BEGIN {${^WARNING_BITS} = "\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\x0f"} use feature 'array_base'; no feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval'; ; return 1; } }, disabled => {in_config_name => 'Disabled', type => 10, validator => sub ($input) { package Wireguard::WGmeta::Validator; BEGIN {${^WARNING_BITS} = "\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\x0f"} use feature 'array_base'; no feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval'; ; return 1; } }, dns => {in_config_name => 'DNS', type => 12, validator => sub ($input) { package Wireguard::WGmeta::Validator; BEGIN {${^WARNING_BITS} = "\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\x0f"} use feature 'array_base'; no feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval'; ; return 1; } }, endpoint => {in_config_name => 'Endpoint', type => 14, validator => sub ($input) { package Wireguard::WGmeta::Validator; BEGIN {${^WARNING_BITS} = "\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\x0f"} use feature 'array_base'; no feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval'; ; return 1; } }, fwmark => {in_config_name => 'Fwmark', type => 13, validator => sub ($input) { package Wireguard::WGmeta::Validator; BEGIN {${^WARNING_BITS} = "\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\x0f"} use feature 'array_base'; no feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval'; ; return 1; } }, listen-port => {in_config_name => 'ListenPort', type => 13, validator => sub ($input) { package Wireguard::WGmeta::Validator; BEGIN {${^WARNING_BITS} = "\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\x0f"} use feature 'array_base'; no feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval'; ; return &looks_like_number($input); } }, mtu => {in_config_name => 'MTU', type => 12, validator => sub ($input) { package Wireguard::WGmeta::Validator; BEGIN {${^WARNING_BITS} = "\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\x0f"} use feature 'array_base'; no feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval'; ; return 1; } }, persistent-keepalive => {in_config_name => 'PersistentKeepalive', type => 14, validator => sub ($input) { package Wireguard::WGmeta::Validator; BEGIN {${^WARNING_BITS} = "\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\x0f"} use feature 'array_base'; no feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval'; ; return 1; } }, post-down => {in_config_name => 'PostDown', type => 12, validator => sub ($input) { package Wireguard::WGmeta::Validator; BEGIN {${^WARNING_BITS} = "\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\x0f"} use feature 'array_base'; no feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval'; ; return 1; } }, post-up => {in_config_name => 'PostUP', type => 12, validator => sub ($input) { package Wireguard::WGmeta::Validator; BEGIN {${^WARNING_BITS} = "\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\x0f"} use feature 'array_base'; no feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval'; ; return 1; } }, pre-down => {in_config_name => 'PreDown', type => 12, validator => sub ($input) { package Wireguard::WGmeta::Validator; BEGIN {${^WARNING_BITS} = "\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\x0f"} use feature 'array_base'; no feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval'; ; return 1; } }, pre-up => {in_config_name => 'PreUp', type => 12, validator => sub ($input) { package Wireguard::WGmeta::Validator; BEGIN {${^WARNING_BITS} = "\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\x0f"} use feature 'array_base'; no feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval'; ; return 1; } }, preshared-key => {in_config_name => 'PresharedKey', type => 14, validator => sub ($input) { package Wireguard::WGmeta::Validator; BEGIN {${^WARNING_BITS} = "\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\x0f"} use feature 'array_base'; no feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval'; ; return 1; } }, private-key => {in_config_name => 'PrivateKey', type => 13, validator => sub ($input) { package Wireguard::WGmeta::Validator; BEGIN {${^WARNING_BITS} = "\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\x0f"} use feature 'array_base'; no feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval'; ; return 1; } }, public-key => {in_config_name => 'PublicKey', type => 14, validator => sub ($input) { package Wireguard::WGmeta::Validator; BEGIN {${^WARNING_BITS} = "\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\x0f"} use feature 'array_base'; no feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval'; ; return 1; } }, save-config => {in_config_name => 'SaveConfig', type => 12, validator => sub ($input) { package Wireguard::WGmeta::Validator; BEGIN {${^WARNING_BITS} = "\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\x0f"} use feature 'array_base'; no feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval'; ; return 1; } }, table => {in_config_name => 'Table', type => 12, validator => sub ($input) { package Wireguard::WGmeta::Validator; BEGIN {${^WARNING_BITS} = "\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\x0f"} use feature 'array_base'; no feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval'; ; return 1; } }}->{$attribute}) { }
1 8 elsif (exists $self->{'custom_attributes'}{$attribute}) { }
235 4 10 if ${my $v = {"address" => {"in_config_name" => "Address","type" => 12,"validator" => sub { ;}},"alias" => {"in_config_name" => "Alias","type" => 10,"validator" => do{my $o}},"allowed-ips" => {"in_config_name" => "AllowedIPs","type" => 14,"validator" => do{my $o}},"checksum" => {"in_config_name" => "Checksum","type" => 10,"validator" => do{my $o}},"disabled" => {"in_config_name" => "Disabled","type" => 10,"validator" => do{my $o}},"dns" => {"in_config_name" => "DNS","type" => 12,"validator" => do{my $o}},"endpoint" => {"in_config_name" => "Endpoint","type" => 14,"validator" => do{my $o}},"fwmark" => {"in_config_name" => "Fwmark","type" => 13,"validator" => do{my $o}},"listen-port" => {"in_config_name" => "ListenPort","type" => 13,"validator" => sub { ;}},"mtu" => {"in_config_name" => "MTU","type" => 12,"validator" => do{my $o}},"persistent-keepalive" => {"in_config_name" => "PersistentKeepalive","type" => 14,"validator" => do{my $o}},"post-down" => {"in_config_name" => "PostDown","type" => 12,"validator" => do{my $o}},"post-up" => {"in_config_name" => "PostUP","type" => 12,"validator" => do{my $o}},"pre-down" => {"in_config_name" => "PreDown","type" => 12,"validator" => do{my $o}},"pre-up" => {"in_config_name" => "PreUp","type" => 12,"validator" => do{my $o}},"preshared-key" => {"in_config_name" => "PresharedKey","type" => 14,"validator" => do{my $o}},"private-key" => {"in_config_name" => "PrivateKey","type" => 13,"validator" => do{my $o}},"public-key" => {"in_config_name" => "PublicKey","type" => 14,"validator" => do{my $o}},"save-config" => {"in_config_name" => "SaveConfig","type" => 12,"validator" => do{my $o}},"table" => {"in_config_name" => "Table","type" => 12,"validator" => do{my $o}}};$v->{"alias"}{"validator"} = $v->{"address"}{"validator"};$v->{"allowed-ips"}{"validator"} = $v->{"address"}{"validator"};$v->{"checksum"}{"validator"} = $v->{"address"}{"validator"};$v->{"disabled"}{"validator"} = $v->{"address"}{"validator"};$v->{"dns"}{"validator"} = $v->{"address"}{"validator"};$v->{"endpoint"}{"validator"} = $v->{"address"}{"validator"};$v->{"fwmark"}{"validator"} = $v->{"address"}{"validator"};$v->{"mtu"}{"validator"} = $v->{"address"}{"validator"};$v->{"persistent-keepalive"}{"validator"} = $v->{"address"}{"validator"};$v->{"post-down"}{"validator"} = $v->{"address"}{"validator"};$v->{"post-up"}{"validator"} = $v->{"address"}{"validator"};$v->{"pre-down"}{"validator"} = $v->{"address"}{"validator"};$v->{"pre-up"}{"validator"} = $v->{"address"}{"validator"};$v->{"preshared-key"}{"validator"} = $v->{"address"}{"validator"};$v->{"private-key"}{"validator"} = $v->{"address"}{"validator"};$v->{"public-key"}{"validator"} = $v->{"address"}{"validator"};$v->{"save-config"}{"validator"} = $v->{"address"}{"validator"};$v->{"table"}{"validator"} = $v->{"address"}{"validator"}; \$v}->{$attribute}{'type'} == 10
243 8 0 if (defined $unknown_callback) { }
255 8 29 if ($attribute eq "alias")
286 27 12 if exists ${my $v = {"address" => {"in_config_name" => "Address","type" => 12,"validator" => sub { ;}},"alias" => {"in_config_name" => "Alias","type" => 10,"validator" => do{my $o}},"allowed-ips" => {"in_config_name" => "AllowedIPs","type" => 14,"validator" => do{my $o}},"checksum" => {"in_config_name" => "Checksum","type" => 10,"validator" => do{my $o}},"disabled" => {"in_config_name" => "Disabled","type" => 10,"validator" => do{my $o}},"dns" => {"in_config_name" => "DNS","type" => 12,"validator" => do{my $o}},"endpoint" => {"in_config_name" => "Endpoint","type" => 14,"validator" => do{my $o}},"fwmark" => {"in_config_name" => "Fwmark","type" => 13,"validator" => do{my $o}},"listen-port" => {"in_config_name" => "ListenPort","type" => 13,"validator" => sub { ;}},"mtu" => {"in_config_name" => "MTU","type" => 12,"validator" => do{my $o}},"persistent-keepalive" => {"in_config_name" => "PersistentKeepalive","type" => 14,"validator" => do{my $o}},"post-down" => {"in_config_name" => "PostDown","type" => 12,"validator" => do{my $o}},"post-up" => {"in_config_name" => "PostUP","type" => 12,"validator" => do{my $o}},"pre-down" => {"in_config_name" => "PreDown","type" => 12,"validator" => do{my $o}},"pre-up" => {"in_config_name" => "PreUp","type" => 12,"validator" => do{my $o}},"preshared-key" => {"in_config_name" => "PresharedKey","type" => 14,"validator" => do{my $o}},"private-key" => {"in_config_name" => "PrivateKey","type" => 13,"validator" => do{my $o}},"public-key" => {"in_config_name" => "PublicKey","type" => 14,"validator" => do{my $o}},"save-config" => {"in_config_name" => "SaveConfig","type" => 12,"validator" => do{my $o}},"table" => {"in_config_name" => "Table","type" => 12,"validator" => do{my $o}}};$v->{"alias"}{"validator"} = $v->{"address"}{"validator"};$v->{"allowed-ips"}{"validator"} = $v->{"address"}{"validator"};$v->{"checksum"}{"validator"} = $v->{"address"}{"validator"};$v->{"disabled"}{"validator"} = $v->{"address"}{"validator"};$v->{"dns"}{"validator"} = $v->{"address"}{"validator"};$v->{"endpoint"}{"validator"} = $v->{"address"}{"validator"};$v->{"fwmark"}{"validator"} = $v->{"address"}{"validator"};$v->{"mtu"}{"validator"} = $v->{"address"}{"validator"};$v->{"persistent-keepalive"}{"validator"} = $v->{"address"}{"validator"};$v->{"post-down"}{"validator"} = $v->{"address"}{"validator"};$v->{"post-up"}{"validator"} = $v->{"address"}{"validator"};$v->{"pre-down"}{"validator"} = $v->{"address"}{"validator"};$v->{"pre-up"}{"validator"} = $v->{"address"}{"validator"};$v->{"preshared-key"}{"validator"} = $v->{"address"}{"validator"};$v->{"private-key"}{"validator"} = $v->{"address"}{"validator"};$v->{"public-key"}{"validator"} = $v->{"address"}{"validator"};$v->{"save-config"}{"validator"} = $v->{"address"}{"validator"};$v->{"table"}{"validator"} = $v->{"address"}{"validator"}; \$v}->{$attribute}
287 1 11 if exists $self->{'custom_attributes'}{$attribute}
292 1 7 if (exists $self->{'parsed_config'}{$interface}{'int_alias_map'}{$alias}) { }
431 5 57 if (exists $self->{'parsed_config'}{$interface}{'int_alias_map'}{$may_alias}) { }
460 0 10 if (@config_files == 0)
498 7 7 if ($self->_has_changed($interface))
503 6 1 if ($is_hot_config == 1) { }
504 0 6 unless open $fh, ">", $hot_path
508 0 1 unless open $fh, ">", $safe_path
514 0 7 unless close $fh
517 1 6 if (-e $safe_path and $is_hot_config)
565 3 0 if (exists $self->{'parsed_config'}{$interface}{$identifier}) { }
594 4 1 if ($self->is_valid_interface($interface)) { }
648 0 1 if ($self->is_valid_interface($interface_name))
710 5 0 if ($self->is_valid_interface($interface)) { }
711 0 5 if ($self->is_valid_identifier($interface, $public_key))
719 4 1 if (defined $alias)
722 0 5 if (defined $preshared_key)
765 2 0 if ($self->is_valid_interface($interface)) { }
767 2 0 if ($self->is_valid_identifier($interface, $identifier)) { }
780 2 1 if ($a_identifier eq $identifier)
819 3 0 if ($self->is_valid_interface($interface))
822 3 0 if (-e "$self->{'wireguard_home'}$interface.conf")
823 0 3 unless unlink "$self->{'wireguard_home'}$interface.conf"
851 2 1 if (defined $interface and $self->is_valid_interface($interface)) { }
900 1 148 if (-e $not_applied_path)
901 1 0 if (get_mtime($not_applied_path) > get_mtime($config_path))
905 54 95 if ($new == 0) { }
907 54 0 if (exists $self->{'parsed_config'}{$interface}) { }
916 11 43 if ($force or $unexpected_delete or $self->{'parsed_config'}{$interface}{'int_mtime'} < $on_disk_mtime)
921 1 10 $config_path =~ /$self->{'not_applied_suffix'}/u ? :
922 11 0 if $_init == 0
931 95 0 if (-e $config_path) { }
934 21 74 if (defined $maybe_new_config) { }
939 0 21 $config_path =~ /$self->{'not_applied_suffix'}/u ? :
940 1 20 if $_init == 0
972 17 0 if exists $self->{'parsed_config'}{$interface}{'has_changed'}
1008 0 1 if ($self->{'reload_listeners'}{$handler_id}) { }
1041 0 0 if (exists $self->{'reload_listeners'}{$handler_id}) { }
1055 0 1 if ($@)