From ce7dc23446052a87ec8700f4982d0c8a183eef49 Mon Sep 17 00:00:00 2001 From: Vigilans Date: Wed, 7 Jun 2023 01:44:31 +0800 Subject: [PATCH] Apply DomainStrategy to outbound target --- app/proxyman/outbound/handler.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index 5c6d0dd3d..71e66c2dd 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -151,6 +151,18 @@ func (h *Handler) Tag() string { // Dispatch implements proxy.Outbound.Dispatch. func (h *Handler) Dispatch(ctx context.Context, link *transport.Link) { + if h.senderSettings != nil && h.senderSettings.DomainStrategy != proxyman.SenderConfig_AS_IS { + outbound := session.OutboundFromContext(ctx) + if outbound == nil { + outbound = new(session.Outbound) + ctx = session.ContextWithOutbound(ctx, outbound) + } + if outbound.Target.Address != nil && outbound.Target.Address.Family().IsDomain() { + if addr := h.resolveIP(ctx, outbound.Target.Address.Domain(), h.Address()); addr != nil { + outbound.Target.Address = addr + } + } + } if h.mux != nil && (h.mux.Enabled || session.MuxPreferedFromContext(ctx)) { if err := h.mux.Dispatch(ctx, link); err != nil { err := newError("failed to process mux outbound traffic").Base(err)