diff --git a/bin/tests/system/ditch.pl b/bin/tests/system/ditch.pl index e2082503d7..f77d02224d 100644 --- a/bin/tests/system/ditch.pl +++ b/bin/tests/system/ditch.pl @@ -34,12 +34,12 @@ use IO::File; use IO::Socket; sub usage { - print ("Usage: ditch.pl [-s address] [-p port] [file]\n"); + print ("Usage: ditch.pl [-s address] [-p port] [-b source_port] [file]\n"); exit 1; } my %options={}; -getopts("s:p:t:", \%options); +getopts("s:p:b:", \%options); my $addr = "127.0.0.1"; $addr = $options{s} if defined $options{s}; @@ -47,6 +47,9 @@ $addr = $options{s} if defined $options{s}; my $port = 53; $port = $options{p} if defined $options{p}; +my $source_port = 0; +$source_port = $options{b} if defined $options{b}; + my $file = "STDIN"; if (@ARGV >= 1) { my $filename = shift @ARGV; @@ -74,8 +77,12 @@ while (defined(my $line = <$file>) ) { $packet->header->rd(1); $packet->push(question => $q); - my $sock = IO::Socket::INET->new(PeerAddr => $addr, PeerPort => $port, - Proto => "udp",) or die "$!"; + my $sock = IO::Socket::INET->new( + PeerAddr => $addr, + PeerPort => $port, + Proto => "udp", + LocalPort => $source_port, + ) or die "$!"; my $bytes = $sock->send($packet->data); #print ("sent $bytes bytes to $addr:$port:\n"); diff --git a/bin/tests/system/fetchlimit/tests.sh b/bin/tests/system/fetchlimit/tests.sh index 6e3f7494fe..44818c8a5f 100644 --- a/bin/tests/system/fetchlimit/tests.sh +++ b/bin/tests/system/fetchlimit/tests.sh @@ -35,7 +35,7 @@ burst() { echo "${num}${2}${3}.lamesub.example A" >>burst.input.$$ fi done - $PERL ../ditch.pl -p ${PORT} -s ${server} burst.input.$$ + $PERL ../ditch.pl -p ${PORT} -s ${server} -b ${EXTRAPORT8} burst.input.$$ rm -f burst.input.$$ } diff --git a/bin/tests/system/serve-stale/tests.sh b/bin/tests/system/serve-stale/tests.sh index da54c3a4db..b9e5888f10 100755 --- a/bin/tests/system/serve-stale/tests.sh +++ b/bin/tests/system/serve-stale/tests.sh @@ -2500,7 +2500,7 @@ burst() { num=$((num - 1)) echo "fetch${num}.example A" >>burst.input.$$ done - $PERL ../ditch.pl -p ${PORT} -s 10.53.0.3 burst.input.$$ + $PERL ../ditch.pl -p ${PORT} -s 10.53.0.3 -b ${EXTRAPORT8} burst.input.$$ rm -f burst.input.$$ }