mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-25 07:20:44 +00:00
lazy evaluation of log fields
This commit is contained in:
1 parent
8f20933457
commit
eec0bb4db4
25 files changed
+124
-117
No files matched your search
+7
-7
@@ -17,7 +17,7 @@ func (this *SocksServer) ListenUDP(port v2net.Port) error {
|
||||
}
|
||||
conn, err := net.ListenUDP("udp", addr)
|
||||
if err != nil {
|
||||
log.Error("Socks: failed to listen UDP on port %d: %v", port, err)
|
||||
log.Error("Socks: failed to listen UDP on port ", port, ": ", err)
|
||||
return err
|
||||
}
|
||||
this.udpMutex.Lock()
|
||||
@@ -40,15 +40,15 @@ func (this *SocksServer) AcceptPackets() error {
|
||||
nBytes, addr, err := this.udpConn.ReadFromUDP(buffer.Value)
|
||||
this.udpMutex.RUnlock()
|
||||
if err != nil {
|
||||
log.Error("Socks: failed to read UDP packets: %v", err)
|
||||
log.Error("Socks: failed to read UDP packets: ", err)
|
||||
buffer.Release()
|
||||
continue
|
||||
}
|
||||
log.Info("Socks: Client UDP connection from %v", addr)
|
||||
log.Info("Socks: Client UDP connection from ", addr)
|
||||
request, err := protocol.ReadUDPRequest(buffer.Value[:nBytes])
|
||||
buffer.Release()
|
||||
if err != nil {
|
||||
log.Error("Socks: failed to parse UDP request: %v", err)
|
||||
log.Error("Socks: failed to parse UDP request: ", err)
|
||||
continue
|
||||
}
|
||||
if request.Data == nil || request.Data.Len() == 0 {
|
||||
@@ -62,7 +62,7 @@ func (this *SocksServer) AcceptPackets() error {
|
||||
}
|
||||
|
||||
udpPacket := v2net.NewPacket(request.Destination(), request.Data, false)
|
||||
log.Info("Socks: Send packet to %s with %d bytes", udpPacket.Destination().String(), request.Data.Len())
|
||||
log.Info("Socks: Send packet to ", udpPacket.Destination(), " with ", request.Data.Len(), " bytes")
|
||||
go this.handlePacket(udpPacket, addr, request.Address, request.Port)
|
||||
}
|
||||
return nil
|
||||
@@ -79,7 +79,7 @@ func (this *SocksServer) handlePacket(packet v2net.Packet, clientAddr *net.UDPAd
|
||||
Port: port,
|
||||
Data: data,
|
||||
}
|
||||
log.Info("Socks: Writing back UDP response with %d bytes from %s to %s", data.Len(), targetAddr.String(), clientAddr.String())
|
||||
log.Info("Socks: Writing back UDP response with ", data.Len(), " bytes from ", targetAddr, " to ", clientAddr)
|
||||
|
||||
udpMessage := alloc.NewSmallBuffer().Clear()
|
||||
response.Write(udpMessage)
|
||||
@@ -94,7 +94,7 @@ func (this *SocksServer) handlePacket(packet v2net.Packet, clientAddr *net.UDPAd
|
||||
udpMessage.Release()
|
||||
response.Data.Release()
|
||||
if err != nil {
|
||||
log.Error("Socks: failed to write UDP message (%d bytes) to %s: %v", nBytes, clientAddr.String(), err)
|
||||
log.Error("Socks: failed to write UDP message (", nBytes, " bytes) to ", clientAddr, ": ", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user