2020-08-18 09:01:08 +00:00
|
|
|
package session
|
|
|
|
|
|
|
|
import (
|
2021-11-16 17:30:55 +00:00
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/rpc/message"
|
2020-11-13 13:40:00 +00:00
|
|
|
session "github.com/nspcc-dev/neofs-api-go/v2/session/grpc"
|
2021-11-16 17:30:55 +00:00
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/util/proto"
|
2020-11-13 13:40:00 +00:00
|
|
|
goproto "google.golang.org/protobuf/proto"
|
2020-08-18 09:01:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2020-08-20 10:32:02 +00:00
|
|
|
createReqBodyOwnerField = 1
|
|
|
|
createReqBodyExpirationField = 2
|
2020-08-18 09:01:08 +00:00
|
|
|
|
|
|
|
createRespBodyIDField = 1
|
|
|
|
createRespBodyKeyField = 2
|
2020-08-20 10:32:02 +00:00
|
|
|
|
|
|
|
xheaderKeyField = 1
|
|
|
|
xheaderValueField = 2
|
|
|
|
|
|
|
|
lifetimeExpirationField = 1
|
|
|
|
lifetimeNotValidBeforeField = 2
|
|
|
|
lifetimeIssuedAtField = 3
|
|
|
|
|
2022-09-16 15:09:25 +00:00
|
|
|
objectCtxVerbField = 1
|
|
|
|
objectCtxTargetField = 2
|
2020-08-20 10:32:02 +00:00
|
|
|
|
|
|
|
sessionTokenBodyIDField = 1
|
|
|
|
sessionTokenBodyOwnerField = 2
|
|
|
|
sessionTokenBodyLifetimeField = 3
|
|
|
|
sessionTokenBodyKeyField = 4
|
|
|
|
sessionTokenBodyObjectCtxField = 5
|
2021-05-24 14:46:39 +00:00
|
|
|
sessionTokenBodyCnrCtxField = 6
|
2020-08-20 10:32:02 +00:00
|
|
|
|
|
|
|
sessionTokenBodyField = 1
|
|
|
|
sessionTokenSignatureField = 2
|
|
|
|
|
|
|
|
reqMetaHeaderVersionField = 1
|
|
|
|
reqMetaHeaderEpochField = 2
|
|
|
|
reqMetaHeaderTTLField = 3
|
|
|
|
reqMetaHeaderXHeadersField = 4
|
|
|
|
reqMetaHeaderSessionTokenField = 5
|
|
|
|
reqMetaHeaderBearerTokenField = 6
|
|
|
|
reqMetaHeaderOriginField = 7
|
2022-01-13 12:25:03 +00:00
|
|
|
reqMetaHeaderNetMagicField = 8
|
2020-08-20 10:32:02 +00:00
|
|
|
|
|
|
|
reqVerifHeaderBodySignatureField = 1
|
|
|
|
reqVerifHeaderMetaSignatureField = 2
|
|
|
|
reqVerifHeaderOriginSignatureField = 3
|
|
|
|
reqVerifHeaderOriginField = 4
|
|
|
|
|
|
|
|
respMetaHeaderVersionField = 1
|
|
|
|
respMetaHeaderEpochField = 2
|
|
|
|
respMetaHeaderTTLField = 3
|
|
|
|
respMetaHeaderXHeadersField = 4
|
|
|
|
respMetaHeaderOriginField = 5
|
2021-11-06 10:40:15 +00:00
|
|
|
respMetaHeaderStatusField = 6
|
2020-08-20 10:32:02 +00:00
|
|
|
|
|
|
|
respVerifHeaderBodySignatureField = 1
|
|
|
|
respVerifHeaderMetaSignatureField = 2
|
|
|
|
respVerifHeaderOriginSignatureField = 3
|
|
|
|
respVerifHeaderOriginField = 4
|
2020-08-18 09:01:08 +00:00
|
|
|
)
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (c *CreateRequestBody) StableMarshal(buf []byte) []byte {
|
2020-08-18 09:01:08 +00:00
|
|
|
if c == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2020-08-18 09:01:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, c.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
var offset int
|
2020-08-18 09:01:08 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
offset += proto.NestedStructureMarshal(createReqBodyOwnerField, buf[offset:], c.ownerID)
|
2022-03-12 12:20:19 +00:00
|
|
|
proto.UInt64Marshal(createReqBodyExpirationField, buf[offset:], c.expiration)
|
2020-08-18 09:01:08 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2020-08-18 09:01:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *CreateRequestBody) StableSize() (size int) {
|
|
|
|
if c == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
size += proto.NestedStructureSize(createReqBodyOwnerField, c.ownerID)
|
2020-08-20 10:32:02 +00:00
|
|
|
size += proto.UInt64Size(createReqBodyExpirationField, c.expiration)
|
2020-08-18 09:01:08 +00:00
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (c *CreateRequestBody) Unmarshal(data []byte) error {
|
|
|
|
return message.Unmarshal(c, data, new(session.CreateRequest_Body))
|
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (c *CreateResponseBody) StableMarshal(buf []byte) []byte {
|
2020-08-18 09:01:08 +00:00
|
|
|
if c == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2020-08-18 09:01:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, c.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
var offset int
|
2020-08-18 09:01:08 +00:00
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
offset += proto.BytesMarshal(createRespBodyIDField, buf[offset:], c.id)
|
|
|
|
proto.BytesMarshal(createRespBodyKeyField, buf[offset:], c.sessionKey)
|
2020-08-18 09:01:08 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2020-08-18 09:01:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *CreateResponseBody) StableSize() (size int) {
|
|
|
|
if c == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
size += proto.BytesSize(createRespBodyIDField, c.id)
|
|
|
|
size += proto.BytesSize(createRespBodyKeyField, c.sessionKey)
|
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (c *CreateResponseBody) Unmarshal(data []byte) error {
|
|
|
|
return message.Unmarshal(c, data, new(session.CreateResponse_Body))
|
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (x *XHeader) StableMarshal(buf []byte) []byte {
|
2020-08-20 10:32:02 +00:00
|
|
|
if x == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, x.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
var offset int
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
offset += proto.StringMarshal(xheaderKeyField, buf[offset:], x.key)
|
|
|
|
proto.StringMarshal(xheaderValueField, buf[offset:], x.val)
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (x *XHeader) StableSize() (size int) {
|
|
|
|
if x == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
size += proto.StringSize(xheaderKeyField, x.key)
|
|
|
|
size += proto.StringSize(xheaderValueField, x.val)
|
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
2020-11-13 13:58:08 +00:00
|
|
|
func (x *XHeader) Unmarshal(data []byte) error {
|
|
|
|
m := new(session.XHeader)
|
|
|
|
if err := goproto.Unmarshal(data, m); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return x.FromGRPCMessage(m)
|
2020-11-13 13:58:08 +00:00
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (l *TokenLifetime) StableMarshal(buf []byte) []byte {
|
2020-08-20 10:32:02 +00:00
|
|
|
if l == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, l.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
var offset int
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
offset += proto.UInt64Marshal(lifetimeExpirationField, buf[offset:], l.exp)
|
|
|
|
offset += proto.UInt64Marshal(lifetimeNotValidBeforeField, buf[offset:], l.nbf)
|
|
|
|
proto.UInt64Marshal(lifetimeIssuedAtField, buf[offset:], l.iat)
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (l *TokenLifetime) StableSize() (size int) {
|
|
|
|
if l == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
size += proto.UInt64Size(lifetimeExpirationField, l.exp)
|
|
|
|
size += proto.UInt64Size(lifetimeNotValidBeforeField, l.nbf)
|
|
|
|
size += proto.UInt64Size(lifetimeIssuedAtField, l.iat)
|
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
2020-11-13 13:43:54 +00:00
|
|
|
func (l *TokenLifetime) Unmarshal(data []byte) error {
|
|
|
|
m := new(session.SessionToken_Body_TokenLifetime)
|
|
|
|
if err := goproto.Unmarshal(data, m); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return l.FromGRPCMessage(m)
|
2020-11-13 13:43:54 +00:00
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (c *ObjectSessionContext) StableMarshal(buf []byte) []byte {
|
2020-08-20 10:32:02 +00:00
|
|
|
if c == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, c.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-09-16 15:09:25 +00:00
|
|
|
offset := proto.EnumMarshal(objectCtxVerbField, buf, int32(c.verb))
|
|
|
|
proto.NestedStructureMarshal(objectCtxTargetField, buf[offset:], &objectSessionContextTarget{
|
|
|
|
cnr: c.cnr,
|
|
|
|
objs: c.objs,
|
|
|
|
})
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *ObjectSessionContext) StableSize() (size int) {
|
|
|
|
if c == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
size += proto.EnumSize(objectCtxVerbField, int32(c.verb))
|
2022-09-16 15:09:25 +00:00
|
|
|
size += proto.NestedStructureSize(objectCtxTargetField, &objectSessionContextTarget{
|
|
|
|
cnr: c.cnr,
|
|
|
|
objs: c.objs,
|
|
|
|
})
|
2020-08-20 10:32:02 +00:00
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
2020-11-13 13:40:00 +00:00
|
|
|
func (c *ObjectSessionContext) Unmarshal(data []byte) error {
|
|
|
|
m := new(session.ObjectSessionContext)
|
|
|
|
if err := goproto.Unmarshal(data, m); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return c.FromGRPCMessage(m)
|
2020-11-13 13:40:00 +00:00
|
|
|
}
|
|
|
|
|
2021-05-24 14:46:39 +00:00
|
|
|
const (
|
|
|
|
_ = iota
|
|
|
|
cnrCtxVerbFNum
|
|
|
|
cnrCtxWildcardFNum
|
|
|
|
cnrCtxCidFNum
|
|
|
|
)
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (x *ContainerSessionContext) StableMarshal(buf []byte) []byte {
|
2021-05-24 14:46:39 +00:00
|
|
|
if x == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2021-05-24 14:46:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, x.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
var offset int
|
2021-05-24 14:46:39 +00:00
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
offset += proto.EnumMarshal(cnrCtxVerbFNum, buf[offset:], int32(ContainerSessionVerbToGRPCField(x.verb)))
|
|
|
|
offset += proto.BoolMarshal(cnrCtxWildcardFNum, buf[offset:], x.wildcard)
|
|
|
|
proto.NestedStructureMarshal(cnrCtxCidFNum, buf[offset:], x.cid)
|
2021-05-24 14:46:39 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2021-05-24 14:46:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (x *ContainerSessionContext) StableSize() (size int) {
|
|
|
|
if x == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
size += proto.EnumSize(cnrCtxVerbFNum, int32(ContainerSessionVerbToGRPCField(x.verb)))
|
|
|
|
size += proto.BoolSize(cnrCtxWildcardFNum, x.wildcard)
|
|
|
|
size += proto.NestedStructureSize(cnrCtxCidFNum, x.cid)
|
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *ContainerSessionContext) Unmarshal(data []byte) error {
|
|
|
|
return message.Unmarshal(x, data, new(session.ContainerSessionContext))
|
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (t *TokenBody) StableMarshal(buf []byte) []byte {
|
2020-08-20 10:32:02 +00:00
|
|
|
if t == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, t.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
var offset int
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
offset += proto.BytesMarshal(sessionTokenBodyIDField, buf[offset:], t.id)
|
2022-04-05 08:24:34 +00:00
|
|
|
offset += proto.NestedStructureMarshal(sessionTokenBodyOwnerField, buf[offset:], t.ownerID)
|
|
|
|
offset += proto.NestedStructureMarshal(sessionTokenBodyLifetimeField, buf[offset:], t.lifetime)
|
2022-03-12 12:20:19 +00:00
|
|
|
offset += proto.BytesMarshal(sessionTokenBodyKeyField, buf[offset:], t.sessionKey)
|
2020-08-20 10:32:02 +00:00
|
|
|
|
|
|
|
if t.ctx != nil {
|
|
|
|
switch v := t.ctx.(type) {
|
|
|
|
case *ObjectSessionContext:
|
2022-04-05 08:24:34 +00:00
|
|
|
proto.NestedStructureMarshal(sessionTokenBodyObjectCtxField, buf[offset:], v)
|
2021-05-24 14:46:39 +00:00
|
|
|
case *ContainerSessionContext:
|
2022-04-05 08:24:34 +00:00
|
|
|
proto.NestedStructureMarshal(sessionTokenBodyCnrCtxField, buf[offset:], v)
|
2020-08-20 10:32:02 +00:00
|
|
|
default:
|
|
|
|
panic("cannot marshal unknown session token context")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *TokenBody) StableSize() (size int) {
|
2020-08-20 10:32:02 +00:00
|
|
|
if t == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
size += proto.BytesSize(sessionTokenBodyIDField, t.id)
|
|
|
|
size += proto.NestedStructureSize(sessionTokenBodyOwnerField, t.ownerID)
|
|
|
|
size += proto.NestedStructureSize(sessionTokenBodyLifetimeField, t.lifetime)
|
|
|
|
size += proto.BytesSize(sessionTokenBodyKeyField, t.sessionKey)
|
|
|
|
|
|
|
|
if t.ctx != nil {
|
|
|
|
switch v := t.ctx.(type) {
|
|
|
|
case *ObjectSessionContext:
|
|
|
|
size += proto.NestedStructureSize(sessionTokenBodyObjectCtxField, v)
|
2021-05-24 14:46:39 +00:00
|
|
|
case *ContainerSessionContext:
|
|
|
|
size += proto.NestedStructureSize(sessionTokenBodyCnrCtxField, v)
|
2020-08-20 10:32:02 +00:00
|
|
|
default:
|
|
|
|
panic("cannot marshal unknown session token context")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *TokenBody) Unmarshal(data []byte) error {
|
2020-11-13 13:49:46 +00:00
|
|
|
m := new(session.SessionToken_Body)
|
|
|
|
if err := goproto.Unmarshal(data, m); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return t.FromGRPCMessage(m)
|
2020-11-13 13:49:46 +00:00
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (t *Token) StableMarshal(buf []byte) []byte {
|
2020-08-20 10:32:02 +00:00
|
|
|
if t == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, t.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
var offset int
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
offset += proto.NestedStructureMarshal(sessionTokenBodyField, buf[offset:], t.body)
|
|
|
|
proto.NestedStructureMarshal(sessionTokenSignatureField, buf[offset:], t.sig)
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *Token) StableSize() (size int) {
|
2020-08-20 10:32:02 +00:00
|
|
|
if t == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
size += proto.NestedStructureSize(sessionTokenBodyField, t.body)
|
|
|
|
size += proto.NestedStructureSize(sessionTokenSignatureField, t.sig)
|
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *Token) Unmarshal(data []byte) error {
|
2020-11-13 13:53:42 +00:00
|
|
|
m := new(session.SessionToken)
|
|
|
|
if err := goproto.Unmarshal(data, m); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return t.FromGRPCMessage(m)
|
2020-11-13 13:53:42 +00:00
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (r *RequestMetaHeader) StableMarshal(buf []byte) []byte {
|
2020-08-20 10:32:02 +00:00
|
|
|
if r == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, r.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
var offset int
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
offset += proto.NestedStructureMarshal(reqMetaHeaderVersionField, buf[offset:], r.version)
|
2022-03-12 12:20:19 +00:00
|
|
|
offset += proto.UInt64Marshal(reqMetaHeaderEpochField, buf[offset:], r.epoch)
|
|
|
|
offset += proto.UInt32Marshal(reqMetaHeaderTTLField, buf[offset:], r.ttl)
|
2020-08-20 10:32:02 +00:00
|
|
|
|
|
|
|
for i := range r.xHeaders {
|
2022-04-05 08:24:34 +00:00
|
|
|
offset += proto.NestedStructureMarshal(reqMetaHeaderXHeadersField, buf[offset:], &r.xHeaders[i])
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
offset += proto.NestedStructureMarshal(reqMetaHeaderSessionTokenField, buf[offset:], r.sessionToken)
|
|
|
|
offset += proto.NestedStructureMarshal(reqMetaHeaderBearerTokenField, buf[offset:], r.bearerToken)
|
|
|
|
offset += proto.NestedStructureMarshal(reqMetaHeaderOriginField, buf[offset:], r.origin)
|
2022-03-12 12:20:19 +00:00
|
|
|
proto.UInt64Marshal(reqMetaHeaderNetMagicField, buf[offset:], r.netMagic)
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RequestMetaHeader) StableSize() (size int) {
|
|
|
|
if r == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
if r.version != nil {
|
|
|
|
size += proto.NestedStructureSize(reqMetaHeaderVersionField, r.version)
|
|
|
|
}
|
|
|
|
|
|
|
|
size += proto.UInt64Size(reqMetaHeaderEpochField, r.epoch)
|
|
|
|
size += proto.UInt32Size(reqMetaHeaderTTLField, r.ttl)
|
|
|
|
|
|
|
|
for i := range r.xHeaders {
|
2022-03-02 08:01:03 +00:00
|
|
|
size += proto.NestedStructureSize(reqMetaHeaderXHeadersField, &r.xHeaders[i])
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
size += proto.NestedStructureSize(reqMetaHeaderSessionTokenField, r.sessionToken)
|
|
|
|
size += proto.NestedStructureSize(reqMetaHeaderBearerTokenField, r.bearerToken)
|
|
|
|
size += proto.NestedStructureSize(reqMetaHeaderOriginField, r.origin)
|
2022-01-13 12:25:03 +00:00
|
|
|
size += proto.UInt64Size(reqMetaHeaderNetMagicField, r.netMagic)
|
2020-08-20 10:32:02 +00:00
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
2020-11-13 14:02:30 +00:00
|
|
|
func (r *RequestMetaHeader) Unmarshal(data []byte) error {
|
|
|
|
m := new(session.RequestMetaHeader)
|
|
|
|
if err := goproto.Unmarshal(data, m); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.FromGRPCMessage(m)
|
2020-11-13 14:02:30 +00:00
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (r *RequestVerificationHeader) StableMarshal(buf []byte) []byte {
|
2020-08-20 10:32:02 +00:00
|
|
|
if r == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, r.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
var offset int
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
offset += proto.NestedStructureMarshal(reqVerifHeaderBodySignatureField, buf[offset:], r.bodySig)
|
|
|
|
offset += proto.NestedStructureMarshal(reqVerifHeaderMetaSignatureField, buf[offset:], r.metaSig)
|
|
|
|
offset += proto.NestedStructureMarshal(reqVerifHeaderOriginSignatureField, buf[offset:], r.originSig)
|
|
|
|
proto.NestedStructureMarshal(reqVerifHeaderOriginField, buf[offset:], r.origin)
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RequestVerificationHeader) StableSize() (size int) {
|
|
|
|
if r == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
size += proto.NestedStructureSize(reqVerifHeaderBodySignatureField, r.bodySig)
|
|
|
|
size += proto.NestedStructureSize(reqVerifHeaderMetaSignatureField, r.metaSig)
|
|
|
|
size += proto.NestedStructureSize(reqVerifHeaderOriginSignatureField, r.originSig)
|
|
|
|
size += proto.NestedStructureSize(reqVerifHeaderOriginField, r.origin)
|
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
2020-11-13 14:07:49 +00:00
|
|
|
func (r *RequestVerificationHeader) Unmarshal(data []byte) error {
|
|
|
|
m := new(session.RequestVerificationHeader)
|
|
|
|
if err := goproto.Unmarshal(data, m); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.FromGRPCMessage(m)
|
2020-11-13 14:07:49 +00:00
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (r *ResponseMetaHeader) StableMarshal(buf []byte) []byte {
|
2020-08-20 10:32:02 +00:00
|
|
|
if r == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, r.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
var offset int
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
offset += proto.NestedStructureMarshal(respMetaHeaderVersionField, buf[offset:], r.version)
|
2022-03-12 12:20:19 +00:00
|
|
|
offset += proto.UInt64Marshal(respMetaHeaderEpochField, buf[offset:], r.epoch)
|
|
|
|
offset += proto.UInt32Marshal(respMetaHeaderTTLField, buf[offset:], r.ttl)
|
2020-08-20 10:32:02 +00:00
|
|
|
|
|
|
|
for i := range r.xHeaders {
|
2022-04-05 08:24:34 +00:00
|
|
|
offset += proto.NestedStructureMarshal(respMetaHeaderXHeadersField, buf[offset:], &r.xHeaders[i])
|
2021-11-06 10:40:15 +00:00
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
offset += proto.NestedStructureMarshal(respMetaHeaderOriginField, buf[offset:], r.origin)
|
|
|
|
proto.NestedStructureMarshal(respMetaHeaderStatusField, buf[offset:], r.status)
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ResponseMetaHeader) StableSize() (size int) {
|
|
|
|
if r == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
if r.version != nil {
|
|
|
|
size += proto.NestedStructureSize(respMetaHeaderVersionField, r.version)
|
|
|
|
}
|
|
|
|
|
|
|
|
size += proto.UInt64Size(respMetaHeaderEpochField, r.epoch)
|
|
|
|
size += proto.UInt32Size(respMetaHeaderTTLField, r.ttl)
|
|
|
|
|
|
|
|
for i := range r.xHeaders {
|
2022-03-02 08:01:03 +00:00
|
|
|
size += proto.NestedStructureSize(respMetaHeaderXHeadersField, &r.xHeaders[i])
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
size += proto.NestedStructureSize(respMetaHeaderOriginField, r.origin)
|
2021-11-06 10:40:15 +00:00
|
|
|
size += proto.NestedStructureSize(respMetaHeaderStatusField, r.status)
|
2020-08-20 10:32:02 +00:00
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
2020-11-13 14:11:09 +00:00
|
|
|
func (r *ResponseMetaHeader) Unmarshal(data []byte) error {
|
|
|
|
m := new(session.ResponseMetaHeader)
|
|
|
|
if err := goproto.Unmarshal(data, m); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.FromGRPCMessage(m)
|
2020-11-13 14:11:09 +00:00
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (r *ResponseVerificationHeader) StableMarshal(buf []byte) []byte {
|
2020-08-20 10:32:02 +00:00
|
|
|
if r == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, r.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
var offset int
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
offset += proto.NestedStructureMarshal(respVerifHeaderBodySignatureField, buf[offset:], r.bodySig)
|
|
|
|
offset += proto.NestedStructureMarshal(respVerifHeaderMetaSignatureField, buf[offset:], r.metaSig)
|
|
|
|
offset += proto.NestedStructureMarshal(respVerifHeaderOriginSignatureField, buf[offset:], r.originSig)
|
|
|
|
proto.NestedStructureMarshal(respVerifHeaderOriginField, buf[offset:], r.origin)
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ResponseVerificationHeader) StableSize() (size int) {
|
|
|
|
if r == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
size += proto.NestedStructureSize(respVerifHeaderBodySignatureField, r.bodySig)
|
|
|
|
size += proto.NestedStructureSize(respVerifHeaderMetaSignatureField, r.metaSig)
|
|
|
|
size += proto.NestedStructureSize(respVerifHeaderOriginSignatureField, r.originSig)
|
|
|
|
size += proto.NestedStructureSize(respVerifHeaderOriginField, r.origin)
|
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
2020-11-13 14:14:43 +00:00
|
|
|
|
|
|
|
func (r *ResponseVerificationHeader) Unmarshal(data []byte) error {
|
|
|
|
m := new(session.ResponseVerificationHeader)
|
|
|
|
if err := goproto.Unmarshal(data, m); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.FromGRPCMessage(m)
|
2020-11-13 14:14:43 +00:00
|
|
|
}
|