mirror of https://github.com/v2ray/v2ray-core
change ip everytime when dial IP
parent
e29ff05912
commit
59819871a1
|
@ -81,21 +81,22 @@ func (h *Handler) Process(ctx context.Context, link *core.Link, dialer proxy.Dia
|
||||||
input := link.Reader
|
input := link.Reader
|
||||||
output := link.Writer
|
output := link.Writer
|
||||||
|
|
||||||
if h.config.DomainStrategy == Config_USE_IP && destination.Address.Family().IsDomain() {
|
var conn internet.Connection
|
||||||
ip := h.resolveIP(ctx, destination.Address.Domain())
|
err := retry.ExponentialBackoff(5, 100).On(func() error {
|
||||||
|
dialDest := destination
|
||||||
|
if h.config.DomainStrategy == Config_USE_IP && dialDest.Address.Family().IsDomain() {
|
||||||
|
ip := h.resolveIP(ctx, dialDest.Address.Domain())
|
||||||
if ip != nil {
|
if ip != nil {
|
||||||
destination = net.Destination{
|
dialDest = net.Destination{
|
||||||
Network: destination.Network,
|
Network: dialDest.Network,
|
||||||
Address: ip,
|
Address: ip,
|
||||||
Port: destination.Port,
|
Port: dialDest.Port,
|
||||||
}
|
}
|
||||||
newError("changing destination to ", destination).WriteToLog(session.ExportIDToError(ctx))
|
newError("dialing to to ", dialDest).WriteToLog(session.ExportIDToError(ctx))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var conn internet.Connection
|
rawConn, err := dialer.Dial(ctx, dialDest)
|
||||||
err := retry.ExponentialBackoff(5, 100).On(func() error {
|
|
||||||
rawConn, err := dialer.Dial(ctx, destination)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -105,7 +106,7 @@ func (h *Handler) Process(ctx context.Context, link *core.Link, dialer proxy.Dia
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return newError("failed to open connection to ", destination).Base(err)
|
return newError("failed to open connection to ", destination).Base(err)
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close() // nolint: errcheck
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
timer := signal.CancelAfterInactivity(ctx, cancel, h.policy().Timeouts.ConnectionIdle)
|
timer := signal.CancelAfterInactivity(ctx, cancel, h.policy().Timeouts.ConnectionIdle)
|
||||||
|
|
Loading…
Reference in New Issue