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.
decrypt performs an RSA decryption, resulting in a plaintext integer. If a random source is given, RSA blinding is used.
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.
NewMessage creates a new blank message primitive.
ReadMessage reads the message primitive from the passed reader, and returns it as a new Message.
Decrypt reads through the entire message buffer (moving the read cursor), and returns a new Message containing the decrypted buffer.
Encrypt reads through the entire message buffer (moving the read cursor), and returns a new Message containing the encrypted buffer.
Finalize correctly adds the message length and checksum, as well as performs the XTEA encryption on the message.
PrependSize only prepends the size+checksum+innert size to the message. Used only to send initial 0x1F packet.
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.
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.
ReadTibiaPosition is a helper function to decode Tibia-style position on the tiled map.
ReadTibiaString is a helper function to decode Tibia-style strings coming up in the buffer: u16+bytes of the message.
WriteTibiaPosition is a helper function to encode Tibia-style position on the tiled map.
WriteTibiaString is a helper function to encode Tibia-style string passed, appending it onto the message buffer.
Position defines the network representation of a character or creature position in the tiled world.