This commit is contained in:
David Dean 2023-12-26 07:31:26 +11:00
parent fa37f4a22f
commit 81c8f1d297
No known key found for this signature in database
GPG Key ID: 5B60492A7C71BBFC

View File

@ -2,6 +2,7 @@ package socks5
import ( import (
"context" "context"
"net"
"net/netip" "net/netip"
) )
@ -14,10 +15,12 @@ type NameResolver interface {
type DNSResolver struct{} type DNSResolver struct{}
func (d DNSResolver) Resolve(ctx context.Context, name string) (context.Context, netip.Addr, error) { func (d DNSResolver) Resolve(ctx context.Context, name string) (context.Context, netip.Addr, error) {
addr, err := netip.ParseAddr(name) ipAddr, err := net.ResolveIPAddr("ip", name)
if err != nil { if err != nil {
return ctx, netip.Addr{}, err return ctx, netip.Addr{}, err
} }
addr := netip.MustParseAddr(ipAddr.String())
return ctx, addr, err return ctx, addr, err
} }