mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-17 23:06:30 -05:00
update error messages
This commit is contained in:
parent
9bb66b4de4
commit
a034276eee
@ -110,38 +110,38 @@ func (v *CommandSwitchAccountFactory) Marshal(command interface{}, writer io.Wri
|
|||||||
func (v *CommandSwitchAccountFactory) Unmarshal(data []byte) (interface{}, error) {
|
func (v *CommandSwitchAccountFactory) Unmarshal(data []byte) (interface{}, error) {
|
||||||
cmd := new(protocol.CommandSwitchAccount)
|
cmd := new(protocol.CommandSwitchAccount)
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
return nil, errors.New("VMess|SwitchAccountCommand: Insufficient length.")
|
return nil, errors.New("insufficient length.").Path("Proxy", "VMess", "Encoding", "Command")
|
||||||
}
|
}
|
||||||
lenHost := int(data[0])
|
lenHost := int(data[0])
|
||||||
if len(data) < lenHost+1 {
|
if len(data) < lenHost+1 {
|
||||||
return nil, errors.New("VMess|SwitchAccountCommand: Insufficient length.")
|
return nil, errors.New("insufficient length.").Path("Proxy", "VMess", "Encoding", "Command")
|
||||||
}
|
}
|
||||||
if lenHost > 0 {
|
if lenHost > 0 {
|
||||||
cmd.Host = net.ParseAddress(string(data[1 : 1+lenHost]))
|
cmd.Host = net.ParseAddress(string(data[1 : 1+lenHost]))
|
||||||
}
|
}
|
||||||
portStart := 1 + lenHost
|
portStart := 1 + lenHost
|
||||||
if len(data) < portStart+2 {
|
if len(data) < portStart+2 {
|
||||||
return nil, errors.New("VMess|SwitchAccountCommand: Insufficient length.")
|
return nil, errors.New("insufficient length.").Path("Proxy", "VMess", "Encoding", "Command")
|
||||||
}
|
}
|
||||||
cmd.Port = net.PortFromBytes(data[portStart : portStart+2])
|
cmd.Port = net.PortFromBytes(data[portStart : portStart+2])
|
||||||
idStart := portStart + 2
|
idStart := portStart + 2
|
||||||
if len(data) < idStart+16 {
|
if len(data) < idStart+16 {
|
||||||
return nil, errors.New("VMess|SwitchAccountCommand: Insufficient length.")
|
return nil, errors.New("insufficient length.").Path("Proxy", "VMess", "Encoding", "Command")
|
||||||
}
|
}
|
||||||
cmd.ID, _ = uuid.ParseBytes(data[idStart : idStart+16])
|
cmd.ID, _ = uuid.ParseBytes(data[idStart : idStart+16])
|
||||||
alterIDStart := idStart + 16
|
alterIDStart := idStart + 16
|
||||||
if len(data) < alterIDStart+2 {
|
if len(data) < alterIDStart+2 {
|
||||||
return nil, errors.New("VMess|SwitchAccountCommand: Insufficient length.")
|
return nil, errors.New("insufficient length.").Path("Proxy", "VMess", "Encoding", "Command")
|
||||||
}
|
}
|
||||||
cmd.AlterIds = serial.BytesToUint16(data[alterIDStart : alterIDStart+2])
|
cmd.AlterIds = serial.BytesToUint16(data[alterIDStart : alterIDStart+2])
|
||||||
levelStart := alterIDStart + 2
|
levelStart := alterIDStart + 2
|
||||||
if len(data) < levelStart+1 {
|
if len(data) < levelStart+1 {
|
||||||
return nil, errors.New("VMess|SwitchAccountCommand: Insufficient length.")
|
return nil, errors.New("insufficient length.").Path("Proxy", "VMess", "Encoding", "Command")
|
||||||
}
|
}
|
||||||
cmd.Level = uint32(data[levelStart])
|
cmd.Level = uint32(data[levelStart])
|
||||||
timeStart := levelStart + 1
|
timeStart := levelStart + 1
|
||||||
if len(data) < timeStart {
|
if len(data) < timeStart {
|
||||||
return nil, errors.New("VMess|SwitchAccountCommand: Insufficient length.")
|
return nil, errors.New("insufficient length.").Path("Proxy", "VMess", "Encoding", "Command")
|
||||||
}
|
}
|
||||||
cmd.ValidMin = data[timeStart]
|
cmd.ValidMin = data[timeStart]
|
||||||
return cmd, nil
|
return cmd, nil
|
||||||
|
@ -82,7 +82,7 @@ type Handler struct {
|
|||||||
func New(ctx context.Context, config *Config) (*Handler, error) {
|
func New(ctx context.Context, config *Config) (*Handler, error) {
|
||||||
space := app.SpaceFromContext(ctx)
|
space := app.SpaceFromContext(ctx)
|
||||||
if space == nil {
|
if space == nil {
|
||||||
return nil, errors.New("VMess|Inbound: No space in context.")
|
return nil, errors.New("no space in context").Path("Proxy", "VMess", "Inbound")
|
||||||
}
|
}
|
||||||
|
|
||||||
allowedClients := vmess.NewTimedUserValidator(ctx, protocol.DefaultIDHash)
|
allowedClients := vmess.NewTimedUserValidator(ctx, protocol.DefaultIDHash)
|
||||||
@ -100,7 +100,7 @@ func New(ctx context.Context, config *Config) (*Handler, error) {
|
|||||||
space.OnInitialize(func() error {
|
space.OnInitialize(func() error {
|
||||||
handler.inboundHandlerManager = proxyman.InboundHandlerManagerFromSpace(space)
|
handler.inboundHandlerManager = proxyman.InboundHandlerManagerFromSpace(space)
|
||||||
if handler.inboundHandlerManager == nil {
|
if handler.inboundHandlerManager == nil {
|
||||||
return errors.New("VMess|Inbound: InboundHandlerManager is not found is space.")
|
return errors.New("InboundHandlerManager is not found is space").Path("Proxy", "VMess", "Inbound")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@ -180,12 +180,12 @@ func (v *Handler) Process(ctx context.Context, network net.Network, connection i
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Cause(err) != io.EOF {
|
if errors.Cause(err) != io.EOF {
|
||||||
log.Access(connection.RemoteAddr(), "", log.AccessRejected, err)
|
log.Access(connection.RemoteAddr(), "", log.AccessRejected, err)
|
||||||
log.Trace(errors.New("VMess|Inbound: Invalid request from ", connection.RemoteAddr(), ": ", err))
|
log.Trace(errors.New("invalid request from ", connection.RemoteAddr(), ": ", err).Path("Proxy", "VMess", "Inbound"))
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Access(connection.RemoteAddr(), request.Destination(), log.AccessAccepted, "")
|
log.Access(connection.RemoteAddr(), request.Destination(), log.AccessAccepted, "")
|
||||||
log.Trace(errors.New("VMess|Inbound: Received request for ", request.Destination()))
|
log.Trace(errors.New("received request for ", request.Destination()).Path("Proxy", "VMess", "Inbound"))
|
||||||
|
|
||||||
connection.SetReadDeadline(time.Time{})
|
connection.SetReadDeadline(time.Time{})
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ func (v *Handler) generateCommand(ctx context.Context, request *protocol.Request
|
|||||||
if v.inboundHandlerManager != nil {
|
if v.inboundHandlerManager != nil {
|
||||||
handler, err := v.inboundHandlerManager.GetHandler(ctx, tag)
|
handler, err := v.inboundHandlerManager.GetHandler(ctx, tag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Trace(errors.New("VMess|Inbound: Failed to get detour handler: ", tag, err).AtWarning())
|
log.Trace(errors.New("failed to get detour handler: ", tag, err).AtWarning().Path("Proxy", "VMess", "Inbound"))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
proxyHandler, port, availableMin := handler.GetRandomInboundProxy()
|
proxyHandler, port, availableMin := handler.GetRandomInboundProxy()
|
||||||
@ -248,7 +248,7 @@ func (v *Handler) generateCommand(ctx context.Context, request *protocol.Request
|
|||||||
availableMin = 255
|
availableMin = 255
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Trace(errors.New("VMess|Inbound: Pick detour handler for port ", port, " for ", availableMin, " minutes."))
|
log.Trace(errors.New("pick detour handler for port ", port, " for ", availableMin, " minutes.").Path("Proxy", "VMess", "Inbound").AtDebug())
|
||||||
user := inboundHandler.GetUser(request.User.Email)
|
user := inboundHandler.GetUser(request.User.Email)
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return nil
|
return nil
|
||||||
|
@ -30,7 +30,7 @@ type Handler struct {
|
|||||||
func New(ctx context.Context, config *Config) (*Handler, error) {
|
func New(ctx context.Context, config *Config) (*Handler, error) {
|
||||||
space := app.SpaceFromContext(ctx)
|
space := app.SpaceFromContext(ctx)
|
||||||
if space == nil {
|
if space == nil {
|
||||||
return nil, errors.New("VMess|Outbound: No space in context.")
|
return nil, errors.New("no space in context.").Path("Proxy", "VMess", "Outbound")
|
||||||
}
|
}
|
||||||
|
|
||||||
serverList := protocol.NewServerList()
|
serverList := protocol.NewServerList()
|
||||||
@ -61,15 +61,15 @@ func (v *Handler) Process(ctx context.Context, outboundRay ray.OutboundRay, dial
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("VMess|Outbound: Failed to find an available destination.").Base(err).AtWarning()
|
return errors.New("failed to find an available destination").Base(err).AtWarning().Path("Proxy", "VMess", "Outbound")
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
target, ok := proxy.TargetFromContext(ctx)
|
target, ok := proxy.TargetFromContext(ctx)
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("VMess|Outbound: Target not specified.")
|
return errors.New("target not specified").Path("Proxy", "VMess", "Outbound").AtError()
|
||||||
}
|
}
|
||||||
log.Trace(errors.New("VMess|Outbound: Tunneling request to ", target, " via ", rec.Destination()))
|
log.Trace(errors.New("tunneling request to ", target, " via ", rec.Destination()).Path("Proxy", "VMess", "Outbound"))
|
||||||
|
|
||||||
command := protocol.RequestCommandTCP
|
command := protocol.RequestCommandTCP
|
||||||
if target.Network == net.Network_UDP {
|
if target.Network == net.Network_UDP {
|
||||||
@ -86,7 +86,7 @@ func (v *Handler) Process(ctx context.Context, outboundRay ray.OutboundRay, dial
|
|||||||
|
|
||||||
rawAccount, err := request.User.GetTypedAccount()
|
rawAccount, err := request.User.GetTypedAccount()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("VMess|Outbound: Failed to get user account.").Base(err).AtWarning()
|
return errors.New("failed to get user account").Base(err).AtWarning().Path("Proxy", "VMess", "Outbound")
|
||||||
}
|
}
|
||||||
account := rawAccount.(*vmess.InternalAccount)
|
account := rawAccount.(*vmess.InternalAccount)
|
||||||
request.Security = account.Security
|
request.Security = account.Security
|
||||||
@ -109,11 +109,11 @@ func (v *Handler) Process(ctx context.Context, outboundRay ray.OutboundRay, dial
|
|||||||
bodyWriter := session.EncodeRequestBody(request, writer)
|
bodyWriter := session.EncodeRequestBody(request, writer)
|
||||||
firstPayload, err := input.ReadTimeout(time.Millisecond * 500)
|
firstPayload, err := input.ReadTimeout(time.Millisecond * 500)
|
||||||
if err != nil && err != buf.ErrReadTimeout {
|
if err != nil && err != buf.ErrReadTimeout {
|
||||||
return errors.New("failed to get first payload").Base(err).Path("VMess", "Outbound")
|
return errors.New("failed to get first payload").Base(err).Path("Proxy", "VMess", "Outbound")
|
||||||
}
|
}
|
||||||
if !firstPayload.IsEmpty() {
|
if !firstPayload.IsEmpty() {
|
||||||
if err := bodyWriter.Write(firstPayload); err != nil {
|
if err := bodyWriter.Write(firstPayload); err != nil {
|
||||||
return errors.New("failed to write first payload").Base(err).Path("VMess", "Outbound")
|
return errors.New("failed to write first payload").Base(err).Path("Proxy", "VMess", "Outbound")
|
||||||
}
|
}
|
||||||
firstPayload.Release()
|
firstPayload.Release()
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ func (v *Handler) Process(ctx context.Context, outboundRay ray.OutboundRay, dial
|
|||||||
})
|
})
|
||||||
|
|
||||||
if err := signal.ErrorOrFinish2(ctx, requestDone, responseDone); err != nil {
|
if err := signal.ErrorOrFinish2(ctx, requestDone, responseDone); err != nil {
|
||||||
return errors.New("connection ends").Base(err).Path("VMess", "Outbound")
|
return errors.New("connection ends").Base(err).Path("Proxy", "VMess", "Outbound")
|
||||||
}
|
}
|
||||||
runtime.KeepAlive(timer)
|
runtime.KeepAlive(timer)
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ var (
|
|||||||
|
|
||||||
func RegisterTransportDialer(protocol TransportProtocol, dialer Dialer) error {
|
func RegisterTransportDialer(protocol TransportProtocol, dialer Dialer) error {
|
||||||
if _, found := transportDialerCache[protocol]; found {
|
if _, found := transportDialerCache[protocol]; found {
|
||||||
return errors.New("Internet|Dialer: ", protocol, " dialer already registered.")
|
return errors.New(protocol, " dialer already registered").AtError().Path("Transport", "Internet")
|
||||||
}
|
}
|
||||||
transportDialerCache[protocol] = dialer
|
transportDialerCache[protocol] = dialer
|
||||||
return nil
|
return nil
|
||||||
@ -40,14 +40,14 @@ func Dial(ctx context.Context, dest v2net.Destination) (Connection, error) {
|
|||||||
}
|
}
|
||||||
dialer := transportDialerCache[protocol]
|
dialer := transportDialerCache[protocol]
|
||||||
if dialer == nil {
|
if dialer == nil {
|
||||||
return nil, errors.New("Internet|Dialer: ", protocol, " dialer not registered.")
|
return nil, errors.New(protocol, " dialer not registered").AtError().Path("Transport", "Internet")
|
||||||
}
|
}
|
||||||
return dialer(ctx, dest)
|
return dialer(ctx, dest)
|
||||||
}
|
}
|
||||||
|
|
||||||
udpDialer := transportDialerCache[TransportProtocol_UDP]
|
udpDialer := transportDialerCache[TransportProtocol_UDP]
|
||||||
if udpDialer == nil {
|
if udpDialer == nil {
|
||||||
return nil, errors.New("Internet|Dialer: UDP dialer not registered.")
|
return nil, errors.New("UDP dialer not registered").AtError().Path("Transport", "Internet")
|
||||||
}
|
}
|
||||||
return udpDialer(ctx, dest)
|
return udpDialer(ctx, dest)
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ type Connection struct {
|
|||||||
|
|
||||||
// NewConnection create a new KCP connection between local and remote.
|
// NewConnection create a new KCP connection between local and remote.
|
||||||
func NewConnection(conv uint16, sysConn SystemConnection, config *Config) *Connection {
|
func NewConnection(conv uint16, sysConn SystemConnection, config *Config) *Connection {
|
||||||
log.Trace(errors.New("KCP|Connection: creating connection ", conv))
|
log.Trace(errors.New("creating connection ", conv).Path("Transport", "Internet", "mKCP", "Connection"))
|
||||||
|
|
||||||
conn := &Connection{
|
conn := &Connection{
|
||||||
conv: conv,
|
conv: conv,
|
||||||
@ -335,7 +335,7 @@ func (v *Connection) SetState(state State) {
|
|||||||
current := v.Elapsed()
|
current := v.Elapsed()
|
||||||
atomic.StoreInt32((*int32)(&v.state), int32(state))
|
atomic.StoreInt32((*int32)(&v.state), int32(state))
|
||||||
atomic.StoreUint32(&v.stateBeginTime, current)
|
atomic.StoreUint32(&v.stateBeginTime, current)
|
||||||
log.Trace(errors.New("KCP|Connection: #", v.conv, " entering state ", state, " at ", current).AtDebug())
|
log.Trace(errors.New("#", v.conv, " entering state ", state, " at ", current).AtDebug().Path("Transport", "Internet", "mKCP", "Connection"))
|
||||||
|
|
||||||
switch state {
|
switch state {
|
||||||
case StateReadyToClose:
|
case StateReadyToClose:
|
||||||
@ -372,7 +372,7 @@ func (v *Connection) Close() error {
|
|||||||
if state.Is(StateReadyToClose, StateTerminating, StateTerminated) {
|
if state.Is(StateReadyToClose, StateTerminating, StateTerminated) {
|
||||||
return ErrClosedConnection
|
return ErrClosedConnection
|
||||||
}
|
}
|
||||||
log.Trace(errors.New("KCP|Connection: Closing connection to ", v.conn.RemoteAddr()))
|
log.Trace(errors.New("closing connection to ", v.conn.RemoteAddr()).Path("Transport", "Internet", "mKCP", "Connection"))
|
||||||
|
|
||||||
if state == StateActive {
|
if state == StateActive {
|
||||||
v.SetState(StateReadyToClose)
|
v.SetState(StateReadyToClose)
|
||||||
@ -441,7 +441,7 @@ func (v *Connection) Terminate() {
|
|||||||
if v == nil {
|
if v == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Trace(errors.New("KCP|Connection: Terminating connection to ", v.RemoteAddr()))
|
log.Trace(errors.New("terminating connection to ", v.RemoteAddr()).Path("Transport", "Internet", "mKCP", "Connection"))
|
||||||
|
|
||||||
//v.SetState(StateTerminated)
|
//v.SetState(StateTerminated)
|
||||||
v.OnDataInput()
|
v.OnDataInput()
|
||||||
@ -531,7 +531,7 @@ func (v *Connection) flush() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if v.State() == StateTerminating {
|
if v.State() == StateTerminating {
|
||||||
log.Trace(errors.New("KCP|Connection: #", v.conv, " sending terminating cmd.").AtDebug())
|
log.Trace(errors.New("#", v.conv, " sending terminating cmd.").AtDebug().Path("Transport", "Internet", "mKCP", "Connection"))
|
||||||
v.Ping(current, CommandTerminate)
|
v.Ping(current, CommandTerminate)
|
||||||
|
|
||||||
if current-atomic.LoadUint32(&v.stateBeginTime) > 8000 {
|
if current-atomic.LoadUint32(&v.stateBeginTime) > 8000 {
|
||||||
|
Loading…
Reference in New Issue
Block a user