1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 01:57:12 -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 return nil
}) })
if err != 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 return err
} }
defer conn.Close() 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) tcpListener, err := hub.ListenTCP(address, port, this.handleConnection, tlsConfig)
if err != nil { if err != nil {
log.Error("Http: Failed listen on port ", port, ": ", err) log.Error("HTTP: Failed listen on port ", port, ": ", err)
return err return err
} }
this.Lock() this.Lock()
@ -110,7 +110,9 @@ func (this *Server) handleConnection(conn *hub.Connection) {
request, err := http.ReadRequest(reader) request, err := http.ReadRequest(reader)
if err != nil { if err != nil {
if err != io.EOF {
log.Warning("HTTP: Failed to read http request: ", err) log.Warning("HTTP: Failed to read http request: ", err)
}
return return
} }
log.Info("HTTP: Request to Method [", request.Method, "] Host [", request.Host, "] with URL [", request.URL, "]") log.Info("HTTP: Request to Method [", request.Method, "] Host [", request.Host, "] with URL [", request.URL, "]")

View File

@ -43,9 +43,12 @@ func ReadRequest(reader io.Reader, auth *Authenticator, udp bool) (*Request, err
_, err := io.ReadFull(reader, buffer.Value[:1]) _, err := io.ReadFull(reader, buffer.Value[:1])
if err != nil { if err != nil {
log.Error("Shadowsocks: Failed to read address type: ", err) if err != io.EOF {
log.Warning("Shadowsocks: Failed to read address type: ", err)
return nil, transport.ErrorCorruptedPacket return nil, transport.ErrorCorruptedPacket
} }
return nil, err
}
lenBuffer := 1 lenBuffer := 1
request := new(Request) request := new(Request)
@ -58,7 +61,7 @@ func ReadRequest(reader io.Reader, auth *Authenticator, udp bool) (*Request, err
case AddrTypeIPv4: case AddrTypeIPv4:
_, err := io.ReadFull(reader, buffer.Value[lenBuffer:lenBuffer+4]) _, err := io.ReadFull(reader, buffer.Value[lenBuffer:lenBuffer+4])
if err != nil { 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 return nil, transport.ErrorCorruptedPacket
} }
request.Address = v2net.IPAddress(buffer.Value[lenBuffer : lenBuffer+4]) 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: case AddrTypeIPv6:
_, err := io.ReadFull(reader, buffer.Value[lenBuffer:lenBuffer+16]) _, err := io.ReadFull(reader, buffer.Value[lenBuffer:lenBuffer+16])
if err != nil { 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 return nil, transport.ErrorCorruptedPacket
} }
request.Address = v2net.IPAddress(buffer.Value[lenBuffer : lenBuffer+16]) 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: case AddrTypeDomain:
_, err := io.ReadFull(reader, buffer.Value[lenBuffer:lenBuffer+1]) _, err := io.ReadFull(reader, buffer.Value[lenBuffer:lenBuffer+1])
if err != nil { 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 return nil, transport.ErrorCorruptedPacket
} }
domainLength := int(buffer.Value[lenBuffer]) domainLength := int(buffer.Value[lenBuffer])
lenBuffer++ lenBuffer++
_, err = io.ReadFull(reader, buffer.Value[lenBuffer:lenBuffer+domainLength]) _, err = io.ReadFull(reader, buffer.Value[lenBuffer:lenBuffer+domainLength])
if err != nil { if err != nil {
log.Error("Shadowsocks: Failed to read domain: ", err) log.Warning("Shadowsocks: Failed to read domain: ", err)
return nil, transport.ErrorCorruptedPacket return nil, transport.ErrorCorruptedPacket
} }
request.Address = v2net.DomainAddress(string(buffer.Value[lenBuffer : lenBuffer+domainLength])) request.Address = v2net.DomainAddress(string(buffer.Value[lenBuffer : lenBuffer+domainLength]))
lenBuffer += domainLength lenBuffer += domainLength
default: default:
log.Error("Shadowsocks: Unknown address type: ", addrType) log.Warning("Shadowsocks: Unknown address type: ", addrType)
return nil, transport.ErrorCorruptedPacket return nil, transport.ErrorCorruptedPacket
} }
_, err = io.ReadFull(reader, buffer.Value[lenBuffer:lenBuffer+2]) _, err = io.ReadFull(reader, buffer.Value[lenBuffer:lenBuffer+2])
if err != nil { if err != nil {
log.Error("Shadowsocks: Failed to read port: ", err) log.Warning("Shadowsocks: Failed to read port: ", err)
return nil, transport.ErrorCorruptedPacket return nil, transport.ErrorCorruptedPacket
} }
@ -105,7 +108,7 @@ func ReadRequest(reader io.Reader, auth *Authenticator, udp bool) (*Request, err
if udp { if udp {
nBytes, err := reader.Read(buffer.Value[lenBuffer:]) nBytes, err := reader.Read(buffer.Value[lenBuffer:])
if err != nil { 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 return nil, transport.ErrorCorruptedPacket
} }
buffer.Slice(0, lenBuffer+nBytes) 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] authBytes = buffer.Value[lenBuffer : lenBuffer+AuthSize]
_, err = io.ReadFull(reader, authBytes) _, err = io.ReadFull(reader, authBytes)
if err != nil { if err != nil {
log.Error("Shadowsocks: Failed to read OTA: ", err) log.Warning("Shadowsocks: Failed to read OTA: ", err)
return nil, transport.ErrorCorruptedPacket return nil, transport.ErrorCorruptedPacket
} }
} }
@ -130,7 +133,6 @@ func ReadRequest(reader io.Reader, auth *Authenticator, udp bool) (*Request, err
if request.OTA { if request.OTA {
actualAuth := auth.Authenticate(nil, buffer.Value[0:lenBuffer]) actualAuth := auth.Authenticate(nil, buffer.Value[0:lenBuffer])
if !bytes.Equal(actualAuth, authBytes) { if !bytes.Equal(actualAuth, authBytes) {
log.Debug("Shadowsocks: Invalid OTA. Expecting ", actualAuth, ", but got ", authBytes)
log.Warning("Shadowsocks: Invalid OTA.") log.Warning("Shadowsocks: Invalid OTA.")
return nil, proxy.ErrorInvalidAuthentication 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) request, err := ReadRequest(reader, NewAuthenticator(HeaderKeyGenerator(key, iv)), true)
if err != nil { if err != nil {
if err != io.EOF {
log.Access(source, "", log.AccessRejected, err) log.Access(source, "", log.AccessRejected, err)
log.Warning("Shadowsocks: Invalid request from ", source, ": ", err) log.Warning("Shadowsocks: Invalid request from ", source, ": ", err)
}
return return
} }
//defer request.Release() //defer request.Release()
@ -173,8 +175,10 @@ func (this *Server) handleConnection(conn *hub.Connection) {
ivLen := this.config.Cipher.IVSize() ivLen := this.config.Cipher.IVSize()
_, err := io.ReadFull(bufferedReader, buffer.Value[:ivLen]) _, err := io.ReadFull(bufferedReader, buffer.Value[:ivLen])
if err != nil { if err != nil {
if err != io.EOF {
log.Access(conn.RemoteAddr(), "", log.AccessRejected, err) log.Access(conn.RemoteAddr(), "", log.AccessRejected, err)
log.Error("Shadowsocks: Failed to read IV: ", err) log.Warning("Shadowsocks: Failed to read IV: ", err)
}
return return
} }

View File

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