Documentation ¶
Overview ¶
Package maplelib contains various go utilities related to MapleStory (encryption, packets, and so on)
Index ¶
- func Crc32(crc uint32, data []byte) uint32
- func GetPacketLength(encryptedHeader []byte) int
- type Crypt
- type EndOfPacketError
- type Packet
- func (p *Packet) Append(data []byte)
- func (p Packet) At(i int) PacketIterator
- func (p Packet) Begin() PacketIterator
- func (p *Packet) Encode1(b byte)
- func (p *Packet) Encode1s(b int8)
- func (p *Packet) Encode2(w uint16)
- func (p *Packet) Encode2s(b int16)
- func (p *Packet) Encode4(dw uint32)
- func (p *Packet) Encode4s(b int32)
- func (p *Packet) Encode8(qw uint64)
- func (p *Packet) Encode8s(b int64)
- func (p *Packet) EncodeBuffer(b []byte)
- func (p *Packet) EncodeString(str string)
- func (p Packet) String() string
- type PacketIterator
- func (it *PacketIterator) Decode1() (res byte, err error)
- func (it *PacketIterator) Decode1s() (res int8, err error)
- func (it *PacketIterator) Decode2() (res uint16, err error)
- func (it *PacketIterator) Decode2s() (res int16, err error)
- func (it *PacketIterator) Decode4() (res uint32, err error)
- func (it *PacketIterator) Decode4s() (res int32, err error)
- func (it *PacketIterator) Decode8() (res uint64, err error)
- func (it *PacketIterator) Decode8s() (res int64, err error)
- func (it *PacketIterator) DecodeBuffer() (res []byte, err error)
- func (it *PacketIterator) DecodeString() (res string, err error)
- func (it *PacketIterator) PopBytes(count int) (res []byte, err error)
- func (it *PacketIterator) Skip(count int) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Crc32 ¶
Crc32 calculates the checksum for data using the initial checksum value crc. Maplestory's CRC32 uses the IEEE polynomial without mirroring.
func GetPacketLength ¶
GetPacketLength decodes the packet length from the encrypted header. NOTE: this size does not include the 4-byte encrypted header.
Types ¶
type Crypt ¶
type Crypt struct {
// contains filtered or unexported fields
}
A Crypt is an encryption key for MapleStory packets. It consists of a 4-byte value repeated four times for a total of 16 bytes.
MapleStory uses two keys: one is used to encrypt sent packets and the other is used to decrypt received packets. This is valid for both the client and the server. The two keys are randomly generated when a client connects and sent in the unencrypted handshake packet which is the first packet that is sent to a client that connects to a server. The MapleStory protocol will shift encryption keys every time a packet is send or received, so you will have to call .Shuffle() every time this happens.
func (*Crypt) Decrypt ¶
Decrypt decrypts the given array of bytes. NOTE: you must omit the first 4 bytes (encrypted header)
func (*Crypt) DecryptNoShanda ¶
DecryptNoShanda decrypts the given array of bytes only using maple's AES. NOTE: you must omit the first 4 bytes (encrypted header)
func (*Crypt) Encrypt ¶
Encrypt encrypts the given array of bytes. NOTE: the array must have 4 bytes of space at the beginning for the encrypted header
func (*Crypt) EncryptNoShanda ¶
EncryptNoShanda encrypts the given array of bytes only using maple's AES. NOTE: the array must have 4 bytes of space at the beginning for the encrypted header
func (*Crypt) MapleVersion ¶
MapleVersion returns the target MapleStory version for this encryption key
type EndOfPacketError ¶
type EndOfPacketError struct {
// contains filtered or unexported fields
}
A EndOfPacketError is returned when trying to read past the end of the packet
func (EndOfPacketError) Error ¶
func (e EndOfPacketError) Error() string
type Packet ¶
type Packet []byte
A Packet is an array of bytes that contains a decrypted MapleStory packet. All of the numeric values are encoded in little endian.
func NewPacket ¶
func NewPacket() Packet
NewPacket initializes an empty packet NOTE: do not create packets with make or new, as that will cause unexpected behaviour
func (Packet) At ¶
func (p Packet) At(i int) PacketIterator
At returns a packet iterator that points at the desired position
func (Packet) Begin ¶
func (p Packet) Begin() PacketIterator
Begin returns a packet iterator that points to the beginning of the packet
func (*Packet) EncodeBuffer ¶
EncodeBuffer encodes and appends a buffer to the packet using 2 bytes for the length followed by the data
func (*Packet) EncodeString ¶
EncodeString encodes and appends a string to the packet using 2 bytes for the length followed by the text bytes
type PacketIterator ¶
type PacketIterator []byte
A PacketIterator is a slice of the packet array which is used as an iterator when reading values
func (*PacketIterator) Decode1 ¶
func (it *PacketIterator) Decode1() (res byte, err error)
Decode1 decodes a byte at the current position of the iterator which is then incremented
func (*PacketIterator) Decode1s ¶
func (it *PacketIterator) Decode1s() (res int8, err error)
Decode1 with signed values
func (*PacketIterator) Decode2 ¶
func (it *PacketIterator) Decode2() (res uint16, err error)
Decode2 decodes a word (2 bytes) at the current position of the iterator which is then incremented
func (*PacketIterator) Decode2s ¶
func (it *PacketIterator) Decode2s() (res int16, err error)
Decode2 with signed values
func (*PacketIterator) Decode4 ¶
func (it *PacketIterator) Decode4() (res uint32, err error)
Decode4 decodes a dword (4 bytes) at the current position of the iterator which is then incremented
func (*PacketIterator) Decode4s ¶
func (it *PacketIterator) Decode4s() (res int32, err error)
Decode4 with signed values
func (*PacketIterator) Decode8 ¶
func (it *PacketIterator) Decode8() (res uint64, err error)
Decode8 decodes a qword (8 bytes) at the current position of the iterator which is then incremented
func (*PacketIterator) Decode8s ¶
func (it *PacketIterator) Decode8s() (res int64, err error)
Decode8 with signed values
func (*PacketIterator) DecodeBuffer ¶
func (it *PacketIterator) DecodeBuffer() (res []byte, err error)
DecodeBuffer decodes a buffer and returns a slice of the packet that points to the buffer NOTE: the returned slice is NOT a copy and any operation on it will affect the packet
func (*PacketIterator) DecodeString ¶
func (it *PacketIterator) DecodeString() (res string, err error)
DecodeString decodes a string and returns it as a copy of the data
func (*PacketIterator) PopBytes ¶
func (it *PacketIterator) PopBytes(count int) (res []byte, err error)
PopBytes returns a slice of the packet of count length starting from the iterator. NOTE: the returned slice is NOT a copy and any operation on it will affect the packet.
func (*PacketIterator) Skip ¶
func (it *PacketIterator) Skip(count int) error
Skip moves the iterator forward by count bytes.