packet

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Index

Constants

View Source
const (
	AuthResponseSuccess byte = iota
	AuthResponseIncorrectSecret
	AuthResponseUnknownType
	AuthResponseInvalidData
)
View Source
const (
	IDAuthRequest uint16 = iota
	IDAuthResponse
	IDTransferRequest
	IDTransferResponse
	IDPlayerInfoRequest
	IDPlayerInfoResponse
	IDServerListRequest
	IDServerListResponse
	IDFindPlayerRequest
	IDFindPlayerResponse
	IDUpdatePlayerLatency
)
View Source
const (
	PlayerInfoResponseSuccess byte = iota
	PlayerInfoResponsePlayerNotFound
)
View Source
const (
	TransferResponseSuccess byte = iota
	TransferResponseGroupNotFound
	TransferResponseServerNotFound
	TransferResponseAlreadyOnServer
	TransferResponsePlayerNotFound
	TransferResponseError
)
View Source
const (
	ClientTypeServer = iota
)

Variables

This section is empty.

Functions

func Register

func Register(id uint16, pk func() Packet)

Register registers a function that returns a packet for a specific ID. Packets with this ID coming in from connections will resolve to the packet returned by the function passed.

Types

type AuthRequest

type AuthRequest struct {
	// Type is the type of connection being made. The different types can be seen above.
	Type byte
	// Secret is the secret key to authenticate with. It must match the configured key in the proxy otherwise
	// the client will not be authenticated.
	Secret string
	// Name is the name of the client that is being authenticated. The name must be different to existing
	// connections.
	Name string
	// ExtraData contains extra data linked to the connection. Different types of connections will require
	// different data to be provided.
	ExtraData []byte
}

AuthRequest is sent by a connection to authenticate with the proxy.

func (*AuthRequest) ID

func (pk *AuthRequest) ID() uint16

ID ...

func (*AuthRequest) Marshal

func (pk *AuthRequest) Marshal(w *protocol.Writer)

Marshal ...

func (*AuthRequest) Unmarshal

func (pk *AuthRequest) Unmarshal(r *protocol.Reader)

Unmarshal ...

type AuthResponse

type AuthResponse struct {
	// Status is the response status from authentication. The possible values for this can be found above.
	Status byte
}

AuthResponse is sent by the proxy in response to AuthRequest. It tells the client if the authentication request was successful or not.

func (*AuthResponse) ID

func (*AuthResponse) ID() uint16

ID ...

func (*AuthResponse) Marshal

func (pk *AuthResponse) Marshal(w *protocol.Writer)

Marshal ...

func (*AuthResponse) Unmarshal

func (pk *AuthResponse) Unmarshal(r *protocol.Reader)

Unmarshal ...

type FindPlayerRequest

type FindPlayerRequest struct {
	// PlayerUUID is the UUID of the player to find.
	PlayerUUID uuid.UUID
	// PlayerName is the name of the player to find.
	PlayerName string
}

FindPlayerRequest is sent by a connection to find the server the request player is currently on.

func (*FindPlayerRequest) ID

func (*FindPlayerRequest) ID() uint16

ID ...

func (*FindPlayerRequest) Marshal

func (pk *FindPlayerRequest) Marshal(w *protocol.Writer)

Marshal ...

func (*FindPlayerRequest) Unmarshal

func (pk *FindPlayerRequest) Unmarshal(r *protocol.Reader)

Unmarshal ...

type FindPlayerResponse

type FindPlayerResponse struct {
	// PlayerUUID is the UUID of the player that has been searched for.
	PlayerUUID uuid.UUID
	// PlayerName is the name of the player that has been searched for.
	PlayerName string
	// Online is if the player is connected to the proxy.
	Online bool
	// Group is the group the player is in, if connected.
	Group string
	// Server is the server within the group the player is in, if connected.
	Server string
}

FindPlayerResponse is sent by the proxy in response to PlayerInfoRequest to tell the connection the XUID and IP address of the requested player.

func (*FindPlayerResponse) ID

func (*FindPlayerResponse) ID() uint16

ID ...

func (*FindPlayerResponse) Marshal

func (pk *FindPlayerResponse) Marshal(w *protocol.Writer)

Marshal ...

func (*FindPlayerResponse) Unmarshal

func (pk *FindPlayerResponse) Unmarshal(r *protocol.Reader)

Unmarshal ...

type Header struct {
	PacketID uint16
}

func (*Header) Read

func (header *Header) Read(r io.ByteReader) error

func (*Header) Write

func (header *Header) Write(w io.ByteWriter) error

type Packet

type Packet interface {
	// ID returns the ID of the packet. All of these identifiers of packets may be found in id.go.
	ID() uint16
	// Marshal encodes the packet to its binary representation into buf.
	Marshal(w *protocol.Writer)
	// Unmarshal decodes a serialised packet in buf into the Packet instance. The serialised packet passed
	// into Unmarshal will not have a header in it.
	Unmarshal(r *protocol.Reader)
}

type PlayerInfoRequest

type PlayerInfoRequest struct {
	// PlayerUUID is the UUID of the player to get information about.
	PlayerUUID uuid.UUID
}

PlayerInfoRequest is sent by a connection to request information such as the XUID and IP address of a player connected to the proxy.

func (*PlayerInfoRequest) ID

func (*PlayerInfoRequest) ID() uint16

ID ...

func (*PlayerInfoRequest) Marshal

func (pk *PlayerInfoRequest) Marshal(w *protocol.Writer)

Marshal ...

func (*PlayerInfoRequest) Unmarshal

func (pk *PlayerInfoRequest) Unmarshal(r *protocol.Reader)

Unmarshal ...

type PlayerInfoResponse

type PlayerInfoResponse struct {
	// PlayerUUID is the UUID of the player the information belongs to.
	PlayerUUID uuid.UUID
	// Status is the response status from fetching the player information. The possible values for this can
	// be found above.
	Status byte
	// XUID is the Xbox Unique Identifier of the requested player.
	XUID string
	// Address is the IP address of the requested player. This can be IPv4 or IPv6 depending on which address
	// they join with.
	Address string
}

PlayerInfoResponse is sent by the proxy in response to PlayerInfoRequest to tell the connection the XUID and IP address of the requested player.

func (*PlayerInfoResponse) ID

func (*PlayerInfoResponse) ID() uint16

ID ...

func (*PlayerInfoResponse) Marshal

func (pk *PlayerInfoResponse) Marshal(w *protocol.Writer)

Marshal ...

func (*PlayerInfoResponse) Unmarshal

func (pk *PlayerInfoResponse) Unmarshal(r *protocol.Reader)

Unmarshal ...

type Pool

type Pool map[uint16]Packet

Pool is a map holding packets indexed by a packet ID.

func NewPool

func NewPool() Pool

NewPool returns a new pool with all supported packets sent. Packets may be retrieved from it simply by indexing it with the packet ID.

type ServerEntry

type ServerEntry struct {
	// Name is name of the server.
	Name string
	// Group is group of the server.
	Group string
	// Online returns if the server is connected to the TCP socket server or not.
	Online bool
	// PlayerCount returns player count of the server.
	PlayerCount int64
}

ServerEntry represents server connected the proxy.

type ServerListRequest

type ServerListRequest struct{}

ServerListRequest is sent by the client to request list of all the servers connected to portal proxy (including offline servers).

func (*ServerListRequest) ID

func (*ServerListRequest) ID() uint16

ID ...

func (*ServerListRequest) Marshal

func (pk *ServerListRequest) Marshal(w *protocol.Writer)

Marshal ...

func (*ServerListRequest) Unmarshal

func (pk *ServerListRequest) Unmarshal(r *protocol.Reader)

Unmarshal ...

type ServerListResponse

type ServerListResponse struct {
	// Servers represents all the servers connected to the proxy.
	Servers []ServerEntry
}

ServerListResponse is sent by the proxy in response to ServerListRequest. It sends list of all the servers connected to the proxy.

func (*ServerListResponse) ID

func (*ServerListResponse) ID() uint16

ID ...

func (*ServerListResponse) Marshal

func (pk *ServerListResponse) Marshal(w *protocol.Writer)

Marshal ...

func (*ServerListResponse) Unmarshal

func (pk *ServerListResponse) Unmarshal(r *protocol.Reader)

Unmarshal ...

type TransferRequest

type TransferRequest struct {
	// PlayerUUID is the UUID of the player to be transferred.
	PlayerUUID uuid.UUID
	// Group is the name of the group to transfer the player to.
	Group string
	// Server is the name of the server in the group to transfer to.
	Server string
}

TransferRequest is sent by a server to request the transfer of a player.

func (*TransferRequest) ID

func (*TransferRequest) ID() uint16

ID ...

func (*TransferRequest) Marshal

func (pk *TransferRequest) Marshal(w *protocol.Writer)

Marshal ...

func (*TransferRequest) Unmarshal

func (pk *TransferRequest) Unmarshal(r *protocol.Reader)

Unmarshal ...

type TransferResponse

type TransferResponse struct {
	// PlayerUUID is the UUID of the player being transferred.
	PlayerUUID uuid.UUID
	// Status is the response status from the transfer. The possible values for this can be found above.
	Status byte
	// Error is the error message when the Status field is TransferResponseError.
	Error string
}

TransferResponse is sent by the proxy in response to a transfer request.

func (*TransferResponse) ID

func (*TransferResponse) ID() uint16

ID ...

func (*TransferResponse) Marshal

func (pk *TransferResponse) Marshal(w *protocol.Writer)

Marshal ...

func (*TransferResponse) Unmarshal

func (pk *TransferResponse) Unmarshal(r *protocol.Reader)

Unmarshal ...

type UpdatePlayerLatency

type UpdatePlayerLatency struct {
	// PlayerUUID is the UUID of the player the latency belongs to.
	PlayerUUID uuid.UUID
	// Latency is the latency of the player's connection to the proxy in milliseconds.
	Latency int64
}

UpdatePlayerLatency is sent by the proxy to update a player's latency on the server they are connected to.

func (*UpdatePlayerLatency) ID

ID ...

func (*UpdatePlayerLatency) Marshal

func (pk *UpdatePlayerLatency) Marshal(w *protocol.Writer)

Marshal ...

func (*UpdatePlayerLatency) Unmarshal

func (pk *UpdatePlayerLatency) Unmarshal(r *protocol.Reader)

Unmarshal ...

Jump to

Keyboard shortcuts

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