• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang log.Error函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/v2ray/v2ray-core/log.Error函数的典型用法代码示例。如果您正苦于以下问题:Golang Error函数的具体用法?Golang Error怎么用?Golang Error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Error函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: startCommunicate

func (handler *VMessOutboundHandler) startCommunicate(request *vmessio.VMessRequest, dest v2net.Address, ray core.OutboundRay) error {
	conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{dest.IP, int(dest.Port), ""})
	log.Debug("VMessOutbound dialing tcp: %s", dest.String())
	if err != nil {
		log.Error("Failed to open tcp (%s): %v", dest.String(), err)
		return err
	}
	defer conn.Close()

	input := ray.OutboundInput()
	output := ray.OutboundOutput()

	requestWriter := vmessio.NewVMessRequestWriter()
	err = requestWriter.Write(conn, request)
	if err != nil {
		log.Error("Failed to write VMess request: %v", err)
		close(output)
		return err
	}

	requestKey := request.RequestKey[:]
	requestIV := request.RequestIV[:]
	responseKey := md5.Sum(requestKey)
	responseIV := md5.Sum(requestIV)

	response := vmessio.VMessResponse{}
	nBytes, err := conn.Read(response[:])
	if err != nil {
		close(output)
		log.Error("Failed to read VMess response (%d bytes): %v", nBytes, err)
		return err
	}
	log.Debug("Got response %v", response)
	// TODO: check response

	encryptRequestWriter, err := v2io.NewAesEncryptWriter(requestKey, requestIV, conn)
	if err != nil {
		close(output)
		log.Error("Failed to create encrypt writer: %v", err)
		return err
	}
	decryptResponseReader, err := v2io.NewAesDecryptReader(responseKey[:], responseIV[:], conn)
	if err != nil {
		close(output)
		log.Error("Failed to create decrypt reader: %v", err)
		return err
	}

	readFinish := make(chan bool)
	writeFinish := make(chan bool)

	go handler.dumpInput(encryptRequestWriter, input, readFinish)
	go handler.dumpOutput(decryptResponseReader, output, writeFinish)

	<-readFinish
	conn.CloseWrite()
	log.Debug("VMessOut closing write")
	<-writeFinish
	return nil
}
开发者ID:nikedog,项目名称:v2ray-core,代码行数:60,代码来源:vmessout.go


示例2: handleRequest

func handleRequest(conn *net.TCPConn, request *vmessio.VMessRequest, input <-chan []byte, finish chan<- bool) error {
	defer close(finish)
	encryptRequestWriter, err := v2io.NewAesEncryptWriter(request.RequestKey[:], request.RequestIV[:], conn)
	if err != nil {
		log.Error("Failed to create encrypt writer: %v", err)
		return err
	}

	buffer, err := request.ToBytes(v2hash.NewTimeHash(v2hash.HMACHash{}), v2math.GenerateRandomInt64InRange)
	if err != nil {
		log.Error("VMessOut: Failed to serialize VMess request: %v", err)
	}
	//conn.Write(buffer)
	data, open := <-input
	if open {
		encryptRequestWriter.Crypt(data)
		buffer = append(buffer, data...)
	}

	_, err = conn.Write(buffer)
	if err != nil {
		log.Error("VMessOut: Failed to write VMess request: %v", err)
	}

	if !open {
		return nil
	}

	v2net.ChanToWriter(encryptRequestWriter, input)
	return nil
}
开发者ID:Jamalmo,项目名称:v2ray-core,代码行数:31,代码来源:vmessout.go


示例3: NewPoint

// NewPoint returns a new Point server based on given configuration.
// The server is not started at this point.
func NewPoint(config Config) (*Point, error) {
	var vpoint = new(Point)
	vpoint.port = config.Port

	ichFactory, ok := inboundFactories[config.InboundConfig.Protocol]
	if !ok {
		panic(log.Error("Unknown inbound connection handler factory %s", config.InboundConfig.Protocol))
	}
	vpoint.ichFactory = ichFactory
	if len(config.InboundConfig.File) > 0 {
		ichConfig, err := ioutil.ReadFile(config.InboundConfig.File)
		if err != nil {
			panic(log.Error("Unable to read config file %v", err))
		}
		vpoint.ichConfig = ichConfig
	}

	ochFactory, ok := outboundFactories[config.OutboundConfig.Protocol]
	if !ok {
		panic(log.Error("Unknown outbound connection handler factory %s", config.OutboundConfig.Protocol))
	}

	vpoint.ochFactory = ochFactory
	if len(config.OutboundConfig.File) > 0 {
		ochConfig, err := ioutil.ReadFile(config.OutboundConfig.File)
		if err != nil {
			panic(log.Error("Unable to read config file %v", err))
		}
		vpoint.ochConfig = ochConfig
	}

	return vpoint, nil
}
开发者ID:neverisland,项目名称:v2ray-core,代码行数:35,代码来源:point.go


示例4: handleRequest

func handleRequest(conn *net.TCPConn, request *vmessio.VMessRequest, input <-chan []byte, finish chan<- bool) {
	defer close(finish)
	encryptRequestWriter, err := v2io.NewAesEncryptWriter(request.RequestKey[:], request.RequestIV[:], conn)
	if err != nil {
		log.Error("VMessOut: Failed to create encrypt writer: %v", err)
		return
	}

	buffer, err := request.ToBytes(v2hash.NewTimeHash(v2hash.HMACHash{}), v2math.GenerateRandomInt64InRange)
	if err != nil {
		log.Error("VMessOut: Failed to serialize VMess request: %v", err)
		return
	}

	// Send first packet of payload together with request, in favor of small requests.
	payload, open := <-input
	if open {
		encryptRequestWriter.Crypt(payload)
		buffer = append(buffer, payload...)

		_, err = conn.Write(buffer)
		if err != nil {
			log.Error("VMessOut: Failed to write VMess request: %v", err)
			return
		}

		v2net.ChanToWriter(encryptRequestWriter, input)
	}
	return
}
开发者ID:nuaajeff,项目名称:v2ray-core,代码行数:30,代码来源:vmessout.go


示例5: handleResponse

func handleResponse(conn *net.TCPConn, request *vmessio.VMessRequest, output chan<- []byte, finish chan<- bool) {
	defer close(finish)
	defer close(output)
	responseKey := md5.Sum(request.RequestKey[:])
	responseIV := md5.Sum(request.RequestIV[:])

	decryptResponseReader, err := v2io.NewAesDecryptReader(responseKey[:], responseIV[:], conn)
	if err != nil {
		log.Error("VMessOut: Failed to create decrypt reader: %v", err)
		return
	}

	response := vmessio.VMessResponse{}
	nBytes, err := decryptResponseReader.Read(response[:])
	if err != nil {
		log.Error("VMessOut: Failed to read VMess response (%d bytes): %v", nBytes, err)
		return
	}
	if !bytes.Equal(response[:], request.ResponseHeader[:]) {
		log.Warning("VMessOut: unexepcted response header. The connection is probably hijacked.")
		return
	}

	v2net.ReaderToChan(output, decryptResponseReader)
	return
}
开发者ID:nuaajeff,项目名称:v2ray-core,代码行数:26,代码来源:vmessout.go


示例6: main

func main() {
	flag.Parse()

	if *version {
		fmt.Printf("V2Ray version %s (%s): %s", core.Version, core.Codename, core.Intro)
		fmt.Println()
		return
	}

	switch *logLevel {
	case "debug":
		log.SetLogLevel(log.DebugLevel)
	case "info":
		log.SetLogLevel(log.InfoLevel)
	case "warning":
		log.SetLogLevel(log.WarningLevel)
	case "error":
		log.SetLogLevel(log.ErrorLevel)
	}

	if configFile == nil || len(*configFile) == 0 {
		panic(log.Error("Config file is not set."))
	}
	rawVConfig, err := ioutil.ReadFile(*configFile)
	if err != nil {
		panic(log.Error("Failed to read config file (%s): %v", *configFile, err))
	}
	vconfig, err := core.LoadConfig(rawVConfig)
	if err != nil {
		panic(log.Error("Failed to parse Config: %v", err))
	}

	if !filepath.IsAbs(vconfig.InboundConfig.File) && len(vconfig.InboundConfig.File) > 0 {
		vconfig.InboundConfig.File = filepath.Join(filepath.Dir(*configFile), vconfig.InboundConfig.File)
	}

	if !filepath.IsAbs(vconfig.OutboundConfig.File) && len(vconfig.OutboundConfig.File) > 0 {
		vconfig.OutboundConfig.File = filepath.Join(filepath.Dir(*configFile), vconfig.OutboundConfig.File)
	}

	vPoint, err := core.NewPoint(vconfig)
	if err != nil {
		panic(log.Error("Failed to create Point server: %v", err))
	}

	err = vPoint.Start()
	if err != nil {
		log.Error("Error starting Point server: %v", err)
	}

	finish := make(chan bool)
	<-finish
}
开发者ID:nuaajeff,项目名称:v2ray-core,代码行数:53,代码来源:main.go


示例7: HandleConnection

func (handler *VMessInboundHandler) HandleConnection(connection net.Conn) error {
	defer connection.Close()

	reader := vmessio.NewVMessRequestReader(handler.clients)

	request, err := reader.Read(connection)
	if err != nil {
		log.Debug("Failed to parse VMess request: %v", err)
		return err
	}
	log.Debug("Received request for %s", request.Address.String())

	response := vmessio.NewVMessResponse(request)
	nBytes, err := connection.Write(response[:])
	if err != nil {
		return log.Error("Failed to write VMess response (%d bytes): %v", nBytes, err)
	}

	requestKey := request.RequestKey[:]
	requestIV := request.RequestIV[:]
	responseKey := md5.Sum(requestKey)
	responseIV := md5.Sum(requestIV)

	requestReader, err := v2io.NewAesDecryptReader(requestKey, requestIV, connection)
	if err != nil {
		return log.Error("Failed to create decrypt reader: %v", err)
	}

	responseWriter, err := v2io.NewAesEncryptWriter(responseKey[:], responseIV[:], connection)
	if err != nil {
		return log.Error("Failed to create encrypt writer: %v", err)
	}

	ray := handler.vPoint.NewInboundConnectionAccepted(request.Address)
	input := ray.InboundInput()
	output := ray.InboundOutput()

	readFinish := make(chan bool)
	writeFinish := make(chan bool)

	go handler.dumpInput(requestReader, input, readFinish)
	go handler.dumpOutput(responseWriter, output, writeFinish)

	<-writeFinish
	if tcpConn, ok := connection.(*net.TCPConn); ok {
		log.Debug("VMessIn closing write")
		tcpConn.CloseWrite()
	}
	<-readFinish

	return nil
}
开发者ID:neverisland,项目名称:v2ray-core,代码行数:52,代码来源:vmessin.go


示例8: Create

func (factory *VMessInboundHandlerFactory) Create(vp *core.Point, rawConfig []byte) (core.InboundConnectionHandler, error) {
	config, err := loadInboundConfig(rawConfig)
	if err != nil {
		panic(log.Error("Failed to load VMess inbound config: %v", err))
	}
	allowedClients := core.NewTimedUserSet()
	for _, client := range config.AllowedClients {
		user, err := client.ToUser()
		if err != nil {
			panic(log.Error("Failed to parse user id %s: %v", client.Id, err))
		}
		allowedClients.AddUser(user)
	}
	return NewVMessInboundHandler(vp, allowedClients), nil
}
开发者ID:Jamalmo,项目名称:v2ray-core,代码行数:15,代码来源:vmessin.go


示例9: startCommunicate

func startCommunicate(request *vmessio.VMessRequest, dest v2net.Address, ray core.OutboundRay) error {
	input := ray.OutboundInput()
	output := ray.OutboundOutput()

	conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{dest.IP, int(dest.Port), ""})
	log.Debug("VMessOutbound dialing tcp: %s", dest.String())
	if err != nil {
		log.Error("Failed to open tcp (%s): %v", dest.String(), err)
		close(output)
		return err
	}
	defer conn.Close()
	defer close(output)

	requestFinish := make(chan bool)
	responseFinish := make(chan bool)

	go handleRequest(conn, request, input, requestFinish)
	go handleResponse(conn, request, output, responseFinish)

	<-requestFinish
	conn.CloseWrite()
	<-responseFinish
	return nil
}
开发者ID:neverisland,项目名称:v2ray-core,代码行数:25,代码来源:vmessout.go


示例10: UUIDToID

// TODO: leverage a full functional UUID library
func UUIDToID(uuid string) (v ID, err error) {
	text := []byte(uuid)
	if len(text) < 32 {
		err = log.Error("uuid: invalid UUID string: %s", text)
		return
	}

	b := v[:]

	for _, byteGroup := range byteGroups {
		if text[0] == '-' {
			text = text[1:]
		}

		_, err = hex.Decode(b[:byteGroup/2], text[:byteGroup])

		if err != nil {
			return
		}

		text = text[byteGroup:]
		b = b[byteGroup/2:]
	}

	return
}
开发者ID:noah70,项目名称:v2ray-core,代码行数:27,代码来源:id.go


示例11: NewID

func NewID(id string) (ID, error) {
	idBytes, err := UUIDToID(id)
	if err != nil {
		return ID{}, log.Error("Failed to parse id %s", id)
	}
	hasher := hmac.New(md5.New, idBytes)
	return ID{id, idBytes, hasher}, nil
}
开发者ID:vinsonzou,项目名称:v2ray-core,代码行数:8,代码来源:id.go


示例12: ToVNextServer

func (config VNextConfig) ToVNextServer() VNextServer {
	users := make([]core.User, 0, len(config.Users))
	for _, user := range config.Users {
		vuser, err := user.ToUser()
		if err != nil {
			panic(log.Error("Failed to convert %v to User.", user))
		}
		users = append(users, vuser)
	}
	ip := net.ParseIP(config.Address)
	if ip == nil {
		panic(log.Error("Unable to parse VNext IP: %s", config.Address))
	}
	return VNextServer{
		v2net.IPAddress(ip, config.Port),
		users}
}
开发者ID:JamesLiAndroid,项目名称:v2ray-core,代码行数:17,代码来源:config.go


示例13: handleRequest

func handleRequest(conn *net.TCPConn, request *vmessio.VMessRequest, input <-chan []byte, finish chan<- bool) error {
	defer close(finish)
	requestWriter := vmessio.NewVMessRequestWriter(v2hash.NewTimeHash(v2hash.HMACHash{}), v2math.GenerateRandomInt64InRange)
	err := requestWriter.Write(conn, request)
	if err != nil {
		log.Error("Failed to write VMess request: %v", err)
		return err
	}

	encryptRequestWriter, err := v2io.NewAesEncryptWriter(request.RequestKey[:], request.RequestIV[:], conn)
	if err != nil {
		log.Error("Failed to create encrypt writer: %v", err)
		return err
	}

	v2net.ChanToWriter(encryptRequestWriter, input)
	return nil
}
开发者ID:neverisland,项目名称:v2ray-core,代码行数:18,代码来源:vmessout.go


示例14: Listen

func (server *SocksServer) Listen(port uint16) error {
	listener, err := net.Listen("tcp", ":"+strconv.Itoa(int(port)))
	if err != nil {
		return log.Error("Error on listening port %d: %v", port, err)
	}
	server.accepting = true
	go server.AcceptConnections(listener)
	return nil
}
开发者ID:nicedayzhu,项目名称:v2ray-core,代码行数:9,代码来源:socks.go


示例15: AcceptConnections

func (server *SocksServer) AcceptConnections(listener net.Listener) {
	for server.accepting {
		connection, err := listener.Accept()
		if err != nil {
			log.Error("Error on accepting socks connection: %v", err)
		}
		go server.HandleConnection(connection)
	}
}
开发者ID:nuaajeff,项目名称:v2ray-core,代码行数:9,代码来源:socks.go


示例16: Read

// Read reads blocks from underlying reader, the length of blocks must be
// a multiply of BlockSize()
func (reader CryptionReader) Read(blocks []byte) (int, error) {
	nBytes, err := reader.reader.Read(blocks)
	if nBytes > 0 {
		reader.stream.XORKeyStream(blocks[:nBytes], blocks[:nBytes])
	}
	if err != nil && err != io.EOF {
		log.Error("Error reading blocks: %v", err)
	}
	return nBytes, err
}
开发者ID:nikedog,项目名称:v2ray-core,代码行数:12,代码来源:encryption.go


示例17: NewSocksServer

func NewSocksServer(vp *core.Point, rawConfig []byte) *SocksServer {
	server := new(SocksServer)
	server.vPoint = vp
	config, err := loadConfig(rawConfig)
	if err != nil {
		panic(log.Error("Unable to load socks config: %v", err))
	}
	server.config = config
	return server
}
开发者ID:noah70,项目名称:v2ray-core,代码行数:10,代码来源:socks.go


示例18: NewSocksServer

func NewSocksServer(vp *core.Point, rawConfig []byte) *SocksServer {
	config, err := loadConfig(rawConfig)
	if err != nil {
		panic(log.Error("Unable to load socks config: %v", err))
	}
	return &SocksServer{
		vPoint: vp,
		config: config,
	}
}
开发者ID:yatwql,项目名称:v2ray-core,代码行数:10,代码来源:socks.go


示例19: AcceptConnections

func (handler *VMessInboundHandler) AcceptConnections(listener net.Listener) error {
	for handler.accepting {
		connection, err := listener.Accept()
		if err != nil {
			return log.Error("Failed to accpet connection: %s", err.Error())
		}
		go handler.HandleConnection(connection)
	}
	return nil
}
开发者ID:Jamalmo,项目名称:v2ray-core,代码行数:10,代码来源:vmessin.go


示例20: HandleConnection

func (handler *VMessInboundHandler) HandleConnection(connection net.Conn) error {
	defer connection.Close()
	reader := vmessio.NewVMessRequestReader(handler.clients)

	request, err := reader.Read(connection)
	if err != nil {
		return err
	}
	log.Debug("Received request for %s", request.Address.String())

	response := vmessio.NewVMessResponse(request)
	nBytes, err := connection.Write(response[:])
	log.Debug("Writing VMess response %v", response)
	if err != nil {
		return log.Error("Failed to write VMess response (%d bytes): %v", nBytes, err)
	}

	requestKey := request.RequestKey[:]
	requestIV := request.RequestIV[:]
	responseKey := md5.Sum(requestKey)
	responseIV := md5.Sum(requestIV)

	requestReader, err := v2io.NewAesDecryptReader(requestKey, requestIV, connection)
	if err != nil {
		return log.Error("Failed to create decrypt reader: %v", err)
	}

	responseWriter, err := v2io.NewAesEncryptWriter(responseKey[:], responseIV[:], connection)
	if err != nil {
		return log.Error("Failed to create encrypt writer: %v", err)
	}

	ray := handler.vPoint.NewInboundConnectionAccepted(request.Address)
	input := ray.InboundInput()
	output := ray.InboundOutput()
	finish := make(chan bool, 2)

	go handler.dumpInput(requestReader, input, finish)
	go handler.dumpOutput(responseWriter, output, finish)
	handler.waitForFinish(finish)

	return nil
}
开发者ID:h82258652,项目名称:v2ray-core,代码行数:43,代码来源:vmessin.go



注:本文中的github.com/v2ray/v2ray-core/log.Error函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang net.DomainAddress函数代码示例发布时间:2022-05-28
下一篇:
Golang log.Debug函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap