You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
498 B
Go
32 lines
498 B
Go
2 years ago
|
package plain
|
||
|
|
||
|
import (
|
||
|
"encoding/hex"
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
type Packet struct {
|
||
|
Data []byte // 原始数据
|
||
|
}
|
||
|
|
||
|
func newPacket() *Packet {
|
||
|
return &Packet{}
|
||
|
}
|
||
|
|
||
|
func (p *Packet) GetHeader() interface{} {
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (p *Packet) GetLen() uint64 {
|
||
|
return uint64(len(p.Data))
|
||
|
}
|
||
|
|
||
|
func (p *Packet) GetBody() []byte {
|
||
|
return p.Data
|
||
|
}
|
||
|
|
||
|
func (p *Packet) String() string {
|
||
|
return fmt.Sprintf("PlainPacket[Len: %d] BodyStr: [%s], BodyHex: [%s]",
|
||
|
len(p.Data), string(p.Data), hex.EncodeToString(p.Data))
|
||
|
}
|