Mercurial > hg > nginx-tests
annotate stream_ssl_realip.t @ 1836:74cffa9d4c43
Tests: enabled session reuse via TLS session tickets.
This fixes tests with TLSv1.3 enabled when using BoringSSL, since
for TLSv1.3 it only supports session reuse via TLS session tickets,
and not server-side session cache.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 23 Mar 2023 19:50:02 +0300 |
parents | f3ba4c74de31 |
children | cdcd75657e52 |
rev | line source |
---|---|
1029
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for stream realip module, server side proxy protocol with ssl. |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 use Socket qw/ $CRLF /; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 BEGIN { use FindBin; chdir($FindBin::Bin); } |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use lib 'lib'; |
1458
e95133e85798
Tests: unbreak stream_ssl_realip.t with TLS 1.3.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1421
diff
changeset
|
20 use Test::Nginx qw/ :DEFAULT http_end /; |
1029
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 ############################################################################### |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDERR; $| = 1; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 select STDOUT; $| = 1; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 eval { require IO::Socket::SSL; }; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 plan(skip_all => 'IO::Socket::SSL not installed') if $@; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); }; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 plan(skip_all => 'IO::Socket::SSL too old') if $@; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
1170
cf14cfe9ec8c
Tests: dropped obsolete ipv6 prerequisite.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1168
diff
changeset
|
32 my $t = Test::Nginx->new()->has(qw/stream stream_return stream_realip/) |
1029
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 ->has(qw/stream_ssl/)->has_daemon('openssl') |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 ->write_file_expand('nginx.conf', <<'EOF'); |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 %%TEST_GLOBALS%% |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 daemon off; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 events { |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 } |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 stream { |
1609
f3ba4c74de31
Tests: added TEST_GLOBALS_STREAM variable support.
Andrei Belov <defan@nginx.com>
parents:
1488
diff
changeset
|
44 %%TEST_GLOBALS_STREAM%% |
f3ba4c74de31
Tests: added TEST_GLOBALS_STREAM variable support.
Andrei Belov <defan@nginx.com>
parents:
1488
diff
changeset
|
45 |
1029
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 ssl_certificate_key localhost.key; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 ssl_certificate localhost.crt; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 server { |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 listen 127.0.0.1:8083 proxy_protocol ssl; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 return $proxy_protocol_addr:$proxy_protocol_port; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 } |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 server { |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 listen 127.0.0.1:8086 proxy_protocol ssl; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 listen [::1]:%%PORT_8086%% proxy_protocol ssl; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 return "$remote_addr:$remote_port: |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 $realip_remote_addr:$realip_remote_port"; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 set_real_ip_from ::1; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 set_real_ip_from 127.0.0.2; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 } |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 server { |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 listen 127.0.0.1:8087; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 proxy_pass [::1]:%%PORT_8086%%; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 } |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 server { |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 listen 127.0.0.1:8088 proxy_protocol ssl; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 listen [::1]:%%PORT_8088%% proxy_protocol ssl; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 return "$remote_addr:$remote_port: |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 $realip_remote_addr:$realip_remote_port"; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 set_real_ip_from 127.0.0.1; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 set_real_ip_from ::2; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 } |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 server { |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 listen 127.0.0.1:8089; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 proxy_pass [::1]:%%PORT_8088%%; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 } |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 } |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 EOF |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 $t->write_file('openssl.conf', <<EOF); |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 [ req ] |
1488
dbce8fb5f5f8
Tests: align with OpenSSL security level 2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1458
diff
changeset
|
89 default_bits = 2048 |
1029
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 encrypt_key = no |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 distinguished_name = req_distinguished_name |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 [ req_distinguished_name ] |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 EOF |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 my $d = $t->testdir(); |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 foreach my $name ('localhost') { |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 system('openssl req -x509 -new ' |
1220
0af58b78df35
Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1190
diff
changeset
|
99 . "-config $d/openssl.conf -subj /CN=$name/ " |
0af58b78df35
Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1190
diff
changeset
|
100 . "-out $d/$name.crt -keyout $d/$name.key " |
1029
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 . ">>$d/openssl.out 2>&1") == 0 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 or die "Can't create certificate for $name: $!\n"; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 } |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 |
1251
766bcbb632ee
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1220
diff
changeset
|
105 $t->try_run('no inet6 support')->plan(6); |
1029
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 ############################################################################### |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 is(pp_get(8083, "PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678${CRLF}"), |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 '192.0.2.1:1234', 'server'); |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 like(pp_get(8086, "PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678${CRLF}"), |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 qr/^(\Q127.0.0.1:\E\d+):\s+\1$/, 'server ipv6 realip - no match'); |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 like(pp_get(8087, "PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678${CRLF}"), |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 qr/\Q192.0.2.1:1234:\E\s+\Q::1:\E\d+/, 'server ipv6 realip'); |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 like(pp_get(8088, "PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678${CRLF}"), |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 qr/\Q192.0.2.1:1234:\E\s+\Q127.0.0.1:\E\d+/, 'server ipv4 realip'); |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 like(pp_get(8089, "PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678${CRLF}"), |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 qr/^(::1:\d+):\s+\1$/, 'server ipv4 realip - no match'); |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 like(pp_get(8088, "PROXY UNKNOWN TCP4 192.0.2.1 192.0.2.2 1234 5678${CRLF}"), |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 qr/^(\Q127.0.0.1:\E\d+):\s+\1$/, 'server unknown'); |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 ############################################################################### |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 sub pp_get { |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 my ($port, $proxy) = @_; |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 |
1458
e95133e85798
Tests: unbreak stream_ssl_realip.t with TLS 1.3.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1421
diff
changeset
|
132 my $s = IO::Socket::INET->new('127.0.0.1:' . port($port)) or return; |
e95133e85798
Tests: unbreak stream_ssl_realip.t with TLS 1.3.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1421
diff
changeset
|
133 http($proxy, start => 1, socket => $s); |
1029
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 |
1168
8821e405b91e
Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
135 eval { |
8821e405b91e
Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
136 local $SIG{ALRM} = sub { die "timeout\n" }; |
8821e405b91e
Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
137 local $SIG{PIPE} = sub { die "sigpipe\n" }; |
1421
4e48bf51714f
Tests: aligned various generic read timeouts to http_end().
Sergey Kandaurov <pluknet@nginx.com>
parents:
1407
diff
changeset
|
138 alarm(8); |
1458
e95133e85798
Tests: unbreak stream_ssl_realip.t with TLS 1.3.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1421
diff
changeset
|
139 IO::Socket::SSL->start_SSL($s, |
1168
8821e405b91e
Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
140 SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(), |
8821e405b91e
Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
141 SSL_error_trap => sub { die $_[1] } |
8821e405b91e
Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
142 ); |
8821e405b91e
Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
143 alarm(0); |
8821e405b91e
Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
144 }; |
8821e405b91e
Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
145 alarm(0); |
8821e405b91e
Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
146 |
8821e405b91e
Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
147 if ($@) { |
8821e405b91e
Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
148 log_in("died: $@"); |
8821e405b91e
Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
149 return undef; |
8821e405b91e
Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
150 } |
1029
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 |
1458
e95133e85798
Tests: unbreak stream_ssl_realip.t with TLS 1.3.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1421
diff
changeset
|
152 http_end($s); |
1029
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 } |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
154 |
21602616d8ee
Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
155 ############################################################################### |