get security quotes

This commit is contained in:
bense
2022-05-09 12:56:02 +08:00
parent ab01ec7539
commit 0172cdb00e
8 changed files with 505 additions and 49 deletions

View File

@@ -3,14 +3,15 @@ package proto
import (
"bytes"
"encoding/binary"
"encoding/hex"
"gotdx/utils"
)
// Hello1 创建握手消息1
type Hello1 struct {
ReqHeader
content []byte
Reply *Hello1Reply
contentHex string
Reply *Hello1Reply
}
type Hello1Reply struct {
Info string
@@ -19,22 +20,24 @@ type Hello1Reply struct {
func NewHello1() *Hello1 {
obj := &Hello1{}
obj.Reply = new(Hello1Reply)
obj.Zip = 0x0c
obj.SeqID = seqID()
obj.PacketType = 0x01
obj.Method = KMSG_CMD1
obj.content = []byte{0x01}
obj.contentHex = "01"
return obj
}
func (obj *Hello1) Serialize() ([]byte, error) {
obj.PkgLen1 = 2 + uint16(len(obj.content))
obj.PkgLen2 = 2 + uint16(len(obj.content))
b, err := hex.DecodeString(obj.contentHex)
obj.PkgLen1 = 2 + uint16(len(b))
obj.PkgLen2 = 2 + uint16(len(b))
buf := new(bytes.Buffer)
err := binary.Write(buf, binary.LittleEndian, obj.ReqHeader)
buf.Write(obj.content)
err = binary.Write(buf, binary.LittleEndian, obj.ReqHeader)
buf.Write(b)
return buf.Bytes(), err
}
@@ -43,9 +46,8 @@ func (obj *Hello1) Serialize() ([]byte, error) {
分 时 秒 日期
*/
func (obj *Hello1) UnSerialize(header interface{}, data []byte) error {
obj.Reply = new(Hello1Reply)
serverInfo := utils.Utf8ToGbk(data[68:])
//fmt.Println(fmt.Sprintf("服务器:%s;", serverInfo))
//fmt.Println(hex.EncodeToString(data))
obj.Reply.Info = serverInfo
return nil
}