Пример #1
0
func (o QueryV2) encodeXDR(xw *xdr.Writer) (int, error) {
	xw.WriteUint32(o.Magic)
	if len(o.NodeID) > 64 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteString(o.NodeID)
	return xw.Tot(), xw.Error()
}
Пример #2
0
func (o Node) encodeXDR(xw *xdr.Writer) (int, error) {
	if len(o.ID) > 64 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteString(o.ID)
	xw.WriteUint32(o.Flags)
	return xw.Tot(), xw.Error()
}
Пример #3
0
func (o BlockInfo) encodeXDR(xw *xdr.Writer) (int, error) {
	xw.WriteUint32(o.Size)
	if len(o.Hash) > 64 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteBytes(o.Hash)
	return xw.Tot(), xw.Error()
}
Пример #4
0
func (o Address) encodeXDR(xw *xdr.Writer) (int, error) {
	if len(o.IP) > 16 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteBytes(o.IP)
	xw.WriteUint16(o.Port)
	return xw.Tot(), xw.Error()
}
Пример #5
0
func (o IndexMessage) encodeXDR(xw *xdr.Writer) (int, error) {
	if len(o.Repository) > 64 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteString(o.Repository)
	xw.WriteUint32(uint32(len(o.Files)))
	for i := range o.Files {
		o.Files[i].encodeXDR(xw)
	}
	return xw.Tot(), xw.Error()
}
Пример #6
0
func (o AnnounceV2) encodeXDR(xw *xdr.Writer) (int, error) {
	xw.WriteUint32(o.Magic)
	o.This.encodeXDR(xw)
	if len(o.Extra) > 16 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteUint32(uint32(len(o.Extra)))
	for i := range o.Extra {
		o.Extra[i].encodeXDR(xw)
	}
	return xw.Tot(), xw.Error()
}
Пример #7
0
func (o CloseMessage) encodeXDR(xw *xdr.Writer) (int, error) {
	if len(o.Reason) > 1024 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteString(o.Reason)
	return xw.Tot(), xw.Error()
}
Пример #8
0
func (o OptionsMessage) encodeXDR(xw *xdr.Writer) (int, error) {
	if len(o.Options) > 64 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteUint32(uint32(len(o.Options)))
	for i := range o.Options {
		o.Options[i].encodeXDR(xw)
	}
	return xw.Tot(), xw.Error()
}
Пример #9
0
func (o versionList) encodeXDR(xw *xdr.Writer) (int, error) {
	xw.WriteUint32(uint32(len(o.versions)))
	for i := range o.versions {
		o.versions[i].encodeXDR(xw)
	}
	return xw.Tot(), xw.Error()
}
Пример #10
0
func (o Option) encodeXDR(xw *xdr.Writer) (int, error) {
	if len(o.Key) > 64 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteString(o.Key)
	if len(o.Value) > 1024 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteString(o.Value)
	return xw.Tot(), xw.Error()
}
Пример #11
0
func (o Node) encodeXDR(xw *xdr.Writer) (int, error) {
	if len(o.ID) > 32 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteBytes(o.ID)
	xw.WriteUint32(o.Flags)
	xw.WriteUint64(o.MaxVersion)
	return xw.Tot(), xw.Error()
}
Пример #12
0
func (o ClusterConfigMessage) encodeXDR(xw *xdr.Writer) (int, error) {
	if len(o.ClientName) > 64 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteString(o.ClientName)
	if len(o.ClientVersion) > 64 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteString(o.ClientVersion)
	if len(o.Repositories) > 64 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteUint32(uint32(len(o.Repositories)))
	for i := range o.Repositories {
		o.Repositories[i].encodeXDR(xw)
	}
	if len(o.Options) > 64 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteUint32(uint32(len(o.Options)))
	for i := range o.Options {
		o.Options[i].encodeXDR(xw)
	}
	return xw.Tot(), xw.Error()
}
Пример #13
0
func (o RequestMessage) encodeXDR(xw *xdr.Writer) (int, error) {
	if len(o.Repository) > 64 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteString(o.Repository)
	if len(o.Name) > 1024 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteString(o.Name)
	xw.WriteUint64(o.Offset)
	xw.WriteUint32(o.Size)
	return xw.Tot(), xw.Error()
}
Пример #14
0
func (o EmptyMessage) encodeXDR(xw *xdr.Writer) (int, error) {
	return xw.Tot(), xw.Error()
}
Пример #15
0
func (o repeatReader) encodeXDR(xw *xdr.Writer) (int, error) {
	xw.WriteBytes(o.data)
	return xw.Tot(), xw.Error()
}
Пример #16
0
func (e encodableBytes) encodeXDR(xw *xdr.Writer) (int, error) {
	return xw.WriteBytes(e)
}
Пример #17
0
func (o Node) encodeXDR(xw *xdr.Writer) (int, error) {
	if len(o.ID) > 32 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteBytes(o.ID)
	if len(o.Addresses) > 16 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteUint32(uint32(len(o.Addresses)))
	for i := range o.Addresses {
		o.Addresses[i].encodeXDR(xw)
	}
	return xw.Tot(), xw.Error()
}
Пример #18
0
func (o fileVersion) encodeXDR(xw *xdr.Writer) (int, error) {
	xw.WriteUint64(o.version)
	xw.WriteBytes(o.node)
	return xw.Tot(), xw.Error()
}
Пример #19
0
func (o TestStruct) encodeXDR(xw *xdr.Writer) (int, error) {
	xw.WriteUint64(uint64(o.I))
	xw.WriteUint16(uint16(o.I16))
	xw.WriteUint16(o.UI16)
	xw.WriteUint32(uint32(o.I32))
	xw.WriteUint32(o.UI32)
	xw.WriteUint64(uint64(o.I64))
	xw.WriteUint64(o.UI64)
	xw.WriteBytes(o.BS)
	xw.WriteString(o.S)
	return xw.Tot(), xw.Error()
}
Пример #20
0
func (o File) encodeXDR(xw *xdr.Writer) (int, error) {
	xw.WriteString(o.Name)
	xw.WriteUint32(o.Flags)
	xw.WriteUint64(uint64(o.Modified))
	xw.WriteUint64(o.Version)
	xw.WriteUint64(uint64(o.Size))
	xw.WriteUint32(uint32(len(o.Blocks)))
	for i := range o.Blocks {
		o.Blocks[i].encodeXDR(xw)
	}
	xw.WriteBool(o.Suppressed)
	return xw.Tot(), xw.Error()
}
Пример #21
0
func (o FileInfo) encodeXDR(xw *xdr.Writer) (int, error) {
	if len(o.Name) > 1024 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteString(o.Name)
	xw.WriteUint32(o.Flags)
	xw.WriteUint64(uint64(o.Modified))
	xw.WriteUint64(o.Version)
	if len(o.Blocks) > 1000000 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteUint32(uint32(len(o.Blocks)))
	for i := range o.Blocks {
		o.Blocks[i].encodeXDR(xw)
	}
	return xw.Tot(), xw.Error()
}
Пример #22
0
func (o AnnounceV1) encodeXDR(xw *xdr.Writer) (int, error) {
	xw.WriteUint32(o.Magic)
	xw.WriteUint16(o.Port)
	if len(o.NodeID) > 64 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteString(o.NodeID)
	if len(o.IP) > 16 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteBytes(o.IP)
	return xw.Tot(), xw.Error()
}
Пример #23
0
func (o Block) encodeXDR(xw *xdr.Writer) (int, error) {
	xw.WriteUint64(uint64(o.Offset))
	xw.WriteUint32(o.Size)
	xw.WriteBytes(o.Hash)
	return xw.Tot(), xw.Error()
}
Пример #24
0
func (o AnnounceV2) encodeXDR(xw *xdr.Writer) (int, error) {
	xw.WriteUint32(o.Magic)
	if len(o.NodeID) > 64 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteString(o.NodeID)
	if len(o.Addresses) > 16 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteUint32(uint32(len(o.Addresses)))
	for i := range o.Addresses {
		o.Addresses[i].encodeXDR(xw)
	}
	return xw.Tot(), xw.Error()
}
Пример #25
0
func (o ResponseMessage) encodeXDR(xw *xdr.Writer) (int, error) {
	xw.WriteBytes(o.Data)
	return xw.Tot(), xw.Error()
}
Пример #26
0
func (h header) encodeXDR(xw *xdr.Writer) (int, error) {
	u := encodeHeader(h)
	return xw.WriteUint32(u)
}
Пример #27
0
func (o XDRBenchStruct) encodeXDR(xw *xdr.Writer) (int, error) {
	xw.WriteUint64(o.I1)
	xw.WriteUint32(o.I2)
	xw.WriteUint16(o.I3)
	if len(o.Bs0) > 128 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteBytes(o.Bs0)
	xw.WriteBytes(o.Bs1)
	if len(o.S0) > 128 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteString(o.S0)
	xw.WriteString(o.S1)
	return xw.Tot(), xw.Error()
}