Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
e998d125
Commit
e998d125
authored
Aug 31, 2021
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Send CONNECTION_CLOSE if Retry token validation failed
parent
95601d31
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
2 deletions
+40
-2
src/shrpx_quic_connection_handler.cc
src/shrpx_quic_connection_handler.cc
+31
-2
src/shrpx_quic_connection_handler.h
src/shrpx_quic_connection_handler.h
+9
-0
No files found.
src/shrpx_quic_connection_handler.cc
View file @
e998d125
...
...
@@ -127,8 +127,10 @@ int QUICConnectionHandler::handle_packet(const UpstreamAddr *faddr,
if
(
verify_retry_token
(
&
odcid
,
hd
.
token
.
base
,
hd
.
token
.
len
,
&
hd
.
dcid
,
&
remote_addr
.
su
.
sa
,
remote_addr
.
len
,
secret
.
data
())
!=
0
)
{
// 2nd Retry packet is not allowed, so just drop it or send
// CONNECTIONC_CLOE with INVALID_TOKEN.
// 2nd Retry packet is not allowed, so send CONNECTIONC_CLOE
// with INVALID_TOKEN.
send_connection_close
(
faddr
,
version
,
&
hd
.
dcid
,
&
hd
.
scid
,
remote_addr
,
local_addr
,
NGTCP2_INVALID_TOKEN
);
return
0
;
}
...
...
@@ -406,6 +408,33 @@ int QUICConnectionHandler::send_stateless_reset(const UpstreamAddr *faddr,
0
);
}
int
QUICConnectionHandler
::
send_connection_close
(
const
UpstreamAddr
*
faddr
,
uint32_t
version
,
const
ngtcp2_cid
*
ini_dcid
,
const
ngtcp2_cid
*
ini_scid
,
const
Address
&
remote_addr
,
const
Address
&
local_addr
,
uint64_t
error_code
)
{
std
::
array
<
uint8_t
,
NGTCP2_DEFAULT_MAX_PKTLEN
>
buf
;
auto
nwrite
=
ngtcp2_crypto_write_connection_close
(
buf
.
data
(),
buf
.
size
(),
version
,
ini_scid
,
ini_dcid
,
error_code
);
if
(
nwrite
<
0
)
{
LOG
(
ERROR
)
<<
"ngtcp2_crypto_write_connection_close failed"
;
return
-
1
;
}
if
(
LOG_ENABLED
(
INFO
))
{
LOG
(
INFO
)
<<
"Send Initial CONNECTION_CLOSE with error_code="
<<
log
::
hex
<<
error_code
<<
log
::
dec
<<
" to remote="
<<
util
::
to_numeric_addr
(
&
remote_addr
)
<<
" dcid="
<<
util
::
format_hex
(
ini_scid
->
data
,
ini_scid
->
datalen
)
<<
" scid="
<<
util
::
format_hex
(
ini_dcid
->
data
,
ini_dcid
->
datalen
);
}
return
quic_send_packet
(
faddr
,
&
remote_addr
.
su
.
sa
,
remote_addr
.
len
,
&
local_addr
.
su
.
sa
,
local_addr
.
len
,
buf
.
data
(),
nwrite
,
0
);
}
void
QUICConnectionHandler
::
add_connection_id
(
const
ngtcp2_cid
*
cid
,
ClientHandler
*
handler
)
{
auto
key
=
make_cid_key
(
cid
);
...
...
src/shrpx_quic_connection_handler.h
View file @
e998d125
...
...
@@ -71,6 +71,15 @@ public:
int
send_stateless_reset
(
const
UpstreamAddr
*
faddr
,
const
uint8_t
*
dcid
,
size_t
dcidlen
,
const
Address
&
remote_addr
,
const
Address
&
local_addr
);
// Send Initial CONNECTION_CLOSE. |ini_dcid| is the destination
// Connection ID which appeared in Client Initial packet.
// |ini_scid| is the source Connection ID which appeared in Client
// Initial packet.
int
send_connection_close
(
const
UpstreamAddr
*
faddr
,
uint32_t
version
,
const
ngtcp2_cid
*
ini_dcid
,
const
ngtcp2_cid
*
ini_scid
,
const
Address
&
remote_addr
,
const
Address
&
local_addr
,
uint64_t
error_code
);
ClientHandler
*
handle_new_connection
(
const
UpstreamAddr
*
faddr
,
const
Address
&
remote_addr
,
const
Address
&
local_addr
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment