func (o BlockInfo) EncodeXDRInto(xw *xdr.Writer) (int, error) { xw.WriteUint32(uint32(o.Size)) if l := len(o.Hash); l > 64 { return xw.Tot(), xdr.ElementSizeExceeded("Hash", l, 64) } xw.WriteBytes(o.Hash) return xw.Tot(), xw.Error() }
func (o Query) EncodeXDRInto(xw *xdr.Writer) (int, error) { xw.WriteUint32(o.Magic) if l := len(o.DeviceID); l > 32 { return xw.Tot(), xdr.ElementSizeExceeded("DeviceID", l, 32) } xw.WriteBytes(o.DeviceID) return xw.Tot(), xw.Error() }
func (o CloseMessage) EncodeXDRInto(xw *xdr.Writer) (int, error) { if l := len(o.Reason); l > 1024 { return xw.Tot(), xdr.ElementSizeExceeded("Reason", l, 1024) } xw.WriteString(o.Reason) xw.WriteUint32(uint32(o.Code)) return xw.Tot(), xw.Error() }
func (o Query) encodeXDR(xw *xdr.Writer) (int, error) { xw.WriteUint32(o.Magic) if len(o.DeviceID) > 32 { return xw.Tot(), xdr.ErrElementSizeExceeded } xw.WriteBytes(o.DeviceID) return xw.Tot(), xw.Error() }
func (o Address) EncodeXDRInto(xw *xdr.Writer) (int, error) { if l := len(o.IP); l > 16 { return xw.Tot(), xdr.ElementSizeExceeded("IP", l, 16) } xw.WriteBytes(o.IP) xw.WriteUint16(o.Port) return xw.Tot(), xw.Error() }
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() }
func (o Relay) EncodeXDRInto(xw *xdr.Writer) (int, error) { if l := len(o.Address); l > 256 { return xw.Tot(), xdr.ElementSizeExceeded("Address", l, 256) } xw.WriteString(o.Address) xw.WriteUint32(uint32(o.Latency)) return xw.Tot(), xw.Error() }
func (o Relay) EncodeXDRInto(xw *xdr.Writer) (int, error) { if l := len(o.URL); l > 2083 { return xw.Tot(), xdr.ElementSizeExceeded("URL", l, 2083) } xw.WriteString(o.URL) xw.WriteUint32(uint32(o.Latency)) return xw.Tot(), xw.Error() }
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() }
func (o ConnectRequest) EncodeXDRInto(xw *xdr.Writer) (int, error) { if l := len(o.ID); l > 32 { return xw.Tot(), xdr.ElementSizeExceeded("ID", l, 32) } xw.WriteBytes(o.ID) return xw.Tot(), xw.Error() }
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() }
func (o Address) EncodeXDRInto(xw *xdr.Writer) (int, error) { if l := len(o.URL); l > 2083 { return xw.Tot(), xdr.ElementSizeExceeded("URL", l, 2083) } xw.WriteString(o.URL) return xw.Tot(), xw.Error() }
func (o JoinSessionRequest) EncodeXDRInto(xw *xdr.Writer) (int, error) { if l := len(o.Key); l > 32 { return xw.Tot(), xdr.ElementSizeExceeded("Key", l, 32) } xw.WriteBytes(o.Key) return xw.Tot(), xw.Error() }
func (o fileVersion) EncodeXDRInto(xw *xdr.Writer) (int, error) { _, err := o.version.EncodeXDRInto(xw) if err != nil { return xw.Tot(), err } xw.WriteBytes(o.device) return xw.Tot(), xw.Error() }
func (o versionList) EncodeXDRInto(xw *xdr.Writer) (int, error) { xw.WriteUint32(uint32(len(o.versions))) for i := range o.versions { _, err := o.versions[i].EncodeXDRInto(xw) if err != nil { return xw.Tot(), err } } return xw.Tot(), xw.Error() }
func (o addressList) encodeXDR(xw *xdr.Writer) (int, error) { xw.WriteUint32(uint32(len(o.addresses))) for i := range o.addresses { o.addresses[i].encodeXDR(xw) } return xw.Tot(), xw.Error() }
func timeoutWriteHeader(w *xdr.Writer, hdr header) { // This tries to write a message header to w, but times out after a while. // This is useful because in testing, with a PipeWriter, it will block // forever if the other side isn't reading any more. On the other hand we // can't just "go" it into the background, because if the other side is // still there we should wait for the write to complete. Yay. var buf [8]byte // header and message length binary.BigEndian.PutUint32(buf[:], encodeHeader(hdr)) binary.BigEndian.PutUint32(buf[4:], 0) // zero message length, explicitly done := make(chan struct{}) go func() { w.WriteRaw(buf[:]) l.Infoln("write completed") close(done) }() select { case <-done: case <-time.After(250 * time.Millisecond): } }
func (o FileInfoTruncated) encodeXDR(xw *xdr.Writer) (int, error) { if len(o.Name) > 8192 { return xw.Tot(), xdr.ErrElementSizeExceeded } xw.WriteString(o.Name) xw.WriteUint32(o.Flags) xw.WriteUint64(uint64(o.Modified)) xw.WriteUint64(o.Version) xw.WriteUint64(o.LocalVersion) xw.WriteUint32(o.NumBlocks) return xw.Tot(), xw.Error() }
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() }
func (o Device) 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.MaxLocalVersion) return xw.Tot(), xw.Error() }
func (o Folder) encodeXDR(xw *xdr.Writer) (int, error) { if len(o.ID) > 64 { return xw.Tot(), xdr.ErrElementSizeExceeded } xw.WriteString(o.ID) if len(o.Devices) > 64 { return xw.Tot(), xdr.ErrElementSizeExceeded } xw.WriteUint32(uint32(len(o.Devices))) for i := range o.Devices { _, err := o.Devices[i].encodeXDR(xw) if err != nil { return xw.Tot(), err } } return xw.Tot(), xw.Error() }
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.Folders) > 64 { return xw.Tot(), xdr.ErrElementSizeExceeded } xw.WriteUint32(uint32(len(o.Folders))) for i := range o.Folders { _, err := o.Folders[i].encodeXDR(xw) if err != nil { return xw.Tot(), err } } if len(o.Options) > 64 { return xw.Tot(), xdr.ErrElementSizeExceeded } xw.WriteUint32(uint32(len(o.Options))) for i := range o.Options { _, err := o.Options[i].encodeXDR(xw) if err != nil { return xw.Tot(), err } } return xw.Tot(), xw.Error() }
func (o ResponseMessage) encodeXDR(xw *xdr.Writer) (int, error) { xw.WriteBytes(o.Data) return xw.Tot(), xw.Error() }
func (o RequestMessage) encodeXDR(xw *xdr.Writer) (int, error) { if len(o.Folder) > 64 { return xw.Tot(), xdr.ErrElementSizeExceeded } xw.WriteString(o.Folder) if len(o.Name) > 8192 { return xw.Tot(), xdr.ErrElementSizeExceeded } xw.WriteString(o.Name) xw.WriteUint64(o.Offset) xw.WriteUint32(o.Size) return xw.Tot(), xw.Error() }
func (o EmptyMessage) encodeXDR(xw *xdr.Writer) (int, error) { return xw.Tot(), xw.Error() }
func (o FileInfo) encodeXDR(xw *xdr.Writer) (int, error) { if len(o.Name) > 8192 { return xw.Tot(), xdr.ErrElementSizeExceeded } xw.WriteString(o.Name) xw.WriteUint32(o.Flags) xw.WriteUint64(uint64(o.Modified)) xw.WriteUint64(o.Version) xw.WriteUint64(o.LocalVersion) xw.WriteUint32(uint32(len(o.Blocks))) for i := range o.Blocks { _, err := o.Blocks[i].encodeXDR(xw) if err != nil { return xw.Tot(), err } } return xw.Tot(), xw.Error() }
func (o Option) encodeXDR(xw *xdr.Writer) (int, error) { if l := len(o.Key); l > 64 { return xw.Tot(), xdr.ElementSizeExceeded("Key", l, 64) } xw.WriteString(o.Key) if l := len(o.Value); l > 1024 { return xw.Tot(), xdr.ElementSizeExceeded("Value", l, 1024) } xw.WriteString(o.Value) return xw.Tot(), xw.Error() }
func (o IndexMessage) encodeXDR(xw *xdr.Writer) (int, error) { if l := len(o.Folder); l > 64 { return xw.Tot(), xdr.ElementSizeExceeded("Folder", l, 64) } xw.WriteString(o.Folder) xw.WriteUint32(uint32(len(o.Files))) for i := range o.Files { _, err := o.Files[i].encodeXDR(xw) if err != nil { return xw.Tot(), err } } return xw.Tot(), xw.Error() }
func (h header) encodeXDR(xw *xdr.Writer) (int, error) { u := encodeHeader(h) return xw.WriteUint32(u) }
func (o RequestMessage) encodeXDR(xw *xdr.Writer) (int, error) { if l := len(o.Folder); l > 64 { return xw.Tot(), xdr.ElementSizeExceeded("Folder", l, 64) } xw.WriteString(o.Folder) if l := len(o.Name); l > 8192 { return xw.Tot(), xdr.ElementSizeExceeded("Name", l, 8192) } xw.WriteString(o.Name) xw.WriteUint64(o.Offset) xw.WriteUint32(o.Size) return xw.Tot(), xw.Error() }