mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 17:46:58 -05:00
add packet addr support in outbound handler
This commit is contained in:
parent
5b536a7d02
commit
552a15085d
@ -8,6 +8,7 @@ import (
|
||||
"github.com/v2fly/v2ray-core/v5/common"
|
||||
"github.com/v2fly/v2ray-core/v5/common/mux"
|
||||
"github.com/v2fly/v2ray-core/v5/common/net"
|
||||
"github.com/v2fly/v2ray-core/v5/common/net/packetaddr"
|
||||
"github.com/v2fly/v2ray-core/v5/common/serial"
|
||||
"github.com/v2fly/v2ray-core/v5/common/session"
|
||||
"github.com/v2fly/v2ray-core/v5/features/outbound"
|
||||
@ -208,6 +209,15 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (internet.Conn
|
||||
ctx = session.SetTransportLayerProxyTagToContext(ctx, tag)
|
||||
}
|
||||
|
||||
if isStream, err := packetaddr.GetDestinationSubsetOf(dest); err == nil {
|
||||
packetConn, err := internet.ListenSystemPacket(ctx, nil, h.streamSettings.SocketSettings)
|
||||
if err != nil {
|
||||
return nil, newError("unable to listen socket").Base(err)
|
||||
}
|
||||
conn := packetaddr.ToPacketAddrConnWrapper(packetConn, isStream)
|
||||
return h.getStatCouterConnection(conn), nil
|
||||
}
|
||||
|
||||
conn, err := internet.Dial(ctx, dest, h.streamSettings)
|
||||
return h.getStatCouterConnection(conn), err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user