Skip to content

Commit

Permalink
decouple token accept from token validation
Browse files Browse the repository at this point in the history
  • Loading branch information
birneee committed Feb 22, 2022
1 parent b52e3cc commit f82e447
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ func (s *baseServer) run() {
}
}

var defaultAcceptToken = func(clientAddr net.Addr, token *Token) bool {
var defaultAcceptToken = isClientAddressValidationTokenValid

var isClientAddressValidationTokenValid = func(clientAddr net.Addr, token *Token) bool {
if token == nil {
return false
}
Expand Down Expand Up @@ -421,10 +423,7 @@ func (s *baseServer) handleInitialImpl(p *receivedPacket, hdr *wire.Header) erro
}
}
}

clientAddressValidated := s.config.AcceptToken(p.remoteAddr, token)

if !clientAddressValidated {
if !s.config.AcceptToken(p.remoteAddr, token) {
go func() {
defer p.buffer.Release()
if token != nil && token.IsRetryToken {
Expand Down Expand Up @@ -485,7 +484,7 @@ func (s *baseServer) handleInitialImpl(p *receivedPacket, hdr *wire.Header) erro
s.tlsConf,
s.tokenGenerator,
s.acceptEarlySessions,
clientAddressValidated,
isClientAddressValidationTokenValid(p.remoteAddr, token),
tracer,
tracingID,
s.logger,
Expand Down

0 comments on commit f82e447

Please sign in to comment.