mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-07-29 11:10:32 -04:00
refactor error interface
This commit is contained in:
@@ -60,7 +60,7 @@ func (v *Client) Process(ctx context.Context, outboundRay ray.OutboundRay, diale
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return errors.Base(err).RequireUserAction().Message("Shadowsocks|Client: Failed to find an available destination.")
|
||||
return errors.New("failed to find an available destination").AtWarning().Base(err).Path("Shadowsocks", "Client")
|
||||
}
|
||||
log.Info("Shadowsocks|Client: Tunneling request to ", destination, " via ", server.Destination())
|
||||
|
||||
@@ -81,7 +81,7 @@ func (v *Client) Process(ctx context.Context, outboundRay ray.OutboundRay, diale
|
||||
user := server.PickUser()
|
||||
rawAccount, err := user.GetTypedAccount()
|
||||
if err != nil {
|
||||
return errors.Base(err).Message("Shadowsocks|Client: Failed to get a valid user account.").RequireUserAction()
|
||||
return errors.New("failed to get a valid user account").AtWarning().Base(err).Path("Shadowsocks", "Client")
|
||||
}
|
||||
account := rawAccount.(*ShadowsocksAccount)
|
||||
request.User = user
|
||||
@@ -96,7 +96,7 @@ func (v *Client) Process(ctx context.Context, outboundRay ray.OutboundRay, diale
|
||||
bufferedWriter := buf.NewBufferedWriter(conn)
|
||||
bodyWriter, err := WriteTCPRequest(request, bufferedWriter)
|
||||
if err != nil {
|
||||
return errors.Base(err).Message("Shadowsocks|Client: Failed to write request")
|
||||
return errors.New("failed to write request").Base(err).Path("Shadowsocks", "Client")
|
||||
}
|
||||
|
||||
if err := bufferedWriter.SetBuffered(false); err != nil {
|
||||
@@ -127,7 +127,7 @@ func (v *Client) Process(ctx context.Context, outboundRay ray.OutboundRay, diale
|
||||
})
|
||||
|
||||
if err := signal.ErrorOrFinish2(ctx, requestDone, responseDone); err != nil {
|
||||
return errors.Base(err).Message("Shadowsocks|Client: Connection ends.")
|
||||
return errors.New("connection ends").Base(err).Path("Shadowsocks", "Client")
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -142,7 +142,7 @@ func (v *Client) Process(ctx context.Context, outboundRay ray.OutboundRay, diale
|
||||
|
||||
requestDone := signal.ExecuteAsync(func() error {
|
||||
if err := buf.PipeUntilEOF(timer, outboundRay.OutboundInput(), writer); err != nil {
|
||||
return errors.Base(err).Message("Shadowsocks|Client: Failed to transport all UDP request")
|
||||
return errors.New("failed to transport all UDP request").Base(err).Path("Shadowsocks", "Client")
|
||||
}
|
||||
return nil
|
||||
})
|
||||
@@ -156,13 +156,13 @@ func (v *Client) Process(ctx context.Context, outboundRay ray.OutboundRay, diale
|
||||
}
|
||||
|
||||
if err := buf.PipeUntilEOF(timer, reader, outboundRay.OutboundOutput()); err != nil {
|
||||
return errors.Base(err).Message("Shadowsocks|Client: Failed to transport all UDP response.")
|
||||
return errors.New("failed to transport all UDP response").Base(err).Path("Shadowsocks", "Client")
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
if err := signal.ErrorOrFinish2(ctx, requestDone, responseDone); err != nil {
|
||||
return errors.Base(err).Message("Shadowsocks|Client: Connection ends.")
|
||||
return errors.New("connection ends").Base(err).Path("Shadowsocks", "Client")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -41,7 +41,7 @@ func (v *Account) GetCipher() (Cipher, error) {
|
||||
func (v *Account) AsAccount() (protocol.Account, error) {
|
||||
cipher, err := v.GetCipher()
|
||||
if err != nil {
|
||||
return nil, errors.Base(err).Message("Shadowsocks|Account: Failed to get cipher.")
|
||||
return nil, errors.New("failed to get cipher").Base(err).Path("Shadowsocks", "Account")
|
||||
}
|
||||
return &ShadowsocksAccount{
|
||||
Cipher: cipher,
|
||||
|
||||
@@ -25,7 +25,7 @@ const (
|
||||
func ReadTCPSession(user *protocol.User, reader io.Reader) (*protocol.RequestHeader, buf.Reader, error) {
|
||||
rawAccount, err := user.GetTypedAccount()
|
||||
if err != nil {
|
||||
return nil, nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to parse account.")
|
||||
return nil, nil, errors.New("failed to parse account").Path("Shadowsocks", "TCP").Base(err)
|
||||
}
|
||||
account := rawAccount.(*ShadowsocksAccount)
|
||||
|
||||
@@ -35,14 +35,14 @@ func ReadTCPSession(user *protocol.User, reader io.Reader) (*protocol.RequestHea
|
||||
ivLen := account.Cipher.IVSize()
|
||||
err = buffer.AppendSupplier(buf.ReadFullFrom(reader, ivLen))
|
||||
if err != nil {
|
||||
return nil, nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to read IV.")
|
||||
return nil, nil, errors.New("failed to read IV").Path("Shadowsocks", "TCP").Base(err)
|
||||
}
|
||||
|
||||
iv := append([]byte(nil), buffer.BytesTo(ivLen)...)
|
||||
|
||||
stream, err := account.Cipher.NewDecodingStream(account.Key, iv)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to initialize decoding stream.")
|
||||
return nil, nil, errors.New("failed to initialize decoding stream").Path("Shadowsocks", "TCP").Base(err)
|
||||
}
|
||||
reader = crypto.NewCryptionReader(stream, reader)
|
||||
|
||||
@@ -56,7 +56,7 @@ func ReadTCPSession(user *protocol.User, reader io.Reader) (*protocol.RequestHea
|
||||
buffer.Clear()
|
||||
err = buffer.AppendSupplier(buf.ReadFullFrom(reader, 1))
|
||||
if err != nil {
|
||||
return nil, nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to read address type.")
|
||||
return nil, nil, errors.New("failed to read address type").Path("Shadowsocks", "TCP").Base(err)
|
||||
}
|
||||
|
||||
addrType := (buffer.Byte(0) & 0x0F)
|
||||
@@ -65,35 +65,35 @@ func ReadTCPSession(user *protocol.User, reader io.Reader) (*protocol.RequestHea
|
||||
}
|
||||
|
||||
if request.Option.Has(RequestOptionOneTimeAuth) && account.OneTimeAuth == Account_Disabled {
|
||||
return nil, nil, errors.New("Shadowsocks|TCP: Rejecting connection with OTA enabled, while server disables OTA.")
|
||||
return nil, nil, errors.New("rejecting connection with OTA enabled, while server disables OTA").Path("Shadowsocks", "TCP")
|
||||
}
|
||||
|
||||
if !request.Option.Has(RequestOptionOneTimeAuth) && account.OneTimeAuth == Account_Enabled {
|
||||
return nil, nil, errors.New("Shadowsocks|TCP: Rejecting connection with OTA disabled, while server enables OTA.")
|
||||
return nil, nil, errors.New("rejecting connection with OTA disabled, while server enables OTA").Path("Shadowsocks", "TCP")
|
||||
}
|
||||
|
||||
switch addrType {
|
||||
case AddrTypeIPv4:
|
||||
err := buffer.AppendSupplier(buf.ReadFullFrom(reader, 4))
|
||||
if err != nil {
|
||||
return nil, nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to read IPv4 address.")
|
||||
return nil, nil, errors.New("failed to read IPv4 address").Path("Shadowsocks", "TCP").Base(err)
|
||||
}
|
||||
request.Address = v2net.IPAddress(buffer.BytesFrom(-4))
|
||||
case AddrTypeIPv6:
|
||||
err := buffer.AppendSupplier(buf.ReadFullFrom(reader, 16))
|
||||
if err != nil {
|
||||
return nil, nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to read IPv6 address.")
|
||||
return nil, nil, errors.New("failed to read IPv6 address").Path("Shadowsocks", "TCP").Base(err)
|
||||
}
|
||||
request.Address = v2net.IPAddress(buffer.BytesFrom(-16))
|
||||
case AddrTypeDomain:
|
||||
err := buffer.AppendSupplier(buf.ReadFullFrom(reader, 1))
|
||||
if err != nil {
|
||||
return nil, nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to read domain lenth.")
|
||||
return nil, nil, errors.New("failed to read domain lenth.").Path("Shadowsocks", "TCP").Base(err)
|
||||
}
|
||||
domainLength := int(buffer.BytesFrom(-1)[0])
|
||||
err = buffer.AppendSupplier(buf.ReadFullFrom(reader, domainLength))
|
||||
if err != nil {
|
||||
return nil, nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to read domain.")
|
||||
return nil, nil, errors.New("failed to read domain").Path("Shadowsocks", "TCP").Base(err)
|
||||
}
|
||||
request.Address = v2net.DomainAddress(string(buffer.BytesFrom(-domainLength)))
|
||||
default:
|
||||
@@ -102,7 +102,7 @@ func ReadTCPSession(user *protocol.User, reader io.Reader) (*protocol.RequestHea
|
||||
|
||||
err = buffer.AppendSupplier(buf.ReadFullFrom(reader, 2))
|
||||
if err != nil {
|
||||
return nil, nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to read port.")
|
||||
return nil, nil, errors.New("failed to read port").Path("Shadowsocks", "TCP").Base(err)
|
||||
}
|
||||
request.Port = v2net.PortFromBytes(buffer.BytesFrom(-2))
|
||||
|
||||
@@ -112,16 +112,16 @@ func ReadTCPSession(user *protocol.User, reader io.Reader) (*protocol.RequestHea
|
||||
|
||||
err := buffer.AppendSupplier(buf.ReadFullFrom(reader, AuthSize))
|
||||
if err != nil {
|
||||
return nil, nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to read OTA.")
|
||||
return nil, nil, errors.New("Failed to read OTA").Path("Shadowsocks", "TCP").Base(err)
|
||||
}
|
||||
|
||||
if !bytes.Equal(actualAuth, buffer.BytesFrom(-AuthSize)) {
|
||||
return nil, nil, errors.New("Shadowsocks|TCP: Invalid OTA")
|
||||
return nil, nil, errors.New("invalid OTA").Path("Shadowsocks", "TCP")
|
||||
}
|
||||
}
|
||||
|
||||
if request.Address == nil {
|
||||
return nil, nil, errors.New("Shadowsocks|TCP: Invalid remote address.")
|
||||
return nil, nil, errors.New("invalid remote address.").Path("Shadowsocks", "TCP")
|
||||
}
|
||||
|
||||
var chunkReader buf.Reader
|
||||
@@ -138,7 +138,7 @@ func WriteTCPRequest(request *protocol.RequestHeader, writer io.Writer) (buf.Wri
|
||||
user := request.User
|
||||
rawAccount, err := user.GetTypedAccount()
|
||||
if err != nil {
|
||||
return nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to parse account.")
|
||||
return nil, errors.New("failed to parse account").Path("Shadowsocks", "TCP").Base(err)
|
||||
}
|
||||
account := rawAccount.(*ShadowsocksAccount)
|
||||
|
||||
@@ -146,12 +146,12 @@ func WriteTCPRequest(request *protocol.RequestHeader, writer io.Writer) (buf.Wri
|
||||
rand.Read(iv)
|
||||
_, err = writer.Write(iv)
|
||||
if err != nil {
|
||||
return nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to write IV.")
|
||||
return nil, errors.New("failed to write IV").Path("Shadowsocks", "TCP")
|
||||
}
|
||||
|
||||
stream, err := account.Cipher.NewEncodingStream(account.Key, iv)
|
||||
if err != nil {
|
||||
return nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to create encoding stream.")
|
||||
return nil, errors.New("failed to create encoding stream").Path("Shadowsocks", "TCP").Base(err)
|
||||
}
|
||||
|
||||
writer = crypto.NewCryptionWriter(stream, writer)
|
||||
@@ -183,7 +183,7 @@ func WriteTCPRequest(request *protocol.RequestHeader, writer io.Writer) (buf.Wri
|
||||
|
||||
_, err = writer.Write(header.Bytes())
|
||||
if err != nil {
|
||||
return nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to write header.")
|
||||
return nil, errors.New("Shadowsocks|TCP: Failed to write header.").Base(err)
|
||||
}
|
||||
|
||||
var chunkWriter buf.Writer
|
||||
@@ -199,19 +199,19 @@ func WriteTCPRequest(request *protocol.RequestHeader, writer io.Writer) (buf.Wri
|
||||
func ReadTCPResponse(user *protocol.User, reader io.Reader) (buf.Reader, error) {
|
||||
rawAccount, err := user.GetTypedAccount()
|
||||
if err != nil {
|
||||
return nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to parse account.")
|
||||
return nil, errors.New("Shadowsocks|TCP: Failed to parse account.").Base(err)
|
||||
}
|
||||
account := rawAccount.(*ShadowsocksAccount)
|
||||
|
||||
iv := make([]byte, account.Cipher.IVSize())
|
||||
_, err = io.ReadFull(reader, iv)
|
||||
if err != nil {
|
||||
return nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to read IV.")
|
||||
return nil, errors.New("Shadowsocks|TCP: Failed to read IV.").Base(err)
|
||||
}
|
||||
|
||||
stream, err := account.Cipher.NewDecodingStream(account.Key, iv)
|
||||
if err != nil {
|
||||
return nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to initialize decoding stream.")
|
||||
return nil, errors.New("Shadowsocks|TCP: Failed to initialize decoding stream.").Base(err)
|
||||
}
|
||||
return buf.NewReader(crypto.NewCryptionReader(stream, reader)), nil
|
||||
}
|
||||
@@ -220,7 +220,7 @@ func WriteTCPResponse(request *protocol.RequestHeader, writer io.Writer) (buf.Wr
|
||||
user := request.User
|
||||
rawAccount, err := user.GetTypedAccount()
|
||||
if err != nil {
|
||||
return nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to parse account.")
|
||||
return nil, errors.New("Shadowsocks|TCP: Failed to parse account.").Base(err)
|
||||
}
|
||||
account := rawAccount.(*ShadowsocksAccount)
|
||||
|
||||
@@ -228,12 +228,12 @@ func WriteTCPResponse(request *protocol.RequestHeader, writer io.Writer) (buf.Wr
|
||||
rand.Read(iv)
|
||||
_, err = writer.Write(iv)
|
||||
if err != nil {
|
||||
return nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to write IV.")
|
||||
return nil, errors.New("Shadowsocks|TCP: Failed to write IV.").Base(err)
|
||||
}
|
||||
|
||||
stream, err := account.Cipher.NewEncodingStream(account.Key, iv)
|
||||
if err != nil {
|
||||
return nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to create encoding stream.")
|
||||
return nil, errors.New("Shadowsocks|TCP: Failed to create encoding stream.").Base(err)
|
||||
}
|
||||
|
||||
return buf.NewWriter(crypto.NewCryptionWriter(stream, writer)), nil
|
||||
@@ -243,7 +243,7 @@ func EncodeUDPPacket(request *protocol.RequestHeader, payload *buf.Buffer) (*buf
|
||||
user := request.User
|
||||
rawAccount, err := user.GetTypedAccount()
|
||||
if err != nil {
|
||||
return nil, errors.Base(err).Message("Shadowsocks|UDP: Failed to parse account.")
|
||||
return nil, errors.New("Shadowsocks|UDP: Failed to parse account.").Base(err)
|
||||
}
|
||||
account := rawAccount.(*ShadowsocksAccount)
|
||||
|
||||
@@ -278,7 +278,7 @@ func EncodeUDPPacket(request *protocol.RequestHeader, payload *buf.Buffer) (*buf
|
||||
|
||||
stream, err := account.Cipher.NewEncodingStream(account.Key, iv)
|
||||
if err != nil {
|
||||
return nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to create encoding stream.")
|
||||
return nil, errors.New("Shadowsocks|TCP: Failed to create encoding stream.").Base(err)
|
||||
}
|
||||
|
||||
stream.XORKeyStream(buffer.BytesFrom(ivLen), buffer.BytesFrom(ivLen))
|
||||
@@ -288,7 +288,7 @@ func EncodeUDPPacket(request *protocol.RequestHeader, payload *buf.Buffer) (*buf
|
||||
func DecodeUDPPacket(user *protocol.User, payload *buf.Buffer) (*protocol.RequestHeader, *buf.Buffer, error) {
|
||||
rawAccount, err := user.GetTypedAccount()
|
||||
if err != nil {
|
||||
return nil, nil, errors.Base(err).Message("Shadowsocks|UDP: Failed to parse account.")
|
||||
return nil, nil, errors.New("Shadowsocks|UDP: Failed to parse account.").Base(err)
|
||||
}
|
||||
account := rawAccount.(*ShadowsocksAccount)
|
||||
|
||||
@@ -298,7 +298,7 @@ func DecodeUDPPacket(user *protocol.User, payload *buf.Buffer) (*protocol.Reques
|
||||
|
||||
stream, err := account.Cipher.NewDecodingStream(account.Key, iv)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Base(err).Message("Shadowsocks|UDP: Failed to initialize decoding stream.")
|
||||
return nil, nil, errors.New("Shadowsocks|UDP: Failed to initialize decoding stream.").Base(err)
|
||||
}
|
||||
stream.XORKeyStream(payload.Bytes(), payload.Bytes())
|
||||
|
||||
|
||||
+15
-15
@@ -28,15 +28,15 @@ type Server struct {
|
||||
func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) {
|
||||
space := app.SpaceFromContext(ctx)
|
||||
if space == nil {
|
||||
return nil, errors.New("Shadowsocks|Server: No space in context.")
|
||||
return nil, errors.New("no space in context").Path("Shadowsocks", "Server")
|
||||
}
|
||||
if config.GetUser() == nil {
|
||||
return nil, errors.New("Shadowsocks|Server: User is not specified.")
|
||||
return nil, errors.New("user is not specified").Path("Shadowsocks", "Server")
|
||||
}
|
||||
|
||||
rawAccount, err := config.User.GetTypedAccount()
|
||||
if err != nil {
|
||||
return nil, errors.Base(err).Message("Shadowsocks|Server: Failed to get user account.")
|
||||
return nil, errors.New("failed to get user account").Base(err).Path("Shadowsocks", "Server")
|
||||
}
|
||||
account := rawAccount.(*ShadowsocksAccount)
|
||||
|
||||
@@ -68,7 +68,7 @@ func (s *Server) Process(ctx context.Context, network net.Network, conn internet
|
||||
case net.Network_UDP:
|
||||
return s.handlerUDPPayload(ctx, conn, dispatcher)
|
||||
default:
|
||||
return errors.New("Shadowsocks|Server: Unknown network: ", network)
|
||||
return errors.New("unknown network: ", network).Path("Shadowsocks", "Server")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ func (v *Server) handlerUDPPayload(ctx context.Context, conn internet.Connection
|
||||
request, data, err := DecodeUDPPacket(v.user, payload)
|
||||
if err != nil {
|
||||
if source, ok := proxy.SourceFromContext(ctx); ok {
|
||||
log.Info("Shadowsocks|Server: Skipping invalid UDP packet from: ", source, ": ", err)
|
||||
log.Trace(errors.New("dropping invalid UDP packet from: ", source).Base(err).Path("Shadowsocks", "Server"))
|
||||
log.Access(source, "", log.AccessRejected, err)
|
||||
}
|
||||
payload.Release()
|
||||
@@ -93,13 +93,13 @@ func (v *Server) handlerUDPPayload(ctx context.Context, conn internet.Connection
|
||||
}
|
||||
|
||||
if request.Option.Has(RequestOptionOneTimeAuth) && v.account.OneTimeAuth == Account_Disabled {
|
||||
log.Info("Shadowsocks|Server: Client payload enables OTA but server doesn't allow it.")
|
||||
log.Trace(errors.New("client payload enables OTA but server doesn't allow it").Path("Shadowsocks", "Server"))
|
||||
payload.Release()
|
||||
continue
|
||||
}
|
||||
|
||||
if !request.Option.Has(RequestOptionOneTimeAuth) && v.account.OneTimeAuth == Account_Enabled {
|
||||
log.Info("Shadowsocks|Server: Client payload disables OTA but server forces it.")
|
||||
log.Trace(errors.New("client payload disables OTA but server forces it").Path("Shadowsocks", "Server"))
|
||||
payload.Release()
|
||||
continue
|
||||
}
|
||||
@@ -108,7 +108,7 @@ func (v *Server) handlerUDPPayload(ctx context.Context, conn internet.Connection
|
||||
if source, ok := proxy.SourceFromContext(ctx); ok {
|
||||
log.Access(source, dest, log.AccessAccepted, "")
|
||||
}
|
||||
log.Info("Shadowsocks|Server: Tunnelling request to ", dest)
|
||||
log.Trace(errors.New("tunnelling request to ", dest).Path("Shadowsocks", "Server"))
|
||||
|
||||
ctx = protocol.ContextWithUser(ctx, request.User)
|
||||
udpServer.Dispatch(ctx, dest, data, func(payload *buf.Buffer) {
|
||||
@@ -116,7 +116,7 @@ func (v *Server) handlerUDPPayload(ctx context.Context, conn internet.Connection
|
||||
|
||||
data, err := EncodeUDPPacket(request, payload)
|
||||
if err != nil {
|
||||
log.Warning("Shadowsocks|Server: Failed to encode UDP packet: ", err)
|
||||
log.Trace(errors.New("failed to encode UDP packet").Base(err).Path("Shadowsocks", "Server").AtWarning())
|
||||
return
|
||||
}
|
||||
defer data.Release()
|
||||
@@ -134,7 +134,7 @@ func (s *Server) handleConnection(ctx context.Context, conn internet.Connection,
|
||||
request, bodyReader, err := ReadTCPSession(s.user, bufferedReader)
|
||||
if err != nil {
|
||||
log.Access(conn.RemoteAddr(), "", log.AccessRejected, err)
|
||||
return errors.Base(err).Message("Shadowsocks|Server: Failed to create request from: ", conn.RemoteAddr())
|
||||
return errors.New("failed to create request from: ", conn.RemoteAddr()).Base(err).Path("Shadowsocks", "Server")
|
||||
}
|
||||
conn.SetReadDeadline(time.Time{})
|
||||
|
||||
@@ -142,7 +142,7 @@ func (s *Server) handleConnection(ctx context.Context, conn internet.Connection,
|
||||
|
||||
dest := request.Destination()
|
||||
log.Access(conn.RemoteAddr(), dest, log.AccessAccepted, "")
|
||||
log.Info("Shadowsocks|Server: Tunnelling request to ", dest)
|
||||
log.Trace(errors.New("tunnelling request to ", dest).Path("Shadowsocks", "Server"))
|
||||
|
||||
ctx = protocol.ContextWithUser(ctx, request.User)
|
||||
|
||||
@@ -157,7 +157,7 @@ func (s *Server) handleConnection(ctx context.Context, conn internet.Connection,
|
||||
bufferedWriter := buf.NewBufferedWriter(conn)
|
||||
responseWriter, err := WriteTCPResponse(request, bufferedWriter)
|
||||
if err != nil {
|
||||
return errors.Base(err).Message("Shadowsocks|Server: Failed to write response.")
|
||||
return errors.New("failed to write response").Base(err).Path("Shadowsocks", "Server")
|
||||
}
|
||||
|
||||
payload, err := ray.InboundOutput().Read()
|
||||
@@ -174,7 +174,7 @@ func (s *Server) handleConnection(ctx context.Context, conn internet.Connection,
|
||||
}
|
||||
|
||||
if err := buf.PipeUntilEOF(timer, ray.InboundOutput(), responseWriter); err != nil {
|
||||
return errors.Base(err).Message("Shadowsocks|Server: Failed to transport all TCP response.")
|
||||
return errors.New("failed to transport all TCP response").Base(err).Path("Shadowsocks", "Server")
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -184,7 +184,7 @@ func (s *Server) handleConnection(ctx context.Context, conn internet.Connection,
|
||||
defer ray.InboundInput().Close()
|
||||
|
||||
if err := buf.PipeUntilEOF(timer, bodyReader, ray.InboundInput()); err != nil {
|
||||
return errors.Base(err).Message("Shadowsocks|Server: Failed to transport all TCP request.")
|
||||
return errors.New("failed to transport all TCP request").Base(err).Path("Shadowsocks", "Server")
|
||||
}
|
||||
return nil
|
||||
})
|
||||
@@ -192,7 +192,7 @@ func (s *Server) handleConnection(ctx context.Context, conn internet.Connection,
|
||||
if err := signal.ErrorOrFinish2(ctx, requestDone, responseDone); err != nil {
|
||||
ray.InboundInput().CloseError()
|
||||
ray.InboundOutput().CloseError()
|
||||
return errors.Base(err).Message("Shadowsocks|Server: Connection ends.")
|
||||
return errors.New("connection ends").Base(err).Path("Shadowsocks", "Server")
|
||||
}
|
||||
|
||||
runtime.KeepAlive(timer)
|
||||
|
||||
Reference in New Issue
Block a user