a geicko-2 based round robin ranking system designed to test c++ battleship submissions
battleship.dunkirk.sh
1package sshfx
2
3// ExtensionPair defines the extension-pair type defined in draft-ietf-secsh-filexfer-13.
4// This type is backwards-compatible with how draft-ietf-secsh-filexfer-02 defines extensions.
5//
6// Defined in: https://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-4.2
7type ExtensionPair struct {
8 Name string
9 Data string
10}
11
12// Len returns the number of bytes e would marshal into.
13func (e *ExtensionPair) Len() int {
14 return 4 + len(e.Name) + 4 + len(e.Data)
15}
16
17// MarshalInto marshals e onto the end of the given Buffer.
18func (e *ExtensionPair) MarshalInto(buf *Buffer) {
19 buf.AppendString(e.Name)
20 buf.AppendString(e.Data)
21}
22
23// MarshalBinary returns e as the binary encoding of e.
24func (e *ExtensionPair) MarshalBinary() ([]byte, error) {
25 buf := NewBuffer(make([]byte, 0, e.Len()))
26 e.MarshalInto(buf)
27 return buf.Bytes(), nil
28}
29
30// UnmarshalFrom unmarshals an ExtensionPair from the given Buffer into e.
31func (e *ExtensionPair) UnmarshalFrom(buf *Buffer) (err error) {
32 *e = ExtensionPair{
33 Name: buf.ConsumeString(),
34 Data: buf.ConsumeString(),
35 }
36
37 return buf.Err
38}
39
40// UnmarshalBinary decodes the binary encoding of ExtensionPair into e.
41func (e *ExtensionPair) UnmarshalBinary(data []byte) error {
42 return e.UnmarshalFrom(NewBuffer(data))
43}