Skip to content

Commit

Permalink
fix: save QUIC visitor when H3 is enabled only
Browse files Browse the repository at this point in the history
otherwise the TLS-fallback will incorrectly overwrite the cached QUIC fingerprint's sender.

Signed-off-by: Gaukas Wang <[email protected]>
  • Loading branch information
gaukas committed Jun 6, 2024
1 parent 5f4cf92 commit b1b2b88
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions modcaddy/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,17 @@ func (h *Handler) serveQUIC(wr http.ResponseWriter, req *http.Request, next cadd

// h.logger.Debug(fmt.Sprintf("Fetched QUIC fingerprint for %s", req.RemoteAddr))

// Get IP part of the RemoteAddr
ip, _, err := net.SplitHostPort(req.RemoteAddr)
if err == nil {
h.reservoir.NewQUICVisitor(ip, req.RemoteAddr)
} else {
h.logger.Error(fmt.Sprintf("Can't extract IP from %s: %v", req.RemoteAddr, err))
// If this is a QUIC request, we record the IP address as a QUIC visitor
// so this QUIC fingerprint is associated with the IP address and can be
// fetched for even HTTP-over-TLS (TCP-based) requests.
if req.ProtoMajor == 3 {
// Get IP part of the RemoteAddr
ip, _, err := net.SplitHostPort(req.RemoteAddr)
if err == nil {
h.reservoir.NewQUICVisitor(ip, req.RemoteAddr)
} else {
h.logger.Error(fmt.Sprintf("Can't extract IP from %s: %v", req.RemoteAddr, err))
}
}

qfp.UserAgent = req.UserAgent()
Expand Down

0 comments on commit b1b2b88

Please sign in to comment.