Skip to content

Commit

Permalink
Test localhost in config file.
Browse files Browse the repository at this point in the history
Write localhost into pfresolved config.
Wait until pfresolved creates table regress-pfresolved.
Read IP addresses from pf table with pfctl.
Check that pfresolved added 127.0.0.1 and ::1.
Check that table contains 127.0.0.1 and ::1.
  • Loading branch information
bluhm committed Nov 3, 2023
1 parent 4d6392d commit 739b04f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
10 changes: 7 additions & 3 deletions regress/Pfctl.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ sub new {

sub child {
my $self = shift;
my $timeout = $self->{timeout} || 5;
my $updates = $self->{updates};
my $pfresolved = $self->{pfresolved};

my $table = "updating addresses for pf table";
$pfresolved->loggrep($table, 5)
or die ref($self), " no '$table' in $pfresolved->{logfile} ".
"after 5 seconds";
my $tomsg = $timeout ? " after $timeout seconds" : "";
my $upmsg = $updates ? " for $updates times" : "";
$pfresolved->loggrep($table, $timeout, $updates)
or die ref($self), " no '$table' in $pfresolved->{logfile}",
$tomsg, $upmsg;

open(STDOUT, '>&', \*STDERR)
or die ref($self), " dup STDOUT failed: $!";
Expand Down
27 changes: 27 additions & 0 deletions regress/args-localhost.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Write localhost into pfresolved config.
# Wait until pfresolved creates table regress-pfresolved.
# Read IP addresses from pf table with pfctl.
# Check that pfresolved added 127.0.0.1 and ::1.
# Check that table contains 127.0.0.1 and ::1.

use strict;
use warnings;

our %args = (
pfresolved => {
address_list => [qw(localhost.)], # must resolve A and AAAA
loggrep => {
qr{added: 127.0.0.1/32,} => 1,
qr{added: ::1/128,} => 1,
},
},
pfctl => {
updates => 3,
loggrep => {
qr/^ 127.0.0.1$/ => 1,
qr/^ ::1$/ => 1,
},
},
);

1;

0 comments on commit 739b04f

Please sign in to comment.