Mercurial > hg > nginx-tests
annotate http_resolver_cname.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | e4974af3fb12 |
children |
rev | line source |
---|---|
825
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for http resolver with CNAME. |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx qw/ :DEFAULT http_end /; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(11); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 $t->write_file_expand('nginx.conf', <<'EOF'); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 %%TEST_GLOBALS%% |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 daemon off; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 events { |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 } |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 http { |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 %%TEST_GLOBALS_HTTP%% |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
40 listen 127.0.0.1:8080; |
825
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 server_name localhost; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 location /short { |
1237
e4974af3fb12
Tests: adjusted udp ports to match allocated ports range.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
974
diff
changeset
|
44 resolver 127.0.0.1:%%PORT_8981_UDP%%; |
825
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 resolver_timeout 2s; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
47 proxy_pass http://$host:%%PORT_8080%%/t; |
825
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 } |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 location /long { |
1237
e4974af3fb12
Tests: adjusted udp ports to match allocated ports range.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
974
diff
changeset
|
51 resolver 127.0.0.1:%%PORT_8981_UDP%%; |
825
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 resolver_timeout 5s; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
54 proxy_pass http://$host:%%PORT_8080%%/t; |
825
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 } |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 location / { } |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 } |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 } |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 EOF |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 |
1237
e4974af3fb12
Tests: adjusted udp ports to match allocated ports range.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
974
diff
changeset
|
63 $t->run_daemon(\&dns_daemon, port(8981), $t); |
825
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 $t->write_file('t', ''); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 $t->run(); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 |
1237
e4974af3fb12
Tests: adjusted udp ports to match allocated ports range.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
974
diff
changeset
|
68 $t->waitforfile($t->testdir . '/' . port(8981)); |
825
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 ############################################################################### |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 # CNAME pointing to name which times out |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 like(http_host('cn01.example.net', '/short'), qr/502 Bad/, 'CNAME timeout'); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 # several requests on CNAME pointing to invalid name |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 my @s; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 push @s, http_host('cn03.example.net', '/long', start => 1); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 push @s, http_host('cn03.example.net', '/long', start => 1); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 like(http_end(pop @s), qr/502 Bad/, 'invalid CNAME - first'); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 like(http_end(pop @s), qr/502 Bad/, 'invalid CNAME - last'); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 # several requests on CNAME pointing to cached name |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 @s = (); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 http_host('a.example.net', '/long'); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 push @s, http_host('cn04.example.net', '/long', start => 1); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 push @s, http_host('cn04.example.net', '/long', start => 1); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 like(http_end(pop @s), qr/200 OK/, 'cached CNAME - first'); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 like(http_end(pop @s), qr/200 OK/, 'cached CNAME - last'); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 # several requests on CNAME pointing to name being resolved |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 @s = (); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 my $s = http_host('cn06.example.net', '/long', start => 1); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 sleep 1; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 push @s, http_host('cn05.example.net', '/long', start => 1); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 push @s, http_host('cn05.example.net', '/long', start => 1); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 like(http_end(pop @s), qr/502 Bad/, 'CNAME in progress - first'); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 like(http_end(pop @s), qr/502 Bad/, 'CNAME in progress - last'); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 # several requests on CNAME pointing to name which times out |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 # 1st request receives CNAME with short ttl |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 # 2nd request replaces expired CNAME |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 @s = (); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 push @s, http_host('cn07.example.net', '/long', start => 1); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 sleep 2; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 push @s, http_host('cn07.example.net', '/long', start => 1); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 like(http_end(pop @s), qr/502 Bad/, 'CNAME ttl - first'); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 like(http_end(pop @s), qr/502 Bad/, 'CNAME ttl - last'); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 # several requests on CNAME pointing to name |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 # 1st request aborts before name is resolved |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 # 2nd request finishes with name resolved |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 @s = (); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 push @s, http_host('cn09.example.net', '/long', start => 1); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 push @s, http_host('cn09.example.net', '/long', start => 1); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 |
863
44a9a45aa041
Tests: adjusted http_resolver_cname.t test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
825
diff
changeset
|
136 select undef, undef, undef, 0.4; # let resolver hang on CNAME |
825
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 close(shift @s); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 like(http_end(pop @s), qr/200 OK/, 'abort on CNAME'); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 like(http_host('cn001.example.net', '/short'), qr/502 Bad/, 'recurse uncached'); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 ############################################################################### |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 sub http_host { |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 my ($host, $uri, %extra) = @_; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 return http(<<EOF, %extra); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 GET $uri HTTP/1.0 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 Host: $host |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 EOF |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 } |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
154 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
155 ############################################################################### |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
156 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
157 sub reply_handler { |
925
6bb1f2ccd386
Tests: removed unused variables.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
863
diff
changeset
|
158 my ($recv_data) = @_; |
825
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
159 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
160 my (@name, @rdata); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
161 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
162 use constant NOERROR => 0; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 use constant A => 1; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
165 use constant CNAME => 5; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 |
937
b1fa8e0cc27b
Tests: whitespaces fix.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
925
diff
changeset
|
167 use constant IN => 1; |
825
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
169 # default values |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
170 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
171 my ($hdr, $rcode, $ttl) = (0x8180, NOERROR, 3600); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
173 # decode name |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
174 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
175 my ($len, $offset) = (undef, 12); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
176 while (1) { |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
177 $len = unpack("\@$offset C", $recv_data); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
178 last if $len == 0; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
179 $offset++; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
180 push @name, unpack("\@$offset A$len", $recv_data); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
181 $offset += $len; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
182 } |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
183 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
184 $offset -= 1; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
185 my ($id, $type, $class) = unpack("n x$offset n2", $recv_data); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
186 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
187 my $name = join('.', @name); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
188 if ($name eq 'a.example.net' && $type == A) { |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
189 push @rdata, rd_addr($ttl, '127.0.0.1'); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
190 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
191 } elsif ($name eq 'b.example.net' && $type == A) { |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
192 sleep 2; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
193 push @rdata, rd_addr($ttl, '127.0.0.1'); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
194 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
195 } elsif ($name eq 'cn01.example.net') { |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
196 $ttl = 1; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
197 push @rdata, pack("n3N nCa4n", 0xc00c, CNAME, IN, $ttl, |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
198 7, 4, "cn02", 0xc011); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
199 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
200 } elsif ($name =~ /cn0[268].example.net/) { |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
201 # resolver timeout |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
202 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
203 return; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
204 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
205 } elsif ($name eq 'cn03.example.net') { |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
206 select undef, undef, undef, 1.1; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
207 push @rdata, pack("n3N nC", 0xc00c, CNAME, IN, $ttl, 0); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
208 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
209 } elsif ($name eq 'cn04.example.net') { |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
210 select undef, undef, undef, 1.1; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
211 push @rdata, pack("n3N nCa1n", 0xc00c, CNAME, IN, $ttl, |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
212 4, 1, "a", 0xc011); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
213 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
214 } elsif ($name eq 'cn05.example.net') { |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
215 select undef, undef, undef, 1.1; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
216 push @rdata, pack("n3N nCa4n", 0xc00c, CNAME, IN, $ttl, |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
217 7, 4, "cn06", 0xc011); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
218 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
219 } elsif ($name eq 'cn07.example.net') { |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
220 $ttl = 1; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
221 push @rdata, pack("n3N nCa4n", 0xc00c, CNAME, IN, $ttl, |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
222 7, 4, "cn08", 0xc011); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
223 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
224 } elsif ($name eq 'cn09.example.net') { |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
225 if ($type == A) { |
863
44a9a45aa041
Tests: adjusted http_resolver_cname.t test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
825
diff
changeset
|
226 # await both HTTP requests |
44a9a45aa041
Tests: adjusted http_resolver_cname.t test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
825
diff
changeset
|
227 select undef, undef, undef, 0.2; |
825
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
228 } |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
229 push @rdata, pack("n3N nCa1n", 0xc00c, CNAME, IN, $ttl, |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
230 4, 1, "b", 0xc011); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
231 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
232 } elsif ($name eq 'cn052.example.net') { |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
233 if ($type == A) { |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
234 push @rdata, rd_addr($ttl, '127.0.0.1'); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
235 } |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
236 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
237 } elsif ($name =~ /cn0\d+.example.net/) { |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
238 my ($id) = $name =~ /cn(\d+)/; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
239 $id++; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
240 push @rdata, pack("n3N nCa5n", 0xc00c, CNAME, IN, $ttl, |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
241 8, 5, "cn$id", 0xc012); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
242 } |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
243 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
244 $len = @name; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
245 pack("n6 (C/a*)$len x n2", $id, $hdr | $rcode, 1, scalar @rdata, |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
246 0, 0, @name, $type, $class) . join('', @rdata); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
247 } |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
248 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
249 sub rd_addr { |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
250 my ($ttl, $addr) = @_; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
251 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
252 my $code = 'split(/\./, $addr)'; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
253 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
254 return pack 'n3N', 0xc00c, A, IN, $ttl if $addr eq ''; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
255 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
256 pack 'n3N nC4', 0xc00c, A, IN, $ttl, eval "scalar $code", eval($code); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
257 } |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
258 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
259 sub dns_daemon { |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
260 my ($port, $t) = @_; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
261 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
262 my ($data, $recv_data); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
263 my $socket = IO::Socket::INET->new( |
937
b1fa8e0cc27b
Tests: whitespaces fix.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
925
diff
changeset
|
264 LocalAddr => '127.0.0.1', |
b1fa8e0cc27b
Tests: whitespaces fix.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
925
diff
changeset
|
265 LocalPort => $port, |
b1fa8e0cc27b
Tests: whitespaces fix.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
925
diff
changeset
|
266 Proto => 'udp', |
825
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
267 ) |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
268 or die "Can't create listening socket: $!\n"; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
269 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
270 # signal we are ready |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
271 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
272 open my $fh, '>', $t->testdir() . '/' . $port; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
273 close $fh; |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
274 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
275 while (1) { |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
276 $socket->recv($recv_data, 65536); |
925
6bb1f2ccd386
Tests: removed unused variables.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
863
diff
changeset
|
277 $data = reply_handler($recv_data); |
825
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
278 $socket->send($data); |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
279 } |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
280 } |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
281 |
ff8c68cd2be4
Tests: http resolver tests with CNAME, complicated cases.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
282 ############################################################################### |