Base Module =========== This module contains common functions and classes used throughout the rest of the library .. cpp:function:: static std::string get_user_salt() This generates a uuid4 for use in this library .. cpp:var:: const static std::string user_salt A generated uuid4 for use in this library .. cpp:function:: unsigned long long unpack_value(std::string str) Unpacks a big-endian binary value into an unsigned long long :param str: The value you'd like to unpack :returns: The value this string contained .. warning:: Integer overflow will not be accounted for .. cpp:function:: std::string pack_value(size_t len, unsigned long long i) Packs an unsigned long long into a big-endian binary string of length len :param len: The length of the string you'd like to produce :param i: The value you'd like to pack :returns: A :cpp:class:`std::string` packed with the equivalent big-endian data .. warning:: Integer overflow will not be accounted for .. cpp:function:: std::string sanitize_string(std::string str, bool sizeless) This function takes in a string and removes metadata that the :cpp:class:`pathfinding_message` deserializer can't handle :param str: The string you would like to sanitize :param sizeless: A bool indicating if this string has a size header attached :returns: A :cpp:class:`std::string` which has the safe version of ``str`` .. cpp:function:: std::string decompress_string(std::string str, std::vector compressions) This function is currently an identity function which returns ``str``. In the future this function will decompress strings for the :cpp:class:`pathfinding_message` parser to deal with. :param str: The string you would like to decompress :param compressions: A :cpp:class:`std::vector\` which contains the list of possible compression methods :returns: A :cpp:class:`std::string` which has the decompressed version of ``str`` .. cpp:function:: std::vector process_string(std::string str) This deserializes a :cpp:class:`pathfinding_message` string into a :cpp:class:`std::vector\` of packets :param str: The :cpp:class`std::string` you would like to parse :returns: A :cpp:class:`std::vector\` which contains the packets serialized in this string .. cpp:class:: protocol This class is used as a subnet object. Its role is to reject undesired connections. If you connect to someone who has a different protocol object than you, this descrepency is detected, and you are silently disconnected. .. cpp:function:: protocol::protocol(std::string, std::string encryption) :param subnet: The subnet you'd like to use :param encryption: The encryption method you'd like to use .. cpp:function:: protocol::~protocol() An empty deconstructor .. cpp:function:: std::string protocol::id() :returns: A :cpp:class:`std::string` which contains the base_58 encoded, SHA256 based ID of this protocol object .. cpp:function:: std::string protocol::subnet() .. cpp:function:: std::string protocol::encryption() .. cpp:class:: pathfinding_message This is the message serialization/deserialization class. .. note:: This is just a wrapper for :c:type:`InternalMessageStruct`. Use that if you prefer efficiency over pleasant APIs. .. cpp:function:: pathfinding_message::pathfinding_message(std::string msg_type, std::string sender, std::vector payload) .. cpp:function:: pathfinding_message::pathfinding_message(std::string msg_type, std::string sender, std::vector payload, std::vector compressions) :param msg_type: This is the main flag checked by nodes, used for routing information :param sender: The ID of the person sending the message :param payload: A :cpp:class:`std::vector\` of "packets" that you want your peers to receive :param compression: A :cpp:class:`std::vector\` of compression methods that the receiver supports .. cpp:function:: static pathfinding_message *pathfinding_message::feed_string(std::string msg) .. cpp:function:: static pathfinding_message *pathfinding_message::feed_string(std::string msg, bool sizeless) .. cpp:function:: static pathfinding_message *pathfinding_message::feed_string(std::string msg, std::vector compressions) .. cpp:function:: static pathfinding_message *pathfinding_message::feed_string(std::string msg, bool sizeless, std::vector compressions) :param msg: A :cpp:class:`std::string` which contains the serialized message :param sizeless: A :c:type:`bool` which indicates if the message has a size header attached (default: it does) :param compressions: A :cpp:class:`std::vector\` which contains the possible compression methods this message may be using :returns: A pointer to the deserialized message .. cpp:function:: pathfinding_message::~pathfinding_message() .. cpp:var:: std::string pathfinding_message::msg_type() .. cpp:var:: std::string pathfinding_message::sender() .. cpp:var:: unsigned long long pathfinding_message::timestamp() .. cpp:var:: std::vector pathfinding_message::payload() .. cpp:var:: std::vector pathfinding_message::compression() .. cpp:function:: std::string pathfinding_message::compression_used() :returns: The compression method this message was sent under .. cpp:function:: std::string pathfinding_message::time_58() :returns: :cpp:var:`pathfinding_message::timestamp` encoded in base_58 .. cpp:function:: std::string pathfinding_message::id() :returns: A SHA384 hash of this message encoded in base_58 .. cpp:function:: std::vector pathfinding_message::packets() A copy of :cpp:var:`pathfinding_message::payload` with some additional metadata appended to the front. Specifically: 0. :cpp:var:`pathfinding_message::msg_type` #. :cpp:var:`pathfinding_message::sender` #. :cpp:func:`pathfinding_message::id()` #. :cpp:func:`pathfinding_message::time_58()` #. :cpp:var:`pathfinding_message::payload` from here on out :returns: A :cpp:class:`std::vector\` in the above format .. cpp:function:: std::string pathfinding_message::str() :returns: the serialized message, including the four byte size header at the beginning .. cpp:function:: unsigned long long pathfinding_message::length() :returns: the length of the serialized message, excepting the four byte size header at the beginning .. cpp:function:: std::string pathfinding_message::header() :returns: the four byte size header at the beginning of the serialized message