Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test localhost in config file. #11

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 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 $table = "updated addresses for pf table";
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
2 changes: 1 addition & 1 deletion regress/Pfresolved.pm
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ sub child {
my @ktrace;
@ktrace = ($self->{ktraceexec}, "-i", "-f", $self->{ktracefile})
if $self->{ktraceexec};
my @cmd = (@sudo, @ktrace, $self->{execfile}, "-dvv",
my @cmd = (@sudo, @ktrace, $self->{execfile}, "-dvvv",
"-f", $self->{conffile});
print STDERR "execute: @cmd\n";
exec @cmd;
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;