mirror of https://github.com/v2ray/v2ray-core
				
				
				
			update error messages
							parent
							
								
									67956b9120
								
							
						
					
					
						commit
						b4cd497abf
					
				|  | @ -238,7 +238,7 @@ func (w *udpWorker) callback(b *buf.Buffer, source v2net.Destination, originalDe | |||
| 			ctx = proxy.ContextWithSource(ctx, source) | ||||
| 			ctx = proxy.ContextWithInboundEntryPoint(ctx, v2net.UDPDestination(w.address, w.port)) | ||||
| 			if err := w.proxy.Process(ctx, v2net.Network_UDP, conn, w.dispatcher); err != nil { | ||||
| 				log.Trace(errors.New("connection ends").Base(err).Path("Proxymann|UDPWorker")) | ||||
| 				log.Trace(errors.New("connection ends").Base(err).Path("App", "Proxymann", "Inbound", "UDPWorker")) | ||||
| 			} | ||||
| 			w.removeConn(source) | ||||
| 			cancel() | ||||
|  |  | |||
|  | @ -30,7 +30,7 @@ func (r *Reader) ReadMetadata() (*FrameMetadata, error) { | |||
| 	} | ||||
| 	metaLen := serial.BytesToUint16(b.Bytes()) | ||||
| 	if metaLen > 512 { | ||||
| 		return nil, errors.New("Proxyman|Mux|Reader: Invalid metalen ", metaLen) | ||||
| 		return nil, errors.New("invalid metalen ", metaLen).Path("App", "Proxyman", "Mux", "Reader") | ||||
| 	} | ||||
| 	b.Clear() | ||||
| 	if err := b.AppendSupplier(buf.ReadFullFrom(r.reader, int(metaLen))); err != nil { | ||||
|  |  | |||
|  | @ -32,12 +32,12 @@ func NewHandler(ctx context.Context, config *proxyman.OutboundHandlerConfig) (*H | |||
| 	} | ||||
| 	space := app.SpaceFromContext(ctx) | ||||
| 	if space == nil { | ||||
| 		return nil, errors.New("Proxyman|OutboundHandler: No space in context.") | ||||
| 		return nil, errors.New("no space in context").Path("App", "Proxyman", "Outbound", "Handler") | ||||
| 	} | ||||
| 	space.OnInitialize(func() error { | ||||
| 		ohm := proxyman.OutboundHandlerManagerFromSpace(space) | ||||
| 		if ohm == nil { | ||||
| 			return errors.New("Proxyman|OutboundHandler: No OutboundManager in space.") | ||||
| 			return errors.New("no OutboundManager in space").Path("App", "Proxyman", "Outbound", "Handler") | ||||
| 		} | ||||
| 		h.outboundManager = ohm | ||||
| 		return nil | ||||
|  | @ -52,7 +52,7 @@ func NewHandler(ctx context.Context, config *proxyman.OutboundHandlerConfig) (*H | |||
| 		case *proxyman.SenderConfig: | ||||
| 			h.senderSettings = s | ||||
| 		default: | ||||
| 			return nil, errors.New("Proxyman|DefaultOutboundHandler: settings is not SenderConfig.") | ||||
| 			return nil, errors.New("settings is not SenderConfig").Path("App", "Proxyman", "Outbound", "Handler") | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|  | @ -73,13 +73,13 @@ func (h *Handler) Dispatch(ctx context.Context, outboundRay ray.OutboundRay) { | |||
| 	if h.mux != nil { | ||||
| 		err := h.mux.Dispatch(ctx, outboundRay) | ||||
| 		if err != nil { | ||||
| 			log.Trace(errors.New("failed to process outbound traffic").Base(err).Path("Proxyman", "OutboundHandler")) | ||||
| 			log.Trace(errors.New("failed to process outbound traffic").Base(err).Path("App", "Proxyman", "Outbound", "Handler")) | ||||
| 		} | ||||
| 	} else { | ||||
| 		err := h.proxy.Process(ctx, outboundRay, h) | ||||
| 		// Ensure outbound ray is properly closed.
 | ||||
| 		if err != nil && errors.Cause(err) != io.EOF { | ||||
| 			log.Trace(errors.New("failed to process outbound traffic").Base(err).Path("Proxyman", "OutboundHandler")) | ||||
| 			log.Trace(errors.New("failed to process outbound traffic").Base(err).Path("App", "Proxyman", "Outbound", "Handler")) | ||||
| 			outboundRay.OutboundOutput().CloseError() | ||||
| 		} else { | ||||
| 			outboundRay.OutboundOutput().Close() | ||||
|  | @ -95,14 +95,14 @@ func (h *Handler) Dial(ctx context.Context, dest v2net.Destination) (internet.Co | |||
| 			tag := h.senderSettings.ProxySettings.Tag | ||||
| 			handler := h.outboundManager.GetHandler(tag) | ||||
| 			if handler != nil { | ||||
| 				log.Trace(errors.New("proxying to ", tag).AtDebug().Path("App", "Proxyman", "OutboundHandler")) | ||||
| 				log.Trace(errors.New("proxying to ", tag).AtDebug().Path("App", "Proxyman", "Outbound", "Handler")) | ||||
| 				ctx = proxy.ContextWithTarget(ctx, dest) | ||||
| 				stream := ray.NewRay(ctx) | ||||
| 				go handler.Dispatch(ctx, stream) | ||||
| 				return NewConnection(stream), nil | ||||
| 			} | ||||
| 
 | ||||
| 			log.Trace(errors.New("Proxyman|OutboundHandler: Failed to get outbound handler with tag: ", tag).AtWarning()) | ||||
| 			log.Trace(errors.New("failed to get outbound handler with tag: ", tag).AtWarning().Path("App", "Proxyman", "Outbound", "Handler")) | ||||
| 		} | ||||
| 
 | ||||
| 		if h.senderSettings.Via != nil { | ||||
|  |  | |||
|  | @ -97,7 +97,7 @@ func (v *ChunkReader) Read() (*buf.Buffer, error) { | |||
| 	v.auth.Authenticate(payload)(actualAuthBytes) | ||||
| 	if !bytes.Equal(authBytes, actualAuthBytes) { | ||||
| 		buffer.Release() | ||||
| 		return nil, errors.New("Shadowsocks|AuthenticationReader: Invalid auth.") | ||||
| 		return nil, errors.New("invalid auth").Path("Proxy", "Shadowsocks", "ChunkReader") | ||||
| 	} | ||||
| 	buffer.SliceFrom(AuthSize) | ||||
| 
 | ||||
|  |  | |||
|  | @ -36,7 +36,7 @@ func NewClient(ctx context.Context, config *ClientConfig) (*Client, error) { | |||
| func (c *Client) Process(ctx context.Context, ray ray.OutboundRay, dialer proxy.Dialer) error { | ||||
| 	destination, ok := proxy.TargetFromContext(ctx) | ||||
| 	if !ok { | ||||
| 		return errors.New("Socks|Client: Target not specified.") | ||||
| 		return errors.New("target not specified.").Path("Proxy", "Socks", "Client") | ||||
| 	} | ||||
| 
 | ||||
| 	var server *protocol.ServerSpec | ||||
|  | @ -55,7 +55,7 @@ func (c *Client) Process(ctx context.Context, ray ray.OutboundRay, dialer proxy. | |||
| 	}) | ||||
| 
 | ||||
| 	if err != nil { | ||||
| 		return errors.New("failed to find an available destination").Base(err).Path("Socks", "Client") | ||||
| 		return errors.New("failed to find an available destination").Base(err).Path("Proxy", "Socks", "Client") | ||||
| 	} | ||||
| 
 | ||||
| 	defer conn.Close() | ||||
|  | @ -78,7 +78,7 @@ func (c *Client) Process(ctx context.Context, ray ray.OutboundRay, dialer proxy. | |||
| 
 | ||||
| 	udpRequest, err := ClientHandshake(request, conn, conn) | ||||
| 	if err != nil { | ||||
| 		return errors.New("failed to establish connection to server").AtWarning().Base(err).Path("Socks", "Client") | ||||
| 		return errors.New("failed to establish connection to server").AtWarning().Base(err).Path("Proxy", "Socks", "Client") | ||||
| 	} | ||||
| 
 | ||||
| 	ctx, timer := signal.CancelAfterInactivity(ctx, time.Minute*2) | ||||
|  | @ -96,7 +96,7 @@ func (c *Client) Process(ctx context.Context, ray ray.OutboundRay, dialer proxy. | |||
| 	} else if request.Command == protocol.RequestCommandUDP { | ||||
| 		udpConn, err := dialer.Dial(ctx, udpRequest.Destination()) | ||||
| 		if err != nil { | ||||
| 			return errors.New("failed to create UDP connection").Base(err).Path("Socks", "Client") | ||||
| 			return errors.New("failed to create UDP connection").Base(err).Path("Proxy", "Socks", "Client") | ||||
| 		} | ||||
| 		defer udpConn.Close() | ||||
| 		requestFunc = func() error { | ||||
|  | @ -112,7 +112,7 @@ func (c *Client) Process(ctx context.Context, ray ray.OutboundRay, dialer proxy. | |||
| 	requestDone := signal.ExecuteAsync(requestFunc) | ||||
| 	responseDone := signal.ExecuteAsync(responseFunc) | ||||
| 	if err := signal.ErrorOrFinish2(ctx, requestDone, responseDone); err != nil { | ||||
| 		return errors.New("connection ends").Base(err).Path("Socks", "Client") | ||||
| 		return errors.New("connection ends").Base(err).Path("Proxy", "Socks", "Client") | ||||
| 	} | ||||
| 
 | ||||
| 	runtime.KeepAlive(timer) | ||||
|  |  | |||
|  | @ -29,7 +29,7 @@ type Server struct { | |||
| func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) { | ||||
| 	space := app.SpaceFromContext(ctx) | ||||
| 	if space == nil { | ||||
| 		return nil, errors.New("Socks|Server: No space in context.").AtWarning() | ||||
| 		return nil, errors.New("no space in context").AtWarning().Path("Proxy", "Socks", "Server") | ||||
| 	} | ||||
| 	s := &Server{ | ||||
| 		config: config, | ||||
|  | @ -56,7 +56,7 @@ func (s *Server) Process(ctx context.Context, network net.Network, conn internet | |||
| 	case net.Network_UDP: | ||||
| 		return s.handleUDPPayload(ctx, conn, dispatcher) | ||||
| 	default: | ||||
| 		return errors.New("Socks|Server: Unknown network: ", network) | ||||
| 		return errors.New("unknown network: ", network).Path("Proxy", "Socks", "Server") | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  | @ -66,7 +66,7 @@ func (s *Server) processTCP(ctx context.Context, conn internet.Connection, dispa | |||
| 
 | ||||
| 	inboundDest, ok := proxy.InboundEntryPointFromContext(ctx) | ||||
| 	if !ok { | ||||
| 		return errors.New("Socks|Server: inbound entry point not specified.") | ||||
| 		return errors.New("inbound entry point not specified").Path("Proxy", "Socks", "Server") | ||||
| 	} | ||||
| 	session := &ServerSession{ | ||||
| 		config: s.config, | ||||
|  | @ -78,14 +78,14 @@ func (s *Server) processTCP(ctx context.Context, conn internet.Connection, dispa | |||
| 		if source, ok := proxy.SourceFromContext(ctx); ok { | ||||
| 			log.Access(source, "", log.AccessRejected, err) | ||||
| 		} | ||||
| 		log.Trace(errors.New("Socks|Server: Failed to read request: ", err)) | ||||
| 		log.Trace(errors.New("failed to read request").Base(err).Path("Proxy", "Socks", "Server")) | ||||
| 		return err | ||||
| 	} | ||||
| 	conn.SetReadDeadline(time.Time{}) | ||||
| 
 | ||||
| 	if request.Command == protocol.RequestCommandTCP { | ||||
| 		dest := request.Destination() | ||||
| 		log.Trace(errors.New("Socks|Server: TCP Connect request to ", dest)) | ||||
| 		log.Trace(errors.New("TCP Connect request to ", dest).Path("Proxy", "Socks", "Server")) | ||||
| 		if source, ok := proxy.SourceFromContext(ctx); ok { | ||||
| 			log.Access(source, dest, log.AccessAccepted, "") | ||||
| 		} | ||||
|  | @ -129,7 +129,7 @@ func (v *Server) transport(ctx context.Context, reader io.Reader, writer io.Writ | |||
| 
 | ||||
| 		v2reader := buf.NewReader(reader) | ||||
| 		if err := buf.PipeUntilEOF(timer, v2reader, input); err != nil { | ||||
| 			return errors.New("failed to transport all TCP request").Base(err).Path("Socks", "Server") | ||||
| 			return errors.New("failed to transport all TCP request").Base(err).Path("Proxy", "Socks", "Server") | ||||
| 		} | ||||
| 		return nil | ||||
| 	}) | ||||
|  | @ -137,7 +137,7 @@ func (v *Server) transport(ctx context.Context, reader io.Reader, writer io.Writ | |||
| 	responseDone := signal.ExecuteAsync(func() error { | ||||
| 		v2writer := buf.NewWriter(writer) | ||||
| 		if err := buf.PipeUntilEOF(timer, output, v2writer); err != nil { | ||||
| 			return errors.New("failed to transport all TCP response").Base(err).Path("Socks", "Server") | ||||
| 			return errors.New("failed to transport all TCP response").Base(err).Path("Proxy", "Socks", "Server") | ||||
| 		} | ||||
| 		return nil | ||||
| 	}) | ||||
|  | @ -145,7 +145,7 @@ func (v *Server) transport(ctx context.Context, reader io.Reader, writer io.Writ | |||
| 	if err := signal.ErrorOrFinish2(ctx, requestDone, responseDone); err != nil { | ||||
| 		input.CloseError() | ||||
| 		output.CloseError() | ||||
| 		return errors.New("connection ends").Base(err).Path("Socks", "Server") | ||||
| 		return errors.New("connection ends").Base(err).Path("Proxy", "Socks", "Server") | ||||
| 	} | ||||
| 
 | ||||
| 	runtime.KeepAlive(timer) | ||||
|  | @ -157,7 +157,7 @@ func (v *Server) handleUDPPayload(ctx context.Context, conn internet.Connection, | |||
| 	udpServer := udp.NewDispatcher(dispatcher) | ||||
| 
 | ||||
| 	if source, ok := proxy.SourceFromContext(ctx); ok { | ||||
| 		log.Trace(errors.New("client UDP connection from ", source).Path("Socks", "Server")) | ||||
| 		log.Trace(errors.New("client UDP connection from ", source).Path("Proxy", "Socks", "Server")) | ||||
| 	} | ||||
| 
 | ||||
| 	reader := buf.NewReader(conn) | ||||
|  | @ -169,7 +169,7 @@ func (v *Server) handleUDPPayload(ctx context.Context, conn internet.Connection, | |||
| 		request, data, err := DecodeUDPPacket(payload.Bytes()) | ||||
| 
 | ||||
| 		if err != nil { | ||||
| 			log.Trace(errors.New("Socks|Server: Failed to parse UDP request: ", err)) | ||||
| 			log.Trace(errors.New("failed to parse UDP request").Base(err).Path("Proxy", "Socks", "Server")) | ||||
| 			continue | ||||
| 		} | ||||
| 
 | ||||
|  | @ -177,7 +177,7 @@ func (v *Server) handleUDPPayload(ctx context.Context, conn internet.Connection, | |||
| 			continue | ||||
| 		} | ||||
| 
 | ||||
| 		log.Trace(errors.New("Socks: Send packet to ", request.Destination(), " with ", len(data), " bytes")) | ||||
| 		log.Trace(errors.New("send packet to ", request.Destination(), " with ", len(data), " bytes").Path("Proxy", "Socks", "Server").AtDebug()) | ||||
| 		if source, ok := proxy.SourceFromContext(ctx); ok { | ||||
| 			log.Access(source, request.Destination, log.AccessAccepted, "") | ||||
| 		} | ||||
|  | @ -187,7 +187,7 @@ func (v *Server) handleUDPPayload(ctx context.Context, conn internet.Connection, | |||
| 		udpServer.Dispatch(ctx, request.Destination(), dataBuf, func(payload *buf.Buffer) { | ||||
| 			defer payload.Release() | ||||
| 
 | ||||
| 			log.Trace(errors.New("Socks|Server: Writing back UDP response with ", payload.Len(), " bytes")) | ||||
| 			log.Trace(errors.New("writing back UDP response with ", payload.Len(), " bytes").Path("Proxy", "Socks", "Server").AtDebug()) | ||||
| 
 | ||||
| 			udpMessage := EncodeUDPPacket(request, payload.Bytes()) | ||||
| 			defer udpMessage.Release() | ||||
|  |  | |||
|  | @ -2,9 +2,9 @@ package encoding | |||
| 
 | ||||
| import ( | ||||
| 	"crypto/md5" | ||||
| 	"errors" | ||||
| 	"hash/fnv" | ||||
| 
 | ||||
| 	"v2ray.com/core/common/errors" | ||||
| 	"v2ray.com/core/common/serial" | ||||
| ) | ||||
| 
 | ||||
|  | @ -58,7 +58,7 @@ func (v *FnvAuthenticator) Seal(dst, nonce, plaintext, additionalData []byte) [] | |||
| // Open implements AEAD.Open().
 | ||||
| func (v *FnvAuthenticator) Open(dst, nonce, ciphertext, additionalData []byte) ([]byte, error) { | ||||
| 	if serial.BytesToUint32(ciphertext[:4]) != Authenticate(ciphertext[4:]) { | ||||
| 		return dst, errors.New("VMess|FNV: Invalid authentication.") | ||||
| 		return dst, errors.New("invalid authentication").Path("Proxy", "VMess", "Encoding", "FnvAuthenticator") | ||||
| 	} | ||||
| 	return append(dst, ciphertext[4:]...), nil | ||||
| } | ||||
|  |  | |||
|  | @ -63,7 +63,7 @@ func (v *ClientSession) EncodeRequestHeader(header *protocol.RequestHeader, writ | |||
| 	timestamp := protocol.NewTimestampGenerator(protocol.NowTime(), 30)() | ||||
| 	account, err := header.User.GetTypedAccount() | ||||
| 	if err != nil { | ||||
| 		log.Trace(errors.New("VMess: Failed to get user account: ", err).AtError()) | ||||
| 		log.Trace(errors.New("failed to get user account: ", err).AtError().Path("Proxy", "VMess", "Encoding", "ClientSession")) | ||||
| 		return | ||||
| 	} | ||||
| 	idHash := v.idHash(account.(*vmess.InternalAccount).AnyValidID().Bytes()) | ||||
|  | @ -186,12 +186,12 @@ func (v *ClientSession) DecodeResponseHeader(reader io.Reader) (*protocol.Respon | |||
| 
 | ||||
| 	_, err := io.ReadFull(v.responseReader, buffer[:4]) | ||||
| 	if err != nil { | ||||
| 		log.Trace(errors.New("VMess|Client: Failed to read response header: ", err)) | ||||
| 		log.Trace(errors.New("failed to read response header").Base(err).Path("Proxy", "VMess", "Encoding", "ClientSession")) | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	if buffer[0] != v.responseHeader { | ||||
| 		return nil, errors.Format("VMess|Client: Unexpected response header. Expecting %d but actually %d", v.responseHeader, buffer[0]) | ||||
| 		return nil, errors.Format("unexpected response header. Expecting %d but actually %d", v.responseHeader, buffer[0]).Path("Proxy", "VMess", "Encoding", "ClientSession") | ||||
| 	} | ||||
| 
 | ||||
| 	header := &protocol.ResponseHeader{ | ||||
|  | @ -203,7 +203,7 @@ func (v *ClientSession) DecodeResponseHeader(reader io.Reader) (*protocol.Respon | |||
| 		dataLen := int(buffer[3]) | ||||
| 		_, err := io.ReadFull(v.responseReader, buffer[:dataLen]) | ||||
| 		if err != nil { | ||||
| 			log.Trace(errors.New("VMess|Client: Failed to read response command: ", err)) | ||||
| 			log.Trace(errors.New("failed to read response command").Base(err).Path("Proxy", "VMess", "Encoding", "ClientSession")) | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		data := buffer[:dataLen] | ||||
|  |  | |||
|  | @ -53,12 +53,12 @@ func MarshalCommand(command interface{}, writer io.Writer) error { | |||
| 
 | ||||
| func UnmarshalCommand(cmdID byte, data []byte) (protocol.ResponseCommand, error) { | ||||
| 	if len(data) <= 4 { | ||||
| 		return nil, errors.New("VMess|Command: Insufficient length.") | ||||
| 		return nil, errors.New("insufficient length").Path("Proxy", "VMess", "Encoding", "Command") | ||||
| 	} | ||||
| 	expectedAuth := Authenticate(data[4:]) | ||||
| 	actualAuth := serial.BytesToUint32(data[:4]) | ||||
| 	if expectedAuth != actualAuth { | ||||
| 		return nil, errors.New("VMess|Command: Invalid auth.") | ||||
| 		return nil, errors.New("invalid auth").Path("Proxy", "VMess", "Encoding", "Command") | ||||
| 	} | ||||
| 
 | ||||
| 	var factory CommandFactory | ||||
|  |  | |||
|  | @ -123,12 +123,12 @@ func (v *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request | |||
| 
 | ||||
| 	_, err := io.ReadFull(reader, buffer[:protocol.IDBytesLen]) | ||||
| 	if err != nil { | ||||
| 		return nil, errors.New("failed to read request header").Base(err).Path("VMess", "Server") | ||||
| 		return nil, errors.New("failed to read request header").Base(err).Path("Proxy", "VMess", "Encoding", "ServerSession") | ||||
| 	} | ||||
| 
 | ||||
| 	user, timestamp, valid := v.userValidator.Get(buffer[:protocol.IDBytesLen]) | ||||
| 	if !valid { | ||||
| 		return nil, errors.New("VMess|Server: Invalid user.") | ||||
| 		return nil, errors.New("invalid user").Path("Proxy", "VMess", "Encoding", "ServerSession") | ||||
| 	} | ||||
| 
 | ||||
| 	timestampHash := md5.New() | ||||
|  | @ -136,7 +136,7 @@ func (v *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request | |||
| 	iv := timestampHash.Sum(nil) | ||||
| 	account, err := user.GetTypedAccount() | ||||
| 	if err != nil { | ||||
| 		return nil, errors.New("failed to get user account").Base(err).Path("VMess", "Server") | ||||
| 		return nil, errors.New("failed to get user account").Base(err).Path("Proxy", "VMess", "Encoding", "ServerSession") | ||||
| 	} | ||||
| 	vmessAccount := account.(*vmess.InternalAccount) | ||||
| 
 | ||||
|  | @ -145,7 +145,7 @@ func (v *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request | |||
| 
 | ||||
| 	nBytes, err := io.ReadFull(decryptor, buffer[:41]) | ||||
| 	if err != nil { | ||||
| 		return nil, errors.New("failed to read request header").Base(err).Path("VMess", "Server") | ||||
| 		return nil, errors.New("failed to read request header").Base(err).Path("Proxy", "VMess", "Encoding", "ServerSession") | ||||
| 	} | ||||
| 	bufferLen := nBytes | ||||
| 
 | ||||
|  | @ -155,7 +155,7 @@ func (v *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request | |||
| 	} | ||||
| 
 | ||||
| 	if request.Version != Version { | ||||
| 		return nil, errors.New("invalid protocol version ", request.Version).Path("VMess", "Server") | ||||
| 		return nil, errors.New("invalid protocol version ", request.Version).Path("Proxy", "VMess", "Encoding", "ServerSession") | ||||
| 	} | ||||
| 
 | ||||
| 	v.requestBodyIV = append([]byte(nil), buffer[1:17]...)   // 16 bytes
 | ||||
|  | @ -165,7 +165,7 @@ func (v *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request | |||
| 	copy(sid.key[:], v.requestBodyKey) | ||||
| 	copy(sid.nonce[:], v.requestBodyIV) | ||||
| 	if v.sessionHistory.has(sid) { | ||||
| 		return nil, errors.New("duplicated session id, possibly under replay attack").Path("VMess", "Server") | ||||
| 		return nil, errors.New("duplicated session id, possibly under replay attack").Path("Proxy", "VMess", "Encoding", "ServerSession") | ||||
| 	} | ||||
| 	v.sessionHistory.add(sid) | ||||
| 
 | ||||
|  | @ -183,28 +183,28 @@ func (v *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request | |||
| 		_, err = io.ReadFull(decryptor, buffer[41:45]) // 4 bytes
 | ||||
| 		bufferLen += 4 | ||||
| 		if err != nil { | ||||
| 			return nil, errors.New("failed to read IPv4 address").Base(err).Path("VMess", "Server") | ||||
| 			return nil, errors.New("failed to read IPv4 address").Base(err).Path("Proxy", "VMess", "Encoding", "ServerSession") | ||||
| 		} | ||||
| 		request.Address = net.IPAddress(buffer[41:45]) | ||||
| 	case AddrTypeIPv6: | ||||
| 		_, err = io.ReadFull(decryptor, buffer[41:57]) // 16 bytes
 | ||||
| 		bufferLen += 16 | ||||
| 		if err != nil { | ||||
| 			return nil, errors.New("failed to read IPv6 address").Base(err).Path("VMess", "Server") | ||||
| 			return nil, errors.New("failed to read IPv6 address").Base(err).Path("Proxy", "VMess", "Encoding", "ServerSession") | ||||
| 		} | ||||
| 		request.Address = net.IPAddress(buffer[41:57]) | ||||
| 	case AddrTypeDomain: | ||||
| 		_, err = io.ReadFull(decryptor, buffer[41:42]) | ||||
| 		if err != nil { | ||||
| 			return nil, errors.New("failed to read domain address").Base(err).Path("VMess", "Server") | ||||
| 			return nil, errors.New("failed to read domain address").Base(err).Path("Proxy", "VMess", "Encoding", "ServerSession") | ||||
| 		} | ||||
| 		domainLength := int(buffer[41]) | ||||
| 		if domainLength == 0 { | ||||
| 			return nil, errors.New("zero length domain").Base(err).Path("VMess", "Server") | ||||
| 			return nil, errors.New("zero length domain").Base(err).Path("Proxy", "VMess", "Encoding", "ServerSession") | ||||
| 		} | ||||
| 		_, err = io.ReadFull(decryptor, buffer[42:42+domainLength]) | ||||
| 		if err != nil { | ||||
| 			return nil, errors.New("failed to read domain address").Base(err).Path("VMess", "Server") | ||||
| 			return nil, errors.New("failed to read domain address").Base(err).Path("Proxy", "VMess", "Encoding", "ServerSession") | ||||
| 		} | ||||
| 		bufferLen += 1 + domainLength | ||||
| 		request.Address = net.DomainAddress(string(buffer[42 : 42+domainLength])) | ||||
|  | @ -213,14 +213,14 @@ func (v *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request | |||
| 	if padingLen > 0 { | ||||
| 		_, err = io.ReadFull(decryptor, buffer[bufferLen:bufferLen+padingLen]) | ||||
| 		if err != nil { | ||||
| 			return nil, errors.New("failed to read padding").Base(err).Path("VMess", "Server") | ||||
| 			return nil, errors.New("failed to read padding").Base(err).Path("Proxy", "VMess", "Encoding", "ServerSession") | ||||
| 		} | ||||
| 		bufferLen += padingLen | ||||
| 	} | ||||
| 
 | ||||
| 	_, err = io.ReadFull(decryptor, buffer[bufferLen:bufferLen+4]) | ||||
| 	if err != nil { | ||||
| 		return nil, errors.New("failed to read checksum").Base(err).Path("VMess", "Server") | ||||
| 		return nil, errors.New("failed to read checksum").Base(err).Path("Proxy", "VMess", "Encoding", "ServerSession") | ||||
| 	} | ||||
| 
 | ||||
| 	fnv1a := fnv.New32a() | ||||
|  | @ -229,11 +229,11 @@ func (v *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request | |||
| 	expectedHash := serial.BytesToUint32(buffer[bufferLen : bufferLen+4]) | ||||
| 
 | ||||
| 	if actualHash != expectedHash { | ||||
| 		return nil, errors.New("VMess|Server: Invalid auth.") | ||||
| 		return nil, errors.New("invalid auth").Path("Proxy", "VMess", "Encoding", "ServerSession") | ||||
| 	} | ||||
| 
 | ||||
| 	if request.Address == nil { | ||||
| 		return nil, errors.New("VMess|Server: Invalid remote address.") | ||||
| 		return nil, errors.New("invalid remote address").Path("Proxy", "VMess", "Encoding", "ServerSession") | ||||
| 	} | ||||
| 
 | ||||
| 	return request, nil | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Darien Raymond
						Darien Raymond