1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-28 14:56:33 -04:00

format code

This commit is contained in:
V2Ray 2015-10-08 23:29:06 +02:00
parent ebb4f5b7bd
commit 936fd03c30
2 changed files with 9 additions and 9 deletions

View File

@ -27,14 +27,14 @@ func (request *Socks5UDPRequest) Write(buffer *alloc.Buffer) {
buffer.AppendBytes(0, 0, request.Fragment)
switch {
case request.Address.IsIPv4():
buffer.AppendBytes(AddrTypeIPv4).Append(request.Address.IP())
buffer.AppendBytes(AddrTypeIPv4).Append(request.Address.IP())
case request.Address.IsIPv6():
buffer.AppendBytes(AddrTypeIPv6).Append(request.Address.IP())
buffer.AppendBytes(AddrTypeIPv6).Append(request.Address.IP())
case request.Address.IsDomain():
buffer.AppendBytes(AddrTypeDomain, byte(len(request.Address.Domain()))).Append([]byte(request.Address.Domain()))
buffer.AppendBytes(AddrTypeDomain, byte(len(request.Address.Domain()))).Append([]byte(request.Address.Domain()))
}
buffer.Append(request.Address.PortBytes())
buffer.Append(request.Data.Value)
buffer.Append(request.Address.PortBytes())
buffer.Append(request.Data.Value)
}
func ReadUDPRequest(packet []byte) (request Socks5UDPRequest, err error) {

View File

@ -78,12 +78,12 @@ func (server *SocksServer) handlePacket(conn *net.UDPConn, packet v2net.Packet,
Data: data,
}
log.Info("Writing back UDP response with %d bytes from %s to %s", data.Len(), targetAddr.String(), clientAddr.String())
udpMessage := alloc.NewSmallBuffer().Clear()
response.Write(udpMessage)
udpMessage := alloc.NewSmallBuffer().Clear()
response.Write(udpMessage)
nBytes, err := conn.WriteToUDP(udpMessage.Value, clientAddr)
udpMessage.Release()
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)