当前位置: 首页>>代码示例>>Golang>>正文


Golang serial.Uint16ToBytes函数代码示例

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


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

示例1: Bytes

func (this *DataSegment) Bytes(b []byte) []byte {
	b = serial.Uint16ToBytes(this.Conv, b)
	b = append(b, byte(CommandData), byte(this.Option))
	b = serial.Uint32ToBytes(this.Timestamp, b)
	b = serial.Uint32ToBytes(this.Number, b)
	b = serial.Uint32ToBytes(this.SendingNext, b)
	b = serial.Uint16ToBytes(uint16(this.Data.Len()), b)
	b = append(b, this.Data.Value...)
	return b
}
开发者ID:DZLZHCODE,项目名称:v2ray-core,代码行数:10,代码来源:segment.go

示例2: Bytes

func (v *DataSegment) Bytes() buf.Supplier {
	return func(b []byte) (int, error) {
		b = serial.Uint16ToBytes(v.Conv, b[:0])
		b = append(b, byte(CommandData), byte(v.Option))
		b = serial.Uint32ToBytes(v.Timestamp, b)
		b = serial.Uint32ToBytes(v.Number, b)
		b = serial.Uint32ToBytes(v.SendingNext, b)
		b = serial.Uint16ToBytes(uint16(v.Data.Len()), b)
		b = append(b, v.Data.Bytes()...)
		return v.ByteSize(), nil
	}
}
开发者ID:v2ray,项目名称:v2ray-core,代码行数:12,代码来源:segment.go

示例3: Marshal

func (this *CommandSwitchAccountFactory) Marshal(command interface{}, writer io.Writer) error {
	cmd, ok := command.(*protocol.CommandSwitchAccount)
	if !ok {
		return ErrCommandTypeMismatch
	}

	hostStr := ""
	if cmd.Host != nil {
		hostStr = cmd.Host.String()
	}
	writer.Write([]byte{byte(len(hostStr))})

	if len(hostStr) > 0 {
		writer.Write([]byte(hostStr))
	}

	writer.Write(cmd.Port.Bytes(nil))

	idBytes := cmd.ID.Bytes()
	writer.Write(idBytes)

	writer.Write(serial.Uint16ToBytes(cmd.AlterIds, nil))
	writer.Write([]byte{byte(cmd.Level)})

	writer.Write([]byte{cmd.ValidMin})
	return nil
}
开发者ID:DZLZHCODE,项目名称:v2ray-core,代码行数:27,代码来源:commands.go

示例4: Write

func (v *ChunkWriter) Write(payload *buf.Buffer) error {
	totalLength := payload.Len()
	serial.Uint16ToBytes(uint16(totalLength), v.buffer[:0])
	v.auth.Authenticate(payload.Bytes())(v.buffer[2:])
	copy(v.buffer[2+AuthSize:], payload.Bytes())
	_, err := v.writer.Write(v.buffer[:2+AuthSize+payload.Len()])
	return err
}
开发者ID:v2ray,项目名称:v2ray-core,代码行数:8,代码来源:ota.go

示例5: Write

func (v *AuthenticationWriter) Write(b []byte) (int, error) {
	cipherChunk, err := v.auth.Seal(v.buffer[2:2], b)
	if err != nil {
		return 0, err
	}

	serial.Uint16ToBytes(uint16(len(cipherChunk)), v.buffer[:0])
	_, err = v.writer.Write(v.buffer[:2+len(cipherChunk)])
	return len(b), err
}
开发者ID:ylywyn,项目名称:v2ray-core,代码行数:10,代码来源:auth.go

示例6: Bytes

func (v *AckSegment) Bytes() buf.Supplier {
	return func(b []byte) (int, error) {
		b = serial.Uint16ToBytes(v.Conv, b[:0])
		b = append(b, byte(CommandACK), byte(v.Option))
		b = serial.Uint32ToBytes(v.ReceivingWindow, b)
		b = serial.Uint32ToBytes(v.ReceivingNext, b)
		b = serial.Uint32ToBytes(v.Timestamp, b)
		count := byte(len(v.NumberList))
		b = append(b, count)
		for _, number := range v.NumberList {
			b = serial.Uint32ToBytes(number, b)
		}
		return v.ByteSize(), nil
	}
}
开发者ID:ylywyn,项目名称:v2ray-core,代码行数:15,代码来源:segment.go

示例7: Seal

// Seal implements cipher.AEAD.Seal().
func (v *SimpleAuthenticator) Seal(dst, nonce, plain, extra []byte) []byte {
	dst = append(dst, 0, 0, 0, 0)
	dst = serial.Uint16ToBytes(uint16(len(plain)), dst)
	dst = append(dst, plain...)

	fnvHash := fnv.New32a()
	fnvHash.Write(dst[4:])
	fnvHash.Sum(dst[:0])

	len := len(dst)
	xtra := 4 - len%4
	if xtra != 4 {
		dst = append(dst, make([]byte, xtra)...)
	}
	xorfwd(dst)
	if xtra != 4 {
		dst = dst[:len]
	}
	return dst
}
开发者ID:v2ray,项目名称:v2ray-core,代码行数:21,代码来源:crypt.go

示例8: Write

func (v *UTP) Write(b []byte) (int, error) {
	serial.Uint16ToBytes(v.connectionId, b[:0])
	b[2] = v.header
	b[3] = v.extension
	return 4, nil
}
开发者ID:v2ray,项目名称:v2ray-core,代码行数:6,代码来源:utp.go

示例9: Bytes

// Bytes returns the correspoding bytes of v Port, in big endian order.
func (v Port) Bytes(b []byte) []byte {
	return serial.Uint16ToBytes(v.Value(), b)
}
开发者ID:v2ray,项目名称:v2ray-core,代码行数:4,代码来源:port.go

示例10: Next

func (v *ChunkNonceGenerator) Next() []byte {
	serial.Uint16ToBytes(v.count, v.Nonce[:0])
	v.count++
	return v.Nonce[:v.Size]
}
开发者ID:v2ray,项目名称:v2ray-core,代码行数:5,代码来源:client.go

示例11: Bytes

// Bytes returns the correspoding bytes of this Port, in big endian order.
func (this Port) Bytes(b []byte) []byte {
	return serial.Uint16ToBytes(this.Value(), b)
}
开发者ID:DZLZHCODE,项目名称:v2ray-core,代码行数:4,代码来源:port.go

示例12: AppendUint16

func (b *Buffer) AppendUint16(v uint16) *Buffer {
	b.Value = serial.Uint16ToBytes(v, b.Value)
	return b
}
开发者ID:xyz12810,项目名称:v2ray-core,代码行数:4,代码来源:buffer.go

示例13: PrependUint16

func (b *Buffer) PrependUint16(v uint16) *Buffer {
	b.SliceBack(2)
	serial.Uint16ToBytes(v, b.Value[:0])
	return b
}
开发者ID:xyz12810,项目名称:v2ray-core,代码行数:5,代码来源:buffer.go

示例14: Write

func (v *SRTP) Write(b []byte) (int, error) {
	v.number++
	serial.Uint16ToBytes(v.number, b[:0])
	serial.Uint16ToBytes(v.number, b[:2])
	return 4, nil
}
开发者ID:ylywyn,项目名称:v2ray-core,代码行数:6,代码来源:srtp.go


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