update context functions

This commit is contained in:
Darien Raymond
2017-02-09 22:49:38 +01:00
parent d270a99d4f
commit d04d92c187
15 changed files with 122 additions and 98 deletions
+4 -4
View File
@@ -44,13 +44,13 @@ func (w *tcpWorker) callback(conn internet.Connection) {
if w.recvOrigDest {
dest := tcp.GetOriginalDestination(conn)
if dest.IsValid() {
ctx = proxy.ContextWithOriginalDestination(ctx, dest)
ctx = proxy.ContextWithOriginalTarget(ctx, dest)
}
}
if len(w.tag) > 0 {
ctx = proxy.ContextWithInboundTag(ctx, w.tag)
}
ctx = proxy.ContextWithInboundDestination(ctx, v2net.TCPDestination(w.address, w.port))
ctx = proxy.ContextWithInboundEntryPoint(ctx, v2net.TCPDestination(w.address, w.port))
ctx = proxy.ContextWithSource(ctx, v2net.DestinationFromAddr(conn.RemoteAddr()))
if err := w.proxy.Process(ctx, v2net.Network_TCP, conn, w.dispatcher); err != nil {
log.Info("Proxyman|TCPWorker: Connection ends with ", err)
@@ -205,13 +205,13 @@ func (w *udpWorker) callback(b *buf.Buffer, source v2net.Destination, originalDe
ctx, cancel := context.WithCancel(ctx)
conn.cancel = cancel
if originalDest.IsValid() {
ctx = proxy.ContextWithOriginalDestination(ctx, originalDest)
ctx = proxy.ContextWithOriginalTarget(ctx, originalDest)
}
if len(w.tag) > 0 {
ctx = proxy.ContextWithInboundTag(ctx, w.tag)
}
ctx = proxy.ContextWithSource(ctx, source)
ctx = proxy.ContextWithInboundDestination(ctx, v2net.UDPDestination(w.address, w.port))
ctx = proxy.ContextWithInboundEntryPoint(ctx, v2net.UDPDestination(w.address, w.port))
if err := w.proxy.Process(ctx, v2net.Network_UDP, conn, w.dispatcher); err != nil {
log.Info("Proxyman|UDPWorker: Connection ends with ", err)
}
+1 -1
View File
@@ -81,7 +81,7 @@ func (h *Handler) Dial(ctx context.Context, dest v2net.Destination) (internet.Co
handler := h.outboundManager.GetHandler(tag)
if handler != nil {
log.Info("Proxyman|OutboundHandler: Proxying to ", tag)
ctx = proxy.ContextWithDestination(ctx, dest)
ctx = proxy.ContextWithTarget(ctx, dest)
stream := ray.NewRay(ctx)
go handler.Dispatch(ctx, stream)
return NewConnection(stream), nil