peer

package
v0.0.0-...-08d2443 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package peer can be used for communication with Roblox servers and clients, as well as parsing packets captured from Roblox network traffic.

Index

Examples

Constants

View Source
const (
	// CapabilityBasic indicates the base capabilities of a Roblox client
	CapabilityBasic = 0x3E | 0x80
	// CapabilityServerCopiesPlayerGui3 indicates that the server should create and replicate the PlayerGui
	CapabilityServerCopiesPlayerGui3 = 0x40
	// CapabilityDebugForceStreamingEnabled indicates that streaming should be activated regardless
	// of what is reported in ID_SET_GLOBALS
	CapabilityDebugForceStreamingEnabled = 0x100
	// CapabilityIHasMinDistToUnstreamed indicates an unknown capability
	CapabilityIHasMinDistToUnstreamed = 0x400
	// CapabilityReplicateLuau indicates an unknown capability
	CapabilityReplicateLuau = 0x800
	// CapabilityPositionBasedStreaming indicates whether the Character's region should be used for streaming
	CapabilityPositionBasedStreaming = 0x1000
	// CapabilityVersionedIDSync indicates an unknown capability
	CapabilityVersionedIDSync = 0x2000

	CapabilityPubKeyExchange                      = 0x800000
	CapabilitySystemAddressIsPeerId               = 0x200000
	CapabilityStreamingPrefetch                   = 0x1000000
	CapabilityTerrainReplicationUseLargerChunks   = 0x2000000
	CapabilityUseBlake2BHashInSharedString        = 0x100000
	CapabilityUseSharedStringForScriptReplication = 0x200

	CapabilityRoblox = CapabilityBasic | CapabilityServerCopiesPlayerGui3 | CapabilityIHasMinDistToUnstreamed | CapabilityReplicateLuau | CapabilityVersionedIDSync
	CapabilityAll    = CapabilityBasic | CapabilityServerCopiesPlayerGui3 | CapabilityDebugForceStreamingEnabled | CapabilityIHasMinDistToUnstreamed | CapabilityReplicateLuau | CapabilityPositionBasedStreaming | CapabilityVersionedIDSync | CapabilityPubKeyExchange | CapabilitySystemAddressIsPeerId | CapabilityStreamingPrefetch | CapabilityTerrainReplicationUseLargerChunks | CapabilityUseBlake2BHashInSharedString | CapabilityUseSharedStringForScriptReplication
)

The following declarations are to be used with ID_OPEN_CONNECTION_{REQUEST/REPLY}_2 packets

View Source
const (
	// PropertyTypeNil is the type for nil values
	PropertyTypeNil uint8 = iota
	// PropertyTypeString is the type for string values
	PropertyTypeString = iota
	// PropertyTypeStringNoCache is the type for string values that
	// should never be cached
	PropertyTypeStringNoCache = iota
	// PropertyTypeProtectedString0 is a type the purpose of which is unknown
	PropertyTypeProtectedString0 = iota
	// PropertyTypeProtectedString1 is a type the purpose of which is unknown
	PropertyTypeProtectedString1 = iota
	// PropertyTypeProtectedString2 is the type for encrypted
	// ProtectedStrings
	PropertyTypeProtectedString2 = iota
	// PropertyTypeProtectedString3 is the type for unencrypted
	// ProtectedStrings
	PropertyTypeProtectedString3 = iota
	// PropertyTypeEnum is the type for enum values
	PropertyTypeEnum = iota
	// PropertyTypeBinaryString is the type for BinaryString values
	PropertyTypeBinaryString = iota
	// PropertyTypeBool is the type for boolean values
	PropertyTypeBool = iota
	// PropertyTypeInt is the type for 32-bit signed integer values
	PropertyTypeInt = iota
	// PropertyTypeFloat is the type for single-precision floating point values
	PropertyTypeFloat = iota
	// PropertyTypeDouble is the type for double-precision floating point values
	PropertyTypeDouble = iota
	// PropertyTypeUDim is the type for UDim values
	PropertyTypeUDim = iota
	// PropertyTypeUDim2 is the type for UDim2 values
	PropertyTypeUDim2 = iota
	// PropertyTypeRay is the type for Ray values
	PropertyTypeRay = iota
	// PropertyTypeFaces is the type for Faces values
	PropertyTypeFaces = iota
	// PropertyTypeAxes is the type for Axes values
	PropertyTypeAxes = iota
	// PropertyTypeBrickColor is the type for BrickColor values
	PropertyTypeBrickColor = iota
	// PropertyTypeColor3 is the type for floating-point Color3 values
	PropertyTypeColor3 = iota
	// PropertyTypeColor3uint8 is the type for uint8 Color3 values
	PropertyTypeColor3uint8 = iota
	// PropertyTypeVector2 is the type for Vector2 values
	PropertyTypeVector2 = iota
	// PropertyTypeSimpleVector3 is the type for most Vector3 values
	PropertyTypeSimpleVector3 = iota
	// PropertyTypeComplicatedVector3 is the type for Vector3 values that use
	// the "complicated" schema (usage and purpose currently unknown)
	PropertyTypeComplicatedVector3 = iota
	// PropertyTypeVector2int16 is the type for Vector2int16 values
	PropertyTypeVector2int16 = iota
	// PropertyTypeVector3int16 is the type for Vector2int16 values
	PropertyTypeVector3int16 = iota
	// PropertyTypeSimpleCFrame is the type for CFrame values that use
	// the "simple" schema (usage and purpose currently unknown)
	PropertyTypeSimpleCFrame = iota
	// PropertyTypeComplicatedCFrame is the type for most CFrame values
	PropertyTypeComplicatedCFrame = iota
	// PropertyTypeInstance is the type for Reference values
	PropertyTypeInstance = iota
	// PropertyTypeTuple is the type for Tuple values
	PropertyTypeTuple = iota
	// PropertyTypeArray is the type for Array values
	PropertyTypeArray = iota
	// PropertyTypeDictionary is the type for Dictionary values
	PropertyTypeDictionary = iota
	// PropertyTypeMap is the type for Map values
	PropertyTypeMap = iota
	// PropertyTypeContent is the type for Content values
	PropertyTypeContent = iota
	// PropertyTypeSystemAddress is the type for SystemAddress values
	PropertyTypeSystemAddress = iota
	// PropertyTypeNumberSequence is the type for NumberSequence values
	PropertyTypeNumberSequence = iota
	// PropertyTypeNumberSequenceKeypoint is the type for NumberSequenceKeypoint values
	PropertyTypeNumberSequenceKeypoint = iota
	// PropertyTypeNumberRange is the type for NumberRange values
	PropertyTypeNumberRange = iota
	// PropertyTypeColorSequence is the type for ColorSequence values
	PropertyTypeColorSequence = iota
	// PropertyTypeColorSequenceKeypoint is the type for ColorSequenceKeypoint values
	PropertyTypeColorSequenceKeypoint = iota
	// PropertyTypeRect2D is the type for Rect2D values
	PropertyTypeRect2D = iota
	// PropertyTypePhysicalProperties is the type for PhysicalProperties values
	PropertyTypePhysicalProperties = iota
	// PropertyTypeRegion3 is the type for Region3 values
	PropertyTypeRegion3 = iota
	// PropertyTypeRegion3int16 is the type for Region3int16 values
	PropertyTypeRegion3int16 = iota
	// PropertyTypeInt64 is the type for 64-bit signed integer values
	PropertyTypeInt64 = iota
	// PropertyTypePathWaypoint is the type for path waypoints
	PropertyTypePathWaypoint = iota
	// PropertyTypeSharedString is the type for shared strings
	PropertyTypeSharedString = iota
	// PropertyTypeLuauString is the type for Luau ProtectedStrings
	PropertyTypeLuauString = iota
	// PropertyTypeDateTime is the type for DateTime values
	PropertyTypeDateTime = iota
	// PropertyTypeOptimizedString is the type for string values that can be loaded from a lookup table
	PropertyTypeOptimizedString = iota
)
View Source
const (
	// Unreliable is the RakNet UNRELIABLE reliability
	Unreliable = iota
	// UnreliableSequenced is the RakNet UNRELIABLE_SEQUENCED reliability
	UnreliableSequenced
	// Reliable is the RakNet RELIABLE reliability
	Reliable
	// ReliableOrdered is the RakNet RELIABLE_ORDERED reliability
	ReliableOrdered
	// ReliableSequenced is the RakNet RELIABLE_SEQUENCED reliability
	ReliableSequenced
)
View Source
const CameraScript = `` /* 2259-byte string literal not displayed */

CameraScript is the default Lua script to be replicated to server clients

View Source
const MaxJoinDataBytes = 80000

MaxJoinDataBytes tells how many bytes a JoinData layer can use at most Generally speaking, Roblox can usually handle about 100 kB but we set the limit a little lower here to be safe TODO: Move this to JoinDataStreamer?

Variables

View Source
var DefaultPasswordBytes = []byte{0x37, 0x4F, 0x5E, 0x11, 0x6C, 0x45}

DefaultPasswordBytes is the RakNet password used for Roblox connections by default

View Source
var ErrCacheReadOOB = errors.New("cache read is out of bounds")

ErrCacheReadOOB is an error specifying that there was a cache miss, i.e. a cached used before it was initialized

View Source
var OfflineMessageID = []byte{0x00, 0xFF, 0xFF, 0x00, 0xFE, 0xFE, 0xFE, 0xFE, 0xFD, 0xFD, 0xFD, 0xFD, 0x12, 0x34, 0x56, 0x78}

OfflineMessageID is the offline message contained in pre-connection packets.

View Source
var Packet83Subpackets = map[uint8]string{
	0x00: "ID_REPLIC_END",
	0x01: "ID_REPLIC_DELETE_INSTANCE",
	0x02: "ID_REPLIC_NEW_INSTANCE",
	0x03: "ID_REPLIC_PROP",
	0x04: "ID_REPLIC_MARKER",
	0x05: "ID_REPLIC_PING",
	0x06: "ID_REPLIC_PING_BACK",
	0x07: "ID_REPLIC_EVENT",
	0x08: "ID_REPLIC_REQUEST_CHAR",
	0x09: "ID_REPLIC_ROCKY",
	0x0A: "ID_REPLIC_CFRAME_ACK",
	0x0B: "ID_REPLIC_JOIN_DATA",
	0x0C: "ID_REPLIC_UPDATE_CLIENT_QUOTA",
	0x0D: "ID_REPLIC_STREAM_DATA",
	0x0E: "ID_REPLIC_REGION_REMOVAL",
	0x0F: "ID_REPLIC_INSTANCE_REMOVAL",
	0x10: "ID_REPLIC_TAG",
	0x11: "ID_REPLIC_STATS",
	0x12: "ID_REPLIC_HASH",
	0x13: "ID_REPLIC_ATOMIC",
	0x14: "ID_REPLIC_STREAM_DATA_INFO",
}

Packet83Subpackets containts a list of string names for all 0x83 subpackets

View Source
var PacketNames = map[byte]string{
	0x00: "ID_CONNECTED_PING",
	0x01: "ID_UNCONNECTED_PING",
	0x03: "ID_CONNECTED_PONG",
	0x04: "ID_DETECT_LOST_CONNECTIONS",
	0x05: "ID_OPEN_CONNECTION_REQUEST_1",
	0x06: "ID_OPEN_CONNECTION_REPLY_1",
	0x07: "ID_OPEN_CONNECTION_REQUEST_2",
	0x08: "ID_OPEN_CONNECTION_REPLY_2",
	0x09: "ID_CONNECTION_REQUEST",
	0x10: "ID_CONNECTION_REQUEST_ACCEPTED",
	0x11: "ID_CONNECTION_ATTEMPT_FAILED",
	0x13: "ID_NEW_INCOMING_CONNECTION",
	0x15: "ID_DISCONNECTION_NOTIFICATION",
	0x18: "ID_INVALID_PASSWORD",
	0x1B: "ID_TIMESTAMP",
	0x1C: "ID_UNCONNECTED_PONG",
	0x81: "ID_SET_GLOBALS",
	0x82: "ID_TEACH_DESCRIPTOR_DICTIONARIES",
	0x83: "ID_DATA",
	0x84: "ID_MARKER",
	0x85: "ID_PHYSICS",
	0x86: "ID_TOUCHES",
	0x87: "ID_CHAT_ALL",
	0x88: "ID_CHAT_TEAM",
	0x89: "ID_REPORT_ABUSE",
	0x8A: "ID_SUBMIT_TICKET",
	0x8B: "ID_CHAT_GAME",
	0x8C: "ID_CHAT_PLAYER",
	0x8D: "ID_CLUSTER",
	0x8E: "ID_PROTOCOL_MISMATCH",
	0x8F: "ID_PREFERRED_SPAWN_NAME",
	0x90: "ID_PROTOCOL_SYNC",
	0x91: "ID_SCHEMA_SYNC",
	0x92: "ID_PLACEID_VERIFICATION",
	0x93: "ID_DICTIONARY_FORMAT",
	0x94: "ID_HASH_MISMATCH",
	0x95: "ID_SECURITYKEY_MISMATCH",
	0x96: "ID_REQUEST_STATS",
	0x97: "ID_NEW_SCHEMA",
}

PacketNames contains the names of most packet types

View Source
var StudioPasswordBytes = []byte{0x5E, 0x11}

StudioPasswordBytes is the RakNet password used for Studio connections by default

View Source
var TypeNames = map[uint8]string{
	PropertyTypeNil:                    "nil",
	PropertyTypeString:                 "string",
	PropertyTypeStringNoCache:          "string (no cache)",
	PropertyTypeProtectedString0:       "Server ProtectedString",
	PropertyTypeProtectedString1:       "ProtectedString 1",
	PropertyTypeProtectedString2:       "Encrypted ProtectedString",
	PropertyTypeProtectedString3:       "Studio ProtectedString",
	PropertyTypeEnum:                   "Enum",
	PropertyTypeBinaryString:           "BinaryString",
	PropertyTypeBool:                   "bool",
	PropertyTypeInt:                    "sint",
	PropertyTypeFloat:                  "float",
	PropertyTypeDouble:                 "double",
	PropertyTypeUDim:                   "UDim",
	PropertyTypeUDim2:                  "UDim2",
	PropertyTypeRay:                    "Ray",
	PropertyTypeFaces:                  "Faces",
	PropertyTypeAxes:                   "Axes",
	PropertyTypeBrickColor:             "BrickColor",
	PropertyTypeColor3:                 "Color3",
	PropertyTypeColor3uint8:            "Color3uint8",
	PropertyTypeVector2:                "Vector2",
	PropertyTypeSimpleVector3:          "Vector3 (simple)",
	PropertyTypeComplicatedVector3:     "Vector3 (complicated)",
	PropertyTypeVector2int16:           "Vector2uint16",
	PropertyTypeVector3int16:           "Vector3uint16",
	PropertyTypeSimpleCFrame:           "CFrame (simple)",
	PropertyTypeComplicatedCFrame:      "CFrame (complicated)",
	PropertyTypeInstance:               "Instance",
	PropertyTypeTuple:                  "Tuple",
	PropertyTypeArray:                  "Array",
	PropertyTypeDictionary:             "Dictionary",
	PropertyTypeMap:                    "Map",
	PropertyTypeContent:                "Content",
	PropertyTypeSystemAddress:          "SystemAddress",
	PropertyTypeNumberSequence:         "NumberSequence",
	PropertyTypeNumberSequenceKeypoint: "NumberSequenceKeypoint",
	PropertyTypeNumberRange:            "NumberRange",
	PropertyTypeColorSequence:          "ColorSequence",
	PropertyTypeColorSequenceKeypoint:  "ColorSequenceKeypoint",
	PropertyTypeRect2D:                 "Rect2D",
	PropertyTypePhysicalProperties:     "PhysicalProperties",
	PropertyTypeInt64:                  "sint64",
	PropertyTypePathWaypoint:           "PathWaypoint",
	PropertyTypeSharedString:           "SharedString",
	PropertyTypeLuauString:             "Luau ProtectedString",
	PropertyTypeDateTime:               "DateTime",
	PropertyTypeOptimizedString:        "string (optimized)",
}

TypeNames is a list of names for value types

Functions

func IsOfflineMessage

func IsOfflineMessage(data []byte) bool

IsOfflineMessage checks whether the packet payload is an offline message

func ResolveLuaChallenge

func ResolveLuaChallenge(arg1, arg2 int32) int32

ResolveLuaChallenge implements the Luau callback challenge algorithm

Types

type ACKRange

type ACKRange struct {
	Min uint32
	Max uint32
}

ACKRange describes the range of an ACK or an NAK.

type Cache

type Cache interface {
	// Get fetches the object matching a cache index.
	Get(uint8) (interface{}, bool)
	// Put creates a new object in the caches at the specific index.
	Put(interface{}, uint8)
	// Equal compares a cached object and another object and returns if
	// they are equal, and if the indexed object exists.
	Equal(uint8, interface{}) (bool, bool)
	// LastWrite returns the cache index that was last written to.
	LastWrite() uint8
}

Cache represents a network cache that stores repeatable objects such as strings.

type Caches

type Caches struct {
	String StringCache
}

Caches represents a collection of network caches that are used by various packets

type Cell

type Cell struct {
	Material  uint8
	Occupancy uint8
}

Cell represents a terrain cell package

type Chunk

type Chunk struct {
	ChunkIndex datamodel.ValueVector3int32
	SideLength uint32
	Int1       uint8
	CellCube   [][][]Cell
	Mask       [][]uint8
}

Chunk represents a cubic terrain chunk package

func (Chunk) IsCube

func (chunk Chunk) IsCube() bool

IsCube returns a value indicating whether all sides of the chunk match its SideLength. Note that IsCube() returns false if the chunk is empty.

func (Chunk) IsEmpty

func (chunk Chunk) IsEmpty() bool

IsEmpty returns a value indicating whether the chunk is empty, i.e. doesn't contain any non-air cells.

type CommunicationContext

type CommunicationContext struct {
	// InstanceTopScope is the server's default scope that is
	// mainly used by JoinData
	// TODO: make this use a getter and setter instead, so
	// that an error can be reported if it is accessed prematurely
	InstanceTopScope string

	// DataModel represents the hierarchical collection of instances
	// in the context of which the communication takes place
	DataModel *datamodel.DataModel
	// InstancesByReference provides a convenient way to access the DataModel's instances
	// when only their reference is known
	InstancesByReference *datamodel.InstanceList
	// NetworkSchema is the network instance/enum schema used in this communication
	NetworkSchema *NetworkSchema
	// IsStudio
	IsStudio bool
	// SharedStrings contains a dictionary of SharedStrings indexed by their MD5 hash
	SharedStrings map[string]rbxfile.ValueSharedString

	// ScriptKey and CoreScriptKey are decryption keys for the
	// replicated scripts as reported by the server
	ScriptKey     uint32
	CoreScriptKey uint32
	ServerPeerID  uint32

	PlaceID   int64
	VersionID Packet90VersionID
	// contains filtered or unexported fields
}

CommunicationContext represents a network communication's contextual data

func NewCommunicationContext

func NewCommunicationContext() *CommunicationContext

NewCommunicationContext returns a new CommunicationContext

func (*CommunicationContext) GenerateSubmitTicketKey

func (context *CommunicationContext) GenerateSubmitTicketKey() [0x10]byte

GenerateSubmitTicketKey generates a key to be used by ID_SUBMIT_TICKET packets

type ConnectedPeer

type ConnectedPeer struct {
	// Reader is a PacketReader reading packets sent by the peer.
	*DefaultPacketReader
	// Writer is a PacketWriter writing packets to the peer.
	*DefaultPacketWriter
	DestinationAddress *net.UDPAddr
	// contains filtered or unexported fields
}

ConnectedPeer describes a connection to a peer FIXME: ACKs and NAKs are not properly reacted to. create a resend queue before you forget!

func NewConnectedPeer

func NewConnectedPeer(context *CommunicationContext, withClient bool) *ConnectedPeer

NewConnectedPeer returns a new ConnectedPeer instance withClient specifies whether the target of the connection is a client, i.e. if the caller is acting as a server

type ContextualHandler

type ContextualHandler interface {
	SetContext(*CommunicationContext)
	Context() *CommunicationContext
	SetCaches(*Caches)
	Caches() *Caches
	SharedStrings() map[string]rbxfile.ValueSharedString
}

ContextualHandler is a generic interface for structs that provide a CommunicationContext and Caches

type CustomServer

type CustomServer struct {
	Context            *CommunicationContext
	Connection         *net.UDPConn
	Clients            map[string]*ServerClient
	ClientEmitter      *emitter.Emitter
	Address            *net.UDPAddr
	GUID               uint64
	Schema             *NetworkSchema
	InstanceDictionary *datamodel.InstanceDictionary
	RunningContext     context.Context

	PlayerIndex int
}

CustomServer is custom implementation of a Roblox server

func NewCustomServer

func NewCustomServer(ctx context.Context, port uint16, schema *NetworkSchema, dataModel *datamodel.DataModel, dict *datamodel.InstanceDictionary) (*CustomServer, error)

NewCustomServer initializes a CustomServer

func (*CustomServer) Start

func (myServer *CustomServer) Start() error

Start starts the server's read loop

type DataStoreStats

type DataStoreStats struct {
	Enabled                 bool
	GetAsync                uint32
	SetAndIncrementAsync    uint32
	UpdateAsync             uint32
	GetSortedAsync          uint32
	SetIncrementSortedAsync uint32
	OnUpdate                uint32
}

DataStoreStats represents the DataStore stats reported

type DefaultPacketReader

type DefaultPacketReader struct {

	// LayerEmitter provides a low-level interface for receiving packets
	// Topics: full-reliable, offline, reliable, reliability, ack
	LayerEmitter *emitter.Emitter
	// ErrorEmitter is the same as LayerEmitter, except invoked when layers.Error != nil ErrorEmitter *emitter.Emitter
	ErrorEmitter *emitter.Emitter

	// PacketEmitter provides a high-level interface for receiving offline and reliable packets
	// Topics correspond to TypeString() return values
	PacketEmitter *emitter.Emitter

	// DataEmitter provides a high-level interface for receiving ID_DATA subpackets
	// These topics correspond to TypeString() return values
	DataEmitter *emitter.Emitter
	// contains filtered or unexported fields
}

DefaultPacketReader is a struct that can be used to read packets from a source Pass packets in using ReadPacket() and bind to the given callbacks to receive the results

func NewPacketReader

func NewPacketReader() *DefaultPacketReader

NewPacketReader initializes a new DefaultPacketReader

func (*DefaultPacketReader) BindDataModelHandlers

func (reader *DefaultPacketReader) BindDataModelHandlers()

BindDataModelHandlers binds the default handlers so that the PacketReader will update the DataModel based on what it reads

func (*DefaultPacketReader) Caches

func (handler *DefaultPacketReader) Caches() *Caches

func (*DefaultPacketReader) Context

func (handler *DefaultPacketReader) Context() *CommunicationContext

func (*DefaultPacketReader) Errors

func (reader *DefaultPacketReader) Errors() *emitter.Emitter

Errors returns the emitter for parser errors

func (*DefaultPacketReader) HandlePacket01

func (reader *DefaultPacketReader) HandlePacket01(e *emitter.Event)

HandlePacket01 is the default handler for ID_REPLIC_DELETE_INSTANCE packets

func (*DefaultPacketReader) HandlePacket02

func (reader *DefaultPacketReader) HandlePacket02(e *emitter.Event)

HandlePacket02 is the default handler for ID_REPLIC_NEW_INSTANCE packets

func (*DefaultPacketReader) HandlePacket03

func (reader *DefaultPacketReader) HandlePacket03(e *emitter.Event)

HandlePacket03 is the default handler for ID_REPLIC_PROP packets

func (*DefaultPacketReader) HandlePacket07

func (reader *DefaultPacketReader) HandlePacket07(e *emitter.Event)

HandlePacket07 is the default handler fo ID_REPLIC_EVENT packets

func (*DefaultPacketReader) HandlePacket0B

func (reader *DefaultPacketReader) HandlePacket0B(e *emitter.Event)

HandlePacket0B is the default handler for ID_REPLIC_JOIN_DATA packets

func (*DefaultPacketReader) HandlePacket13

func (reader *DefaultPacketReader) HandlePacket13(e *emitter.Event)

HandlePacket13 is the default handler for ID_REPLIC_ATOMIC packets

func (*DefaultPacketReader) HandlePacket81

func (reader *DefaultPacketReader) HandlePacket81(e *emitter.Event)

HandlePacket81 is the default handler for ID_SET_GLOBALS packets

func (*DefaultPacketReader) IsClient

func (reader *DefaultPacketReader) IsClient() bool

IsClient implements PacketReader.IsClient()

func (*DefaultPacketReader) Layers

func (reader *DefaultPacketReader) Layers() *emitter.Emitter

Layers returns the emitter for successfully parsed packets

func (*DefaultPacketReader) ReadPacket

func (reader *DefaultPacketReader) ReadPacket(payload []byte, layers *PacketLayers)

ReadPacket reads a single packet and invokes all according handler functions

func (*DefaultPacketReader) SetCaches

func (handler *DefaultPacketReader) SetCaches(val *Caches)

func (*DefaultPacketReader) SetContext

func (handler *DefaultPacketReader) SetContext(val *CommunicationContext)

func (*DefaultPacketReader) SetIsClient

func (reader *DefaultPacketReader) SetIsClient(val bool)

SetIsClient implements PacketReader.SetIsClient()

func (*DefaultPacketReader) SharedStrings

func (handler *DefaultPacketReader) SharedStrings() map[string]rbxfile.ValueSharedString

type DefaultPacketWriter

type DefaultPacketWriter struct {

	// LayerEmitter provides a low-level interface for hooking into the
	// packet serialization process
	// Topics: full-reliable, offline, reliable, reliability, ack
	LayerEmitter *emitter.Emitter

	// ErrorEmitter never emits anything. It exists for compatibility
	ErrorEmitter *emitter.Emitter

	// Output sends the byte slice to be sent via UDP
	// It uses the "output" topic
	Output *emitter.Emitter
	// contains filtered or unexported fields
}

DefaultPacketWriter is a struct used to write packets to a peer Pass packets in using WriteOffline/WriteGeneric/etc. and bind to the given emitters

func NewPacketWriter

func NewPacketWriter() *DefaultPacketWriter

NewPacketWriter initializes a new DefaultPacketWriter

func (*DefaultPacketWriter) Caches

func (handler *DefaultPacketWriter) Caches() *Caches

func (*DefaultPacketWriter) Context

func (handler *DefaultPacketWriter) Context() *CommunicationContext

func (*DefaultPacketWriter) Errors

func (writer *DefaultPacketWriter) Errors() *emitter.Emitter

Errors returns a no-op emitter

func (*DefaultPacketWriter) Layers

func (writer *DefaultPacketWriter) Layers() *emitter.Emitter

Layers returns the emitter that emits packet layers while they are being generated

func (*DefaultPacketWriter) SetCaches

func (handler *DefaultPacketWriter) SetCaches(val *Caches)

func (*DefaultPacketWriter) SetContext

func (handler *DefaultPacketWriter) SetContext(val *CommunicationContext)

func (*DefaultPacketWriter) SetToClient

func (writer *DefaultPacketWriter) SetToClient(val bool)

SetToClient implements PacketWriter.SetToClient

func (*DefaultPacketWriter) SharedStrings

func (handler *DefaultPacketWriter) SharedStrings() map[string]rbxfile.ValueSharedString

func (*DefaultPacketWriter) ToClient

func (writer *DefaultPacketWriter) ToClient() bool

ToClient implements PacketWriter.ToClient

func (*DefaultPacketWriter) WriteACKs

func (writer *DefaultPacketWriter) WriteACKs(datagrams []int, isNAK bool) error

WriteACKs writes an ACK/NAK packet for the given datagram numbers

func (*DefaultPacketWriter) WriteOffline

func (writer *DefaultPacketWriter) WriteOffline(packet RakNetPacket) error

WriteOffline is used to write pre-connection packets (IDs 5-8). It doesn't use a ReliabilityLayer.

func (*DefaultPacketWriter) WritePacket

func (writer *DefaultPacketWriter) WritePacket(generic RakNetPacket) error

WritePacket serializes the given RakNetPacket and outputs it. It uses the ReliableOrdered reliability setting.

func (*DefaultPacketWriter) WriteRakNet

func (writer *DefaultPacketWriter) WriteRakNet(layers *PacketLayers) error

WriteRakNet writes the RakNetLayer contained in the PacketLayers

func (*DefaultPacketWriter) WriteTimestamped

func (writer *DefaultPacketWriter) WriteTimestamped(timestamp *Packet1BLayer, generic RakNetPacket) error

WriteTimestamped serializes the given RakNetPacket using the given timestamp It uses the Unreliable reliability setting.

type DisconnectionSource

type DisconnectionSource uint

DisconnectionSource is a type describing what caused a disconnection

const (
	// LocalDisconnection represents a disconnection caused by
	// the local peer (i.e. by PacketLogicHandler.Disconnect())
	LocalDisconnection DisconnectionSource = iota
	// RemoteDisconnection represents a disconnection caused by
	// the remote peer
	RemoteDisconnection
)

type JobStatsItem

type JobStatsItem struct {
	Name  string
	Stat1 float32
	Stat2 float32
	Stat3 float32
}

JobStatsItem represents the stats for one tracked job

type JoinDataStreamer

type JoinDataStreamer struct {
	// BufferEmitter emits Packet83Subpackets on channel "join-data"
	// These buffers should be passed to PacketWriter.WritePacket()
	BufferEmitter *emitter.Emitter
	// contains filtered or unexported fields
}

JoinDataStreamer is a helper struct that allows serialized JoinData objects to be created one at a time, while still constructing JoinData layers of appropriate length

func NewJoinDataStreamer

func NewJoinDataStreamer(writer PacketWriter) *JoinDataStreamer

NewJoinDataStreamer returns a new JoinDataStreamer object which emits RawJoinDataBuffer objects once their internal buffers reach the length specified by MaxJoinDataBytes

func (*JoinDataStreamer) AddInstance

func (state *JoinDataStreamer) AddInstance(instance *ReplicationInstance) error

AddInstance add the instance to the current RawJoinDataBuffer

func (*JoinDataStreamer) Close

func (state *JoinDataStreamer) Close() error

Close flushes the JoinDataStreamer and unbinds BufferEmitter bindings

func (*JoinDataStreamer) Flush

func (state *JoinDataStreamer) Flush() error

Flush forces JoinDataStreamer to emit the RawJoinDataBuffer being serialized currently, unless empty

type MemoryStatsItem

type MemoryStatsItem struct {
	Name   string
	Memory float64
}

MemoryStatsItem contains the memory stats for one category

type NetworkArgumentSchema

type NetworkArgumentSchema struct {
	Type       uint8
	TypeString string
	EnumID     uint16
}

NetworkArgumentSchema describes the schema of one event argument

type NetworkEnumSchema

type NetworkEnumSchema struct {
	Name      string
	BitSize   uint8
	NetworkID uint16
}

NetworkEnumSchema describes the schema of one enum

type NetworkEventSchema

type NetworkEventSchema struct {
	Name           string
	Arguments      []*NetworkArgumentSchema
	InstanceSchema *NetworkInstanceSchema
	NetworkID      uint16
}

NetworkEventSchema describes the schema of one event

func (*NetworkEventSchema) Decode

func (schema *NetworkEventSchema) Decode(reader PacketReader, thisStream serializeReader, layers *PacketLayers, deferred deferredStrings) (*ReplicationEvent, error)

Decode deserializes a network event invocation packet

func (*NetworkEventSchema) Serialize

func (schema *NetworkEventSchema) Serialize(event *ReplicationEvent, writer PacketWriter, stream serializeWriter, deferred writeDeferredStrings) error

Serialize serializes an event invocation packet to its network format

type NetworkInstanceSchema

type NetworkInstanceSchema struct {
	Name       string
	Unknown    uint16
	Properties []*NetworkPropertySchema
	Events     []*NetworkEventSchema
	NetworkID  uint16
}

NetworkInstanceSchema describes the schema of one class

func (*NetworkInstanceSchema) LocalEventIndex

func (schema *NetworkInstanceSchema) LocalEventIndex(name string) int

LocalEventIndex finds the index of a certain event within one class

func (*NetworkInstanceSchema) LocalPropertyIndex

func (schema *NetworkInstanceSchema) LocalPropertyIndex(name string) int

LocalPropertyIndex finds the index of a certain property within one class

func (*NetworkInstanceSchema) SchemaForEvent

func (schema *NetworkInstanceSchema) SchemaForEvent(name string) *NetworkEventSchema

SchemaForEvent finds the schema for a certain event

func (*NetworkInstanceSchema) SchemaForProp

func (schema *NetworkInstanceSchema) SchemaForProp(name string) *NetworkPropertySchema

SchemaForProp finds the schema for a certain property

type NetworkPropertySchema

type NetworkPropertySchema struct {
	Name           string
	Type           uint8
	TypeString     string
	EnumID         uint16
	InstanceSchema *NetworkInstanceSchema
	NetworkID      uint16
}

NetworkPropertySchema describes the schema of one property

func (*NetworkPropertySchema) Decode

func (schema *NetworkPropertySchema) Decode(reader PacketReader, stream serializeReader, layers *PacketLayers, deferred deferredStrings) (rbxfile.Value, error)

Decode deserializes a network property change packet

func (*NetworkPropertySchema) Serialize

func (schema *NetworkPropertySchema) Serialize(value rbxfile.Value, writer PacketWriter, stream serializeWriter, deferred writeDeferredStrings) error

Serialize serializes a property change packet to its network format

type NetworkSchema

type NetworkSchema struct {
	Instances  []*NetworkInstanceSchema
	Properties []*NetworkPropertySchema
	Events     []*NetworkEventSchema
	Enums      []*NetworkEnumSchema

	ContentPrefixes  []string
	OptimizedStrings []string
}

NetworkSchema represents the data serialization schema and class/enum API for a communication as specified by the server

func ParseSchema

func ParseSchema(schemafile io.Reader) (*NetworkSchema, error)

ParseSchema parses a network schema based on a schema dump file

func (*NetworkSchema) Dump

func (schema *NetworkSchema) Dump(file io.Writer) error

Dump encodes a NetworkSchema to a format that can be parsed by ParseSchema()

func (*NetworkSchema) SchemaForClass

func (schema *NetworkSchema) SchemaForClass(instance string) *NetworkInstanceSchema

SchemaForClass finds the schema for a certain class

func (*NetworkSchema) SchemaForEnum

func (schema *NetworkSchema) SchemaForEnum(enum string) *NetworkEnumSchema

SchemaForEnum finds the schema for a certain enum

type Packet00Layer

type Packet00Layer struct {
	// Timestamp (seconds)
	SendPingTime uint64
}

Packet00Layer represents ID_CONNECTED_PING - client <-> server

func (*Packet00Layer) Serialize

func (layer *Packet00Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize()

func (*Packet00Layer) String

func (layer *Packet00Layer) String() string

func (Packet00Layer) Type

func (Packet00Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet00Layer) TypeString

func (Packet00Layer) TypeString() string

TypeString implements RakNetPacket.TypeString()

type Packet03Layer

type Packet03Layer struct {
	// Timestamp from ID_CONNECTED_PING
	SendPingTime uint64
	// Timestamp of reply (seconds)
	SendPongTime uint64
}

Packet03Layer represents ID_CONNECTED_PONG - client <-> server

func (*Packet03Layer) Serialize

func (layer *Packet03Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize()

func (*Packet03Layer) String

func (layer *Packet03Layer) String() string

func (Packet03Layer) Type

func (Packet03Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet03Layer) TypeString

func (Packet03Layer) TypeString() string

TypeString implements RakNetPacket.TypeString()

type Packet05Layer

type Packet05Layer struct {
	// RakNet protocol version, always 5
	ProtocolVersion  uint8
	MTUPaddingLength int
}

Packet05Layer represents ID_OPEN_CONNECTION_REQUEST_1 - client -> server

func (*Packet05Layer) Serialize

func (layer *Packet05Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize()

func (*Packet05Layer) String

func (layer *Packet05Layer) String() string

func (Packet05Layer) Type

func (Packet05Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet05Layer) TypeString

func (Packet05Layer) TypeString() string

TypeString implements RakNetPacket.TypeString()

type Packet06Layer

type Packet06Layer struct {
	// Server GUID
	GUID uint64
	// Use libcat encryption? Always false
	UseSecurity bool
	// MTU in bytes
	MTU uint16
}

Packet06Layer represents ID_OPEN_CONNECTION_REPLY_1 - server -> client

func (*Packet06Layer) Serialize

func (layer *Packet06Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize()

func (*Packet06Layer) String

func (layer *Packet06Layer) String() string

func (Packet06Layer) Type

func (Packet06Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet06Layer) TypeString

func (Packet06Layer) TypeString() string

TypeString impelements RakNetPacket.TypeString()

type Packet07Layer

type Packet07Layer struct {
	// Server external IP address
	IPAddress *net.UDPAddr
	// MTU in bytes
	MTU uint16
	// Client GUID
	GUID             uint64
	SupportedVersion uint32
	Capabilities     uint64
}

Packet07Layer represents ID_OPEN_CONNECTION_REQUEST_2 - client -> server

func (*Packet07Layer) Serialize

func (layer *Packet07Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize()

func (*Packet07Layer) String

func (layer *Packet07Layer) String() string

func (Packet07Layer) Type

func (Packet07Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet07Layer) TypeString

func (Packet07Layer) TypeString() string

TypeString impelements RakNetPacket.TypeString()

type Packet08Layer

type Packet08Layer struct {
	// Server GUID
	GUID uint64
	// Client external IP address
	IPAddress *net.UDPAddr
	// MTU in bytes
	MTU uint16
	// Use libcat encryption? Always false
	UseSecurity      bool
	SupportedVersion uint32
	Capabilities     uint64
}

Packet08Layer represents ID_OPEN_CONNECTION_REPLY_2 - server -> client

func (*Packet08Layer) Serialize

func (layer *Packet08Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize()

func (*Packet08Layer) String

func (layer *Packet08Layer) String() string

func (Packet08Layer) Type

func (Packet08Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet08Layer) TypeString

func (Packet08Layer) TypeString() string

TypeString impelements RakNetPacket.TypeString()

type Packet09Layer

type Packet09Layer struct {
	// Client GUID
	GUID uint64
	// Timestamp of sending the request (seconds)
	Timestamp uint64
	// Use libcat encryption? Always false
	UseSecurity bool
	// Password: 2 or 6 bytes, always {0x5E, 0x11} in Studio, varies in real clients
	Password []byte
}

Packet09Layer represents ID_CONNECTION_REQUEST - client -> server

func (*Packet09Layer) Serialize

func (layer *Packet09Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize()

func (*Packet09Layer) String

func (layer *Packet09Layer) String() string

func (Packet09Layer) Type

func (Packet09Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet09Layer) TypeString

func (Packet09Layer) TypeString() string

TypeString impelements RakNetPacket.TypeString()

type Packet10Layer

type Packet10Layer struct {
	// Client IP address
	IPAddress   *net.UDPAddr
	SystemIndex uint16
	Addresses   [10]*net.UDPAddr
	// Timestamp from ID_CONNECTION_REQUEST
	SendPingTime uint64
	// Timestamp of sending reply (seconds)
	SendPongTime uint64
}

Packet10Layer represents ID_CONNECTION_REQUEST_ACCEPTED - server -> client

func (*Packet10Layer) Serialize

func (layer *Packet10Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize()

func (*Packet10Layer) String

func (layer *Packet10Layer) String() string

func (Packet10Layer) Type

func (Packet10Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet10Layer) TypeString

func (Packet10Layer) TypeString() string

TypeString impelements RakNetPacket.TypeString()

type Packet13Layer

type Packet13Layer struct {
	// Server IP address
	IPAddress *net.UDPAddr
	Addresses [10]*net.UDPAddr
	// SendPongTime from ID_CONNECTION_REQUEST_ACCEPTED
	SendPingTime uint64
	// Timestamp of sending reply (seconds)
	SendPongTime uint64
}

Packet13Layer represents ID_NEW_INCOMING_CONNECTION - client -> server

func (*Packet13Layer) Serialize

func (layer *Packet13Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize()

func (*Packet13Layer) String

func (layer *Packet13Layer) String() string

func (Packet13Layer) Type

func (Packet13Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet13Layer) TypeString

func (Packet13Layer) TypeString() string

TypeString impelements RakNetPacket.TypeString()

type Packet15Layer

type Packet15Layer struct {
	Reason int32
}

Packet15Layer represents ID_DISCONNECTION_NOTIFICATION - client <-> server

func (*Packet15Layer) Serialize

func (layer *Packet15Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize()

func (*Packet15Layer) String

func (layer *Packet15Layer) String() string

func (Packet15Layer) Type

func (Packet15Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet15Layer) TypeString

func (Packet15Layer) TypeString() string

TypeString implements RakNetPacket.TypeString()

type Packet1BLayer

type Packet1BLayer struct {
	// Timestamp of when this packet was sent
	Timestamp  uint64
	Timestamp2 uint64
}

Packet1BLayer represents ID_TIMESTAMP - client <-> server

func (*Packet1BLayer) Serialize

func (layer *Packet1BLayer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize()

func (*Packet1BLayer) String

func (layer *Packet1BLayer) String() string

func (Packet1BLayer) Type

func (Packet1BLayer) Type() byte

Type implements RakNetPacket.Type()

func (Packet1BLayer) TypeString

func (Packet1BLayer) TypeString() string

TypeString implements RakNetPacket.TypeString()

type Packet81Layer

type Packet81Layer struct {
	// Is streaming enabled?
	StreamJob bool
	// Is Filtering enabled?
	FilteringEnabled   bool
	Bool1              bool
	Bool2              bool
	Bool3              bool
	CharacterAutoSpawn bool
	// Server's scope
	ReferenceString string
	PeerID          uint32
	ScriptKey       uint32
	CoreScriptKey   uint32
	// List of services to be created
	Items []*Packet81LayerItem
}

Packet81Layer represents ID_SET_GLOBALS - server -> client

func (*Packet81Layer) Serialize

func (layer *Packet81Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize()

func (*Packet81Layer) String

func (layer *Packet81Layer) String() string

func (Packet81Layer) Type

func (Packet81Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet81Layer) TypeString

func (Packet81Layer) TypeString() string

TypeString implements RakNetPacket.TypeString()

type Packet81LayerItem

type Packet81LayerItem struct {
	Schema        *NetworkInstanceSchema
	Instance      *datamodel.Instance
	WatchChanges  bool
	WatchChildren bool
}

Packet81LayerItem describes a global service from ID_SET_GLOBALS (Packet81Layer)

type Packet83Layer

type Packet83Layer struct {
	SubPackets []Packet83Subpacket
}

Packet83Layer represents ID_DATA - client <-> server

func (*Packet83Layer) Serialize

func (layer *Packet83Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize

func (*Packet83Layer) String

func (layer *Packet83Layer) String() string

func (Packet83Layer) Type

func (Packet83Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet83Layer) TypeString

func (Packet83Layer) TypeString() string

TypeString implements RakNetPacket.TypeString()

type Packet83Subpacket

type Packet83Subpacket interface {
	fmt.Stringer
	Serialize(writer PacketWriter, stream *extendedWriter) error
	Type() uint8
	TypeString() string
}

Packet83Subpacket is an interface implemented by subpackets contained within a 0x83 (ID_DATA) packet

type Packet83_01

type Packet83_01 struct {
	// Instance to be deleted
	Instance *datamodel.Instance
}

Packet83_01 represents ID_DELETE_INSTANCE

func (*Packet83_01) Serialize

func (layer *Packet83_01) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements Packet83Subpacket.Serialize()

func (*Packet83_01) String

func (layer *Packet83_01) String() string

func (Packet83_01) Type

func (Packet83_01) Type() uint8

Type implements Packet83Subpacket.Type()

func (Packet83_01) TypeString

func (Packet83_01) TypeString() string

TypeString implements Packet83Subpacket.TypeString()

type Packet83_02

type Packet83_02 struct {
	// The instance that was created
	*ReplicationInstance
}

Packet83_02 represents ID_CREATE_INSTANCE

func (*Packet83_02) Serialize

func (layer *Packet83_02) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements Packet83Subpacket.Serialize()

func (*Packet83_02) String

func (layer *Packet83_02) String() string

func (Packet83_02) Type

func (Packet83_02) Type() uint8

Type implements Packet83Subpacket.Type()

func (Packet83_02) TypeString

func (Packet83_02) TypeString() string

TypeString implements Packet83Subpacket.TypeString()

type Packet83_03

type Packet83_03 struct {
	// Instance that had the property change
	Instance   *datamodel.Instance
	HasVersion bool
	Version    int32
	Schema     *NetworkPropertySchema
	// New value
	Value rbxfile.Value
}

Packet83_03 represents ID_CHANGE_PROPERTY

func (*Packet83_03) Serialize

func (layer *Packet83_03) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements Packet83Subpacke.Serialize()

func (*Packet83_03) String

func (layer *Packet83_03) String() string

func (Packet83_03) Type

func (Packet83_03) Type() uint8

Type implements Packet83Subpacket.Type()

func (Packet83_03) TypeString

func (Packet83_03) TypeString() string

TypeString implements Packet83Subpacket.TypeString()

type Packet83_04

type Packet83_04 struct {
	MarkerID uint32
}

Packet83_04 represents ID_MARKER

func (*Packet83_04) Serialize

func (layer *Packet83_04) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements Packet83Subpacket.Serialize()

func (*Packet83_04) String

func (layer *Packet83_04) String() string

func (Packet83_04) Type

func (Packet83_04) Type() uint8

Type implements Packet83Subpacket.Type()

func (Packet83_04) TypeString

func (Packet83_04) TypeString() string

TypeString implements Packet83Subpacket.TypeString()

type Packet83_05

type Packet83_05 struct {
	PacketVersion uint8
	// Always false
	Timestamp uint64
	Fps1      float32
	Fps2      float32
	Fps3      float32
	Int1      uint32
	SendStats uint32
	// Hack flags
	ExtraStats uint32
}

Packet83_05 represents ID_PING

func (*Packet83_05) Serialize

func (layer *Packet83_05) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements Packet83Subpacket.Serialize()

func (*Packet83_05) String

func (layer *Packet83_05) String() string

func (Packet83_05) Type

func (Packet83_05) Type() uint8

Type implements Packet83Subpacket.Type()

func (Packet83_05) TypeString

func (Packet83_05) TypeString() string

TypeString implements Packet83Subpacket.TypeString()

type Packet83_06

type Packet83_06 struct {
	// Always true
	IsPingBack bool
	Timestamp  uint64
	SendStats  uint32
	// Hack flags
	ExtraStats uint32
}

Packet83_06 represents ID_PING_BACK

func (*Packet83_06) Serialize

func (layer *Packet83_06) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements Packet83Subpacket.Serialize()

func (*Packet83_06) String

func (layer *Packet83_06) String() string

func (Packet83_06) Type

func (Packet83_06) Type() uint8

Type implements Packet83Subpacket.Type()

func (Packet83_06) TypeString

func (Packet83_06) TypeString() string

TypeString implements Packet83Subpacket.TypeString()

type Packet83_07

type Packet83_07 struct {
	// Instance that the event was invoked on
	Instance *datamodel.Instance
	Schema   *NetworkEventSchema
	// Description about the invocation
	Event *ReplicationEvent
}

Packet83_07 represents ID_EVENT

func (*Packet83_07) Serialize

func (layer *Packet83_07) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements Packet83Subpacket.Serialize()

func (*Packet83_07) String

func (layer *Packet83_07) String() string

func (Packet83_07) Type

func (Packet83_07) Type() uint8

Type implements Packet83Subpacket.Type()

func (Packet83_07) TypeString

func (Packet83_07) TypeString() string

TypeString implements Packet83Subpacket.TypeString()

type Packet83_09

type Packet83_09 struct {
	Subpacket Packet83_09Subpacket
}

Packet83_09 represents ID_ROCKY

func (*Packet83_09) Serialize

func (layer *Packet83_09) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements Packet83Subpacket.Serialize()

func (*Packet83_09) String

func (layer *Packet83_09) String() string

func (Packet83_09) Type

func (Packet83_09) Type() uint8

Type implements Packet83Subpacket.Type()

func (Packet83_09) TypeString

func (Packet83_09) TypeString() string

TypeString implements Packet83Subpacket.TypeString()

type Packet83_09Subpacket

type Packet83_09Subpacket interface {
	fmt.Stringer
	Type() byte
	TypeString() string
}

Packet83_09Subpacket is a generic interface for Packet83_09 subpackets

type Packet83_09_00

type Packet83_09_00 struct {
	Int1 uint32
	Int2 uint32
	Int3 uint32
	Int4 uint32
	Int5 uint32
}

Packet83_09_00 represents a NetPMC packet the purpose of which is unknown

func (*Packet83_09_00) String

func (layer *Packet83_09_00) String() string

func (Packet83_09_00) Type

func (Packet83_09_00) Type() byte

Type implements Packet83_09Subpacket.Type()

func (Packet83_09_00) TypeString

func (Packet83_09_00) TypeString() string

TypeString implements Packet83_09Subpacket.TypeString()

type Packet83_09_04

type Packet83_09_04 struct {
	Int1 byte
	Int2 uint32
}

Packet83_09_04 represents a NetPMC packet the purpose of which is unknown

func (*Packet83_09_04) String

func (layer *Packet83_09_04) String() string

func (Packet83_09_04) Type

func (Packet83_09_04) Type() byte

Type implements Packet83_09Subpacket.Type()

func (Packet83_09_04) TypeString

func (Packet83_09_04) TypeString() string

TypeString implements Packet83_09Subpacket.TypeString()

type Packet83_09_05

type Packet83_09_05 struct {
	Challenge uint32
}

Packet83_09_05 represents an ID Challenge packet

func (*Packet83_09_05) String

func (layer *Packet83_09_05) String() string

func (Packet83_09_05) Type

func (Packet83_09_05) Type() byte

Type implements Packet83_09Subpacket.Type()

func (Packet83_09_05) TypeString

func (Packet83_09_05) TypeString() string

TypeString implements Packet83_09Subpacket.TypeString()

type Packet83_09_06

type Packet83_09_06 struct {
	Challenge uint32
	Response  uint32
}

Packet83_09_06 represents a response to an ID Challenge packet

func (*Packet83_09_06) String

func (layer *Packet83_09_06) String() string

func (Packet83_09_06) Type

func (Packet83_09_06) Type() byte

Type implements Packet83_09Subpacket.Type()

func (Packet83_09_06) TypeString

func (Packet83_09_06) TypeString() string

TypeString implements Packet83_09Subpacket.TypeString()

type Packet83_0A

type Packet83_0A struct {
	// Instance that had the property change
	Instance *datamodel.Instance
	Schema   *NetworkPropertySchema
	Versions []uint32
}

Packet83_0A represents ID_CFRAME_ACK

func (*Packet83_0A) Serialize

func (layer *Packet83_0A) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements Packet83Subpacket.Serialize()

func (*Packet83_0A) String

func (layer *Packet83_0A) String() string

func (Packet83_0A) Type

func (Packet83_0A) Type() uint8

Type implements Packet83Subpacket.Type()

func (Packet83_0A) TypeString

func (Packet83_0A) TypeString() string

TypeString implements Packet83Subpacket.TypeString()

type Packet83_0B

type Packet83_0B struct {
	// Instances replicated by the server
	Instances []*ReplicationInstance
}

Packet83_0B represents ID_JOINDATA

func (*Packet83_0B) Serialize

func (layer *Packet83_0B) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements Packet83Subpacket.Serialize()

func (*Packet83_0B) String

func (layer *Packet83_0B) String() string

func (Packet83_0B) Type

func (Packet83_0B) Type() uint8

Type implements Packet83Subpacket.Type()

func (Packet83_0B) TypeString

func (Packet83_0B) TypeString() string

TypeString implements Packet83Subpacket.TypeString()

type Packet83_0C

type Packet83_0C struct {
	QuotaDiff       int32
	MaxRegionRadius int16
}

Packet83_0C represents ID_UPDATE_CLIENT_QUOTA

func (*Packet83_0C) Serialize

func (layer *Packet83_0C) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements Packet83Subpacket.Serialize()

func (*Packet83_0C) String

func (layer *Packet83_0C) String() string

func (Packet83_0C) Type

func (Packet83_0C) Type() uint8

Type implements Packet83Subpacket.Type()

func (Packet83_0C) TypeString

func (Packet83_0C) TypeString() string

TypeString implements Packet83Subpacket.TypeString()

type Packet83_0D

type Packet83_0D struct {
	Bool1 bool
	Bool2 bool

	Region StreamInfo

	Instances []*ReplicationInstance
}

Packet83_0D represents ID_REPLIC_STREAM_DATA

func (*Packet83_0D) Serialize

func (layer *Packet83_0D) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements Packet83Subpacket.Serialize()

func (*Packet83_0D) String

func (layer *Packet83_0D) String() string

func (Packet83_0D) Type

func (Packet83_0D) Type() uint8

Type implements Packet83Subpacket.Type()

func (Packet83_0D) TypeString

func (Packet83_0D) TypeString() string

TypeString implements Packet83Subpacket.TypeString()

type Packet83_0E

type Packet83_0E struct {
	Region    StreamInfo
	Instances []*datamodel.Instance
}

Packet83_0E represents ID_REPLIC_REGION_REMOVAL

func (*Packet83_0E) Serialize

func (layer *Packet83_0E) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements Packet83Subpacket.Serialize()

func (*Packet83_0E) String

func (layer *Packet83_0E) String() string

func (Packet83_0E) Type

func (Packet83_0E) Type() uint8

Type implements Packet83Subpacket.Type()

func (Packet83_0E) TypeString

func (Packet83_0E) TypeString() string

TypeString implements Packet83Subpacket.TypeString()

type Packet83_0F

type Packet83_0F struct {
	Instance *datamodel.Instance
}

Packet83_0F represents ID_REPLIC_INSTANCE_REMOVAL How is this different from ID_REPLIC_DELETE_INSTANCE? Does the latter force GC? Is this explicitly for streaming?

func (*Packet83_0F) Serialize

func (layer *Packet83_0F) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements Packet83Subpacket.Serialize()

func (*Packet83_0F) String

func (layer *Packet83_0F) String() string

func (Packet83_0F) Type

func (Packet83_0F) Type() uint8

Type implements Packet83Subpacket.Type()

func (Packet83_0F) TypeString

func (Packet83_0F) TypeString() string

TypeString implements Packet83Subpacket.TypeString()

type Packet83_10

type Packet83_10 struct {
	// 12 => ReplicatedFirst replication finished
	// 13 => Initial replication finished
	TagID uint32
}

Packet83_10 represents ID_TAG

func (*Packet83_10) Serialize

func (layer *Packet83_10) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements Packet83Subpacket.Serialize()

func (*Packet83_10) String

func (layer *Packet83_10) String() string

func (Packet83_10) Type

func (Packet83_10) Type() uint8

Type implements Packet83Subpacket.Type()

func (Packet83_10) TypeString

func (Packet83_10) TypeString() string

TypeString implements Packet83Subpacket.TypeString()

type Packet83_11

type Packet83_11 struct {
	Version uint32

	MemoryStats    ServerMemoryStats
	DataStoreStats DataStoreStats
	JobStats       []JobStatsItem
	ScriptStats    []ScriptStatsItem

	AvgPingMs             float32
	AvgPhysicsSenderPktPS float32
	TotalDataKBPS         float32
	TotalPhysicsKBPS      float32
	DataThroughputRatio   float32
}

Packet83_11 represents ID_STATS

func (*Packet83_11) Serialize

func (layer *Packet83_11) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements Packet83Subpacket.Serialize()

func (*Packet83_11) String

func (layer *Packet83_11) String() string

func (Packet83_11) Type

func (Packet83_11) Type() uint8

Type implements Packet83Subpacket.Type()

func (Packet83_11) TypeString

func (Packet83_11) TypeString() string

TypeString implements Packet83Subpacket.TypeString()

type Packet83_12

type Packet83_12 struct {
	HashList          []uint32
	SecurityTokens    [3]uint64
	Nonce             uint32
	HasSecurityTokens bool
}

Packet83_12 represents ID_HASH

func (*Packet83_12) Serialize

func (layer *Packet83_12) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements Packet83Subpacket.Serialize()

func (*Packet83_12) String

func (layer *Packet83_12) String() string

func (Packet83_12) Type

func (Packet83_12) Type() uint8

Type implements Packet83Subpacket.Type()

func (Packet83_12) TypeString

func (Packet83_12) TypeString() string

TypeString implements Packet83Subpacket.TypeString()

type Packet83_13

type Packet83_13 struct {
	Instance *datamodel.Instance
	Parent   *datamodel.Instance
}

Packet83_13 represents ID_REPLIC_ATOMIC

func (*Packet83_13) Serialize

func (layer *Packet83_13) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements Packet83Subpacket.Serialize()

func (*Packet83_13) String

func (layer *Packet83_13) String() string

func (Packet83_13) Type

func (Packet83_13) Type() uint8

Type implements Packet83Subpacket.Type()

func (Packet83_13) TypeString

func (Packet83_13) TypeString() string

TypeString implements Packet83Subpacket.TypeString()

type Packet83_14

type Packet83_14 struct {
	Region StreamInfo
	Int1   int32
}

Packet83_14 represents ID_REPLIC_STREAM_DATA_INFO

func (*Packet83_14) Serialize

func (layer *Packet83_14) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements Packet83Subpacket.Serialize()

func (*Packet83_14) String

func (layer *Packet83_14) String() string

func (Packet83_14) Type

func (Packet83_14) Type() uint8

Type implements Packet83Subpacket.Type()

func (Packet83_14) TypeString

func (Packet83_14) TypeString() string

TypeString implements Packet83Subpacket.TypeString()

type Packet84Layer

type Packet84Layer struct {
	MarkerID uint32
}

Packet84Layer represents ID_MARKER - server -> client

func (*Packet84Layer) Serialize

func (layer *Packet84Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize()

func (*Packet84Layer) String

func (layer *Packet84Layer) String() string

func (Packet84Layer) Type

func (Packet84Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet84Layer) TypeString

func (Packet84Layer) TypeString() string

TypeString implements RakNetPacket.TypeString()

type Packet85Layer

type Packet85Layer struct {
	SubPackets []*Packet85LayerSubpacket
}

Packet85Layer ID_PHYSICS - client <-> server

func (*Packet85Layer) Serialize

func (layer *Packet85Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize

func (*Packet85Layer) String

func (layer *Packet85Layer) String() string

func (Packet85Layer) Type

func (Packet85Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet85Layer) TypeString

func (Packet85Layer) TypeString() string

TypeString implements RakNetPacket.TypeString()

type Packet85LayerSubpacket

type Packet85LayerSubpacket struct {
	Data PhysicsData
	// See http://wiki.roblox.com/index.php?title=API:Enum/HumanoidStateType
	NetworkHumanoidState uint8
	// CFrames for any motors attached
	// Any other parts attached to this mechanism
	Children []*PhysicsData
	History  []*PhysicsData
}

Packet85LayerSubpacket represents physics replication for one instance

func (*Packet85LayerSubpacket) String

func (packet *Packet85LayerSubpacket) String() string

String() implements fmt.Stringer

type Packet86Layer

type Packet86Layer struct {
	SubPackets []*Packet86LayerSubpacket
}

Packet86Layer represents ID_TOUCHES - client <-> server

func (*Packet86Layer) Serialize

func (layer *Packet86Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize

func (*Packet86Layer) String

func (layer *Packet86Layer) String() string

func (Packet86Layer) Type

func (Packet86Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet86Layer) TypeString

func (Packet86Layer) TypeString() string

TypeString implements RakNetPacket.TypeString()

type Packet86LayerSubpacket

type Packet86LayerSubpacket struct {
	Instance1 *datamodel.Instance
	Instance2 *datamodel.Instance
	// Touch started? If false, ended.
	IsTouch bool
}

Packet86LayerSubpacket represents touch replication for a single touch

func (*Packet86LayerSubpacket) String

func (packet *Packet86LayerSubpacket) String() string

String() implements fmt.Stringer

type Packet87Layer

type Packet87Layer struct {
	Instance *datamodel.Instance
	Message  string
}

Packet87Layer represents ID_CHAT_ALL

func (*Packet87Layer) Serialize

func (layer *Packet87Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize

func (*Packet87Layer) String

func (layer *Packet87Layer) String() string

func (Packet87Layer) Type

func (Packet87Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet87Layer) TypeString

func (Packet87Layer) TypeString() string

TypeString implements RakNetPacket.TypeString()

type Packet8ALayer

type Packet8ALayer struct {
	PlayerID      int64
	ClientTicket  string
	TicketHash    uint32
	LuauResponse  uint32
	DataModelHash string
	// Always 36?
	ProtocolVersion   uint32
	SecurityKey       string
	Platform          string
	RobloxProductName string
	CryptoHash        string
	SessionID         string
	GoldenHash        uint32
}

Packet8ALayer represents ID_SUBMIT_TICKET - client -> server

func (*Packet8ALayer) Serialize

func (layer *Packet8ALayer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize

func (*Packet8ALayer) String

func (layer *Packet8ALayer) String() string

func (Packet8ALayer) Type

func (Packet8ALayer) Type() byte

Type implements RakNetPacket.Type()

func (Packet8ALayer) TypeString

func (Packet8ALayer) TypeString() string

TypeString implements RakNetPacket.TypeString()

type Packet8DLayer

type Packet8DLayer struct {
	Instance *datamodel.Instance
	Chunks   []Chunk
}

Packet8DLayer represents ID_CLUSTER: server -> client

func (*Packet8DLayer) Serialize

func (layer *Packet8DLayer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize

func (*Packet8DLayer) String

func (layer *Packet8DLayer) String() string

func (Packet8DLayer) Type

func (Packet8DLayer) Type() byte

Type implements RakNetPacket.Type()

func (Packet8DLayer) TypeString

func (Packet8DLayer) TypeString() string

TypeString implements RakNetPacket.TypeString()

type Packet8FLayer

type Packet8FLayer struct {
	SpawnName string
}

Packet8FLayer represents ID_PREFERRED_SPAWN_NAME - client -> server

func (*Packet8FLayer) Serialize

func (layer *Packet8FLayer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize

func (*Packet8FLayer) String

func (layer *Packet8FLayer) String() string

func (Packet8FLayer) Type

func (Packet8FLayer) Type() byte

Type implements RakNetPacket.Type()

func (Packet8FLayer) TypeString

func (Packet8FLayer) TypeString() string

TypeString implements RakNetPacket.TypeString()

type Packet90Layer

type Packet90Layer struct {
	SchemaVersion  uint32
	Int1           uint8
	Int2           uint8
	RequestedFlags []string
	JoinData       string
	VersionID      Packet90VersionID
}

Packet90Layer represents ID_PROTOCOL_SYNC - client -> server

func (*Packet90Layer) Serialize

func (layer *Packet90Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize

func (*Packet90Layer) String

func (layer *Packet90Layer) String() string

func (Packet90Layer) Type

func (Packet90Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet90Layer) TypeString

func (Packet90Layer) TypeString() string

TypeString implements RakNetPacket.TypeString()

type Packet90VersionID

type Packet90VersionID [5]int32

Packet90VersionID represents a ID_PROTOCOL_SYNC version id

type Packet92Layer

type Packet92Layer struct {
	PlaceID int64
}

Packet92Layer represents ID_PLACEID_VERIFICATION - client -> server

func (*Packet92Layer) Serialize

func (layer *Packet92Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize

func (*Packet92Layer) String

func (layer *Packet92Layer) String() string

func (Packet92Layer) Type

func (Packet92Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet92Layer) TypeString

func (Packet92Layer) TypeString() string

TypeString implements RakNetPacket.TypeString()

type Packet93Layer

type Packet93Layer struct {
	ProtocolSchemaSync bool
	// Use dictionary compression?
	APIDictionaryCompression bool
	// Flags set by the server
	Params map[string]bool
}

Packet93Layer represents ID_DICTIONARY_FORMAT - server -> client Response to ID_PROTOCOL_SYNC (Packet90Layer)

func (*Packet93Layer) Serialize

func (layer *Packet93Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize

func (*Packet93Layer) String

func (layer *Packet93Layer) String() string

func (Packet93Layer) Type

func (Packet93Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet93Layer) TypeString

func (Packet93Layer) TypeString() string

TypeString implements RakNetPacket.TypeString()

type Packet96Layer

type Packet96Layer struct {
	Request bool
	Version uint32
}

Packet96Layer represents ID_REQUEST_STATS

func (*Packet96Layer) Serialize

func (layer *Packet96Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize

func (*Packet96Layer) String

func (layer *Packet96Layer) String() string

func (Packet96Layer) Type

func (Packet96Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet96Layer) TypeString

func (Packet96Layer) TypeString() string

TypeString implements RakNetPacket.TypeString()

type Packet97Layer

type Packet97Layer struct {
	Schema *NetworkSchema
}

Packet97Layer represents ID_NEW_SCHEMA - server -> client Negotiates a network schema with the client

func (*Packet97Layer) Serialize

func (layer *Packet97Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize()

func (*Packet97Layer) String

func (layer *Packet97Layer) String() string

func (Packet97Layer) Type

func (Packet97Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet97Layer) TypeString

func (Packet97Layer) TypeString() string

TypeString implements RakNetPacket.TypeString()

type Packet98Layer

type Packet98Layer struct {
	Message string
}

Packet98Layer represents ID_KICK_MESSAGE - server -> client

func (*Packet98Layer) Serialize

func (layer *Packet98Layer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize

func (*Packet98Layer) String

func (layer *Packet98Layer) String() string

func (Packet98Layer) Type

func (Packet98Layer) Type() byte

Type implements RakNetPacket.Type()

func (Packet98Layer) TypeString

func (Packet98Layer) TypeString() string

TypeString implements RakNetPacket.TypeString()

type Packet9BLayer

type Packet9BLayer struct {
	Int1      uint32
	Challenge uint32
	Response  uint32
	Script    []byte
	Signature []byte
}

Packet9BLayer represents ID_LUAU_CHALLENGE

func (*Packet9BLayer) Serialize

func (layer *Packet9BLayer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements RakNetPacket.Serialize

func (*Packet9BLayer) String

func (layer *Packet9BLayer) String() string

func (Packet9BLayer) Type

func (Packet9BLayer) Type() byte

Type implements RakNetPacket.Type()

func (Packet9BLayer) TypeString

func (Packet9BLayer) TypeString() string

TypeString implements RakNetPacket.TypeString()

type PacketLayers

type PacketLayers struct {
	// Root is the a basic layer containg information about a packet's source and destination
	Root RootLayer
	// RakNetLayer is the outermost layer. All packets have a RakNetLayer.
	RakNet *RakNetLayer
	// Most packets have a ReliabilityLayer. The exceptions to this are ACKs, NAKs and
	// pre-connection packets.
	Reliability *ReliablePacket
	// Contains data about the split packets this packet has.
	SplitPacket *SplitPacketBuffer
	// Timestamped packets (i.e. physics packets) may have a Timestamp layer.
	Timestamp *Packet1BLayer
	// Almost all packets have a Main layer. The exceptions to this are ACKs and NAKs.
	Main RakNetPacket
	// Possible parsing error?
	Error error

	// First byte of the packet payload. Note that this might not be initialized for split packets.
	PacketType byte
	// Packet83Subpacket. Only for internal use.
	OfflinePayload []byte
	// Unique ID given to each packet. Splits of the same packet have the same ID.
	// The value of this is field is undefined for "reliability" packets.
	UniqueID uint64
}

PacketLayers contains the different layers a packet can have.

func (*PacketLayers) String

func (layers *PacketLayers) String() string

type PacketLogicHandler

type PacketLogicHandler struct {
	*ConnectedPeer
	Context        *CommunicationContext
	RunningContext context.Context
	CancelFunc     func()

	Connection *net.UDPConn

	DataModel *datamodel.DataModel
	Connected bool

	GenericEvents *emitter.Emitter
	// contains filtered or unexported fields
}

PacketLogicHandler is a generic struct for connections which should implements DataModelHandlers TODO: Add Logger to this struct?

func (*PacketLogicHandler) Disconnect

func (logicHandler *PacketLogicHandler) Disconnect()

Disconnect sends a "-1" disconnection reason packet to the remote peer. Note that it doesn't close the underlying connection

func (*PacketLogicHandler) ReplicateInstance

func (logicHandler *PacketLogicHandler) ReplicateInstance(inst *datamodel.Instance, deleteOnDisconnect bool) error

ReplicateInstance sends an ID_REPLIC_NEW_INSTANCE to the peer

func (*PacketLogicHandler) ReplicationInstance

func (logicHandler *PacketLogicHandler) ReplicationInstance(inst *datamodel.Instance, deleteOnDisconnect bool) *ReplicationInstance

ReplicationInstance creates a new ReplicationInstance for the given DataModel instance

func (*PacketLogicHandler) SendEvent

func (logicHandler *PacketLogicHandler) SendEvent(instance *datamodel.Instance, name string, arguments ...rbxfile.Value) error

SendEvent sends an event invocation and fires the event locally

func (*PacketLogicHandler) SendHackFlag

func (logicHandler *PacketLogicHandler) SendHackFlag(player *datamodel.Instance, flag string) error

SendHackFlag attempts to fire the StatsAvailable event on the given player

func (*PacketLogicHandler) WriteDataPackets

func (logicHandler *PacketLogicHandler) WriteDataPackets(packets ...Packet83Subpacket) error

WriteDataPackets sends the given Packet83Subpackets to the peer

type PacketReader

type PacketReader interface {
	ContextualHandler
	SetIsClient(bool)
	IsClient() bool
	ReadPacket(payload []byte, layers *PacketLayers)
}

PacketReader is an interface that can be passed to packet decoders

type PacketWriter

type PacketWriter interface {
	ContextualHandler
	SetToClient(bool)
	ToClient() bool
}

PacketWriter is an interface that can be passed to packet serializers

type PasswordType

type PasswordType int

PasswordType describes a RakNet password type

const (
	// DefaultPassword refers to the default type used for most connections
	DefaultPassword PasswordType = iota
	// StudioPassword refers to the default type used for Roblox Studio connections
	StudioPassword
	// InvalidPassword means that the password type couldn't be identified
	InvalidPassword
)

func IdentifyPassword

func IdentifyPassword(password []byte) PasswordType

IdentifyPassword identifies what RakNet password is being used

type PhysicsData

type PhysicsData struct {
	Instance           *datamodel.Instance
	CFrame             rbxfile.ValueCFrame
	LinearVelocity     rbxfile.ValueVector3
	RotationalVelocity rbxfile.ValueVector3
	Motors             []PhysicsMotor
	Interval           float32
	PlatformChild      *datamodel.Instance
}

PhysicsData represents generic physics data

type PhysicsMotor

type PhysicsMotor rbxfile.ValueCFrame

PhysicsMotor is an alias type for rbxfile.ValueCFrames. They are used to describe motors in physics packets

func (PhysicsMotor) String

func (m PhysicsMotor) String() string

Returns the stringified version of the motor

type ProxyHalf

type ProxyHalf struct {
	*ConnectedPeer
	// contains filtered or unexported fields
}

ProxyHalf describes a proxy connection to a connected peer.

func NewProxyHalf

func NewProxyHalf(context *CommunicationContext, withClient bool) *ProxyHalf

NewProxyHalf initializes a new ProxyHalf

type ProxyWriter

type ProxyWriter struct {
	// ClientHalf only does communications with the client
	// ClientHalf receives from client, ClientHalf sends to client
	ClientHalf *ProxyHalf
	// The above also applies to ServerHalf
	ServerHalf *ProxyHalf
	ClientAddr *net.UDPAddr
	ServerAddr *net.UDPAddr

	SecuritySettings SecurityHandler
	RuntimeContext   context.Context
	// contains filtered or unexported fields
}

ProxyWriter describes a proxy that connects two peers. ProxyWriters have injection capabilities.

Example

ExampleProxyWriter provides an example on how to use the ProxyWriter struct.

clientAddr, _ := net.ResolveUDPAddr("udp", "127.0.0.1:53640")
serverAddr, _ := net.ResolveUDPAddr("udp", "30.40.50.60:50000")
proxy := NewProxyWriter(context.TODO())
proxy.ClientAddr = clientAddr
proxy.ServerAddr = serverAddr

proxy.ClientHalf.Output.On("udp", func(e *emitter.Event) {
	payload := e.Args[0].([]byte)
	// the proxy is requesting us to write this payload to the client
	fmt.Printf("Write %X to client (%s)\n", payload, proxy.ClientAddr)
})
proxy.ServerHalf.Output.On("udp", func(e *emitter.Event) {
	payload := e.Args[0].([]byte)
	// the proxy is requesting us to write this payload to the server
	fmt.Printf("Write %X to server (%s)\n", payload, proxy.ServerAddr)
})

var clientHandshake bytes.Buffer

// write packet id and offline message id
clientHandshake.WriteByte(0x05)
clientHandshake.Write(OfflineMessageID)
packet := &Packet05Layer{
	ProtocolVersion:  5,
	MTUPaddingLength: 10,
}
packet.Serialize(nil, &extendedWriter{&clientHandshake}) // pretend we have a packet

// ProxyClient should be called for packets coming in from the client
proxy.ProxyClient(clientHandshake.Bytes(), &PacketLayers{
	Root: RootLayer{
		FromClient:  true,
		Source:      clientAddr,
		Destination: serverAddr,
	},
})
Output:

Write 0500FFFF00FEFEFEFEFDFDFDFD123456780500000000000000000000 to server (30.40.50.60:50000)

func NewProxyWriter

func NewProxyWriter(ctx context.Context) *ProxyWriter

NewProxyWriter creates and initializes a new ProxyWriter

func (*ProxyWriter) ProxyClient

func (writer *ProxyWriter) ProxyClient(payload []byte, layers *PacketLayers)

ProxyClient should be called when the client sends a packet.

func (*ProxyWriter) ProxyServer

func (writer *ProxyWriter) ProxyServer(payload []byte, layers *PacketLayers)

ProxyServer should be called when the server sends a packet.

type RakNetFlags

type RakNetFlags struct {
	// IsValid specifies whether the packet can be considered valid.
	IsValid bool
	// IsACK specifies whether the packet is an acknowledgement packet
	IsACK bool
	// IsNAK specifies whether the packet is a not-acknowledged packet
	IsNAK            bool
	IsPacketPair     bool
	IsContinuousSend bool
	NeedsBAndAS      bool
	HasBAndAS        bool
}

RakNetFlags contains a set of flags which outline basic information about a RakNet layer packet

type RakNetLayer

type RakNetLayer struct {

	// Drop any non-offline packets which don't have IsValid set.
	Flags RakNetFlags
	ACKs  []ACKRange
	// A datagram number that is used to keep the packets in order.
	DatagramNumber uint32
	// contains filtered or unexported fields
}

RakNetLayer is the outermost layer of all packets. It contains basic information about every packet.

func (*RakNetLayer) Serialize

func (layer *RakNetLayer) Serialize(writer PacketWriter, outStream *extendedWriter) error

Serialize serializes the RakNetLayer to its network format

type RakNetPacket

type RakNetPacket interface {
	fmt.Stringer
	Serialize(writer PacketWriter, stream *extendedWriter) error
	TypeString() string
	Type() byte
}

RakNetPacket describes any packet that can be serialized and written to UDP

type RawJoinDataBuffer

type RawJoinDataBuffer struct {
	*Packet83_0B
	// contains filtered or unexported fields
}

RawJoinDataBuffer is a 0x83 subpacket which is functionally identical to Packet83_0B. However, its contents have been serialized ahead-of-time by JoinDataStreamer and hence its Serialize implementation is different

func (*RawJoinDataBuffer) Serialize

func (buf *RawJoinDataBuffer) Serialize(writer PacketWriter, stream *extendedWriter) error

Serialize implements Packet83Subpacket.Serialize()

type ReliabilityLayer

type ReliabilityLayer struct {
	Packets []*ReliablePacket
}

ReliabilityLayer describes a RakNet connection packet container

func (*ReliabilityLayer) Serialize

func (layer *ReliabilityLayer) Serialize(writer PacketWriter, outputStream *extendedWriter) error

Serialize serializes the packet to its network format

type ReliablePacket

type ReliablePacket struct {
	// Reliability ID: (un)reliable? ordered? sequenced?
	Reliability    uint8
	HasSplitPacket bool
	// Length of this split in bits
	LengthInBits uint16
	// Unique ID given to each packet. Splits of the same packet have a different ID.
	ReliableMessageNumber uint32
	// Unchannelled sequencing index
	SequencingIndex uint32
	// Channelled ordering index
	OrderingIndex   uint32
	OrderingChannel uint8
	// Count of splits this packet has
	SplitPacketCount uint32
	// Splits of the same packet have the same SplitPacketID
	SplitPacketID uint16
	// 0 <= SplitPacketIndex < SplitPacketCount
	SplitPacketIndex uint32
	// The RakNet layer containing this packet
	RakNetLayer *RakNetLayer

	// Data contained by this split
	SelfData []byte

	SplitBuffer *SplitPacketBuffer
}

ReliablePacket describes a packet within a ReliabilityLayer

func (*ReliablePacket) Copy

func (packet *ReliablePacket) Copy() *ReliablePacket

Copy creates a safe copy of a ReliablePacket. It doesn't retain the data or its length.

func (*ReliablePacket) IsOrdered

func (packet *ReliablePacket) IsOrdered() bool

IsOrdered returns a bool descibing whether the packet's reliability is considered "Ordered"

func (*ReliablePacket) IsReliable

func (packet *ReliablePacket) IsReliable() bool

IsReliable returns a bool describing whether the packet's reliability is considered "Reliable"

func (*ReliablePacket) IsSequenced

func (packet *ReliablePacket) IsSequenced() bool

IsSequenced returns a bool descibing whether the packet's reliability is considered "Sequenced"

type ReplicationContainer

type ReplicationContainer struct {
	Instance            *datamodel.Instance
	ReplicateProperties bool
	ReplicateChildren   bool
	ReplicateParent     bool
	// contains filtered or unexported fields
}

ReplicationContainer represents replication config for an instance that is specific to a server client

type ReplicationEvent

type ReplicationEvent struct {
	Arguments []rbxfile.Value
}

ReplicationEvent describes an event invocation replication packet.

type ReplicationInstance

type ReplicationInstance struct {
	Instance           *datamodel.Instance
	Properties         map[string]rbxfile.Value
	Parent             *datamodel.Instance
	Schema             *NetworkInstanceSchema
	DeleteOnDisconnect bool
}

ReplicationInstance describes a network instance creation packet

func (*ReplicationInstance) Serialize

func (instance *ReplicationInstance) Serialize(writer PacketWriter, stream instanceWriter, deferred writeDeferredStrings, writeDefers bool) error

Serialize serializes an instance creation packet to its network format

type RootLayer

type RootLayer struct {
	Logger      *log.Logger
	Source      *net.UDPAddr
	Destination *net.UDPAddr
	FromClient  bool
	FromServer  bool
	// contains filtered or unexported fields
}

RootLayer is a meta-layer that is container by every packet It contains basic information about the packet

func (*RootLayer) GetLog

func (layer *RootLayer) GetLog() string

GetLog returns the accumulated log string for a packet

type ScriptStatsItem

type ScriptStatsItem struct {
	Name  string
	Stat1 float32
	Stat2 uint32
}

ScriptStatsItem represents the stats for one tracked script

type SecurityHandler

type SecurityHandler interface {
	// GenerateIdResponse should provide a response to a challenge
	// given in Packet83_09_05
	GenerateIDResponse(challenge uint32) uint32
	// PatchTicketPacket should change the parameters in a Packet8ALayer
	// appropriately
	PatchTicketPacket(*Packet8ALayer)
	// GenerateTicketHash should implement the hashing algorithm
	// used for auth ticket hashes in Packet8ALayer
	GenerateTicketHash(ticket string) uint32
	// GenerateLuauResponse should implement the Luau calback based
	// hashing algorithm used in Packet8ALayer
	GenerateLuauResponse(ticket string) uint32
	// OSPlatform should return a string recognized by Roblox
	// that names the Roblox client platform (Win32, Windows_Universal, Android, etc.)
	OSPlatform() string
	// UserAgent should return a user agent string to be used in
	// HTTP requests
	UserAgent() string
	// VersionID should return the version id to be passed to
	// ID_PROTOCOL_SYNC serialization as well as used to generate the
	// ID_SUBMIT_TICKET encryption key
	VersionID() [5]int32
}

SecurityHandler describes an interface that provides emulation of a certain Roblox client

func Win10Settings

func Win10Settings(args ...string) SecurityHandler

Win10Settings returns a SecurityHandler that imitates a Win10Universal client (Windows Store version) You can optionally pass a custom UserAgent as an argument

type ServerClient

type ServerClient struct {
	PacketLogicHandler
	Server  *CustomServer
	Address *net.UDPAddr

	Player *datamodel.Instance
	// Index is the player's index within the server.
	// Among other things, it is used in the determining the player's name
	// (i.e. Player1, Player2, etc.)
	Index int
	// contains filtered or unexported fields
}

ServerClient represents a local server's connection to a remote client TODO: Filtering?

func (*ServerClient) BindDefaultDataModelHandlers

func (client *ServerClient) BindDefaultDataModelHandlers()

BindDefaultDataModelHandlers binds the client's DataModel handlers so that the client's changes will be reflected in the DataModel

func (*ServerClient) ReadPacket

func (client *ServerClient) ReadPacket(buf []byte)

ReadPacket processes a UDP packet sent by the client Its first argument is a byte slice containing the UDP payload

func (*ServerClient) ReplicationConfig

func (client *ServerClient) ReplicationConfig(inst *datamodel.Instance) *ReplicationContainer

ReplicationConfig returns the replication configuration for an instance

type ServerMemoryStats

type ServerMemoryStats struct {
	TotalServerMemory  float64
	DeveloperTags      []MemoryStatsItem
	InternalCategories []MemoryStatsItem
}

ServerMemoryStats represents the server memory stats reported

type SplitPacketBuffer

type SplitPacketBuffer struct {
	// All ReliabilityLayer packets for this packet received so far
	ReliablePackets []*ReliablePacket
	// All RakNet layers for this packet received so far
	// IN RECEIVE ORDER, NOT SPLIT ORDER!!
	// Use ReliablePackets[i].RakNetLayer to access them in that order.
	RakNetPackets []*RakNetLayer
	// Next expected index
	NextExpectedPacket uint32
	// Number of _ordered_ splits we have received so far
	NumReceivedSplits uint32
	// Has received packet type yet? Set to true when the first split of this packet
	// is received
	HasPacketType bool
	PacketType    byte

	Data []byte

	// Have all splits been received?
	IsFinal bool
	// Total length received so far, in bytes
	RealLength uint32
	UniqueID   uint64

	Logger *log.Logger
	// contains filtered or unexported fields
}

SplitPacketBuffer represents a structure that accumulates every layer that is used to transmit the split packet.

type StreamInfo

type StreamInfo struct {
	X int32
	Y int32
	Z int32
}

StreamInfo represents a streaming region id

func (StreamInfo) Serialize

func (info StreamInfo) Serialize(stream *extendedWriter) error

Serialize writes the StreamInfo into a network stream

func (StreamInfo) String

func (info StreamInfo) String() string

type StringCache

type StringCache struct {
	// Values contains the stored strings.
	Values [0x80]interface{}
	// contains filtered or unexported fields
}

StringCache represents a cache that stores strings.

func (*StringCache) Equal

func (c *StringCache) Equal(index uint8, val interface{}) (bool, bool)

Equal implements Cache.Equal()

func (*StringCache) Get

func (c *StringCache) Get(index uint8) (interface{}, bool)

Get implements Cache.Get()

func (*StringCache) LastWrite

func (c *StringCache) LastWrite() uint8

LastWrite implements Cache.LastWrite()

func (*StringCache) Put

func (c *StringCache) Put(val interface{}, index uint8)

Put implements Cache.Put()

Jump to

Keyboard shortcuts

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