Skip to content

net: DefaultResolver.Lookup{Host,IPAddr} and LookupHost fail to parse a literal IPv6 address w/ zone #20790

@mikioh

Description

@mikioh

When GODEBUG=netdns=go or Resolver.PreferGo is true, DefaultResolver.Lookup{IPAddr,Host} and LookupHost fail to parse a literal IPv6 address w/ zone like the following:

% go run x.go 
lookup fe80::1%lo0: no such host
exit status 1

--
package main

import (
	"context"
	"log"
	"net"
)

func main() {
	r := &net.Resolver{PreferGo: true}
	ipas, err := r.LookupIPAddr(context.Background(), "fe80::1%lo0")
	if err != nil {
		log.Fatal(err)
	}
	log.Println(ipas)
}

Hope this is the last one of long standing issues regarding inconsistency between GODEBUG=netdns=cgo and GODEBUG=netdns=go. The fix would be simply to replace the use of ParseIP with a pair of parseIPv4 and parseIPv6, so this is probably a good first contribution issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions