| 1 | package Net::DNS::RR::SVCB; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | our $VERSION = (qw$Id: SVCB.pm 2043 2026-01-14 13:35:59Z willem $)[2]; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use base qw(Net::DNS::RR); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | Net::DNS::RR::SVCB - DNS SVCB resource record | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =cut | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use integer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use Net::DNS::DomainName; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use Net::DNS::RR::A; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use Net::DNS::RR::AAAA; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use Net::DNS::Text; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 2 | ▶ | use MIME::Base64; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 2 | my %keybyname = ( | |||||||||||||||||||||||||||
| 26 | mandatory => 'key0', # RFC9460(8) | ||||||||||||||||||||||||||||
| 27 | alpn => 'key1', # RFC9460(7.1) | ||||||||||||||||||||||||||||
| 28 | 'no-default-alpn' => 'key2', # RFC9460(7.1) | ||||||||||||||||||||||||||||
| 29 | port => 'key3', # RFC9460(7.2) | ||||||||||||||||||||||||||||
| 30 | ipv4hint => 'key4', # RFC9460(7.3) | ||||||||||||||||||||||||||||
| 31 | ech => 'key5', # RFC9460 | ||||||||||||||||||||||||||||
| 32 | ipv6hint => 'key6', # RFC9460(7.3) | ||||||||||||||||||||||||||||
| 33 | dohpath => 'key7', # RFC9461 | ||||||||||||||||||||||||||||
| 34 | ohttp => 'key8', # RFC9540(4) | ||||||||||||||||||||||||||||
| 35 | 'tls-supported-groups' => 'key9', | ||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 14 | ▶ | sub _decode_rdata { ## decode rdata from wire-format octet string | ||||||||||||||||||||||||||
|
Subroutine
_decode_rdata: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 40 | 14 | my ( $self, $data, $offset ) = @_; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 14 | my $limit = $self->{rdlength}; | |||||||||||||||||||||||||||
| 43 | 14 | my $rdata = $self->{rdata} = substr $$data, $offset, $limit; | |||||||||||||||||||||||||||
| 44 | 14 | $self->{SvcPriority} = unpack 'n', $rdata; | |||||||||||||||||||||||||||
| 45 | 14 | ( $self->{TargetName}, $offset ) = Net::DNS::DomainName->decode( \$rdata, 2 ); | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 14 | my $params = $self->{SvcParams} = []; | |||||||||||||||||||||||||||
| 48 | 14 | ▶ | while ( ( my $start = $offset + 4 ) <= $limit ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 12 | my ( $key, $size ) = unpack( "\@$offset n2", $rdata ); | |||||||||||||||||||||||||||
| 50 | 12 | ▶ | last if ( $offset = $start + $size ) > $limit; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 10 | push @$params, ( $key, substr $rdata, $start, $size ); | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | 14 | ▶ | die $self->type . ': corrupt RDATA' unless $offset == $limit; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 12 | return; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 8 | ▶ | sub _encode_rdata { ## encode rdata as wire-format octet string | ||||||||||||||||||||||||||
|
Subroutine
_encode_rdata: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 59 | 8 | my $self = shift; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 8 | ▶ | return $self->{rdata} if $self->{rdata}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 5 | my @packed = pack 'n a*', $self->{SvcPriority}, $self->{TargetName}->encode; | |||||||||||||||||||||||||||
| 63 | 5 | ▶ | my $params = $self->{SvcParams} || []; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'SvcParams'} || []
MC/DC100%1/1
$self->{'SvcParams'} || []
$self->{'SvcParams'}
Truth table100%2/2
A
A= $self->{'SvcParams'}
| |||||||||||||||||||||||||||||
| 64 | 5 | my @params = @$params; | |||||||||||||||||||||||||||
| 65 | 5 | ▶ | while (@params) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 1 | my $key = shift @params; | |||||||||||||||||||||||||||
| 67 | 1 | my $val = shift @params; | |||||||||||||||||||||||||||
| 68 | 1 | push @packed, pack( 'n2a*', $key, length($val), $val ); | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | 5 | return join '', @packed; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 25 | ▶ | sub _format_rdata { ## format rdata portion of RR string. | ||||||||||||||||||||||||||
|
Subroutine
_format_rdata: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||
| 75 | 25 | my $self = shift; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 25 | my @rdata = unpack 'H4', pack 'n', $self->{SvcPriority}; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 25 | my $encode = $self->{TargetName}->encode(); | |||||||||||||||||||||||||||
| 80 | 25 | my $length = 2 + length $encode; | |||||||||||||||||||||||||||
| 81 | 25 | my @target = grep {length} split /(\S{32})/, unpack 'H*', $encode; | |||||||||||||||||||||||||||
| 82 | 25 | my $target = substr $self->{TargetName}->string, 0, 40; | |||||||||||||||||||||||||||
| 83 | 25 | ▶ | push @rdata, join '', shift(@target), "\t; $target\n" unless $target eq '.'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | 25 | push @rdata, @target; | |||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 25 | ▶ | my $params = $self->{SvcParams} || []; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'SvcParams'} || []
MC/DC100%1/1
$self->{'SvcParams'} || []
$self->{'SvcParams'}
Truth table100%2/2
A
A= $self->{'SvcParams'}
| |||||||||||||||||||||||||||||
| 87 | 25 | my @params = @$params; | |||||||||||||||||||||||||||
| 88 | 25 | ▶ | while (@params) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | 30 | my $key = shift @params; | |||||||||||||||||||||||||||
| 90 | 30 | my $val = shift @params; | |||||||||||||||||||||||||||
| 91 | 30 | push @rdata, "\n", unpack 'H4H4', pack( 'n2', $key, length $val ); | |||||||||||||||||||||||||||
| 92 | 30 | my @hex = grep {length} split /(\S{32})/, unpack 'H*', $val; | |||||||||||||||||||||||||||
| 93 | 30 | ▶ | push @rdata, shift @hex if @hex; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | 30 | ▶ | push @rdata, "\t; key$key\n" unless $key < 16; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | 30 | push @rdata, @hex; | |||||||||||||||||||||||||||
| 96 | 30 | $length += 4 + length $val; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | 25 | ▶ | if ( $self->{rdata} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | 5 | ▶ | if ( my $corrupt = substr $self->{rdata}, $length ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | 2 | my ( $hex, @hex ) = grep {length} split /(\S{32})/, unpack 'H*', $corrupt; | |||||||||||||||||||||||||||
| 101 | 2 | push @rdata, "\n$hex\t; corrupt RDATA\n", @hex; | |||||||||||||||||||||||||||
| 102 | 2 | $length += length $corrupt; | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | 25 | return ( "\\# $length", @rdata ); | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 44 | ▶ | sub _parse_rdata { ## populate RR from rdata in argument list | ||||||||||||||||||||||||||
|
Subroutine
_parse_rdata: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||
| 110 | 44 | my ( $self, @argument ) = @_; | |||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 44 | $self->svcpriority( shift @argument ); | |||||||||||||||||||||||||||
| 113 | 44 | $self->targetname( shift @argument ); | |||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 44 | ▶ | while ( local $_ = shift @argument ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | 55 | m/^([^=]+)(=?)(.*)$/; | |||||||||||||||||||||||||||
| 117 | 55 | my $key = $1; | |||||||||||||||||||||||||||
| 118 | 55 | ▶ | my $val = length($3) ? $3 : $2 ? shift @argument : ''; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 119 | 55 | ▶ | if (/^key\d+/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | 12 | $self->$key($val); | |||||||||||||||||||||||||||
| 121 | } else { | ||||||||||||||||||||||||||||
| 122 | 43 | local $_ = $val; | |||||||||||||||||||||||||||
| 123 | 43 | ▶ | die <<'RIP' if /\\092[,\\]/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | SVCB: Please use standard RFC1035 escapes | ||||||||||||||||||||||||||||
| 125 | RFC9460 double-escape insanity not implemented | ||||||||||||||||||||||||||||
| 126 | RIP | ||||||||||||||||||||||||||||
| 127 | 41 | s/^"([^"]*)"$/$1/s; # strip enclosing quotes | |||||||||||||||||||||||||||
| 128 | 41 | s/\\,/\\044/g; # disguise (RFC1035) escaped comma | |||||||||||||||||||||||||||
| 129 | 41 | $self->$key( split /,/ ); | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | 31 | return; | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 43 | ▶ | sub _post_parse { ## parser post processing | ||||||||||||||||||||||||||
|
Subroutine
_post_parse: called CC=10 SCAR=23.0
| |||||||||||||||||||||||||||||
| 137 | 43 | my $self = shift; | |||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 43 | ▶ | my $paramref = $self->{SvcParams} || []; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'SvcParams'} || []
MC/DC100%1/1
$self->{'SvcParams'} || []
$self->{'SvcParams'}
Truth table100%2/2
A
A= $self->{'SvcParams'}
| |||||||||||||||||||||||||||||
| 140 | 43 | ▶ | my %svcparam = scalar(@$paramref) ? @$paramref : return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 31 | $self->key0(undef); # ruse to force sorting of SvcParams | |||||||||||||||||||||||||||
| 143 | 31 | ▶ | if ( defined $svcparam{0} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | 7 | my %unique; | |||||||||||||||||||||||||||
| 145 | 7 | foreach ( grep { !$unique{$_}++ } unpack 'n*', $svcparam{0} ) { | |||||||||||||||||||||||||||
| 146 | 9 | ▶ | die( $self->type . qq[: unexpected "key0" in mandatory list] ) if $unique{0}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 8 | ▶ | die( $self->type . qq[: duplicate "key$_" in mandatory list] ) if --$unique{$_}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | 7 | ▶ | die( $self->type . qq[: mandatory "key$_" not present] ) unless defined $svcparam{$_}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | 4 | $self->mandatory( keys %unique ); # restore mandatory key list | |||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | 28 | ▶ | die( $self->type . qq[: expected alpn="..." not present] ) if defined( $svcparam{2} ) && !$svcparam{1}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $svcparam{2} and not $svcparam{1}
MC/DC100%2/2
defined $svcparam{2} and not $svcparam{1}
defined $svcparam{2}
not $svcparam{1}
Truth table100%3/3
A and not(B)
A= defined $svcparam{2}B= not $svcparam{1}
| |||||||||||||||||||||||||||||
| 153 | 26 | return; | |||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 2 | ▶ | sub _defaults { ## specify RR attribute default values | ||||||||||||||||||||||||||
|
Subroutine
_defaults: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 158 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 2 | $self->_parse_rdata(qw(0 .)); | |||||||||||||||||||||||||||
| 161 | 2 | return; | |||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 50 | ▶ | sub svcpriority { | ||||||||||||||||||||||||||
|
Subroutine
svcpriority: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 166 | 50 | my ( $self, @value ) = @_; # uncoverable pod | |||||||||||||||||||||||||||
| 167 | 50 | for (@value) { $self->{SvcPriority} = 0 + $_ } | |||||||||||||||||||||||||||
| 168 | 50 | return $self->{SvcPriority}; | |||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 51 | ▶ | sub targetname { | ||||||||||||||||||||||||||
|
Subroutine
targetname: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 173 | 51 | my ( $self, @value ) = @_; # uncoverable pod | |||||||||||||||||||||||||||
| 174 | 51 | ▶ | $self->{TargetName} = Net::DNS::DomainName->new(@value) if @value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 175 | 51 | ▶ | my $target = $self->{TargetName} ? $self->{TargetName}->name : return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 176 | 49 | ▶ | return $target unless $target eq '.'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 177 | 16 | ▶ | return $self->{SvcPriority} ? $self->owner : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 13 | ▶ | sub mandatory { ## mandatory=key1,port,... | ||||||||||||||||||||||||||
|
Subroutine
mandatory: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 182 | 13 | my ( $self, @value ) = @_; | |||||||||||||||||||||||||||
| 183 | 13 | ▶ | my @list = map { $keybyname{lc $_} || $_ } @value; | ||||||||||||||||||||||||||
|
Condition66%2/3
$keybyname{lc $_} || $_
MC/DC0%0/2
$keybyname{lc $_} || $_
$keybyname{lc $_}
$_
Truth table66%2/3
A || B
A= $keybyname{lc $_}B= $_
| |||||||||||||||||||||||||||||
| 184 | 13 | ▶ | my @keys = map { /(\d+)$/ ? $1 : die( $self->type . qq[: unexpected "$_"] ) } @list; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 185 | 12 | return $self->_SvcParam( 0, _integer16( sort { $a <=> $b } @keys ) ); | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 5 | ▶ | sub alpn { ## alpn=h3,h2,... | ||||||||||||||||||||||||||
|
Subroutine
alpn: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 189 | 5 | my ( $self, @value ) = @_; | |||||||||||||||||||||||||||
| 190 | 5 | return $self->_SvcParam( 1, _string(@value) ); | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 6 | ▶ | sub no_default_alpn { ## no-default-alpn (Boolean) | ||||||||||||||||||||||||||
|
Subroutine
no_default_alpn: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 194 | 6 | my ( $self, @value ) = @_; # uncoverable pod | |||||||||||||||||||||||||||
| 195 | 6 | ▶ | return $self->_SvcParam(2) if defined wantarray; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 196 | 4 | return $self->_SvcParam( 2, _boolean(@value) ); | |||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 8 | ▶ | sub port { ## port=1234 | ||||||||||||||||||||||||||
|
Subroutine
port: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 200 | 8 | my ( $self, @value ) = @_; | |||||||||||||||||||||||||||
| 201 | 8 | return $self->_SvcParam( 3, map { _integer16($_) } @value ); | |||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 4 | ▶ | sub ipv4hint { ## ipv4hint=192.0.2.1,... | ||||||||||||||||||||||||||
|
Subroutine
ipv4hint: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 205 | 4 | my ( $self, @value ) = @_; | |||||||||||||||||||||||||||
| 206 | 4 | return $self->_SvcParam( 4, _address4(@value) ); | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | 5 | ▶ | sub ech { ## ech=base64 | ||||||||||||||||||||||||||
|
Subroutine
ech: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 210 | 5 | my ( $self, @value ) = @_; | |||||||||||||||||||||||||||
| 211 | 5 | return $self->_SvcParam( 5, map { _base64($_) } @value ); | |||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 6 | ▶ | sub ipv6hint { ## ipv6hint=2001:DB8::1,... | ||||||||||||||||||||||||||
|
Subroutine
ipv6hint: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 215 | 6 | my ( $self, @value ) = @_; | |||||||||||||||||||||||||||
| 216 | 6 | return $self->_SvcParam( 6, _address6(@value) ); | |||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | 3 | ▶ | sub dohpath { ## dohpath=/dns-query{?dns} | ||||||||||||||||||||||||||
|
Subroutine
dohpath: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 220 | 3 | my ( $self, @value ) = @_; # uncoverable pod | |||||||||||||||||||||||||||
| 221 | 3 | return $self->_SvcParam( 7, map { substr _string($_), 1 } @value ); | |||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 4 | ▶ | sub ohttp { ## ohttp | ||||||||||||||||||||||||||
|
Subroutine
ohttp: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 225 | 4 | my ( $self, @value ) = @_; # uncoverable pod | |||||||||||||||||||||||||||
| 226 | 4 | ▶ | return $self->_SvcParam(8) if defined wantarray; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | 3 | return $self->_SvcParam( 8, _boolean(@value) ); | |||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 3 | ▶ | sub tls_supported_groups { ## tls_supported_groups=29,23 | ||||||||||||||||||||||||||
|
Subroutine
tls_supported_groups: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 231 | 3 | my ( $self, @value ) = @_; # uncoverable pod | |||||||||||||||||||||||||||
| 232 | 3 | return $self->_SvcParam( 9, _integer16(@value) ); | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | ######################################## | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 43 | ▶ | sub _concatenate { ## concatenate octet string(s) | ||||||||||||||||||||||||||
|
Subroutine
_concatenate: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 240 | 43 | my @arg = @_; | |||||||||||||||||||||||||||
| 241 | 43 | ▶ | return scalar(@arg) ? join( '', @arg ) : @arg; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 7 | ▶ | sub _boolean { | ||||||||||||||||||||||||||
|
Subroutine
_boolean: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 245 | 7 | my @arg = @_; | |||||||||||||||||||||||||||
| 246 | 7 | ▶ | return '' unless scalar @arg; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 247 | 3 | ▶ | return map { $_ ? '' : undef } @arg; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | 7 | ▶ | sub _string { | ||||||||||||||||||||||||||
|
Subroutine
_string: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 251 | 7 | my @arg = @_; | |||||||||||||||||||||||||||
| 252 | 7 | my @val = map { split /,/ } @arg; | |||||||||||||||||||||||||||
| 253 | 7 | return _concatenate( map { Net::DNS::Text->new($_)->encode() } @val ); | |||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 4 | ▶ | sub _base64 { | ||||||||||||||||||||||||||
|
Subroutine
_base64: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 257 | 4 | my @arg = @_; | |||||||||||||||||||||||||||
| 258 | 4 | return _concatenate( map { MIME::Base64::decode($_) } @arg ); | |||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | 22 | ▶ | sub _integer16 { | ||||||||||||||||||||||||||
|
Subroutine
_integer16: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 262 | 22 | my @arg = @_; | |||||||||||||||||||||||||||
| 263 | 22 | my @val = map { split /,/ } @arg; | |||||||||||||||||||||||||||
| 264 | 22 | return _concatenate( map { pack( 'n', $_ ) } @val ); | |||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 4 | ▶ | sub _address4 { | ||||||||||||||||||||||||||
|
Subroutine
_address4: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 268 | 4 | my @arg = @_; | |||||||||||||||||||||||||||
| 269 | 4 | my @val = map { split /,/ } @arg; | |||||||||||||||||||||||||||
| 270 | 4 | return _concatenate( map { Net::DNS::RR::A::address( {}, $_ ) } @val ); | |||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 6 | ▶ | sub _address6 { | ||||||||||||||||||||||||||
|
Subroutine
_address6: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 274 | 6 | my @arg = @_; | |||||||||||||||||||||||||||
| 275 | 6 | my @val = map { split /,/ } @arg; | |||||||||||||||||||||||||||
| 276 | 6 | return _concatenate( map { Net::DNS::RR::AAAA::address( {}, $_ ) } @val ); | |||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 57 | ▶ | sub AUTOLOAD { ## Dynamic constructor/accessor methods | ||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 281 | 57 | my ( $self, @argument ) = @_; | |||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | 57 | our $AUTOLOAD; | |||||||||||||||||||||||||||
| 284 | 57 | my ($method) = reverse split /::/, $AUTOLOAD; | |||||||||||||||||||||||||||
| 285 | 57 | my $canonical = lc($method); | |||||||||||||||||||||||||||
| 286 | 57 | $canonical =~ s/-/_/g; | |||||||||||||||||||||||||||
| 287 | 57 | ▶ | if ( $self->can($canonical) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 288 | 2 | ▶ | no strict 'refs'; ## no critic ProhibitNoStrict | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 289 | 4 | ▶ | *{$AUTOLOAD} = sub { shift->$canonical(@_) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 290 | 4 | return $self->$canonical(@argument); | |||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | 53 | my $super = "SUPER::$method"; | |||||||||||||||||||||||||||
| 294 | 53 | ▶ | return $self->$super(@argument) unless $method =~ /^key[0]*(\d+)$/i; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 295 | 52 | my $key = $1; | |||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | 52 | ▶ | return $self->_SvcParam($key) unless @argument; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 298 | 43 | my $first = shift @argument; | |||||||||||||||||||||||||||
| 299 | 43 | ▶ | my $value = defined $first ? Net::DNS::Text->new($first)->raw : $first; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 300 | 43 | return $self->_SvcParam( $key, $value, @argument ); | |||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | 108 | ▶ | sub _SvcParam { | ||||||||||||||||||||||||||
|
Subroutine
_SvcParam: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||
| 305 | 108 | my ( $self, $key, @argument ) = @_; | |||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | 108 | ▶ | my $paramsref = $self->{SvcParams} || []; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'SvcParams'} || []
MC/DC100%1/1
$self->{'SvcParams'} || []
$self->{'SvcParams'}
Truth table100%2/2
A
A= $self->{'SvcParams'}
| |||||||||||||||||||||||||||||
| 308 | 108 | my %svcparams = @$paramsref; | |||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | 108 | ▶ | if ( scalar @argument ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 311 | 82 | my $arg = shift @argument; # keyNN($value); | |||||||||||||||||||||||||||
| 312 | 82 | ▶ | delete $svcparams{$key} unless defined $arg; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 313 | 82 | ▶ | die( $self->type . qq[: duplicate SvcParam "key$key"] ) if defined $svcparams{$key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 314 | 81 | ▶ | die( $self->type . qq[: invalid SvcParam "key$key"] ) if $key > 65534; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 315 | 80 | ▶ | die( $self->type . qq[: unexpected "key$key" value] ) if scalar @argument; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 316 | 78 | delete $self->{rdata}; | |||||||||||||||||||||||||||
| 317 | 78 | ▶ | $svcparams{$key} = $arg if defined $arg; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 318 | 78 | $self->{SvcParams} = [map { ( $_, $svcparams{$_} ) } sort { $a <=> $b } keys %svcparams]; | |||||||||||||||||||||||||||
| 319 | } else { | ||||||||||||||||||||||||||||
| 320 | 26 | ▶ | die( $self->type . qq[: no value specified for "key$key"] ) unless defined wantarray; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | 98 | return $svcparams{$key}; | |||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | ######################################## | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | 2 | 1; | |||||||||||||||||||||||||||
| 330 | __END__ | ||||||||||||||||||||||||||||