diff options
author | 2013-06-03 21:07:45 +0000 | |
---|---|---|
committer | 2013-06-03 21:07:45 +0000 | |
commit | 80917f5ec9af3ecae5b7338fd3f3155583cc743f (patch) | |
tree | 1c9c02c179bb30b948af55906a32c238e7f92ac2 | |
parent | Add bcrypt_pbkdf, a password based key derivation function using bcrypt. (diff) | |
download | wireguard-openbsd-80917f5ec9af3ecae5b7338fd3f3155583cc743f.tar.xz wireguard-openbsd-80917f5ec9af3ecae5b7338fd3f3155583cc743f.zip |
Add tests for UDP divert.
-rw-r--r-- | regress/sys/net/pf_divert/args-tcp-reply.pl | 1 | ||||
-rw-r--r-- | regress/sys/net/pf_divert/args-tcp-to.pl | 1 | ||||
-rw-r--r-- | regress/sys/net/pf_divert/args-udp-reply.pl | 11 | ||||
-rw-r--r-- | regress/sys/net/pf_divert/args-udp-to.pl | 11 | ||||
-rw-r--r-- | regress/sys/net/pf_divert/funcs.pl | 30 | ||||
-rw-r--r-- | regress/sys/net/pf_divert/remote.pl | 10 |
6 files changed, 55 insertions, 9 deletions
diff --git a/regress/sys/net/pf_divert/args-tcp-reply.pl b/regress/sys/net/pf_divert/args-tcp-reply.pl index 93cf76a749f..67f64f49173 100644 --- a/regress/sys/net/pf_divert/args-tcp-reply.pl +++ b/regress/sys/net/pf_divert/args-tcp-reply.pl @@ -7,5 +7,6 @@ use strict; use warnings; our %args = ( + protocol => "tcp", divert => "reply", ); diff --git a/regress/sys/net/pf_divert/args-tcp-to.pl b/regress/sys/net/pf_divert/args-tcp-to.pl index 0296cd35799..e2af43dd2fe 100644 --- a/regress/sys/net/pf_divert/args-tcp-to.pl +++ b/regress/sys/net/pf_divert/args-tcp-to.pl @@ -4,5 +4,6 @@ use strict; use warnings; our %args = ( + protocol => "tcp", divert => "to", ); diff --git a/regress/sys/net/pf_divert/args-udp-reply.pl b/regress/sys/net/pf_divert/args-udp-reply.pl new file mode 100644 index 00000000000..e5ab629de58 --- /dev/null +++ b/regress/sys/net/pf_divert/args-udp-reply.pl @@ -0,0 +1,11 @@ +# test divert-to with udp + +use strict; +use warnings; + +our %args = ( + protocol => "udp", + client => { func => \&write_datagram, noin => 1, }, + server => { func => \&read_datagram, noout => 1, }, + divert => "reply", +); diff --git a/regress/sys/net/pf_divert/args-udp-to.pl b/regress/sys/net/pf_divert/args-udp-to.pl new file mode 100644 index 00000000000..673f7233705 --- /dev/null +++ b/regress/sys/net/pf_divert/args-udp-to.pl @@ -0,0 +1,11 @@ +# test divert-to with udp + +use strict; +use warnings; + +our %args = ( + protocol => "udp", + client => { func => \&write_datagram, noin => 1, }, + server => { func => \&read_datagram, noout => 1, }, + divert => "to", +); diff --git a/regress/sys/net/pf_divert/funcs.pl b/regress/sys/net/pf_divert/funcs.pl index 2d63ea92bfd..2004aead2d7 100644 --- a/regress/sys/net/pf_divert/funcs.pl +++ b/regress/sys/net/pf_divert/funcs.pl @@ -1,4 +1,4 @@ -# $OpenBSD: funcs.pl,v 1.1.1.1 2013/06/03 05:06:38 bluhm Exp $ +# $OpenBSD: funcs.pl,v 1.2 2013/06/03 21:07:45 bluhm Exp $ # Copyright (c) 2010-2013 Alexander Bluhm <bluhm@openbsd.org> # @@ -33,6 +33,22 @@ sub write_read_stream { print STDERR "<<< $in"; } +sub write_datagram { + my $self = shift; + + my $out = ref($self). "\n"; + print $out; + IO::Handle::flush(\*STDOUT); + print STDERR ">>> $out"; +} + +sub read_datagram { + my $self = shift; + + my $in = <STDIN>; + print STDERR "<<< $in"; +} + ######################################################################## # Script funcs ######################################################################## @@ -49,12 +65,16 @@ sub check_inout { my ($c, $s, %args) = @_; if ($c && !$args{client}{nocheck}) { - $c->loggrep(qr/^>>> Client$/) or die "no client out"; - $c->loggrep(qr/^<<< Server$/) or die "no client in"; + $c->loggrep(qr/^>>> Client$/) or die "no client out" + unless $args{client}{noout}; + $c->loggrep(qr/^<<< Server$/) or die "no client in" + unless $args{client}{noin}; } if ($s && !$args{server}{nocheck}) { - $s->loggrep(qr/^>>> Server$/) or die "no server out"; - $s->loggrep(qr/^<<< Client$/) or die "no server in"; + $s->loggrep(qr/^>>> Server$/) or die "no server out" + unless $args{server}{noout}; + $s->loggrep(qr/^<<< Client$/) or die "no server in" + unless $args{server}{noin}; } } diff --git a/regress/sys/net/pf_divert/remote.pl b/regress/sys/net/pf_divert/remote.pl index 44723f512b6..18e4af31389 100644 --- a/regress/sys/net/pf_divert/remote.pl +++ b/regress/sys/net/pf_divert/remote.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $OpenBSD: remote.pl,v 1.1.1.1 2013/06/03 05:06:38 bluhm Exp $ +# $OpenBSD: remote.pl,v 1.2 2013/06/03 21:07:45 bluhm Exp $ # Copyright (c) 2010-2013 Alexander Bluhm <bluhm@openbsd.org> # @@ -71,6 +71,7 @@ if ($mode eq "divert") { if ($local eq "server") { $l = $s = Server->new( func => $func, + %args, %{$args{server}}, logfile => $logfile, listendomain => $domain, @@ -80,7 +81,7 @@ if ($local eq "server") { } if ($mode eq "auto") { $r = Remote->new( - %{$args{relay}}, + %args, af => $af, logfile => "$remote.log", testfile => $test, @@ -97,6 +98,7 @@ if ($mode eq "auto") { if ($local eq "client") { $l = $c = Client->new( func => $func, + %args, %{$args{client}}, logfile => $logfile, connectdomain => $domain, @@ -123,11 +125,11 @@ if ($mode eq "divert") { open(my $pf, '|-', @cmd) or die "Open pipe to pf '@cmd' failed: $!"; if ($local eq "server") { - print $pf "pass in log $af proto tcp ". + print $pf "pass in log $af proto $args{protocol} ". "from $ARGV[1] to $ARGV[0] port $s->{listenport} ". "divert-to $s->{listenaddr} port $s->{listenport}\n"; } else { - print $pf "pass out log $af proto tcp ". + print $pf "pass out log $af proto $args{protocol} ". "from $c->{bindaddr} to $ARGV[1] port $ARGV[2] ". "divert-reply\n"; } |