xivnet

package module
v1.45.2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2019 License: MIT Imports: 13 Imported by: 0

README

xivnet

FFXIV Network Handling Library

A golang parser for incoming or outgoing unencrypted FFXIV network traffic.

Documentation: https://godoc.org/github.com/ff14wed/xivnet

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidHeader = errors.New("invalid header")

ErrInvalidHeader is an error that is returned when the frame header is not something that is recognized by the decoder.

View Source
var ErrNotEnoughData = errors.New("not enough data in packets buffer")

ErrNotEnoughData is an error that is returned when there is not ErrNotEnoughData data to process the packet

Functions

func MarshalBlockBytes

func MarshalBlockBytes(block BlockData) ([]byte, error)

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

func (*Block) Encode

func (b *Block) Encode(w io.Writer) error

Encode writes the byte representation of the block to the output writer

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

func NewDecoder(bufSize int, logger *log.Logger) *Decoder

NewDecoder creates a new instance of a decoder

func (*Decoder) CheckHeader

func (d *Decoder) CheckHeader(buf *bufio.Reader) ([]byte, error)

CheckHeader checks to see whether or not the data in the buffer has a valid header

func (*Decoder) Decode

func (d *Decoder) Decode(buf *bufio.Reader) (*Frame, error)

Decode returns a single decoded FFXIV frame from the packet data stored in buf

func (*Decoder) DiscardDataUntilValid added in v1.44.2

func (d *Decoder) DiscardDataUntilValid(buf *bufio.Reader)

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 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

func (f *Frame) CompressBlocks() error

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

func (f *Frame) CorrectTimestamps(timestamp time.Time)

CorrectTimestamps corrects the timestamps in the FFXIV frame header and its blocks

func (*Frame) Encode

func (f *Frame) Encode(w io.Writer, timestamp time.Time, compress bool) error

Encode writes the byte representation of the frame to the output writer with the given timestamp

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 added in v1.45.2

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 [16]byte

Header defines the type for a 16 byte array

func (*Header) MarshalJSON

func (h *Header) MarshalJSON() ([]byte, error)

MarshalJSON returns the marshaled version of the frame header

func (*Header) UnmarshalJSON

func (h *Header) UnmarshalJSON(data []byte) error

UnmarshalJSON returns the unmarshaled version of the frame header

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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