本文整理汇总了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
}
示例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
}
}
示例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
}
示例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
}
示例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
}
示例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
}
}
示例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
}
示例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
}
示例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)
}
示例10: Next
func (v *ChunkNonceGenerator) Next() []byte {
serial.Uint16ToBytes(v.count, v.Nonce[:0])
v.count++
return v.Nonce[:v.Size]
}
示例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)
}
示例12: AppendUint16
func (b *Buffer) AppendUint16(v uint16) *Buffer {
b.Value = serial.Uint16ToBytes(v, b.Value)
return b
}
示例13: PrependUint16
func (b *Buffer) PrependUint16(v uint16) *Buffer {
b.SliceBack(2)
serial.Uint16ToBytes(v, b.Value[:0])
return b
}
示例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
}