1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-14 08:15:55 -05:00

Style: refine code style

This commit is contained in:
秋のかえで 2022-08-20 13:11:12 +08:00 committed by Shelikhoo
parent 01a2686568
commit 147641e981
No known key found for this signature in database
GPG Key ID: C4D5E79D22B25316
2 changed files with 5 additions and 9 deletions

View File

@ -292,23 +292,20 @@ type PacketSplitReader struct {
Payload *PacketPayload
}
func (r *PacketSplitReader) ReadFrom(p []byte) (int, gonet.Addr, error) {
var err error
func (r *PacketSplitReader) ReadFrom(p []byte) (n int, addr gonet.Addr, err error) {
if r.Payload == nil || r.Payload.Buffer.IsEmpty() {
r.Payload, err = r.Reader.ReadMultiBufferWithMetadata()
if err != nil {
return 0, nil, err
return
}
}
addr := &gonet.UDPAddr{
addr = &gonet.UDPAddr{
IP: r.Payload.Target.Address.IP(),
Port: int(r.Payload.Target.Port),
}
mb, nBytes := buf.SplitBytes(r.Payload.Buffer, p)
r.Payload.Buffer = mb
r.Payload.Buffer, n = buf.SplitBytes(r.Payload.Buffer, p)
return nBytes, addr, nil
return
}

View File

@ -210,7 +210,6 @@ func (s *Server) handleUDPPayload(ctx context.Context, clientReader *PacketReade
udpDispatcherConstructor := udp.NewSplitDispatcher
switch s.packetEncoding {
case packetaddr.PacketAddrType_None:
break
case packetaddr.PacketAddrType_Packet:
packetAddrDispatcherFactory := udp.NewPacketAddrDispatcherCreator(ctx)
udpDispatcherConstructor = packetAddrDispatcherFactory.NewPacketAddrDispatcher