package hotline import ( "bytes" "encoding/binary" "errors" ) type transfer struct { Protocol [4]byte // "HTXF" 0x48545846 ReferenceNumber [4]byte // Unique ID generated for the transfer DataSize [4]byte // File size RSVD [4]byte // Not implemented in Hotline Protocol } var HTXF = [4]byte{0x48, 0x54, 0x58, 0x46} // (HTXF) is the only supported transfer protocol func (tf *transfer) Write(b []byte) (int, error) { if err := binary.Read(bytes.NewReader(b), binary.BigEndian, tf); err != nil { return 0, err } if tf.Protocol != HTXF { return 0, errors.New("invalid protocol") } return len(b), nil }