1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-30 05:56:54 -05:00

fix reading udp packets

This commit is contained in:
Darien Raymond 2019-02-07 16:36:54 +01:00
parent 6e65007d16
commit 4f08b7c795
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
3 changed files with 9 additions and 4 deletions

View File

@ -117,7 +117,12 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in
}
}()
reader := buf.NewReader(conn)
var reader buf.Reader
if dest.Network == net.Network_UDP {
reader = &buf.PacketReader{Reader: conn}
} else {
reader = buf.NewReader(conn)
}
if err := buf.Copy(reader, link.Writer, buf.UpdateActivity(timer)); err != nil {
return newError("failed to transport request").Base(err)
}
@ -151,7 +156,7 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in
defer tConn.Close()
writer = &buf.SequentialWriter{Writer: tConn}
tReader := buf.NewReader(tConn)
tReader := &buf.PacketReader{Reader: tConn}
requestCount++
tproxyRequest = func() error {
defer func() {

View File

@ -97,7 +97,7 @@ func (s *Server) handlerUDPPayload(ctx context.Context, conn internet.Connection
}
inbound.User = s.user
reader := buf.NewReader(conn)
reader := &buf.PacketReader{Reader: conn}
for {
mpayload, err := reader.ReadMultiBuffer()
if err != nil {

View File

@ -200,7 +200,7 @@ func (s *Server) handleUDPPayload(ctx context.Context, conn internet.Connection,
newError("client UDP connection from ", inbound.Source).WriteToLog(session.ExportIDToError(ctx))
}
reader := buf.NewReader(conn)
reader := &buf.PacketReader{Reader: conn}
for {
mpayload, err := reader.ReadMultiBuffer()
if err != nil {