Skip to content

Commit ca787d6

Browse files
add an AddrVerified field to the ClientHelloInfo (#4360)
* add an AddressVerified field to the ClientHelloInfo * rename ClientHelloInfo.AddressVerififed to ClientHelloInfo.AddrVerififed
1 parent f147639 commit ca787d6

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

integrationtests/self/handshake_rtt_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ var _ = Describe("Handshake RTT tests", func() {
7676
context.Background(),
7777
fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port),
7878
getTLSClientConfig(),
79-
getQuicConfig(nil),
79+
getQuicConfig(&quic.Config{GetConfigForClient: func(info *quic.ClientHelloInfo) (*quic.Config, error) {
80+
Expect(info.AddrVerified).To(BeTrue())
81+
return nil, nil
82+
}}),
8083
)
8184
Expect(err).ToNot(HaveOccurred())
8285
defer conn.CloseWithError(0, "")
@@ -94,7 +97,10 @@ var _ = Describe("Handshake RTT tests", func() {
9497
context.Background(),
9598
fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port),
9699
getTLSClientConfig(),
97-
getQuicConfig(nil),
100+
getQuicConfig(&quic.Config{GetConfigForClient: func(info *quic.ClientHelloInfo) (*quic.Config, error) {
101+
Expect(info.AddrVerified).To(BeFalse())
102+
return nil, nil
103+
}}),
98104
)
99105
Expect(err).ToNot(HaveOccurred())
100106
defer conn.CloseWithError(0, "")

interface.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,15 @@ type Config struct {
333333
Tracer func(context.Context, logging.Perspective, ConnectionID) *logging.ConnectionTracer
334334
}
335335

336+
// ClientHelloInfo contains information about an incoming connection attempt.
336337
type ClientHelloInfo struct {
338+
// RemoteAddr is the remote address on the Initial packet.
339+
// Unless AddrVerified is set, the address is not yet verified, and could be a spoofed IP address.
337340
RemoteAddr net.Addr
341+
// AddrVerified says if the remote address was verified using QUIC's Retry mechanism.
342+
// Note that the Retry mechanism costs one network roundtrip,
343+
// and is not performed unless Transport.MaxUnvalidatedHandshakes is surpassed.
344+
AddrVerified bool
338345
}
339346

340347
// ConnectionState records basic details about a QUIC connection

server.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,10 @@ func (s *baseServer) handleInitialImpl(p receivedPacket, hdr *wire.Header) error
639639
tracingID := nextConnTracingID()
640640
config := s.config
641641
if s.config.GetConfigForClient != nil {
642-
conf, err := s.config.GetConfigForClient(&ClientHelloInfo{RemoteAddr: p.remoteAddr})
642+
conf, err := s.config.GetConfigForClient(&ClientHelloInfo{
643+
RemoteAddr: p.remoteAddr,
644+
AddrVerified: clientAddrValidated,
645+
})
643646
if err != nil {
644647
s.logger.Debugf("Rejecting new connection due to GetConfigForClient callback")
645648
delete(s.zeroRTTQueues, hdr.DestConnectionID)

0 commit comments

Comments
 (0)