0
0
mirror of https://github.com/XTLS/Xray-core.git synced 2025-08-30 10:25:31 +00:00

fix origin

This commit is contained in:
patterniha 2025-08-12 23:35:46 +03:30
parent fe84718aad
commit 808aaa53b0

View File

@ -308,26 +308,18 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (stat.Connecti
ob.Gateway = ParseRandomIP(addr, h.senderSettings.ViaCidr) ob.Gateway = ParseRandomIP(addr, h.senderSettings.ViaCidr)
case domain == "origin": case domain == "origin":
if inbound := session.InboundFromContext(ctx); inbound != nil { if inbound := session.InboundFromContext(ctx); inbound != nil {
if inbound.Conn != nil { if inbound.Local.IsValid() && inbound.Local.Address.Family().IsIP() {
origin, _, err := net.SplitHostPort(inbound.Conn.LocalAddr().String()) ob.Gateway = inbound.Local.Address
if err == nil { errors.LogDebug(ctx, "use inbound local ip as sendthrough: ", inbound.Local.Address.String())
ob.Gateway = net.ParseAddress(origin)
errors.LogDebug(ctx, "use receive package ip as snedthrough: ", origin)
}
} }
} }
case domain == "srcip": case domain == "srcip":
if inbound := session.InboundFromContext(ctx); inbound != nil { if inbound := session.InboundFromContext(ctx); inbound != nil {
if inbound.Conn != nil { if inbound.Source.IsValid() && inbound.Source.Address.Family().IsIP() {
clientaddr, _, err := net.SplitHostPort(inbound.Conn.RemoteAddr().String()) ob.Gateway = inbound.Source.Address
if err == nil { errors.LogDebug(ctx, "use inbound source ip as sendthrough: ", inbound.Source.Address.String())
ob.Gateway = net.ParseAddress(clientaddr)
errors.LogDebug(ctx, "use client src ip as snedthrough: ", clientaddr)
}
} }
} }
//case addr.Family().IsDomain(): //case addr.Family().IsDomain():
default: default: