mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-20 08:16:55 -05:00
Style: refine code style
This commit is contained in:
parent
01a2686568
commit
147641e981
@ -292,23 +292,20 @@ type PacketSplitReader struct {
|
|||||||
Payload *PacketPayload
|
Payload *PacketPayload
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *PacketSplitReader) ReadFrom(p []byte) (int, gonet.Addr, error) {
|
func (r *PacketSplitReader) ReadFrom(p []byte) (n int, addr gonet.Addr, err error) {
|
||||||
var err error
|
|
||||||
|
|
||||||
if r.Payload == nil || r.Payload.Buffer.IsEmpty() {
|
if r.Payload == nil || r.Payload.Buffer.IsEmpty() {
|
||||||
r.Payload, err = r.Reader.ReadMultiBufferWithMetadata()
|
r.Payload, err = r.Reader.ReadMultiBufferWithMetadata()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, nil, err
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addr := &gonet.UDPAddr{
|
addr = &gonet.UDPAddr{
|
||||||
IP: r.Payload.Target.Address.IP(),
|
IP: r.Payload.Target.Address.IP(),
|
||||||
Port: int(r.Payload.Target.Port),
|
Port: int(r.Payload.Target.Port),
|
||||||
}
|
}
|
||||||
|
|
||||||
mb, nBytes := buf.SplitBytes(r.Payload.Buffer, p)
|
r.Payload.Buffer, n = buf.SplitBytes(r.Payload.Buffer, p)
|
||||||
r.Payload.Buffer = mb
|
|
||||||
|
|
||||||
return nBytes, addr, nil
|
return
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,6 @@ func (s *Server) handleUDPPayload(ctx context.Context, clientReader *PacketReade
|
|||||||
udpDispatcherConstructor := udp.NewSplitDispatcher
|
udpDispatcherConstructor := udp.NewSplitDispatcher
|
||||||
switch s.packetEncoding {
|
switch s.packetEncoding {
|
||||||
case packetaddr.PacketAddrType_None:
|
case packetaddr.PacketAddrType_None:
|
||||||
break
|
|
||||||
case packetaddr.PacketAddrType_Packet:
|
case packetaddr.PacketAddrType_Packet:
|
||||||
packetAddrDispatcherFactory := udp.NewPacketAddrDispatcherCreator(ctx)
|
packetAddrDispatcherFactory := udp.NewPacketAddrDispatcherCreator(ctx)
|
||||||
udpDispatcherConstructor = packetAddrDispatcherFactory.NewPacketAddrDispatcher
|
udpDispatcherConstructor = packetAddrDispatcherFactory.NewPacketAddrDispatcher
|
||||||
|
Loading…
Reference in New Issue
Block a user