Documentation ¶
Overview ¶
Package net implements network communication primitives for the login and gameworld protocol.
This includes a message (a single communications block sent by client or server) and encryption primitives.
Index ¶
- Variables
- type Message
- func (msg *Message) Decrypt(xteaKey [16]byte) (*Message, error)
- func (msg *Message) Encrypt(xteaKey [16]byte) (*Message, error)
- func (msg *Message) Finalize(xteaKey [16]byte) (*Message, error)
- func (msg *Message) PrependSize() (*Message, error)
- func (msg *Message) RSADecryptRemainder(pk *rsa.PrivateKey) error
- func (msg *Message) Read(b []byte) (int, error)
- func (msg *Message) ReadTibiaPosition() (Position, error)
- func (msg *Message) ReadTibiaString() (string, error)
- func (msg *Message) WriteTibiaPosition(pos Position) error
- func (msg *Message) WriteTibiaString(s string) error
- type Position
Constants ¶
This section is empty.
Variables ¶
var ErrDecryption = rsa.ErrDecryption
Functions ¶
This section is empty.
Types ¶
type Message ¶
Message implements the network message primitive in the login and gameworld protocols, and provides an io.Reader and io.Writer interface.
It happens to be a bytes.Buffer.
func ReadMessage ¶
ReadMessage reads the message primitive from the passed reader, and returns it as a new Message.
func (*Message) Decrypt ¶
Decrypt reads through the entire message buffer (moving the read cursor), and returns a new Message containing the decrypted buffer.
func (*Message) Encrypt ¶
Encrypt reads through the entire message buffer (moving the read cursor), and returns a new Message containing the encrypted buffer.
func (*Message) Finalize ¶
Finalize correctly adds the message length and checksum, as well as performs the XTEA encryption on the message.
func (*Message) PrependSize ¶
PrependSize only prepends the size+checksum+innert size to the message. Used only to send initial 0x1F packet.
func (*Message) RSADecryptRemainder ¶
func (msg *Message) RSADecryptRemainder(pk *rsa.PrivateKey) error
RSADecryptRemainder checks if the remaining bytes form 128 bytes of data, and decrypts them using the passed RSA private key.
Once decrypted, the bytes are overwritten in the original buffer, instead of being returned as a new message.
func (*Message) Read ¶
Read fetches bytes into the passed byte slice, and returns how many bytes were read.
This implements the io.Reader protocol, but happens to be only a thin wrapper around bytes.Buffer. Specific implementation will probably be dropped in favor of fully reusing the bytes.Buffer implementation.
func (*Message) ReadTibiaPosition ¶
ReadTibiaPosition is a helper function to decode Tibia-style position on the tiled map.
func (*Message) ReadTibiaString ¶
ReadTibiaString is a helper function to decode Tibia-style strings coming up in the buffer: u16+bytes of the message.
func (*Message) WriteTibiaPosition ¶
WriteTibiaPosition is a helper function to encode Tibia-style position on the tiled map.
func (*Message) WriteTibiaString ¶
WriteTibiaString is a helper function to encode Tibia-style string passed, appending it onto the message buffer.