1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-12-31 06:25:32 -05:00

move session based info into session package

This commit is contained in:
Darien Raymond
2018-09-18 23:09:54 +02:00
parent f589769947
commit 94b880d060
28 changed files with 212 additions and 194 deletions

View File

@@ -107,7 +107,9 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (internet.Conn
handler := h.outboundManager.GetHandler(tag)
if handler != nil {
newError("proxying to ", tag, " for dest ", dest).AtDebug().WriteToLog(session.ExportIDToError(ctx))
ctx = proxy.ContextWithTarget(ctx, dest)
ctx = session.ContextWithOutbound(ctx, &session.Outbound{
Target: dest,
})
opts := pipe.OptionsFromContext(ctx)
uplinkReader, uplinkWriter := pipe.New(opts...)
@@ -121,7 +123,12 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (internet.Conn
}
if h.senderSettings.Via != nil {
ctx = internet.ContextWithDialerSource(ctx, h.senderSettings.Via.AsAddress())
outbound := session.OutboundFromContext(ctx)
if outbound == nil {
outbound = new(session.Outbound)
ctx = session.ContextWithOutbound(ctx, outbound)
}
outbound.Gateway = h.senderSettings.Via.AsAddress()
}
ctx = internet.ContextWithStreamSettings(ctx, h.streamSettings)