1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 09:36:34 -05:00

update log

This commit is contained in:
v2ray 2016-06-03 20:21:46 +02:00
parent 0a7deabd46
commit 4b92e6b25b
5 changed files with 34 additions and 24 deletions

View File

@ -86,7 +86,7 @@ func (this *FreedomConnection) Dispatch(destination v2net.Destination, payload *
return nil
})
if err != nil {
log.Error("Freedom: Failed to open connection to ", destination, ": ", err)
log.Warning("Freedom: Failed to open connection to ", destination, ": ", err)
return err
}
defer conn.Close()

View File

@ -71,7 +71,7 @@ func (this *Server) Listen(address v2net.Address, port v2net.Port) error {
}
tcpListener, err := hub.ListenTCP(address, port, this.handleConnection, tlsConfig)
if err != nil {
log.Error("Http: Failed listen on port ", port, ": ", err)
log.Error("HTTP: Failed listen on port ", port, ": ", err)
return err
}
this.Lock()
@ -110,7 +110,9 @@ func (this *Server) handleConnection(conn *hub.Connection) {
request, err := http.ReadRequest(reader)
if err != nil {
log.Warning("HTTP: Failed to read http request: ", err)
if err != io.EOF {
log.Warning("HTTP: Failed to read http request: ", err)
}
return
}
log.Info("HTTP: Request to Method [", request.Method, "] Host [", request.Host, "] with URL [", request.URL, "]")

View File

@ -43,8 +43,11 @@ func ReadRequest(reader io.Reader, auth *Authenticator, udp bool) (*Request, err
_, err := io.ReadFull(reader, buffer.Value[:1])
if err != nil {
log.Error("Shadowsocks: Failed to read address type: ", err)
return nil, transport.ErrorCorruptedPacket
if err != io.EOF {
log.Warning("Shadowsocks: Failed to read address type: ", err)
return nil, transport.ErrorCorruptedPacket
}
return nil, err
}
lenBuffer := 1
@ -58,7 +61,7 @@ func ReadRequest(reader io.Reader, auth *Authenticator, udp bool) (*Request, err
case AddrTypeIPv4:
_, err := io.ReadFull(reader, buffer.Value[lenBuffer:lenBuffer+4])
if err != nil {
log.Error("Shadowsocks: Failed to read IPv4 address: ", err)
log.Warning("Shadowsocks: Failed to read IPv4 address: ", err)
return nil, transport.ErrorCorruptedPacket
}
request.Address = v2net.IPAddress(buffer.Value[lenBuffer : lenBuffer+4])
@ -66,7 +69,7 @@ func ReadRequest(reader io.Reader, auth *Authenticator, udp bool) (*Request, err
case AddrTypeIPv6:
_, err := io.ReadFull(reader, buffer.Value[lenBuffer:lenBuffer+16])
if err != nil {
log.Error("Shadowsocks: Failed to read IPv6 address: ", err)
log.Warning("Shadowsocks: Failed to read IPv6 address: ", err)
return nil, transport.ErrorCorruptedPacket
}
request.Address = v2net.IPAddress(buffer.Value[lenBuffer : lenBuffer+16])
@ -74,26 +77,26 @@ func ReadRequest(reader io.Reader, auth *Authenticator, udp bool) (*Request, err
case AddrTypeDomain:
_, err := io.ReadFull(reader, buffer.Value[lenBuffer:lenBuffer+1])
if err != nil {
log.Error("Shadowsocks: Failed to read domain lenth: ", err)
log.Warning("Shadowsocks: Failed to read domain lenth: ", err)
return nil, transport.ErrorCorruptedPacket
}
domainLength := int(buffer.Value[lenBuffer])
lenBuffer++
_, err = io.ReadFull(reader, buffer.Value[lenBuffer:lenBuffer+domainLength])
if err != nil {
log.Error("Shadowsocks: Failed to read domain: ", err)
log.Warning("Shadowsocks: Failed to read domain: ", err)
return nil, transport.ErrorCorruptedPacket
}
request.Address = v2net.DomainAddress(string(buffer.Value[lenBuffer : lenBuffer+domainLength]))
lenBuffer += domainLength
default:
log.Error("Shadowsocks: Unknown address type: ", addrType)
log.Warning("Shadowsocks: Unknown address type: ", addrType)
return nil, transport.ErrorCorruptedPacket
}
_, err = io.ReadFull(reader, buffer.Value[lenBuffer:lenBuffer+2])
if err != nil {
log.Error("Shadowsocks: Failed to read port: ", err)
log.Warning("Shadowsocks: Failed to read port: ", err)
return nil, transport.ErrorCorruptedPacket
}
@ -105,7 +108,7 @@ func ReadRequest(reader io.Reader, auth *Authenticator, udp bool) (*Request, err
if udp {
nBytes, err := reader.Read(buffer.Value[lenBuffer:])
if err != nil {
log.Error("Shadowsocks: Failed to read UDP payload: ", err)
log.Warning("Shadowsocks: Failed to read UDP payload: ", err)
return nil, transport.ErrorCorruptedPacket
}
buffer.Slice(0, lenBuffer+nBytes)
@ -121,7 +124,7 @@ func ReadRequest(reader io.Reader, auth *Authenticator, udp bool) (*Request, err
authBytes = buffer.Value[lenBuffer : lenBuffer+AuthSize]
_, err = io.ReadFull(reader, authBytes)
if err != nil {
log.Error("Shadowsocks: Failed to read OTA: ", err)
log.Warning("Shadowsocks: Failed to read OTA: ", err)
return nil, transport.ErrorCorruptedPacket
}
}
@ -130,7 +133,6 @@ func ReadRequest(reader io.Reader, auth *Authenticator, udp bool) (*Request, err
if request.OTA {
actualAuth := auth.Authenticate(nil, buffer.Value[0:lenBuffer])
if !bytes.Equal(actualAuth, authBytes) {
log.Debug("Shadowsocks: Invalid OTA. Expecting ", actualAuth, ", but got ", authBytes)
log.Warning("Shadowsocks: Invalid OTA.")
return nil, proxy.ErrorInvalidAuthentication
}

View File

@ -107,8 +107,10 @@ func (this *Server) handlerUDPPayload(payload *alloc.Buffer, source v2net.Destin
request, err := ReadRequest(reader, NewAuthenticator(HeaderKeyGenerator(key, iv)), true)
if err != nil {
log.Access(source, "", log.AccessRejected, err)
log.Warning("Shadowsocks: Invalid request from ", source, ": ", err)
if err != io.EOF {
log.Access(source, "", log.AccessRejected, err)
log.Warning("Shadowsocks: Invalid request from ", source, ": ", err)
}
return
}
//defer request.Release()
@ -173,8 +175,10 @@ func (this *Server) handleConnection(conn *hub.Connection) {
ivLen := this.config.Cipher.IVSize()
_, err := io.ReadFull(bufferedReader, buffer.Value[:ivLen])
if err != nil {
log.Access(conn.RemoteAddr(), "", log.AccessRejected, err)
log.Error("Shadowsocks: Failed to read IV: ", err)
if err != io.EOF {
log.Access(conn.RemoteAddr(), "", log.AccessRejected, err)
log.Warning("Shadowsocks: Failed to read IV: ", err)
}
return
}

View File

@ -106,7 +106,9 @@ func (this *Server) handleConnection(connection *hub.Connection) {
auth, auth4, err := protocol.ReadAuthentication(reader)
if err != nil && err != protocol.Socks4Downgrade {
log.Error("Socks: failed to read authentication: ", err)
if err != io.EOF {
log.Warning("Socks: failed to read authentication: ", err)
}
return
}
@ -128,7 +130,7 @@ func (this *Server) handleSocks5(reader *v2io.BufferedReader, writer *v2io.Buffe
err := protocol.WriteAuthentication(writer, authResponse)
writer.Flush()
if err != nil {
log.Error("Socks: failed to write authentication: ", err)
log.Warning("Socks: failed to write authentication: ", err)
return err
}
log.Warning("Socks: client doesn't support any allowed auth methods.")
@ -136,8 +138,8 @@ func (this *Server) handleSocks5(reader *v2io.BufferedReader, writer *v2io.Buffe
}
authResponse := protocol.NewAuthenticationResponse(expectedAuthMethod)
err := protocol.WriteAuthentication(writer, authResponse)
writer.Flush()
protocol.WriteAuthentication(writer, authResponse)
err := writer.Flush()
if err != nil {
log.Error("Socks: failed to write authentication: ", err)
return err
@ -145,7 +147,7 @@ func (this *Server) handleSocks5(reader *v2io.BufferedReader, writer *v2io.Buffe
if this.config.AuthType == AuthTypePassword {
upRequest, err := protocol.ReadUserPassRequest(reader)
if err != nil {
log.Error("Socks: failed to read username and password: ", err)
log.Warning("Socks: failed to read username and password: ", err)
return err
}
status := byte(0)
@ -167,7 +169,7 @@ func (this *Server) handleSocks5(reader *v2io.BufferedReader, writer *v2io.Buffe
request, err := protocol.ReadRequest(reader)
if err != nil {
log.Error("Socks: failed to read request: ", err)
log.Warning("Socks: failed to read request: ", err)
return err
}