2022-08-13 23:55:59 +08:00
|
|
|
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
|
|
|
|
|
|
|
|
|
package iplibrary
|
|
|
|
|
|
2022-08-21 23:09:25 +08:00
|
|
|
import (
|
|
|
|
|
"bytes"
|
|
|
|
|
"encoding/binary"
|
|
|
|
|
)
|
|
|
|
|
|
2022-08-13 23:55:59 +08:00
|
|
|
type ipItem struct {
|
2022-08-21 23:09:25 +08:00
|
|
|
CountryId uint32
|
|
|
|
|
ProvinceId uint32
|
|
|
|
|
CityId uint32
|
|
|
|
|
TownId uint32
|
|
|
|
|
ProviderId uint32
|
|
|
|
|
IPFrom uint64
|
|
|
|
|
IPTo uint64
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *ipItem) AsBinary() ([]byte, error) {
|
|
|
|
|
var buf = &bytes.Buffer{}
|
|
|
|
|
err := binary.Write(buf, binary.BigEndian, this)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return buf.Bytes(), nil
|
2022-08-13 23:55:59 +08:00
|
|
|
}
|