mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-05-18 18:39:07 -04:00
error generator
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
"v2ray.com/core/app/log"
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/buf"
|
||||
"v2ray.com/core/common/errors"
|
||||
"v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/protocol"
|
||||
"v2ray.com/core/common/retry"
|
||||
@@ -40,7 +39,7 @@ func NewClient(ctx context.Context, config *ClientConfig) (*Client, error) {
|
||||
func (v *Client) Process(ctx context.Context, outboundRay ray.OutboundRay, dialer proxy.Dialer) error {
|
||||
destination, ok := proxy.TargetFromContext(ctx)
|
||||
if !ok {
|
||||
return errors.New("target not specified").Path("Proxy", "Shadowsocks", "Client")
|
||||
return newError("target not specified")
|
||||
}
|
||||
network := destination.Network
|
||||
|
||||
@@ -60,9 +59,9 @@ func (v *Client) Process(ctx context.Context, outboundRay ray.OutboundRay, diale
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return errors.New("failed to find an available destination").AtWarning().Base(err).Path("Proxy", "Shadowsocks", "Client")
|
||||
return newError("failed to find an available destination").AtWarning().Base(err)
|
||||
}
|
||||
log.Trace(errors.New("tunneling request to ", destination, " via ", server.Destination()).Path("Proxy", "Shadowsocks", "Client"))
|
||||
log.Trace(newError("tunneling request to ", destination, " via ", server.Destination()))
|
||||
|
||||
defer conn.Close()
|
||||
|
||||
@@ -80,7 +79,7 @@ func (v *Client) Process(ctx context.Context, outboundRay ray.OutboundRay, diale
|
||||
user := server.PickUser()
|
||||
rawAccount, err := user.GetTypedAccount()
|
||||
if err != nil {
|
||||
return errors.New("failed to get a valid user account").AtWarning().Base(err).Path("Proxy", "Shadowsocks", "Client")
|
||||
return newError("failed to get a valid user account").AtWarning().Base(err)
|
||||
}
|
||||
account := rawAccount.(*ShadowsocksAccount)
|
||||
request.User = user
|
||||
@@ -95,7 +94,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.New("failed to write request").Base(err).Path("Proxy", "Shadowsocks", "Client")
|
||||
return newError("failed to write request").Base(err)
|
||||
}
|
||||
|
||||
if err := bufferedWriter.SetBuffered(false); err != nil {
|
||||
@@ -126,7 +125,7 @@ func (v *Client) Process(ctx context.Context, outboundRay ray.OutboundRay, diale
|
||||
})
|
||||
|
||||
if err := signal.ErrorOrFinish2(ctx, requestDone, responseDone); err != nil {
|
||||
return errors.New("connection ends").Base(err).Path("Proxy", "Shadowsocks", "Client")
|
||||
return newError("connection ends").Base(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -141,7 +140,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.New("failed to transport all UDP request").Base(err).Path("Proxy", "Shadowsocks", "Client")
|
||||
return newError("failed to transport all UDP request").Base(err)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
@@ -155,13 +154,13 @@ func (v *Client) Process(ctx context.Context, outboundRay ray.OutboundRay, diale
|
||||
}
|
||||
|
||||
if err := buf.PipeUntilEOF(timer, reader, outboundRay.OutboundOutput()); err != nil {
|
||||
return errors.New("failed to transport all UDP response").Base(err).Path("Proxy", "Shadowsocks", "Client")
|
||||
return newError("failed to transport all UDP response").Base(err)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
if err := signal.ErrorOrFinish2(ctx, requestDone, responseDone); err != nil {
|
||||
return errors.New("connection ends").Base(err).Path("Proxy", "Shadowsocks", "Client")
|
||||
return newError("connection ends").Base(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
7
proxy/shadowsocks/errors.generated.go
Normal file
7
proxy/shadowsocks/errors.generated.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package shadowsocks
|
||||
|
||||
import "v2ray.com/core/common/errors"
|
||||
|
||||
func newError(values ...interface{}) *errors.Error {
|
||||
return errors.New(values...).Path("Proxy", "Shadowsocks")
|
||||
}
|
||||
@@ -12,3 +12,5 @@
|
||||
//
|
||||
// R.I.P Shadowsocks
|
||||
package shadowsocks
|
||||
|
||||
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg shadowsocks -path Proxy,Shadowsocks
|
||||
|
||||
Reference in New Issue
Block a user