@@ -396,9 +396,6 @@ func (r *Resolver) LookupPort(ctx context.Context, network, service string) (por
396
396
// contain DNS "CNAME" records, as long as host resolves to
397
397
// address records.
398
398
//
399
- // The returned canonical name is validated to be a properly
400
- // formatted presentation-format domain name.
401
- //
402
399
// LookupCNAME uses context.Background internally; to specify the context, use
403
400
// Resolver.LookupCNAME.
404
401
func LookupCNAME (host string ) (cname string , err error ) {
@@ -415,18 +412,8 @@ func LookupCNAME(host string) (cname string, err error) {
415
412
// LookupCNAME does not return an error if host does not
416
413
// contain DNS "CNAME" records, as long as host resolves to
417
414
// address records.
418
- //
419
- // The returned canonical name is validated to be a properly
420
- // formatted presentation-format domain name.
421
- func (r * Resolver ) LookupCNAME (ctx context.Context , host string ) (string , error ) {
422
- cname , err := r .lookupCNAME (ctx , host )
423
- if err != nil {
424
- return "" , err
425
- }
426
- if ! isDomainName (cname ) {
427
- return "" , & DNSError {Err : "CNAME target is invalid" , Name : host }
428
- }
429
- return cname , nil
415
+ func (r * Resolver ) LookupCNAME (ctx context.Context , host string ) (cname string , err error ) {
416
+ return r .lookupCNAME (ctx , host )
430
417
}
431
418
432
419
// LookupSRV tries to resolve an SRV query of the given service,
@@ -438,9 +425,6 @@ func (r *Resolver) LookupCNAME(ctx context.Context, host string) (string, error)
438
425
// That is, it looks up _service._proto.name. To accommodate services
439
426
// publishing SRV records under non-standard names, if both service
440
427
// and proto are empty strings, LookupSRV looks up name directly.
441
- //
442
- // The returned service names are validated to be properly
443
- // formatted presentation-format domain names.
444
428
func LookupSRV (service , proto , name string ) (cname string , addrs []* SRV , err error ) {
445
429
return DefaultResolver .lookupSRV (context .Background (), service , proto , name )
446
430
}
@@ -454,88 +438,34 @@ func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err err
454
438
// That is, it looks up _service._proto.name. To accommodate services
455
439
// publishing SRV records under non-standard names, if both service
456
440
// and proto are empty strings, LookupSRV looks up name directly.
457
- //
458
- // The returned service names are validated to be properly
459
- // formatted presentation-format domain names.
460
- func (r * Resolver ) LookupSRV (ctx context.Context , service , proto , name string ) (string , []* SRV , error ) {
461
- cname , addrs , err := r .lookupSRV (ctx , service , proto , name )
462
- if err != nil {
463
- return "" , nil , err
464
- }
465
- if cname != "" && ! isDomainName (cname ) {
466
- return "" , nil , & DNSError {Err : "SRV header name is invalid" , Name : name }
467
- }
468
- for _ , addr := range addrs {
469
- if addr == nil {
470
- continue
471
- }
472
- if ! isDomainName (addr .Target ) {
473
- return "" , nil , & DNSError {Err : "SRV target is invalid" , Name : name }
474
- }
475
- }
476
- return cname , addrs , nil
441
+ func (r * Resolver ) LookupSRV (ctx context.Context , service , proto , name string ) (cname string , addrs []* SRV , err error ) {
442
+ return r .lookupSRV (ctx , service , proto , name )
477
443
}
478
444
479
445
// LookupMX returns the DNS MX records for the given domain name sorted by preference.
480
446
//
481
- // The returned mail server names are validated to be properly
482
- // formatted presentation-format domain names.
483
- //
484
447
// LookupMX uses context.Background internally; to specify the context, use
485
448
// Resolver.LookupMX.
486
449
func LookupMX (name string ) ([]* MX , error ) {
487
450
return DefaultResolver .lookupMX (context .Background (), name )
488
451
}
489
452
490
453
// LookupMX returns the DNS MX records for the given domain name sorted by preference.
491
- //
492
- // The returned mail server names are validated to be properly
493
- // formatted presentation-format domain names.
494
454
func (r * Resolver ) LookupMX (ctx context.Context , name string ) ([]* MX , error ) {
495
- records , err := r .lookupMX (ctx , name )
496
- if err != nil {
497
- return nil , err
498
- }
499
- for _ , mx := range records {
500
- if mx == nil {
501
- continue
502
- }
503
- if ! isDomainName (mx .Host ) {
504
- return nil , & DNSError {Err : "MX target is invalid" , Name : name }
505
- }
506
- }
507
- return records , nil
455
+ return r .lookupMX (ctx , name )
508
456
}
509
457
510
458
// LookupNS returns the DNS NS records for the given domain name.
511
459
//
512
- // The returned name server names are validated to be properly
513
- // formatted presentation-format domain names.
514
- //
515
460
// LookupNS uses context.Background internally; to specify the context, use
516
461
// Resolver.LookupNS.
517
462
func LookupNS (name string ) ([]* NS , error ) {
518
463
return DefaultResolver .lookupNS (context .Background (), name )
519
464
}
520
465
521
466
// LookupNS returns the DNS NS records for the given domain name.
522
- //
523
- // The returned name server names are validated to be properly
524
- // formatted presentation-format domain names.
525
467
func (r * Resolver ) LookupNS (ctx context.Context , name string ) ([]* NS , error ) {
526
- records , err := r .lookupNS (ctx , name )
527
- if err != nil {
528
- return nil , err
529
- }
530
- for _ , ns := range records {
531
- if ns == nil {
532
- continue
533
- }
534
- if ! isDomainName (ns .Host ) {
535
- return nil , & DNSError {Err : "NS target is invalid" , Name : name }
536
- }
537
- }
538
- return records , nil
468
+ return r .lookupNS (ctx , name )
539
469
}
540
470
541
471
// LookupTXT returns the DNS TXT records for the given domain name.
@@ -565,18 +495,6 @@ func LookupAddr(addr string) (names []string, err error) {
565
495
566
496
// LookupAddr performs a reverse lookup for the given address, returning a list
567
497
// of names mapping to that address.
568
- //
569
- // The returned names are validated to be properly
570
- // formatted presentation-format domain names.
571
- func (r * Resolver ) LookupAddr (ctx context.Context , addr string ) ([]string , error ) {
572
- names , err := r .lookupAddr (ctx , addr )
573
- if err != nil {
574
- return nil , err
575
- }
576
- for _ , name := range names {
577
- if ! isDomainName (name ) {
578
- return nil , & DNSError {Err : "PTR target is invalid" , Name : addr }
579
- }
580
- }
581
- return names , nil
498
+ func (r * Resolver ) LookupAddr (ctx context.Context , addr string ) (names []string , err error ) {
499
+ return r .lookupAddr (ctx , addr )
582
500
}
0 commit comments