Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer ipv4 address when lookup hosts #16

Closed
darren opened this issue Aug 1, 2020 · 1 comment
Closed

Prefer ipv4 address when lookup hosts #16

darren opened this issue Aug 1, 2020 · 1 comment
Milestone

Comments

@darren
Copy link

darren commented Aug 1, 2020

socks/net.go

Line 46 in 4d67a70

func lookupIP(host string) (net.IP, error) {

func lookupIP(host string) (net.IP, error) {
	ips, err := net.LookupIP(host)
	if err != nil {
		return nil, err
	}
	if len(ips) == 0 {
		return nil, fmt.Errorf("cannot resolve host: %s", host)
	}

	for _, ip := range ips {
		ip4 := ip.To4()
		if len(ip4) != net.IPv4len {
			continue
		}
		return ip4, nil
	}

	return nil, fmt.Errorf("no ipv4 address found for host: %s", host)
}
@h12w h12w added this to the v1.0.2 milestone Dec 9, 2020
@h12w
Copy link
Owner

h12w commented Dec 9, 2020

Fixed

@h12w h12w closed this as completed Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants