2016-01-22 17:30:47 +00:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"time"
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
_ = unsafe.Sizeof(0)
|
|
|
|
_ = io.ReadFull
|
|
|
|
_ = time.Now()
|
|
|
|
)
|
|
|
|
|
|
|
|
func (d *User) Size() (s uint64) {
|
|
|
|
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Username))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := l
|
|
|
|
for t >= 0x80 {
|
2017-04-19 00:07:31 +00:00
|
|
|
t >>= 7
|
2016-01-22 17:30:47 +00:00
|
|
|
s++
|
|
|
|
}
|
|
|
|
s++
|
|
|
|
|
|
|
|
}
|
|
|
|
s += l
|
|
|
|
}
|
2018-10-15 06:56:17 +00:00
|
|
|
{
|
|
|
|
if d.clientSettings != nil {
|
|
|
|
|
|
|
|
{
|
|
|
|
s += (*d.clientSettings).Size()
|
|
|
|
}
|
|
|
|
s += 0
|
|
|
|
}
|
|
|
|
}
|
2018-08-10 18:24:29 +00:00
|
|
|
{
|
|
|
|
l := uint64(len(d.lastIP))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := l
|
|
|
|
for t >= 0x80 {
|
|
|
|
t >>= 7
|
|
|
|
s++
|
|
|
|
}
|
|
|
|
s++
|
|
|
|
|
|
|
|
}
|
|
|
|
s += l
|
|
|
|
}
|
2018-10-15 06:56:17 +00:00
|
|
|
s += 9
|
2016-01-22 17:30:47 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
func (d *User) Marshal(buf []byte) ([]byte, error) {
|
|
|
|
size := d.Size()
|
|
|
|
{
|
|
|
|
if uint64(cap(buf)) >= size {
|
|
|
|
buf = buf[:size]
|
|
|
|
} else {
|
|
|
|
buf = make([]byte, size)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
2017-04-19 00:07:31 +00:00
|
|
|
*(*uint64)(unsafe.Pointer(&buf[0])) = d.ID
|
2016-01-22 17:30:47 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Username))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := uint64(l)
|
|
|
|
|
|
|
|
for t >= 0x80 {
|
|
|
|
buf[i+8] = byte(t) | 0x80
|
|
|
|
t >>= 7
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
buf[i+8] = byte(t)
|
|
|
|
i++
|
|
|
|
|
|
|
|
}
|
|
|
|
copy(buf[i+8:], d.Username)
|
|
|
|
i += l
|
|
|
|
}
|
2018-10-15 06:56:17 +00:00
|
|
|
{
|
|
|
|
if d.clientSettings == nil {
|
|
|
|
buf[i+8] = 0
|
|
|
|
} else {
|
|
|
|
buf[i+8] = 1
|
|
|
|
|
|
|
|
{
|
|
|
|
nbuf, err := (*d.clientSettings).Marshal(buf[i+9:])
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
i += uint64(len(nbuf))
|
|
|
|
}
|
|
|
|
i += 0
|
|
|
|
}
|
|
|
|
}
|
2018-08-10 18:24:29 +00:00
|
|
|
{
|
|
|
|
l := uint64(len(d.lastIP))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := uint64(l)
|
|
|
|
|
|
|
|
for t >= 0x80 {
|
2018-10-15 06:56:17 +00:00
|
|
|
buf[i+9] = byte(t) | 0x80
|
2018-08-10 18:24:29 +00:00
|
|
|
t >>= 7
|
|
|
|
i++
|
|
|
|
}
|
2018-10-15 06:56:17 +00:00
|
|
|
buf[i+9] = byte(t)
|
2018-08-10 18:24:29 +00:00
|
|
|
i++
|
|
|
|
|
|
|
|
}
|
2018-10-15 06:56:17 +00:00
|
|
|
copy(buf[i+9:], d.lastIP)
|
2018-08-10 18:24:29 +00:00
|
|
|
i += l
|
|
|
|
}
|
2018-10-15 06:56:17 +00:00
|
|
|
return buf[:i+9], nil
|
2016-01-22 17:30:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (d *User) Unmarshal(buf []byte) (uint64, error) {
|
|
|
|
i := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
2017-04-19 00:07:31 +00:00
|
|
|
d.ID = *(*uint64)(unsafe.Pointer(&buf[i+0]))
|
2016-01-22 17:30:47 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bs := uint8(7)
|
|
|
|
t := uint64(buf[i+8] & 0x7F)
|
|
|
|
for buf[i+8]&0x80 == 0x80 {
|
|
|
|
i++
|
|
|
|
t |= uint64(buf[i+8]&0x7F) << bs
|
|
|
|
bs += 7
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
|
|
|
|
l = t
|
|
|
|
|
|
|
|
}
|
|
|
|
d.Username = string(buf[i+8 : i+8+l])
|
|
|
|
i += l
|
|
|
|
}
|
2018-10-15 06:56:17 +00:00
|
|
|
{
|
|
|
|
if buf[i+8] == 1 {
|
|
|
|
if d.clientSettings == nil {
|
|
|
|
d.clientSettings = new(ClientSettings)
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
ni, err := (*d.clientSettings).Unmarshal(buf[i+9:])
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
i += ni
|
|
|
|
}
|
|
|
|
i += 0
|
|
|
|
} else {
|
|
|
|
d.clientSettings = nil
|
|
|
|
}
|
|
|
|
}
|
2018-08-10 18:24:29 +00:00
|
|
|
{
|
|
|
|
l := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bs := uint8(7)
|
2018-10-15 06:56:17 +00:00
|
|
|
t := uint64(buf[i+9] & 0x7F)
|
|
|
|
for buf[i+9]&0x80 == 0x80 {
|
2018-08-10 18:24:29 +00:00
|
|
|
i++
|
2018-10-15 06:56:17 +00:00
|
|
|
t |= uint64(buf[i+9]&0x7F) << bs
|
2018-08-10 18:24:29 +00:00
|
|
|
bs += 7
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
|
|
|
|
l = t
|
|
|
|
|
|
|
|
}
|
|
|
|
if uint64(cap(d.lastIP)) >= l {
|
|
|
|
d.lastIP = d.lastIP[:l]
|
|
|
|
} else {
|
|
|
|
d.lastIP = make([]byte, l)
|
|
|
|
}
|
2018-10-15 06:56:17 +00:00
|
|
|
copy(d.lastIP, buf[i+9:])
|
2018-08-10 18:24:29 +00:00
|
|
|
i += l
|
|
|
|
}
|
2018-10-15 06:56:17 +00:00
|
|
|
return i + 9, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *ClientSettings) Size() (s uint64) {
|
|
|
|
|
|
|
|
s += 1
|
|
|
|
return
|
|
|
|
}
|
|
|
|
func (d *ClientSettings) Marshal(buf []byte) ([]byte, error) {
|
|
|
|
size := d.Size()
|
|
|
|
{
|
|
|
|
if uint64(cap(buf)) >= size {
|
|
|
|
buf = buf[:size]
|
|
|
|
} else {
|
|
|
|
buf = make([]byte, size)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
if d.ColoredNicks {
|
|
|
|
buf[0] = 1
|
|
|
|
} else {
|
|
|
|
buf[0] = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return buf[:i+1], nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *ClientSettings) Unmarshal(buf []byte) (uint64, error) {
|
|
|
|
i := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
d.ColoredNicks = buf[0] == 1
|
|
|
|
}
|
|
|
|
return i + 1, nil
|
2016-01-22 17:30:47 +00:00
|
|
|
}
|
|
|
|
|
2020-06-15 08:58:51 +00:00
|
|
|
func (d *Network) Size() (s uint64) {
|
2016-01-22 17:30:47 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Name))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := l
|
|
|
|
for t >= 0x80 {
|
2017-04-19 00:07:31 +00:00
|
|
|
t >>= 7
|
2016-01-22 17:30:47 +00:00
|
|
|
s++
|
|
|
|
}
|
|
|
|
s++
|
|
|
|
|
|
|
|
}
|
|
|
|
s += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Host))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := l
|
|
|
|
for t >= 0x80 {
|
2017-04-19 00:07:31 +00:00
|
|
|
t >>= 7
|
2016-01-22 17:30:47 +00:00
|
|
|
s++
|
|
|
|
}
|
|
|
|
s++
|
|
|
|
|
|
|
|
}
|
|
|
|
s += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Port))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := l
|
|
|
|
for t >= 0x80 {
|
2017-04-19 00:07:31 +00:00
|
|
|
t >>= 7
|
2016-01-22 17:30:47 +00:00
|
|
|
s++
|
|
|
|
}
|
|
|
|
s++
|
|
|
|
|
|
|
|
}
|
|
|
|
s += l
|
|
|
|
}
|
|
|
|
{
|
2020-05-23 06:05:37 +00:00
|
|
|
l := uint64(len(d.ServerPassword))
|
2016-01-22 17:30:47 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := l
|
|
|
|
for t >= 0x80 {
|
2017-04-19 00:07:31 +00:00
|
|
|
t >>= 7
|
2016-01-22 17:30:47 +00:00
|
|
|
s++
|
|
|
|
}
|
|
|
|
s++
|
|
|
|
|
|
|
|
}
|
|
|
|
s += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Nick))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := l
|
|
|
|
for t >= 0x80 {
|
2017-04-19 00:07:31 +00:00
|
|
|
t >>= 7
|
2016-01-22 17:30:47 +00:00
|
|
|
s++
|
|
|
|
}
|
|
|
|
s++
|
|
|
|
|
|
|
|
}
|
|
|
|
s += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Username))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := l
|
|
|
|
for t >= 0x80 {
|
2017-04-19 00:07:31 +00:00
|
|
|
t >>= 7
|
2016-01-22 17:30:47 +00:00
|
|
|
s++
|
|
|
|
}
|
|
|
|
s++
|
|
|
|
|
|
|
|
}
|
|
|
|
s += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Realname))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := l
|
|
|
|
for t >= 0x80 {
|
2017-04-19 00:07:31 +00:00
|
|
|
t >>= 7
|
2016-01-22 17:30:47 +00:00
|
|
|
s++
|
|
|
|
}
|
|
|
|
s++
|
|
|
|
|
|
|
|
}
|
|
|
|
s += l
|
|
|
|
}
|
2020-05-23 06:05:37 +00:00
|
|
|
{
|
|
|
|
l := uint64(len(d.Account))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := l
|
|
|
|
for t >= 0x80 {
|
|
|
|
t >>= 7
|
|
|
|
s++
|
|
|
|
}
|
|
|
|
s++
|
|
|
|
|
|
|
|
}
|
|
|
|
s += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Password))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := l
|
|
|
|
for t >= 0x80 {
|
|
|
|
t >>= 7
|
|
|
|
s++
|
|
|
|
}
|
|
|
|
s++
|
|
|
|
|
|
|
|
}
|
|
|
|
s += l
|
|
|
|
}
|
2016-01-22 17:30:47 +00:00
|
|
|
s += 1
|
|
|
|
return
|
|
|
|
}
|
2020-06-15 08:58:51 +00:00
|
|
|
func (d *Network) Marshal(buf []byte) ([]byte, error) {
|
2016-01-22 17:30:47 +00:00
|
|
|
size := d.Size()
|
|
|
|
{
|
|
|
|
if uint64(cap(buf)) >= size {
|
|
|
|
buf = buf[:size]
|
|
|
|
} else {
|
|
|
|
buf = make([]byte, size)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Name))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := uint64(l)
|
|
|
|
|
|
|
|
for t >= 0x80 {
|
|
|
|
buf[i+0] = byte(t) | 0x80
|
|
|
|
t >>= 7
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
buf[i+0] = byte(t)
|
|
|
|
i++
|
|
|
|
|
|
|
|
}
|
|
|
|
copy(buf[i+0:], d.Name)
|
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Host))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := uint64(l)
|
|
|
|
|
|
|
|
for t >= 0x80 {
|
|
|
|
buf[i+0] = byte(t) | 0x80
|
|
|
|
t >>= 7
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
buf[i+0] = byte(t)
|
|
|
|
i++
|
|
|
|
|
|
|
|
}
|
|
|
|
copy(buf[i+0:], d.Host)
|
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Port))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := uint64(l)
|
|
|
|
|
|
|
|
for t >= 0x80 {
|
|
|
|
buf[i+0] = byte(t) | 0x80
|
|
|
|
t >>= 7
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
buf[i+0] = byte(t)
|
|
|
|
i++
|
|
|
|
|
|
|
|
}
|
|
|
|
copy(buf[i+0:], d.Port)
|
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
if d.TLS {
|
|
|
|
buf[i+0] = 1
|
|
|
|
} else {
|
|
|
|
buf[i+0] = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2020-05-23 06:05:37 +00:00
|
|
|
l := uint64(len(d.ServerPassword))
|
2016-01-22 17:30:47 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := uint64(l)
|
|
|
|
|
|
|
|
for t >= 0x80 {
|
|
|
|
buf[i+1] = byte(t) | 0x80
|
|
|
|
t >>= 7
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
buf[i+1] = byte(t)
|
|
|
|
i++
|
|
|
|
|
|
|
|
}
|
2020-05-23 06:05:37 +00:00
|
|
|
copy(buf[i+1:], d.ServerPassword)
|
2016-01-22 17:30:47 +00:00
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Nick))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := uint64(l)
|
|
|
|
|
|
|
|
for t >= 0x80 {
|
|
|
|
buf[i+1] = byte(t) | 0x80
|
|
|
|
t >>= 7
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
buf[i+1] = byte(t)
|
|
|
|
i++
|
|
|
|
|
|
|
|
}
|
|
|
|
copy(buf[i+1:], d.Nick)
|
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Username))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := uint64(l)
|
|
|
|
|
|
|
|
for t >= 0x80 {
|
|
|
|
buf[i+1] = byte(t) | 0x80
|
|
|
|
t >>= 7
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
buf[i+1] = byte(t)
|
|
|
|
i++
|
|
|
|
|
|
|
|
}
|
|
|
|
copy(buf[i+1:], d.Username)
|
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Realname))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := uint64(l)
|
|
|
|
|
|
|
|
for t >= 0x80 {
|
|
|
|
buf[i+1] = byte(t) | 0x80
|
|
|
|
t >>= 7
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
buf[i+1] = byte(t)
|
|
|
|
i++
|
|
|
|
|
|
|
|
}
|
|
|
|
copy(buf[i+1:], d.Realname)
|
|
|
|
i += l
|
|
|
|
}
|
2020-05-23 06:05:37 +00:00
|
|
|
{
|
|
|
|
l := uint64(len(d.Account))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := uint64(l)
|
|
|
|
|
|
|
|
for t >= 0x80 {
|
|
|
|
buf[i+1] = byte(t) | 0x80
|
|
|
|
t >>= 7
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
buf[i+1] = byte(t)
|
|
|
|
i++
|
|
|
|
|
|
|
|
}
|
|
|
|
copy(buf[i+1:], d.Account)
|
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Password))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := uint64(l)
|
|
|
|
|
|
|
|
for t >= 0x80 {
|
|
|
|
buf[i+1] = byte(t) | 0x80
|
|
|
|
t >>= 7
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
buf[i+1] = byte(t)
|
|
|
|
i++
|
|
|
|
|
|
|
|
}
|
|
|
|
copy(buf[i+1:], d.Password)
|
|
|
|
i += l
|
|
|
|
}
|
2016-01-22 17:30:47 +00:00
|
|
|
return buf[:i+1], nil
|
|
|
|
}
|
|
|
|
|
2020-06-15 08:58:51 +00:00
|
|
|
func (d *Network) Unmarshal(buf []byte) (uint64, error) {
|
2016-01-22 17:30:47 +00:00
|
|
|
i := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
l := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bs := uint8(7)
|
|
|
|
t := uint64(buf[i+0] & 0x7F)
|
|
|
|
for buf[i+0]&0x80 == 0x80 {
|
|
|
|
i++
|
|
|
|
t |= uint64(buf[i+0]&0x7F) << bs
|
|
|
|
bs += 7
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
|
|
|
|
l = t
|
|
|
|
|
|
|
|
}
|
|
|
|
d.Name = string(buf[i+0 : i+0+l])
|
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bs := uint8(7)
|
|
|
|
t := uint64(buf[i+0] & 0x7F)
|
|
|
|
for buf[i+0]&0x80 == 0x80 {
|
|
|
|
i++
|
|
|
|
t |= uint64(buf[i+0]&0x7F) << bs
|
|
|
|
bs += 7
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
|
|
|
|
l = t
|
|
|
|
|
|
|
|
}
|
|
|
|
d.Host = string(buf[i+0 : i+0+l])
|
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bs := uint8(7)
|
|
|
|
t := uint64(buf[i+0] & 0x7F)
|
|
|
|
for buf[i+0]&0x80 == 0x80 {
|
|
|
|
i++
|
|
|
|
t |= uint64(buf[i+0]&0x7F) << bs
|
|
|
|
bs += 7
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
|
|
|
|
l = t
|
|
|
|
|
|
|
|
}
|
|
|
|
d.Port = string(buf[i+0 : i+0+l])
|
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
d.TLS = buf[i+0] == 1
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bs := uint8(7)
|
|
|
|
t := uint64(buf[i+1] & 0x7F)
|
|
|
|
for buf[i+1]&0x80 == 0x80 {
|
|
|
|
i++
|
|
|
|
t |= uint64(buf[i+1]&0x7F) << bs
|
|
|
|
bs += 7
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
|
|
|
|
l = t
|
|
|
|
|
|
|
|
}
|
2020-05-23 06:05:37 +00:00
|
|
|
d.ServerPassword = string(buf[i+1 : i+1+l])
|
2016-01-22 17:30:47 +00:00
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bs := uint8(7)
|
|
|
|
t := uint64(buf[i+1] & 0x7F)
|
|
|
|
for buf[i+1]&0x80 == 0x80 {
|
|
|
|
i++
|
|
|
|
t |= uint64(buf[i+1]&0x7F) << bs
|
|
|
|
bs += 7
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
|
|
|
|
l = t
|
|
|
|
|
|
|
|
}
|
|
|
|
d.Nick = string(buf[i+1 : i+1+l])
|
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bs := uint8(7)
|
|
|
|
t := uint64(buf[i+1] & 0x7F)
|
|
|
|
for buf[i+1]&0x80 == 0x80 {
|
|
|
|
i++
|
|
|
|
t |= uint64(buf[i+1]&0x7F) << bs
|
|
|
|
bs += 7
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
|
|
|
|
l = t
|
|
|
|
|
|
|
|
}
|
|
|
|
d.Username = string(buf[i+1 : i+1+l])
|
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bs := uint8(7)
|
|
|
|
t := uint64(buf[i+1] & 0x7F)
|
|
|
|
for buf[i+1]&0x80 == 0x80 {
|
|
|
|
i++
|
|
|
|
t |= uint64(buf[i+1]&0x7F) << bs
|
|
|
|
bs += 7
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
|
|
|
|
l = t
|
|
|
|
|
|
|
|
}
|
|
|
|
d.Realname = string(buf[i+1 : i+1+l])
|
|
|
|
i += l
|
|
|
|
}
|
2020-05-23 06:05:37 +00:00
|
|
|
{
|
|
|
|
l := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bs := uint8(7)
|
|
|
|
t := uint64(buf[i+1] & 0x7F)
|
|
|
|
for buf[i+1]&0x80 == 0x80 {
|
|
|
|
i++
|
|
|
|
t |= uint64(buf[i+1]&0x7F) << bs
|
|
|
|
bs += 7
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
|
|
|
|
l = t
|
|
|
|
|
|
|
|
}
|
|
|
|
d.Account = string(buf[i+1 : i+1+l])
|
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bs := uint8(7)
|
|
|
|
t := uint64(buf[i+1] & 0x7F)
|
|
|
|
for buf[i+1]&0x80 == 0x80 {
|
|
|
|
i++
|
|
|
|
t |= uint64(buf[i+1]&0x7F) << bs
|
|
|
|
bs += 7
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
|
|
|
|
l = t
|
|
|
|
|
|
|
|
}
|
|
|
|
d.Password = string(buf[i+1 : i+1+l])
|
|
|
|
i += l
|
|
|
|
}
|
2016-01-22 17:30:47 +00:00
|
|
|
return i + 1, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Channel) Size() (s uint64) {
|
|
|
|
|
|
|
|
{
|
2020-06-15 08:58:51 +00:00
|
|
|
l := uint64(len(d.Network))
|
2016-01-22 17:30:47 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := l
|
|
|
|
for t >= 0x80 {
|
2017-04-19 00:07:31 +00:00
|
|
|
t >>= 7
|
2016-01-22 17:30:47 +00:00
|
|
|
s++
|
|
|
|
}
|
|
|
|
s++
|
|
|
|
|
|
|
|
}
|
|
|
|
s += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Name))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := l
|
|
|
|
for t >= 0x80 {
|
2017-04-19 00:07:31 +00:00
|
|
|
t >>= 7
|
2016-01-22 17:30:47 +00:00
|
|
|
s++
|
|
|
|
}
|
|
|
|
s++
|
|
|
|
|
|
|
|
}
|
|
|
|
s += l
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
func (d *Channel) Marshal(buf []byte) ([]byte, error) {
|
|
|
|
size := d.Size()
|
|
|
|
{
|
|
|
|
if uint64(cap(buf)) >= size {
|
|
|
|
buf = buf[:size]
|
|
|
|
} else {
|
|
|
|
buf = make([]byte, size)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i := uint64(0)
|
|
|
|
|
|
|
|
{
|
2020-06-15 08:58:51 +00:00
|
|
|
l := uint64(len(d.Network))
|
2016-01-22 17:30:47 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := uint64(l)
|
|
|
|
|
|
|
|
for t >= 0x80 {
|
|
|
|
buf[i+0] = byte(t) | 0x80
|
|
|
|
t >>= 7
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
buf[i+0] = byte(t)
|
|
|
|
i++
|
|
|
|
|
|
|
|
}
|
2020-06-15 08:58:51 +00:00
|
|
|
copy(buf[i+0:], d.Network)
|
2016-01-22 17:30:47 +00:00
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Name))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := uint64(l)
|
|
|
|
|
|
|
|
for t >= 0x80 {
|
|
|
|
buf[i+0] = byte(t) | 0x80
|
|
|
|
t >>= 7
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
buf[i+0] = byte(t)
|
|
|
|
i++
|
|
|
|
|
|
|
|
}
|
|
|
|
copy(buf[i+0:], d.Name)
|
|
|
|
i += l
|
|
|
|
}
|
|
|
|
return buf[:i+0], nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Channel) Unmarshal(buf []byte) (uint64, error) {
|
|
|
|
i := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
l := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bs := uint8(7)
|
|
|
|
t := uint64(buf[i+0] & 0x7F)
|
|
|
|
for buf[i+0]&0x80 == 0x80 {
|
|
|
|
i++
|
|
|
|
t |= uint64(buf[i+0]&0x7F) << bs
|
|
|
|
bs += 7
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
|
|
|
|
l = t
|
|
|
|
|
|
|
|
}
|
2020-06-15 08:58:51 +00:00
|
|
|
d.Network = string(buf[i+0 : i+0+l])
|
2016-01-22 17:30:47 +00:00
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bs := uint8(7)
|
|
|
|
t := uint64(buf[i+0] & 0x7F)
|
|
|
|
for buf[i+0]&0x80 == 0x80 {
|
|
|
|
i++
|
|
|
|
t |= uint64(buf[i+0]&0x7F) << bs
|
|
|
|
bs += 7
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
|
|
|
|
l = t
|
|
|
|
|
|
|
|
}
|
|
|
|
d.Name = string(buf[i+0 : i+0+l])
|
|
|
|
i += l
|
|
|
|
}
|
|
|
|
return i + 0, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Message) Size() (s uint64) {
|
|
|
|
|
2017-04-20 03:32:22 +00:00
|
|
|
{
|
|
|
|
l := uint64(len(d.ID))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := l
|
|
|
|
for t >= 0x80 {
|
|
|
|
t >>= 7
|
|
|
|
s++
|
|
|
|
}
|
|
|
|
s++
|
|
|
|
|
|
|
|
}
|
|
|
|
s += l
|
|
|
|
}
|
2016-01-22 17:30:47 +00:00
|
|
|
{
|
|
|
|
l := uint64(len(d.From))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := l
|
|
|
|
for t >= 0x80 {
|
2017-04-19 00:07:31 +00:00
|
|
|
t >>= 7
|
2016-01-22 17:30:47 +00:00
|
|
|
s++
|
|
|
|
}
|
|
|
|
s++
|
|
|
|
|
|
|
|
}
|
|
|
|
s += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Content))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := l
|
|
|
|
for t >= 0x80 {
|
2017-04-19 00:07:31 +00:00
|
|
|
t >>= 7
|
2016-01-22 17:30:47 +00:00
|
|
|
s++
|
|
|
|
}
|
|
|
|
s++
|
|
|
|
|
|
|
|
}
|
|
|
|
s += l
|
|
|
|
}
|
2020-06-03 01:04:38 +00:00
|
|
|
{
|
|
|
|
l := uint64(len(d.Events))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := l
|
|
|
|
for t >= 0x80 {
|
|
|
|
t >>= 7
|
|
|
|
s++
|
|
|
|
}
|
|
|
|
s++
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for k0 := range d.Events {
|
|
|
|
|
|
|
|
{
|
|
|
|
s += d.Events[k0].Size()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2017-04-20 03:32:22 +00:00
|
|
|
s += 8
|
2016-01-22 17:30:47 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
func (d *Message) Marshal(buf []byte) ([]byte, error) {
|
|
|
|
size := d.Size()
|
|
|
|
{
|
|
|
|
if uint64(cap(buf)) >= size {
|
|
|
|
buf = buf[:size]
|
|
|
|
} else {
|
|
|
|
buf = make([]byte, size)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i := uint64(0)
|
|
|
|
|
|
|
|
{
|
2017-04-20 03:32:22 +00:00
|
|
|
l := uint64(len(d.ID))
|
2016-01-22 17:30:47 +00:00
|
|
|
|
2017-04-20 03:32:22 +00:00
|
|
|
{
|
2016-01-22 17:30:47 +00:00
|
|
|
|
2017-04-20 03:32:22 +00:00
|
|
|
t := uint64(l)
|
|
|
|
|
|
|
|
for t >= 0x80 {
|
|
|
|
buf[i+0] = byte(t) | 0x80
|
|
|
|
t >>= 7
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
buf[i+0] = byte(t)
|
|
|
|
i++
|
|
|
|
|
|
|
|
}
|
|
|
|
copy(buf[i+0:], d.ID)
|
|
|
|
i += l
|
2016-01-22 17:30:47 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(len(d.From))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := uint64(l)
|
|
|
|
|
|
|
|
for t >= 0x80 {
|
2017-04-20 03:32:22 +00:00
|
|
|
buf[i+0] = byte(t) | 0x80
|
2016-01-22 17:30:47 +00:00
|
|
|
t >>= 7
|
|
|
|
i++
|
|
|
|
}
|
2017-04-20 03:32:22 +00:00
|
|
|
buf[i+0] = byte(t)
|
2016-01-22 17:30:47 +00:00
|
|
|
i++
|
|
|
|
|
|
|
|
}
|
2017-04-20 03:32:22 +00:00
|
|
|
copy(buf[i+0:], d.From)
|
2016-01-22 17:30:47 +00:00
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Content))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := uint64(l)
|
|
|
|
|
|
|
|
for t >= 0x80 {
|
2017-04-20 03:32:22 +00:00
|
|
|
buf[i+0] = byte(t) | 0x80
|
2016-01-22 17:30:47 +00:00
|
|
|
t >>= 7
|
|
|
|
i++
|
|
|
|
}
|
2017-04-20 03:32:22 +00:00
|
|
|
buf[i+0] = byte(t)
|
2016-01-22 17:30:47 +00:00
|
|
|
i++
|
|
|
|
|
|
|
|
}
|
2017-04-20 03:32:22 +00:00
|
|
|
copy(buf[i+0:], d.Content)
|
2016-01-22 17:30:47 +00:00
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
|
2017-04-20 03:32:22 +00:00
|
|
|
*(*int64)(unsafe.Pointer(&buf[i+0])) = d.Time
|
2016-01-22 17:30:47 +00:00
|
|
|
|
|
|
|
}
|
2020-06-03 01:04:38 +00:00
|
|
|
{
|
|
|
|
l := uint64(len(d.Events))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := uint64(l)
|
|
|
|
|
|
|
|
for t >= 0x80 {
|
|
|
|
buf[i+8] = byte(t) | 0x80
|
|
|
|
t >>= 7
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
buf[i+8] = byte(t)
|
|
|
|
i++
|
|
|
|
|
|
|
|
}
|
|
|
|
for k0 := range d.Events {
|
|
|
|
|
|
|
|
{
|
|
|
|
nbuf, err := d.Events[k0].Marshal(buf[i+8:])
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
i += uint64(len(nbuf))
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2017-04-20 03:32:22 +00:00
|
|
|
return buf[:i+8], nil
|
2016-01-22 17:30:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Message) Unmarshal(buf []byte) (uint64, error) {
|
|
|
|
i := uint64(0)
|
|
|
|
|
|
|
|
{
|
2017-04-20 03:32:22 +00:00
|
|
|
l := uint64(0)
|
2016-01-22 17:30:47 +00:00
|
|
|
|
2017-04-20 03:32:22 +00:00
|
|
|
{
|
2016-01-22 17:30:47 +00:00
|
|
|
|
2017-04-20 03:32:22 +00:00
|
|
|
bs := uint8(7)
|
|
|
|
t := uint64(buf[i+0] & 0x7F)
|
|
|
|
for buf[i+0]&0x80 == 0x80 {
|
|
|
|
i++
|
|
|
|
t |= uint64(buf[i+0]&0x7F) << bs
|
|
|
|
bs += 7
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
|
|
|
|
l = t
|
|
|
|
|
|
|
|
}
|
|
|
|
d.ID = string(buf[i+0 : i+0+l])
|
|
|
|
i += l
|
2016-01-22 17:30:47 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bs := uint8(7)
|
2017-04-20 03:32:22 +00:00
|
|
|
t := uint64(buf[i+0] & 0x7F)
|
|
|
|
for buf[i+0]&0x80 == 0x80 {
|
2016-01-22 17:30:47 +00:00
|
|
|
i++
|
2017-04-20 03:32:22 +00:00
|
|
|
t |= uint64(buf[i+0]&0x7F) << bs
|
2016-01-22 17:30:47 +00:00
|
|
|
bs += 7
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
|
|
|
|
l = t
|
|
|
|
|
|
|
|
}
|
2017-04-20 03:32:22 +00:00
|
|
|
d.From = string(buf[i+0 : i+0+l])
|
2016-01-22 17:30:47 +00:00
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bs := uint8(7)
|
2017-04-20 03:32:22 +00:00
|
|
|
t := uint64(buf[i+0] & 0x7F)
|
|
|
|
for buf[i+0]&0x80 == 0x80 {
|
2016-01-22 17:30:47 +00:00
|
|
|
i++
|
2017-04-20 03:32:22 +00:00
|
|
|
t |= uint64(buf[i+0]&0x7F) << bs
|
2016-01-22 17:30:47 +00:00
|
|
|
bs += 7
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
|
|
|
|
l = t
|
|
|
|
|
|
|
|
}
|
2017-04-20 03:32:22 +00:00
|
|
|
d.Content = string(buf[i+0 : i+0+l])
|
2016-01-22 17:30:47 +00:00
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
|
2017-04-20 03:32:22 +00:00
|
|
|
d.Time = *(*int64)(unsafe.Pointer(&buf[i+0]))
|
2016-01-22 17:30:47 +00:00
|
|
|
|
2020-06-03 01:04:38 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bs := uint8(7)
|
|
|
|
t := uint64(buf[i+8] & 0x7F)
|
|
|
|
for buf[i+8]&0x80 == 0x80 {
|
|
|
|
i++
|
|
|
|
t |= uint64(buf[i+8]&0x7F) << bs
|
|
|
|
bs += 7
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
|
|
|
|
l = t
|
|
|
|
|
|
|
|
}
|
|
|
|
if uint64(cap(d.Events)) >= l {
|
|
|
|
d.Events = d.Events[:l]
|
|
|
|
} else {
|
|
|
|
d.Events = make([]Event, l)
|
|
|
|
}
|
|
|
|
for k0 := range d.Events {
|
|
|
|
|
|
|
|
{
|
|
|
|
ni, err := d.Events[k0].Unmarshal(buf[i+8:])
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
i += ni
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return i + 8, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Event) Size() (s uint64) {
|
|
|
|
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Type))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := l
|
|
|
|
for t >= 0x80 {
|
|
|
|
t >>= 7
|
|
|
|
s++
|
|
|
|
}
|
|
|
|
s++
|
|
|
|
|
|
|
|
}
|
|
|
|
s += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Params))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := l
|
|
|
|
for t >= 0x80 {
|
|
|
|
t >>= 7
|
|
|
|
s++
|
|
|
|
}
|
|
|
|
s++
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for k0 := range d.Params {
|
|
|
|
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Params[k0]))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := l
|
|
|
|
for t >= 0x80 {
|
|
|
|
t >>= 7
|
|
|
|
s++
|
|
|
|
}
|
|
|
|
s++
|
|
|
|
|
|
|
|
}
|
|
|
|
s += l
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
s += 8
|
|
|
|
return
|
|
|
|
}
|
|
|
|
func (d *Event) Marshal(buf []byte) ([]byte, error) {
|
|
|
|
size := d.Size()
|
|
|
|
{
|
|
|
|
if uint64(cap(buf)) >= size {
|
|
|
|
buf = buf[:size]
|
|
|
|
} else {
|
|
|
|
buf = make([]byte, size)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Type))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := uint64(l)
|
|
|
|
|
|
|
|
for t >= 0x80 {
|
|
|
|
buf[i+0] = byte(t) | 0x80
|
|
|
|
t >>= 7
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
buf[i+0] = byte(t)
|
|
|
|
i++
|
|
|
|
|
|
|
|
}
|
|
|
|
copy(buf[i+0:], d.Type)
|
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Params))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := uint64(l)
|
|
|
|
|
|
|
|
for t >= 0x80 {
|
|
|
|
buf[i+0] = byte(t) | 0x80
|
|
|
|
t >>= 7
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
buf[i+0] = byte(t)
|
|
|
|
i++
|
|
|
|
|
|
|
|
}
|
|
|
|
for k0 := range d.Params {
|
|
|
|
|
|
|
|
{
|
|
|
|
l := uint64(len(d.Params[k0]))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t := uint64(l)
|
|
|
|
|
|
|
|
for t >= 0x80 {
|
|
|
|
buf[i+0] = byte(t) | 0x80
|
|
|
|
t >>= 7
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
buf[i+0] = byte(t)
|
|
|
|
i++
|
|
|
|
|
|
|
|
}
|
|
|
|
copy(buf[i+0:], d.Params[k0])
|
|
|
|
i += l
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
|
|
|
|
*(*int64)(unsafe.Pointer(&buf[i+0])) = d.Time
|
|
|
|
|
|
|
|
}
|
|
|
|
return buf[:i+8], nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Event) Unmarshal(buf []byte) (uint64, error) {
|
|
|
|
i := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
l := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bs := uint8(7)
|
|
|
|
t := uint64(buf[i+0] & 0x7F)
|
|
|
|
for buf[i+0]&0x80 == 0x80 {
|
|
|
|
i++
|
|
|
|
t |= uint64(buf[i+0]&0x7F) << bs
|
|
|
|
bs += 7
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
|
|
|
|
l = t
|
|
|
|
|
|
|
|
}
|
|
|
|
d.Type = string(buf[i+0 : i+0+l])
|
|
|
|
i += l
|
|
|
|
}
|
|
|
|
{
|
|
|
|
l := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bs := uint8(7)
|
|
|
|
t := uint64(buf[i+0] & 0x7F)
|
|
|
|
for buf[i+0]&0x80 == 0x80 {
|
|
|
|
i++
|
|
|
|
t |= uint64(buf[i+0]&0x7F) << bs
|
|
|
|
bs += 7
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
|
|
|
|
l = t
|
|
|
|
|
|
|
|
}
|
|
|
|
if uint64(cap(d.Params)) >= l {
|
|
|
|
d.Params = d.Params[:l]
|
|
|
|
} else {
|
|
|
|
d.Params = make([]string, l)
|
|
|
|
}
|
|
|
|
for k0 := range d.Params {
|
|
|
|
|
|
|
|
{
|
|
|
|
l := uint64(0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bs := uint8(7)
|
|
|
|
t := uint64(buf[i+0] & 0x7F)
|
|
|
|
for buf[i+0]&0x80 == 0x80 {
|
|
|
|
i++
|
|
|
|
t |= uint64(buf[i+0]&0x7F) << bs
|
|
|
|
bs += 7
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
|
|
|
|
l = t
|
|
|
|
|
|
|
|
}
|
|
|
|
d.Params[k0] = string(buf[i+0 : i+0+l])
|
|
|
|
i += l
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
|
|
|
|
d.Time = *(*int64)(unsafe.Pointer(&buf[i+0]))
|
|
|
|
|
2016-01-22 17:30:47 +00:00
|
|
|
}
|
2017-04-20 03:32:22 +00:00
|
|
|
return i + 8, nil
|
2016-01-22 17:30:47 +00:00
|
|
|
}
|