fix domain name resolution for router

This commit is contained in:
ginuerzh
2023-09-16 21:46:12 +08:00
parent a2115a3d38
commit 801f835e9a
4 changed files with 10 additions and 13 deletions

View File

@ -155,6 +155,12 @@ func (r *Router) dial(ctx context.Context, network, address string) (conn net.Co
r.options.Logger.Debugf("dial %s/%s", address, network)
for i := 0; i < count; i++ {
address, err = Resolve(ctx, "ip", address, r.options.Resolver, r.options.HostMapper, r.options.Logger)
if err != nil {
r.options.Logger.Error(err)
break
}
var route Route
if r.options.Chain != nil {
route = r.options.Chain.Route(ctx, network, address)
@ -169,12 +175,6 @@ func (r *Router) dial(ctx context.Context, network, address string) (conn net.Co
r.options.Logger.Debugf("route(retry=%d) %s", i, buf.String())
}
address, err = Resolve(ctx, "ip", address, r.options.Resolver, r.options.HostMapper, r.options.Logger)
if err != nil {
r.options.Logger.Error(err)
break
}
if route == nil {
route = DefaultRoute
}