當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。