Skip to content

Commit

Permalink
fix: panic in dns over quic when address is a ip
Browse files Browse the repository at this point in the history
  • Loading branch information
AkinoKaede committed Jul 2, 2023
1 parent e102d52 commit 5c995d9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/dns/nameserver_quic.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,16 @@ func (s *QUICNameServer) getConnection(ctx context.Context) (quic.Connection, er

func (s *QUICNameServer) openConnection(ctx context.Context) (quic.Connection, error) {
tlsConfig := tls.Config{
ServerName: s.destination.Address.Domain(),
ServerName: func() string {
switch s.destination.Address.Family() {
case net.AddressFamilyIPv4, net.AddressFamilyIPv6:
return s.destination.Address.IP().String()
case net.AddressFamilyDomain:
return s.destination.Address.Domain()
default:
panic("unknown address family")
}
}(),
}
quicConfig := &quic.Config{
HandshakeIdleTimeout: handshakeIdleTimeout,
Expand Down

0 comments on commit 5c995d9

Please sign in to comment.