@@ -182,12 +182,16 @@ func NewClient(conf *config.Config) (c *Client, err error) {
182182 },
183183 }
184184 if len (conf .Other .Passthrough ) != 0 {
185- c . passthrough = make ([] string , len ( conf .Other .Passthrough ))
186- for i , passthrough := range conf . Other . Passthrough {
187- if punycode , err := idna .ToASCII (passthrough ); err ! = nil {
188- passthrough = punycode
185+ for _ , passthrough := range conf .Other .Passthrough {
186+ normalized := passthrough
187+ if punycode , err := idna .ToASCII (normalized ); err = = nil {
188+ normalized = punycode
189189 }
190- c .passthrough [i ] = "." + strings .ToLower (strings .Trim (passthrough , "." )) + "."
190+ normalized = strings .Trim (normalized , "." )
191+ if _ , ok := dns .IsDomainName (normalized ); ! ok {
192+ return nil , fmt .Errorf ("passthrough %q is not a valid domain name" , passthrough )
193+ }
194+ c .passthrough = append (c .passthrough , normalized )
191195 }
192196 }
193197 }
@@ -449,12 +453,12 @@ func (c *Client) handlerFunc(w dns.ResponseWriter, r *dns.Msg, isTCP bool) {
449453
450454 shouldPassthrough := false
451455 passthroughQuestionName := questionName
452- if punycode , err := idna .ToASCII (passthroughQuestionName ); err ! = nil {
456+ if punycode , err := idna .ToASCII (passthroughQuestionName ); err = = nil {
453457 passthroughQuestionName = punycode
454458 }
455- passthroughQuestionName = "." + strings .ToLower ( strings . Trim (passthroughQuestionName , "." )) + "."
459+ passthroughQuestionName = strings .Trim (passthroughQuestionName , "." )
456460 for _ , passthrough := range c .passthrough {
457- if strings . HasSuffix ( passthroughQuestionName , passthrough ) {
461+ if dns . IsSubDomain ( passthrough , passthroughQuestionName ) {
458462 shouldPassthrough = true
459463 break
460464 }
0 commit comments