Documentation ¶
Index ¶
- Constants
- func MarshalBlockBytes(block BlockData) ([]byte, error)
- type Block
- type BlockData
- type BlockHeader
- type Decoder
- type DecodingError
- type EOFError
- type Frame
- type GenericBlockData
- func (GenericBlockData) IsBlockData()
- func (b *GenericBlockData) Length() uint32
- func (b *GenericBlockData) MarshalBytes() ([]byte, error)
- func (b *GenericBlockData) MarshalJSON() ([]byte, error)
- func (b *GenericBlockData) UnmarshalBytes(data []byte) error
- func (b *GenericBlockData) UnmarshalJSON(data []byte) error
- type Header
- type InvalidFrameLengthError
- type InvalidHeaderError
- type MismatchedReadLengthsError
Constants ¶
const FFXIV_PATCH_VERSION = "4.5"
FFXIV_PATCH_VERSION defines the exact patch version of FFXIV that this library supports. We tie xivnet to this version since the network opcodes usually only change on minor patch version updates and not smaller updates like hotfixes.
Variables ¶
This section is empty.
Functions ¶
func MarshalBlockBytes ¶
MarshalBlockBytes returns the byte representation of the block data
Types ¶
type Block ¶
type Block struct { Length uint32 Header BlockHeader Data BlockData }
Block defines the structure of a block in an FFXIV frame
func (*Block) CorrectLength ¶
func (b *Block) CorrectLength()
CorrectLength computes the true length of the block and sets its Length field
type BlockData ¶
type BlockData interface {
IsBlockData()
}
BlockData defines the interface for the XIVWS representation of FFXIV block data
type BlockHeader ¶
type BlockHeader struct { SubjectID uint32 CurrentID uint32 U1 uint32 U2 uint16 Opcode uint16 Route uint32 Time time.Time U4 uint32 }
BlockHeader defines the type for a 28 byte array
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder implements an FFXIV frame decoder
func NewDecoder ¶
NewDecoder creates a new instance of a decoder
func (*Decoder) CheckHeader ¶
CheckHeader checks to see whether or not the data in the buffer has a valid header
func (*Decoder) Decode ¶
Decode returns a single decoded FFXIV frame from the packet data stored in buf
func (*Decoder) DiscardDataUntilValid ¶
DiscardDataUntilValid will trim off invalid data on the buffered input until it reaches a header that is valid or the buffer has insufficient data. This is useful for when the input stream has been corrupted with some invalid bytes.
type DecodingError ¶
type DecodingError struct {
// contains filtered or unexported fields
}
DecodingError is returned whenenever some error occurs while decoding the frame or some block within the frame.
func (DecodingError) Error ¶
func (e DecodingError) Error() string
type EOFError ¶
type EOFError struct {
// contains filtered or unexported fields
}
EOFError is an error that is returned when there is not enough data to process the packet
type Frame ¶
type Frame struct { Header Header Time time.Time Length uint32 Reserved1 uint16 NumBlocks uint16 Compression uint16 Reserved2 uint32 Reserved3 uint16 Blocks []*Block // contains filtered or unexported fields }
Frame defines the structure for an FFXIV Frame
func (*Frame) CompressBlocks ¶
CompressBlocks prepares the frame for writing by saving an internal representation of the compressed block bytes
func (*Frame) CorrectLength ¶
func (f *Frame) CorrectLength()
CorrectLength corrects the length in the FFXIV frame header. This method assumes all the block header lengths are correct.
func (*Frame) CorrectTimestamps ¶
CorrectTimestamps corrects the timestamps in the FFXIV frame header and its blocks
type GenericBlockData ¶
type GenericBlockData []byte
GenericBlockData defines the type for a variable length byte slice
func GenericBlockDataFromBytes ¶
func GenericBlockDataFromBytes(blockData []byte) *GenericBlockData
GenericBlockDataFromBytes is a helper that creates a GenericBlockData from raw bytes
func (GenericBlockData) IsBlockData ¶
func (GenericBlockData) IsBlockData()
func (*GenericBlockData) Length ¶
func (b *GenericBlockData) Length() uint32
Length returns the length of the block data
func (*GenericBlockData) MarshalBytes ¶
func (b *GenericBlockData) MarshalBytes() ([]byte, error)
MarshalBytes returns the byte representation of the block data
func (*GenericBlockData) MarshalJSON ¶
func (b *GenericBlockData) MarshalJSON() ([]byte, error)
MarshalJSON returns the marshaled version of the BlockHeader
func (*GenericBlockData) UnmarshalBytes ¶
func (b *GenericBlockData) UnmarshalBytes(data []byte) error
UnmarshalBytes sets the block data to the provided raw bytes
func (*GenericBlockData) UnmarshalJSON ¶
func (b *GenericBlockData) UnmarshalJSON(data []byte) error
UnmarshalJSON returns the unmarshaled version of the BlockHeader
type Header ¶
type Header [16]byte
Header defines the type for a 16 byte array
func (*Header) MarshalJSON ¶
MarshalJSON returns the marshaled version of the frame header
func (*Header) UnmarshalJSON ¶
UnmarshalJSON returns the unmarshaled version of the frame header
type InvalidFrameLengthError ¶
type InvalidFrameLengthError struct {
// contains filtered or unexported fields
}
InvalidFrameLength is an error that is returned when the frame specifies a length that is too large. This error guards against the case when garbage or malicious data is read as part of decoding.
func (InvalidFrameLengthError) Error ¶
func (e InvalidFrameLengthError) Error() string
type InvalidHeaderError ¶
type InvalidHeaderError struct {
// contains filtered or unexported fields
}
InvalidHeaderError is an error that is returned when the frame header is not something that is recognized by the decoder. It uses a string as a field to guarantee that the header is copied, so that changes to the original buffer don't affect the error.
func (InvalidHeaderError) Error ¶
func (e InvalidHeaderError) Error() string
type MismatchedReadLengthsError ¶
type MismatchedReadLengthsError struct {
// contains filtered or unexported fields
}
MismatchedReadError is returned when somehow the amount of bytes read doesn't match the requested length. We don't expect this error to happen because we have previously already peeked the required amount of data.
func (MismatchedReadLengthsError) Error ¶
func (e MismatchedReadLengthsError) Error() string