-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Custom LookupIPAddr function #699
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding another field I would prefer to fix this differently. I think it's better if we change
type TCPDialer struct {
// ...
Resolver *net.Resolver
}
into
type Resolver interface {
LookupAddr(context.Context, string) (names []string, err error)
}
type TCPDialer struct {
// ...
Resolver Resolver
}
That way net.Resolver
implements this interface, but if you want to use a different LookupAddr
function you can use your own struct that implements this interface with your own function.
Wouldn't it better to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand. LookupAddr
does a reverse lookup from IP to name. That's not what we want?
One last change and then I'll merge it. Sorry for being pedantic.
@erikdubbelboer Also, fixed your comment, thanks! |
Where in fasthttp do you think we use fasthttp does support IPv6 just fine. |
@erikdubbelboer yeah, sorry, I just got everything mixed up looking at the example code you've provided above for the interface. Thanks for merging this! |
Ah sorry I didn't realize I put |
Continuing the work started at https://github.com/valyala/fasthttp/pull/689/files .
Turns out, specifying custom resolver doesn't allow to avoid resolving completely (as
Dial()
has to return a connection to a DNS server), so in this way it becomes possible to reimplementLookupIPAddr()
function to specify resolved name manually or get it from some place other than actual DNS query.