mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-07-23 18:34:14 +00:00
pass destination
This commit is contained in:
parent
adea0161ac
commit
31c1a8f974
1 changed files with 3 additions and 6 deletions
|
@ -175,7 +175,6 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
||||||
var newCancel context.CancelFunc
|
var newCancel context.CancelFunc
|
||||||
if session.TimeoutOnlyFromContext(ctx) {
|
if session.TimeoutOnlyFromContext(ctx) {
|
||||||
newCtx, newCancel = context.WithCancel(context.Background())
|
newCtx, newCancel = context.WithCancel(context.Background())
|
||||||
newCtx = session.ContextWithOutbounds(newCtx, session.OutboundsFromContext(ctx))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
plcy := h.policy()
|
plcy := h.policy()
|
||||||
|
@ -239,7 +238,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
||||||
if destination.Network == net.Network_TCP {
|
if destination.Network == net.Network_TCP {
|
||||||
reader = buf.NewReader(conn)
|
reader = buf.NewReader(conn)
|
||||||
} else {
|
} else {
|
||||||
reader = NewPacketReader(ctx, conn, UDPOverride)
|
reader = NewPacketReader(conn, UDPOverride, destination)
|
||||||
}
|
}
|
||||||
if err := buf.Copy(reader, output, buf.UpdateActivity(timer)); err != nil {
|
if err := buf.Copy(reader, output, buf.UpdateActivity(timer)); err != nil {
|
||||||
return errors.New("failed to process response").Base(err)
|
return errors.New("failed to process response").Base(err)
|
||||||
|
@ -274,7 +273,7 @@ func isTLSConn(conn stat.Connection) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPacketReader(ctx context.Context, conn net.Conn, UDPOverride net.Destination) buf.Reader {
|
func NewPacketReader(conn net.Conn, UDPOverride net.Destination, DialDest net.Destination) buf.Reader {
|
||||||
iConn := conn
|
iConn := conn
|
||||||
statConn, ok := iConn.(*stat.CounterConnection)
|
statConn, ok := iConn.(*stat.CounterConnection)
|
||||||
if ok {
|
if ok {
|
||||||
|
@ -286,9 +285,7 @@ func NewPacketReader(ctx context.Context, conn net.Conn, UDPOverride net.Destina
|
||||||
}
|
}
|
||||||
if c, ok := iConn.(*internet.PacketConnWrapper); ok {
|
if c, ok := iConn.(*internet.PacketConnWrapper); ok {
|
||||||
isAddrChanged := false
|
isAddrChanged := false
|
||||||
outbounds := session.OutboundsFromContext(ctx)
|
if UDPOverride.Address != nil || UDPOverride.Port != 0 || DialDest.Address.Family().IsDomain() {
|
||||||
targetAddr := outbounds[len(outbounds)-1].Target.Address
|
|
||||||
if UDPOverride.Address != nil || UDPOverride.Port != 0 || targetAddr.Family().IsDomain() {
|
|
||||||
isAddrChanged = true
|
isAddrChanged = true
|
||||||
}
|
}
|
||||||
return &PacketReader{
|
return &PacketReader{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue