Mercurial > hg > nginx-tests
annotate quic_migration.t @ 1995:d329b05e20fa
Tests: removed usage of "cat" and "grep" in tests.
Both "cat" and "grep" might not be available on Windows. Instead,
$t->read_file() is used, as it is already used in other places. To
simplify checking logs as previously done with "grep", $t->grep_file()
helper function is introduced.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 09 Aug 2024 05:18:51 +0300 |
parents | 00124c7d0ef1 |
children |
rev | line source |
---|---|
1893
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for quic connection migration. |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx::HTTP3; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 plan(skip_all => '127.0.0.20 local address required') |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 unless defined IO::Socket::INET->new( LocalAddr => '127.0.0.20' ); |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
1896
8b74936ff2ac
Tests: added has_feature() test for CryptX.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1893
diff
changeset
|
29 my $t = Test::Nginx->new()->has(qw/http http_v3 cryptx/) |
1942
00124c7d0ef1
Tests: made sure migrated QUIC connection didn't get stall.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1932
diff
changeset
|
30 ->has_daemon('openssl')->plan(3); |
1893
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 $t->write_file_expand('nginx.conf', <<'EOF'); |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 %%TEST_GLOBALS%% |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 daemon off; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 events { |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 } |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 http { |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 %%TEST_GLOBALS_HTTP%% |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 ssl_certificate_key localhost.key; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 ssl_certificate localhost.crt; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 server { |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 listen 127.0.0.1:%%PORT_8980_UDP%% quic; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 server_name localhost; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 location / { |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 add_header X-IP $remote_addr; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 } |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 } |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 } |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 EOF |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 $t->write_file('openssl.conf', <<EOF); |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 [ req ] |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 default_bits = 2048 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 encrypt_key = no |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 distinguished_name = req_distinguished_name |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 [ req_distinguished_name ] |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 EOF |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 my $d = $t->testdir(); |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 foreach my $name ('localhost') { |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 system('openssl req -x509 -new ' |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 . "-config $d/openssl.conf -subj /CN=$name/ " |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 . "-out $d/$name.crt -keyout $d/$name.key " |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 . ">>$d/openssl.out 2>&1") == 0 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 or die "Can't create certificate for $name: $!\n"; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 } |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 $t->write_file('index.html', ''); |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 $t->run(); |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 ############################################################################### |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 # test that $remote_addr is not truncated after migration (ticket #2488), |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 # to test, we migrate to another address large enough in text representation, |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 # then send a request on the new path |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 my $s = Test::Nginx::HTTP3->new(); |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 $s->new_connection_id(1, 0, "connection_id_1", "reset_token_0001"); |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 my $frames = $s->read(all => [{ type => 'NCID' }]); |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 my ($frame) = grep { $_->{type} eq "NCID" } @$frames; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 $s->{socket} = IO::Socket::INET->new( |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 Proto => "udp", |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 LocalAddr => '127.0.0.20', |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 PeerAddr => '127.0.0.1:' . port(8980), |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 ); |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 $s->{scid} = "connection_id_1"; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 $s->{dcid} = $frame->{cid}; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 $s->ping(); |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 $frames = $s->read(all => [{ type => 'PATH_CHALLENGE' }]); |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 ($frame) = grep { $_->{type} eq "PATH_CHALLENGE" } @$frames; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 $s->path_response($frame->{data}); |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 $frames = $s->read(all => [{ sid => $s->new_stream(), fin => 1 }]); |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 is($frame->{headers}{'x-ip'}, '127.0.0.20', 'remote addr after migration'); |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 |
1942
00124c7d0ef1
Tests: made sure migrated QUIC connection didn't get stall.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1932
diff
changeset
|
109 $frames = $s->read(all => [{ sid => $s->new_stream(), fin => 1 }]); |
00124c7d0ef1
Tests: made sure migrated QUIC connection didn't get stall.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1932
diff
changeset
|
110 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
00124c7d0ef1
Tests: made sure migrated QUIC connection didn't get stall.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1932
diff
changeset
|
111 is($frame->{headers}{'x-ip'}, '127.0.0.20', 'next packets after migration'); |
00124c7d0ef1
Tests: made sure migrated QUIC connection didn't get stall.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1932
diff
changeset
|
112 |
1893
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 # test that $remote_addr is not truncated while in the process of migration; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 # the same but migration occurs on receiving a request stream itself, |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 # which is the first non-probing frame on the new path; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 # this might lead to $remote_addr truncation in the following order: |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 # - stream held original sockaddr/addr_text references on stream creation |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 # - values were rewritten as part of handling connection migration |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 # - stream was handled referencing rewritten values, with old local lengths |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 # sockaddr and addr_text are expected to keep copies on stream creation |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 $s = Test::Nginx::HTTP3->new(); |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 $s->new_connection_id(1, 0, "connection_id_1", "reset_token_0001"); |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 $frames = $s->read(all => [{ type => 'NCID' }]); |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 ($frame) = grep { $_->{type} eq "NCID" } @$frames; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 $s->{socket} = IO::Socket::INET->new( |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 Proto => "udp", |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 LocalAddr => '127.0.0.20', |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 PeerAddr => '127.0.0.1:' . port(8980), |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 ); |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 $s->{scid} = "connection_id_1"; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 $s->{dcid} = $frame->{cid}; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 |
1932
b68471aee5ad
Tests: improved test for a stream initiating QUIC path migration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1896
diff
changeset
|
136 my $sid = $s->new_stream(); |
b68471aee5ad
Tests: improved test for a stream initiating QUIC path migration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1896
diff
changeset
|
137 |
b68471aee5ad
Tests: improved test for a stream initiating QUIC path migration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1896
diff
changeset
|
138 $frames = $s->read(all => [{ type => 'PATH_CHALLENGE' }]); |
b68471aee5ad
Tests: improved test for a stream initiating QUIC path migration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1896
diff
changeset
|
139 ($frame) = grep { $_->{type} eq "PATH_CHALLENGE" } @$frames; |
b68471aee5ad
Tests: improved test for a stream initiating QUIC path migration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1896
diff
changeset
|
140 $s->path_response($frame->{data}); |
b68471aee5ad
Tests: improved test for a stream initiating QUIC path migration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1896
diff
changeset
|
141 |
b68471aee5ad
Tests: improved test for a stream initiating QUIC path migration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1896
diff
changeset
|
142 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
1893
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 is($frame->{headers}{'x-ip'}, '127.0.0.1', 'remote addr on migration'); |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 |
6dcf5a1df790
Tests: basic QUIC connection migration tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 ############################################################################### |