mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-05 19:58:41 +00:00
Fix udp
This commit is contained in:
parent
0a099d972b
commit
f6c15a09b3
4 changed files with 7 additions and 5 deletions
|
@ -39,7 +39,7 @@ func (d *Dispatcher) NewConnection(ctx context.Context, conn net.Conn, metadata
|
|||
}
|
||||
|
||||
func (d *Dispatcher) NewPacketConnection(ctx context.Context, conn N.PacketConn, metadata M.Metadata) error {
|
||||
packetConn := &PacketConn{bufio.NewBindPacketConn(conn.(net.PacketConn), metadata.Destination)}
|
||||
packetConn := &PacketConn{bufio.NewBindPacketConn(conn.(net.PacketConn), metadata.Destination), ToDestination(metadata.Destination, net.Network_UDP)}
|
||||
return d.upstream.DispatchLink(ctx, ToDestination(metadata.Destination, net.Network_UDP), &transport.Link{
|
||||
Reader: packetConn,
|
||||
Writer: packetConn,
|
||||
|
|
|
@ -70,13 +70,15 @@ func (c *Conn) WriteMultiBuffer(bufferList buf.MultiBuffer) error {
|
|||
|
||||
type PacketConn struct {
|
||||
net.Conn
|
||||
destination net.Destination
|
||||
}
|
||||
|
||||
func (c *PacketConn) ReadMultiBuffer() (buf.MultiBuffer, error) {
|
||||
buffer, err := buf.ReadOneUDP(c.Conn)
|
||||
buffer, err := buf.ReadBuffer(c.Conn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
buffer.UDP = &c.destination
|
||||
return buf.MultiBuffer{buffer}, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue