amf

package
v1.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AMF0 = 0x00
	AMF3 = 0x03
)
View Source
const (
	AMF0_NUMBER_MARKER         = 0x00
	AMF0_BOOLEAN_MARKER        = 0x01
	AMF0_STRING_MARKER         = 0x02
	AMF0_OBJECT_MARKER         = 0x03
	AMF0_MOVIECLIP_MARKER      = 0x04
	AMF0_NULL_MARKER           = 0x05
	AMF0_UNDEFINED_MARKER      = 0x06
	AMF0_REFERENCE_MARKER      = 0x07
	AMF0_ECMA_ARRAY_MARKER     = 0x08
	AMF0_OBJECT_END_MARKER     = 0x09
	AMF0_STRICT_ARRAY_MARKER   = 0x0a
	AMF0_DATE_MARKER           = 0x0b
	AMF0_LONG_STRING_MARKER    = 0x0c
	AMF0_UNSUPPORTED_MARKER    = 0x0d
	AMF0_RECORDSET_MARKER      = 0x0e
	AMF0_XML_DOCUMENT_MARKER   = 0x0f
	AMF0_TYPED_OBJECT_MARKER   = 0x10
	AMF0_ACMPLUS_OBJECT_MARKER = 0x11
)
View Source
const (
	AMF0_BOOLEAN_FALSE = 0x00
	AMF0_BOOLEAN_TRUE  = 0x01
	AMF0_STRING_MAX    = 65535
	AMF3_INTEGER_MAX   = 536870911
)
View Source
const (
	AMF3_UNDEFINED_MARKER = 0x00
	AMF3_NULL_MARKER      = 0x01
	AMF3_FALSE_MARKER     = 0x02
	AMF3_TRUE_MARKER      = 0x03
	AMF3_INTEGER_MARKER   = 0x04
	AMF3_DOUBLE_MARKER    = 0x05
	AMF3_STRING_MARKER    = 0x06
	AMF3_XMLDOC_MARKER    = 0x07
	AMF3_DATE_MARKER      = 0x08
	AMF3_ARRAY_MARKER     = 0x09
	AMF3_OBJECT_MARKER    = 0x0a
	AMF3_XMLSTRING_MARKER = 0x0b
	AMF3_BYTEARRAY_MARKER = 0x0c
)
View Source
const (
	ADD = 0x0
	DEL = 0x3
)
View Source
const (
	SetDataFrame string = "@setDataFrame"
	OnMetaData   string = "onMetaData"
)

Variables

This section is empty.

Functions

func AssertMarker

func AssertMarker(r io.Reader, checkMarker bool, m byte) error

func Dump

func Dump(label string, val interface{}) error

func DumpBytes

func DumpBytes(label string, buf []byte, size int)

func MetaDataReform

func MetaDataReform(p []byte, flag uint8) ([]byte, error)

func ReadByte

func ReadByte(r io.Reader) (byte, error)

func ReadBytes

func ReadBytes(r io.Reader, n int) ([]byte, error)

func ReadMarker

func ReadMarker(r io.Reader) (byte, error)

func WriteByte

func WriteByte(w io.Writer, b byte) (err error)

func WriteBytes

func WriteBytes(w io.Writer, bytes []byte) (int, error)

func WriteMarker

func WriteMarker(w io.Writer, m byte) error

Types

type Array

type Array []interface{}

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

func NewDecoder

func NewDecoder() *Decoder

func (*Decoder) Decode

func (d *Decoder) Decode(r io.Reader, ver Version) (interface{}, error)

func (*Decoder) DecodeAmf0

func (d *Decoder) DecodeAmf0(r io.Reader) (interface{}, error)

amf0 polymorphic router

func (*Decoder) DecodeAmf0Boolean

func (d *Decoder) DecodeAmf0Boolean(r io.Reader, decodeMarker bool) (result bool, err error)

marker: 1 byte 0x01 format: 1 byte, 0x00 = false, 0x01 = true

func (*Decoder) DecodeAmf0Date

func (d *Decoder) DecodeAmf0Date(r io.Reader, decodeMarker bool) (result float64, err error)

marker: 1 byte 0x0b format: - normal number format:

  • 8 byte big endian float64

- 2 byte unused

func (*Decoder) DecodeAmf0EcmaArray

func (d *Decoder) DecodeAmf0EcmaArray(r io.Reader, decodeMarker bool) (Object, error)

marker: 1 byte 0x08 format: - 4 byte big endian uint32 with length of associative array - normal object format:

  • loop encoded string followed by encoded value
  • terminated with empty string followed by 1 byte 0x09

func (*Decoder) DecodeAmf0LongString

func (d *Decoder) DecodeAmf0LongString(r io.Reader, decodeMarker bool) (result string, err error)

marker: 1 byte 0x0c format: - 4 byte big endian uint32 header to determine size - n (size) byte utf8 string

func (*Decoder) DecodeAmf0Null

func (d *Decoder) DecodeAmf0Null(r io.Reader, decodeMarker bool) (result interface{}, err error)

marker: 1 byte 0x05 no additional data

func (*Decoder) DecodeAmf0Number

func (d *Decoder) DecodeAmf0Number(r io.Reader, decodeMarker bool) (result float64, err error)

marker: 1 byte 0x00 format: 8 byte big endian float64

func (*Decoder) DecodeAmf0Object

func (d *Decoder) DecodeAmf0Object(r io.Reader, decodeMarker bool) (Object, error)

marker: 1 byte 0x03 format: - loop encoded string followed by encoded value - terminated with empty string followed by 1 byte 0x09

func (*Decoder) DecodeAmf0StrictArray

func (d *Decoder) DecodeAmf0StrictArray(r io.Reader, decodeMarker bool) (result Array, err error)

marker: 1 byte 0x0a format: - 4 byte big endian uint32 to determine length of associative array - n (length) encoded values

func (*Decoder) DecodeAmf0String

func (d *Decoder) DecodeAmf0String(r io.Reader, decodeMarker bool) (result string, err error)

marker: 1 byte 0x02 format: - 2 byte big endian uint16 header to determine size - n (size) byte utf8 string

func (*Decoder) DecodeAmf0TypedObject

func (d *Decoder) DecodeAmf0TypedObject(r io.Reader, decodeMarker bool) (TypedObject, error)

marker: 1 byte 0x10 format: - normal string format:

  • 2 byte big endian uint16 header to determine size
  • n (size) byte utf8 string

- normal object format:

  • loop encoded string followed by encoded value
  • terminated with empty string followed by 1 byte 0x09

func (*Decoder) DecodeAmf0Undefined

func (d *Decoder) DecodeAmf0Undefined(r io.Reader, decodeMarker bool) (result interface{}, err error)

marker: 1 byte 0x06 no additional data

func (*Decoder) DecodeAmf0Unsupported

func (d *Decoder) DecodeAmf0Unsupported(r io.Reader, decodeMarker bool) (result interface{}, err error)

marker: 1 byte 0x0d no additional data

func (*Decoder) DecodeAmf0XmlDocument

func (d *Decoder) DecodeAmf0XmlDocument(r io.Reader, decodeMarker bool) (result string, err error)

marker: 1 byte 0x0f format: - normal long string format

  • 4 byte big endian uint32 header to determine size
  • n (size) byte utf8 string

func (*Decoder) DecodeAmf3

func (d *Decoder) DecodeAmf3(r io.Reader) (interface{}, error)

amf3 polymorphic router

func (*Decoder) DecodeAmf3Array

func (d *Decoder) DecodeAmf3Array(r io.Reader, decodeMarker bool) (result Array, err error)

marker: 1 byte 0x09 format: - u29 reference int. if reference, no more data. - string representing associative array if present - n values (length of u29)

func (*Decoder) DecodeAmf3ByteArray

func (d *Decoder) DecodeAmf3ByteArray(r io.Reader, decodeMarker bool) (result []byte, err error)

marker: 1 byte 0x0c format:

  • u29 reference int. if reference, no more data. if not reference, length value of bytes to read.

func (*Decoder) DecodeAmf3Date

func (d *Decoder) DecodeAmf3Date(r io.Reader, decodeMarker bool) (result time.Time, err error)

marker: 1 byte 0x08 format: - u29 reference int, if reference, no more data - timestamp double

func (*Decoder) DecodeAmf3Double

func (d *Decoder) DecodeAmf3Double(r io.Reader, decodeMarker bool) (result float64, err error)

marker: 1 byte 0x05

func (*Decoder) DecodeAmf3False

func (d *Decoder) DecodeAmf3False(r io.Reader, decodeMarker bool) (result bool, err error)

marker: 1 byte 0x02 no additional data

func (*Decoder) DecodeAmf3Integer

func (d *Decoder) DecodeAmf3Integer(r io.Reader, decodeMarker bool) (result int32, err error)

marker: 1 byte 0x04

func (*Decoder) DecodeAmf3Null

func (d *Decoder) DecodeAmf3Null(r io.Reader, decodeMarker bool) (result interface{}, err error)

marker: 1 byte 0x01 no additional data

func (*Decoder) DecodeAmf3Object

func (d *Decoder) DecodeAmf3Object(r io.Reader, decodeMarker bool) (result interface{}, err error)

marker: 1 byte 0x09 format: oh dear god

func (*Decoder) DecodeAmf3String

func (d *Decoder) DecodeAmf3String(r io.Reader, decodeMarker bool) (result string, err error)

marker: 1 byte 0x06 format:

  • u29 reference int. if reference, no more data. if not reference, length value of bytes to read to complete string.

func (*Decoder) DecodeAmf3True

func (d *Decoder) DecodeAmf3True(r io.Reader, decodeMarker bool) (result bool, err error)

marker: 1 byte 0x03 no additional data

func (*Decoder) DecodeAmf3Undefined

func (d *Decoder) DecodeAmf3Undefined(r io.Reader, decodeMarker bool) (result interface{}, err error)

marker: 1 byte 0x00 no additional data

func (*Decoder) DecodeAmf3Xml

func (d *Decoder) DecodeAmf3Xml(r io.Reader, decodeMarker bool) (result string, err error)

marker: 1 byte 0x07 or 0x0b format:

  • u29 reference int. if reference, no more data. if not reference, length value of bytes to read to complete string.

func (*Decoder) DecodeBatch

func (d *Decoder) DecodeBatch(r io.Reader, ver Version) (ret []interface{}, err error)

func (*Decoder) RegisterExternalHandler

func (d *Decoder) RegisterExternalHandler(name string, f ExternalHandler)

type Encoder

type Encoder struct {
}

func (*Encoder) Encode

func (e *Encoder) Encode(w io.Writer, val interface{}, ver Version) (int, error)

func (*Encoder) EncodeAmf0

func (e *Encoder) EncodeAmf0(w io.Writer, val interface{}) (int, error)

amf0 polymorphic router

func (*Encoder) EncodeAmf0Amf3Marker

func (e *Encoder) EncodeAmf0Amf3Marker(w io.Writer) error

marker: 1 byte 0x11

func (*Encoder) EncodeAmf0Boolean

func (e *Encoder) EncodeAmf0Boolean(w io.Writer, val bool, encodeMarker bool) (n int, err error)

marker: 1 byte 0x01 format: 1 byte, 0x00 = false, 0x01 = true

func (*Encoder) EncodeAmf0EcmaArray

func (e *Encoder) EncodeAmf0EcmaArray(w io.Writer, val Object, encodeMarker bool) (n int, err error)

marker: 1 byte 0x08 format: - 4 byte big endian uint32 with length of associative array - normal object format:

  • loop encoded string followed by encoded value
  • terminated with empty string followed by 1 byte 0x09

func (*Encoder) EncodeAmf0LongString

func (e *Encoder) EncodeAmf0LongString(w io.Writer, val string, encodeMarker bool) (n int, err error)

marker: 1 byte 0x0c format: - 4 byte big endian uint32 header to determine size - n (size) byte utf8 string

func (*Encoder) EncodeAmf0Null

func (e *Encoder) EncodeAmf0Null(w io.Writer, encodeMarker bool) (n int, err error)

marker: 1 byte 0x05 no additional data

func (*Encoder) EncodeAmf0Number

func (e *Encoder) EncodeAmf0Number(w io.Writer, val float64, encodeMarker bool) (n int, err error)

marker: 1 byte 0x00 format: 8 byte big endian float64

func (*Encoder) EncodeAmf0Object

func (e *Encoder) EncodeAmf0Object(w io.Writer, val Object, encodeMarker bool) (n int, err error)

marker: 1 byte 0x03 format: - loop encoded string followed by encoded value - terminated with empty string followed by 1 byte 0x09

func (*Encoder) EncodeAmf0StrictArray

func (e *Encoder) EncodeAmf0StrictArray(w io.Writer, val Array, encodeMarker bool) (n int, err error)

marker: 1 byte 0x0a format: - 4 byte big endian uint32 to determine length of associative array - n (length) encoded values

func (*Encoder) EncodeAmf0String

func (e *Encoder) EncodeAmf0String(w io.Writer, val string, encodeMarker bool) (n int, err error)

marker: 1 byte 0x02 format: - 2 byte big endian uint16 header to determine size - n (size) byte utf8 string

func (*Encoder) EncodeAmf0Undefined

func (e *Encoder) EncodeAmf0Undefined(w io.Writer, encodeMarker bool) (n int, err error)

marker: 1 byte 0x06 no additional data

func (*Encoder) EncodeAmf0Unsupported

func (e *Encoder) EncodeAmf0Unsupported(w io.Writer, encodeMarker bool) (n int, err error)

marker: 1 byte 0x0d no additional data

func (*Encoder) EncodeAmf3

func (e *Encoder) EncodeAmf3(w io.Writer, val interface{}) (int, error)

func (*Encoder) EncodeAmf3Array

func (e *Encoder) EncodeAmf3Array(w io.Writer, val Array, encodeMarker bool) (n int, err error)

marker: 1 byte 0x09 format: - u29 reference int. if reference, no more data. - string representing associative array if present - n values (length of u29)

func (*Encoder) EncodeAmf3ByteArray

func (e *Encoder) EncodeAmf3ByteArray(w io.Writer, val []byte, encodeMarker bool) (n int, err error)

marker: 1 byte 0x0c format:

  • u29 reference int. if reference, no more data. if not reference, length value of bytes to read .

func (*Encoder) EncodeAmf3Date

func (e *Encoder) EncodeAmf3Date(w io.Writer, val time.Time, encodeMarker bool) (n int, err error)

marker: 1 byte 0x08 format: - u29 reference int, if reference, no more data - timestamp double

func (*Encoder) EncodeAmf3Double

func (e *Encoder) EncodeAmf3Double(w io.Writer, val float64, encodeMarker bool) (n int, err error)

marker: 1 byte 0x05

func (*Encoder) EncodeAmf3False

func (e *Encoder) EncodeAmf3False(w io.Writer, encodeMarker bool) (n int, err error)

marker: 1 byte 0x02 no additional data

func (*Encoder) EncodeAmf3Integer

func (e *Encoder) EncodeAmf3Integer(w io.Writer, val uint32, encodeMarker bool) (n int, err error)

marker: 1 byte 0x04

func (*Encoder) EncodeAmf3Null

func (e *Encoder) EncodeAmf3Null(w io.Writer, encodeMarker bool) (n int, err error)

marker: 1 byte 0x01 no additional data

func (*Encoder) EncodeAmf3Object

func (e *Encoder) EncodeAmf3Object(w io.Writer, val TypedObject, encodeMarker bool) (n int, err error)

marker: 1 byte 0x0a format: ugh

func (*Encoder) EncodeAmf3String

func (e *Encoder) EncodeAmf3String(w io.Writer, val string, encodeMarker bool) (n int, err error)

marker: 1 byte 0x06 format:

  • u29 reference int. if reference, no more data. if not reference, length value of bytes to read to complete string.

func (*Encoder) EncodeAmf3True

func (e *Encoder) EncodeAmf3True(w io.Writer, encodeMarker bool) (n int, err error)

marker: 1 byte 0x03 no additional data

func (*Encoder) EncodeAmf3Undefined

func (e *Encoder) EncodeAmf3Undefined(w io.Writer, encodeMarker bool) (n int, err error)

marker: 1 byte 0x00 no additional data

func (*Encoder) EncodeBatch

func (e *Encoder) EncodeBatch(w io.Writer, ver Version, val ...interface{}) (int, error)

type ExternalHandler

type ExternalHandler func(*Decoder, io.Reader) (interface{}, error)

type Object

type Object map[string]interface{}

type Trait

type Trait struct {
	Type           string
	Externalizable bool
	Dynamic        bool
	Properties     []string
}

func NewTrait

func NewTrait() *Trait

type TypedObject

type TypedObject struct {
	Type   string
	Object Object
}

func NewTypedObject

func NewTypedObject() *TypedObject

type Version

type Version uint8

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL