client

package
v0.0.0-...-34f5af7 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {

	// Cipher implementation responsible for packet encryption.
	CryptoSession CryptoSession

	// Account associated with the player.
	Account *proto.Account

	// Client information shared amongst most Backend implementations.
	Config ClientConfig

	Flag   uint32
	TeamID uint32
	IsGm   bool
	// The slot corresponding to the currently active character.
	ActiveSlot uint32
	// Guildcard linked to the account.
	Guildcard     uint32
	GuildcardData []byte

	// File list used exclusively by the Data server for tracking which
	// files need updating. TODO: This ought to be expressed more gracefully
	// but we have very little information by which we can identify a unique
	// PSO client in the patch phase and this is easy so...here we are.
	FilesToUpdate map[int]interface{}

	// Debugging information used for logging purposes.
	Debug     bool
	DebugTags map[string]debug.Tag
	// contains filtered or unexported fields
}

Client represents a user connected through a PSOBB game client.

func NewClient

func NewClient(connection *net.TCPConn) *Client

func (*Client) Close

func (c *Client) Close() error

Close the TCP connection.

func (*Client) IPAddr

func (c *Client) IPAddr() string

func (*Client) Port

func (c *Client) Port() string

func (*Client) Read

func (c *Client) Read(b []byte) (int, error)

Read consumes the available bytes directly the client's TCP connection.

func (*Client) Send

func (c *Client) Send(packet interface{}) error

Send converts a packet struct to bytes and encrypts it before using the server's session key before sending the data to the client.

func (*Client) SendRaw

func (c *Client) SendRaw(packet interface{}) error

SendRaw writes all data contained in the slice to the client as-is (e.g. without encrypting it first).

func (*Client) Write

func (c *Client) Write(bytes []byte) (int, error)

Write directly sends data to the client over its TCP connection.

type ClientConfig

type ClientConfig struct {
	// The rest of this holds various portions of client state to represent
	// the client's progression through the login process.
	Magic        uint32 // Must be set to 0x48615467
	CharSelected uint8  // Has a character been selected?
	SlotNum      uint8  // Slot number of selected Character
	Flags        uint16
	Ports        [4]uint16
	Unused       [4]uint32
	Unused2      [2]uint32
}

type CryptoSession

type CryptoSession interface {
	// HeaderSize returns the length of the header of all client packets.
	HeaderSize() uint16

	// Encrypt encrypts bytes in place with the encryption key for the server.
	Encrypt(bytes []byte, length uint32)

	// Decrypt decrypts bytes in place with the encryption key for the client.
	Decrypt(bytes []byte, length uint32)

	// ServerVector returns the key used to initialize the server's block cipher.
	ServerVector() []byte

	// ClientVector returns the key used to initialize the client's's block cipher.
	ClientVector() []byte
}

CryptoSession is an interface for the cryptographic operations required to exchange packets between a PSO game client and the server. It consists of one or more ciphers that handle encrypting packets from the server and decrypting packets from the client.

func NewBlueBurstCryptoSession

func NewBlueBurstCryptoSession() CryptoSession

NewBlueBurstCryptoSession returns a CryptoSession with newly initialized ciphers that can be used to communicate with a PSO Blue Burst client.

func NewPCCryptoSession

func NewPCCryptoSession() CryptoSession

NewPCCryptoSession returns a CryptoSession with newly initialized ciphers that can be used to communicate with either a PSO PC client or the patch protocol used by the PSO Blue Burst client.

Jump to

Keyboard shortcuts

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