Mercurial > hg > nginx-tests
annotate upstream_ip_hash_ipv6.t @ 1571:1b4ceab9cb1c
Tests: fixed ssl_certificate.t with LibreSSL client.
Net::SSLeay::connect() that manages TLS handshake could return unexpected
error when receiving server alert, as seen in server certificate tests if
it could not been selected. Typically, it returns the expected error -1,
but with certain libssl implementations it can be 0, as explained below.
The error is propagated from libssl's SSL_connect(), which is usually -1.
In modern OpenSSL versions, it is the default error code used in the state
machine returned when something went wrong with parsing TLS message header.
In versions up to OpenSSL 1.0.2, with SSLv23_method() used by default, -1
is the only error code in the ssl_connect() method implementation which is
used as well if receiving alert while parsing ServerHello. BoringSSL also
seems to return -1. But it is not so with LibreSSL that returns zero.
Previously, tests failed with client built with LibreSSL with SSLv3 removed.
Here, the error is propagated directly from ssl_read_bytes() method, which
is always implemented as ssl3_read_bytes() in all TLS methods. It could be
also seen with OpenSSL up to 1.0.2 with non-default methods explicitly set.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 29 May 2020 23:10:20 +0300 |
parents | 40e5f2a0a238 |
children |
rev | line source |
---|---|
1429
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Sergey Kandaurov |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 # (C) Nginx, Inc. |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 # Tests for upstream ip_hash balancer with IPv6 and unix sockets. |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 ############################################################################### |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use warnings; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 use strict; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 use Test::More; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 use Socket qw/ CRLF /; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 BEGIN { use FindBin; chdir($FindBin::Bin); } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 use lib 'lib'; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 use Test::Nginx; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 ############################################################################### |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 select STDERR; $| = 1; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 select STDOUT; $| = 1; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 my $t = Test::Nginx->new()->has(qw/http proxy upstream_ip_hash realip unix/) |
1497
40e5f2a0a238
Tests: upstream_ip_hash_ipv6.t startup fixes.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1429
diff
changeset
|
29 ->write_file_expand('nginx.conf', <<'EOF'); |
1429
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 %%TEST_GLOBALS%% |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 daemon off; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 events { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 http { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 %%TEST_GLOBALS_HTTP%% |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 upstream u { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 ip_hash; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server 127.0.0.1:8081; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 server 127.0.0.1:8082; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 server { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 listen 127.0.0.1:8080; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 server_name localhost; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 add_header X-IP $remote_addr always; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 location / { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 set_real_ip_from 127.0.0.0/8; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 proxy_pass http://u; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 location /unix { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 proxy_pass http://unix:%%TESTDIR%%/unix.sock; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 proxy_set_header X-Real-IP $http_x_real_ip; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 location /ipv6 { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 proxy_pass http://[::1]:%%PORT_8080%%; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 proxy_set_header X-Real-IP $http_x_real_ip; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 server { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 listen unix:%%TESTDIR%%/unix.sock; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 listen [::1]:%%PORT_8080%%; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 server_name localhost; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 location / { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 set_real_ip_from unix:; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 set_real_ip_from ::1; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 proxy_pass http://u; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 location /unix/none { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 proxy_pass http://u; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 server { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 listen 127.0.0.1:8081; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 listen 127.0.0.1:8082; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 server_name localhost; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 location / { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 add_header X-Port $server_port always; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 EOF |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 |
1497
40e5f2a0a238
Tests: upstream_ip_hash_ipv6.t startup fixes.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1429
diff
changeset
|
98 $t->try_run('no inet6 support'); |
40e5f2a0a238
Tests: upstream_ip_hash_ipv6.t startup fixes.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1429
diff
changeset
|
99 |
1429
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 plan(skip_all => 'no 127.0.0.1 on host') |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 if http_get('/') !~ /X-IP: 127.0.0.1/m; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 |
1497
40e5f2a0a238
Tests: upstream_ip_hash_ipv6.t startup fixes.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1429
diff
changeset
|
103 $t->plan(4); |
1429
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 ############################################################################### |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 my @ports = my ($port1, $port2) = (port(8081), port(8082)); |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 is(many('/unix', 30), "$port1: 15, $port2: 15", 'ip_hash realip via unix'); |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 is(many('/ipv6', 30), "$port1: 15, $port2: 15", 'ip_hash realip via ipv6'); |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 is(many_ip6('/', 30), "$port1: 15, $port2: 15", 'ip_hash ipv6'); |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 like(many('/unix/none', 30), qr/($port1|$port2): 30/, 'ip_hash unix'); |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 ############################################################################### |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 sub many { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 my ($uri, $count) = @_; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 my %ports; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 for my $i (1 .. $count) { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 my $req = "GET $uri HTTP/1.0" . CRLF |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 . "X-Real-IP: 127.0.$i.2" . CRLF . CRLF; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 if (http($req) =~ /X-Port: (\d+)/) { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 $ports{$1} = 0 unless defined $ports{$1}; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 $ports{$1}++; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 my @keys = map { my $p = $_; grep { $p == $_ } keys %ports } @ports; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 return join ', ', map { $_ . ": " . $ports{$_} } @keys; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 sub many_ip6 { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 my ($uri, $count) = @_; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 my %ports; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 for my $i (1 .. $count) { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 my $req = "GET $uri HTTP/1.0" . CRLF |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 . "X-Real-IP: ::$i" . CRLF . CRLF; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 if (http($req) =~ /X-Port: (\d+)/) { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 $ports{$1} = 0 unless defined $ports{$1}; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 $ports{$1}++; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 my @keys = map { my $p = $_; grep { $p == $_ } keys %ports } @ports; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 return join ', ', map { $_ . ": " . $ports{$_} } @keys; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 ############################################################################### |