Namespaces | |
| namespace | bencode |
| Utility functions. | |
| namespace | network_utils |
| namespace | SearchNodeFlags |
| Search node state flags (bitfield) Flags can be combined to track the full history of a node in a search. | |
Classes | |
| class | BencodeDecoder |
| Bencode decoder. More... | |
| class | BencodeValue |
| Represents a bencoded value which can be: More... | |
| struct | DeferredCallbacks |
| Deferred callbacks structure for avoiding deadlock Callbacks are collected while holding the mutex, then invoked after releasing it. More... | |
| class | DhtClient |
| DHT Kademlia implementation. More... | |
| struct | DhtNode |
| DHT Node information Based on libtorrent's node_entry with fail_count and RTT tracking. More... | |
| struct | DirectoryEntry |
| struct | DirectoryMetadata |
| Directory transfer metadata. More... | |
| struct | DnsHeader |
| struct | DnsMessage |
| struct | DnsQuestion |
| struct | DnsResourceRecord |
| struct | FileChunk |
| File transfer chunk information. More... | |
| struct | FileMetadata |
| File metadata for transfers. More... | |
| struct | FileTransferConfig |
| File transfer configuration. More... | |
| class | FileTransferManager |
| File transfer manager class Handles efficient chunked file transfers with resume capability. More... | |
| struct | FileTransferProgress |
| File transfer progress information. More... | |
| class | GossipSub |
| Main GossipSub implementation class. More... | |
| struct | GossipSubConfig |
| GossipSub configuration parameters. More... | |
| struct | IceCandidate |
| ICE candidate. More... | |
| struct | IceCandidatePair |
| ICE candidate pair. More... | |
| struct | IceConfig |
| ICE configuration. More... | |
| class | IceManager |
| ICE-lite Manager for NAT traversal. More... | |
| struct | IceServer |
| STUN/TURN server configuration. More... | |
| struct | KrpcMessage |
| KRPC Message structure. More... | |
| struct | KrpcNode |
| KRPC Node information. More... | |
| class | KrpcProtocol |
| KRPC Protocol implementation. More... | |
| class | Logger |
| class | MdnsClient |
| struct | MdnsService |
| struct | MessageHeader |
| Message header structure for librats messages Fixed 8-byte header format: [0-3]: Magic number "RATS" (4 bytes) [4]: Message data type (1 byte) [5-7]: Reserved for future use (3 bytes) More... | |
| struct | MessageMetadata |
| Message metadata for tracking and deduplication. More... | |
| struct | Peer |
| UDP peer information. More... | |
| struct | PeerScore |
| Peer scoring metrics for mesh management. More... | |
| class | RatsClient |
| RatsClient - Core peer-to-peer networking client. More... | |
| struct | RatsPeer |
| RatsPeer struct - comprehensive information about a connected rats peer. More... | |
| struct | ReconnectConfig |
| ReconnectConfig - Configuration for automatic peer reconnection. More... | |
| struct | ReconnectInfo |
| ReconnectInfo - Information about a peer pending reconnection. More... | |
| class | SHA1 |
| struct | StunAttribute |
| STUN attribute base class. More... | |
| class | StunClient |
| STUN Client for NAT traversal. More... | |
| struct | StunClientConfig |
| STUN client configuration. More... | |
| struct | StunError |
| STUN error information. More... | |
| struct | StunMappedAddress |
| STUN mapped address (result of binding request) More... | |
| struct | StunMessage |
| STUN message structure. More... | |
| struct | StunResult |
| STUN transaction result. More... | |
| struct | SystemInfo |
| class | ThreadManager |
| ThreadManager - Manages background threads with graceful shutdown. More... | |
| struct | TopicSubscription |
| Topic subscription information. More... | |
Typedefs | |
| using | MessageValidator = std::function< ValidationResult(const std::string &topic, const std::string &message, const std::string &sender_peer_id)> |
| Callback types for GossipSub. | |
| using | MessageHandler = std::function< void(const std::string &topic, const std::string &message, const std::string &sender_peer_id)> |
| using | PeerJoinedHandler = std::function< void(const std::string &topic, const std::string &peer_id)> |
| using | PeerLeftHandler = std::function< void(const std::string &topic, const std::string &peer_id)> |
| using | FileTransferProgressCallback = std::function< void(const FileTransferProgress &)> |
| Callback function types for file transfer events. | |
| using | FileTransferCompletedCallback = std::function< void(const std::string &transfer_id, bool success, const std::string &error_message)> |
| using | FileTransferRequestCallback = std::function< bool(const std::string &peer_id, const FileMetadata &metadata, const std::string &transfer_id)> |
| using | DirectoryTransferProgressCallback = std::function< void(const std::string &transfer_id, const std::string ¤t_file, uint64_t files_completed, uint64_t total_files, uint64_t bytes_completed, uint64_t total_bytes)> |
| using | FileRequestCallback = std::function< bool(const std::string &peer_id, const std::string &file_path, const std::string &transfer_id)> |
| using | DirectoryRequestCallback = std::function< bool(const std::string &peer_id, const std::string &directory_path, bool recursive, const std::string &transfer_id)> |
| using | NodeId = std::array< uint8_t, NODE_ID_SIZE > |
| using | InfoHash = std::array< uint8_t, NODE_ID_SIZE > |
| using | PeerDiscoveryCallback = std::function< void(const std::vector< Peer > &peers, const InfoHash &info_hash)> |
| Peer discovery callback. | |
| using | SpiderAnnounceCallback = std::function< void(const InfoHash &info_hash, const Peer &peer)> |
| Spider mode callback Called when a peer announces they have a torrent (announce_peer request received) | |
| using | IceCandidatesCallback = std::function< void(const std::vector< IceCandidate > &)> |
| Callback when candidates are gathered. | |
| using | IceGatheringStateCallback = std::function< void(IceGatheringState)> |
| Callback when gathering state changes. | |
| using | IceConnectionStateCallback = std::function< void(IceConnectionState)> |
| Callback when connection state changes. | |
| using | IceNewCandidateCallback = std::function< void(const IceCandidate &)> |
| Callback when a new candidate is discovered (trickle ICE) | |
| using | IceSelectedPairCallback = std::function< void(const IceCandidatePair &)> |
| Callback when ICE completes with selected pair. | |
| using | MdnsServiceCallback = std::function< void(const MdnsService &service, bool is_new)> |
| using | BencodeDict = std::unordered_map< std::string, BencodeValue > |
| using | BencodeList = std::vector< BencodeValue > |
Enumerations | |
| enum class | MessageDataType : uint8_t { BINARY = 0x01 , STRING = 0x02 , JSON = 0x03 } |
| Message data types for librats message headers. More... | |
| enum class | GossipSubMessageType { SUBSCRIBE , UNSUBSCRIBE , PUBLISH , GOSSIP , GRAFT , PRUNE , IHAVE , IWANT , HEARTBEAT } |
| GossipSub message types. More... | |
| enum class | ValidationResult { ACCEPT , REJECT , IGNORE_MSG } |
| Message validation result. More... | |
| enum class | FileTransferStatus { PENDING , STARTING , IN_PROGRESS , PAUSED , COMPLETED , FAILED , CANCELLED , RESUMING } |
| File transfer status codes. More... | |
| enum class | FileTransferDirection { SENDING , RECEIVING } |
| File transfer direction. More... | |
| enum class | StunMessageClass : uint8_t { Request = 0x00 , Indication = 0x01 , SuccessResponse = 0x02 , ErrorResponse = 0x03 } |
| STUN message class (2 bits) More... | |
| enum class | StunMethod : uint16_t { Binding = 0x001 , Allocate = 0x003 , Refresh = 0x004 , Send = 0x006 , Data = 0x007 , CreatePermission = 0x008 , ChannelBind = 0x009 } |
| STUN method (12 bits, only Binding is defined in RFC 5389) More... | |
| enum class | StunMessageType : uint16_t { BindingRequest = 0x0001 , BindingIndication = 0x0011 , BindingSuccessResponse = 0x0101 , BindingErrorResponse = 0x0111 , AllocateRequest = 0x0003 , AllocateSuccessResponse = 0x0103 , AllocateErrorResponse = 0x0113 , RefreshRequest = 0x0004 , RefreshSuccessResponse = 0x0104 , RefreshErrorResponse = 0x0114 , SendIndication = 0x0016 , DataIndication = 0x0017 , CreatePermissionRequest = 0x0008 , CreatePermissionSuccessResponse = 0x0108 , CreatePermissionErrorResponse = 0x0118 , ChannelBindRequest = 0x0009 , ChannelBindSuccessResponse = 0x0109 , ChannelBindErrorResponse = 0x0119 } |
| Combined STUN message type (method + class) More... | |
| enum class | StunAttributeType : uint16_t { MappedAddress = 0x0001 , Username = 0x0006 , MessageIntegrity = 0x0008 , ErrorCode = 0x0009 , UnknownAttributes = 0x000A , Realm = 0x0014 , Nonce = 0x0015 , XorMappedAddress = 0x0020 , ChannelNumber = 0x000C , Lifetime = 0x000D , XorPeerAddress = 0x0012 , Data = 0x0013 , XorRelayedAddress = 0x0016 , RequestedTransport = 0x0019 , DontFragment = 0x001A , Software = 0x8022 , AlternateServer = 0x8023 , Fingerprint = 0x8028 } |
| enum class | StunAddressFamily : uint8_t { IPv4 = 0x01 , IPv6 = 0x02 } |
| enum class | StunErrorCode : uint16_t { TryAlternate = 300 , BadRequest = 400 , Unauthorized = 401 , Forbidden = 403 , UnknownAttribute = 420 , StaleNonce = 438 , ServerError = 500 , AllocationMismatch = 437 , WrongCredentials = 441 , UnsupportedTransportProtocol = 442 , AllocationQuotaReached = 486 , InsufficientCapacity = 508 } |
| enum class | IceCandidateType { Host , ServerReflexive , PeerReflexive , Relay } |
| ICE candidate type. More... | |
| enum class | IceTransportProtocol { UDP , TCP } |
| ICE candidate transport protocol. More... | |
| enum class | IceConnectionState { New , Gathering , Checking , Connected , Completed , Failed , Disconnected , Closed } |
| ICE connection state. More... | |
| enum class | IceGatheringState { New , Gathering , Complete } |
| ICE gathering state. More... | |
| enum class | IceCandidatePairState { Frozen , Waiting , InProgress , Succeeded , Failed } |
| ICE candidate pair state. More... | |
| enum class | DnsRecordType : uint16_t { A = 1 , PTR = 12 , TXT = 16 , AAAA = 28 , SRV = 33 } |
| enum class | DnsRecordClass : uint16_t { CLASS_IN = 1 , CLASS_IN_FLUSH = 0x8001 } |
| enum class | MdnsFlags : uint16_t { QUERY = 0x0000 , RESPONSE = 0x8000 , AUTHORITATIVE = 0x8400 } |
| enum class | LogLevel { DEBUG = 0 , INFO = 1 , WARN = 2 , ERROR = 3 } |
| enum class | KrpcMessageType { Query , Response , Error } |
| KRPC Message types. More... | |
| enum class | KrpcQueryType { Ping , FindNode , GetPeers , AnnouncePeer } |
| KRPC Query types. More... | |
| enum class | KrpcErrorCode { GenericError = 201 , ServerError = 202 , ProtocolError = 203 , MethodUnknown = 204 } |
| KRPC Error codes. More... | |
Functions | |
| std::unique_ptr< RatsClient > | create_rats_client (int listen_port) |
| const char * | rats_get_library_version_string () |
| void | rats_get_library_version (int *major, int *minor, int *patch, int *build) |
| const char * | rats_get_library_git_describe () |
| uint32_t | rats_get_library_abi () |
| NodeId | string_to_node_id (const std::string &str) |
| Utility functions. | |
| std::string | node_id_to_string (const NodeId &id) |
| Convert NodeId to string. | |
| NodeId | hex_to_node_id (const std::string &hex) |
| Convert hex string to NodeId. | |
| std::string | node_id_to_hex (const NodeId &id) |
| Convert NodeId to hex string. | |
| uint32_t | stun_crc32 (const uint8_t *data, size_t length) |
| Compute CRC32 for STUN FINGERPRINT attribute Uses CRC-32 as defined in RFC 5389 (ISO 3309) | |
| std::array< uint8_t, 20 > | stun_hmac_sha1 (const std::vector< uint8_t > &key, const std::vector< uint8_t > &data) |
| Compute HMAC-SHA1 for MESSAGE-INTEGRITY attribute. | |
| std::vector< uint8_t > | stun_compute_long_term_key (const std::string &username, const std::string &realm, const std::string &password) |
| Compute long-term credential key: MD5(username:realm:password) | |
| StunMappedAddress | stun_xor_address (const StunMappedAddress &addr, const std::array< uint8_t, STUN_TRANSACTION_ID_SIZE > &transaction_id) |
| XOR an address with the magic cookie and transaction ID Used for XOR-MAPPED-ADDRESS encoding/decoding. | |
| std::vector< std::pair< std::string, uint16_t > > | get_public_stun_servers () |
| Get a list of well-known public STUN servers. | |
| bool | init_socket_library () |
| Initialize the socket library. | |
| void | cleanup_socket_library () |
| Cleanup the socket library. | |
| socket_t | create_tcp_client (const std::string &host, int port, int timeout_ms=0) |
| Create a TCP client socket and connect to a server using dual stack (IPv6 with IPv4 fallback) | |
| socket_t | create_tcp_client_v4 (const std::string &host, int port, int timeout_ms=0) |
| Create a TCP client socket and connect to a server using IPv4 only. | |
| socket_t | create_tcp_client_v6 (const std::string &host, int port, int timeout_ms=0) |
| Create a TCP client socket and connect to a server using IPv6 only. | |
| socket_t | create_tcp_server (int port, int backlog=5, const std::string &bind_address="") |
| Create a TCP server socket and bind to a port using dual stack (IPv6 with IPv4 support) | |
| socket_t | create_tcp_server_v4 (int port, int backlog=5, const std::string &bind_address="") |
| Create a TCP server socket and bind to a port using IPv4 only. | |
| socket_t | create_tcp_server_v6 (int port, int backlog=5, const std::string &bind_address="") |
| Create a TCP server socket and bind to a port using IPv6 only. | |
| socket_t | accept_client (socket_t server_socket) |
| Accept a client connection on a server socket. | |
| std::string | get_peer_address (socket_t socket) |
| Get the peer address (IP:port) from a connected socket. | |
| int | send_tcp_data (socket_t socket, const std::vector< uint8_t > &data) |
| Send data through a TCP socket. | |
| std::vector< uint8_t > | receive_tcp_data (socket_t socket, size_t buffer_size=1024) |
| Receive data from a TCP socket. | |
| int | send_tcp_message_framed (socket_t socket, const std::vector< uint8_t > &message) |
| Send a framed message with length prefix through a TCP socket. | |
| std::vector< uint8_t > | receive_exact_bytes (socket_t socket, size_t num_bytes) |
| Receive exact number of bytes from a TCP socket (blocking until complete) | |
| std::vector< uint8_t > | receive_tcp_message_framed (socket_t socket) |
| Receive a complete framed message from a TCP socket. | |
| int | send_tcp_string (socket_t socket, const std::string &data) |
| Send string data through a TCP socket (converts to binary) | |
| std::string | receive_tcp_string (socket_t socket, size_t buffer_size=1024) |
| Receive data from a TCP socket as string. | |
| int | send_tcp_string_framed (socket_t socket, const std::string &message) |
| Send a framed string message through a TCP socket. | |
| std::string | receive_tcp_string_framed (socket_t socket) |
| Receive a complete framed string message from a TCP socket. | |
| socket_t | create_udp_socket (int port=0, const std::string &bind_address="") |
| Create a UDP socket with dual stack support (IPv6 with IPv4 support) | |
| socket_t | create_udp_socket_v4 (int port=0, const std::string &bind_address="") |
| Create a UDP socket with IPv4 support only. | |
| socket_t | create_udp_socket_v6 (int port=0, const std::string &bind_address="") |
| Create a UDP socket with IPv6 support only. | |
| int | send_udp_data (socket_t socket, const std::vector< uint8_t > &data, const Peer &peer) |
| Send UDP data to a peer. | |
| int | send_udp_data_to (socket_t socket, const std::vector< uint8_t > &data, const std::string &hostname, int port) |
| Send UDP data to a hostname and port directly. | |
| std::vector< uint8_t > | receive_udp_data (socket_t socket, size_t buffer_size, Peer &sender_peer) |
| Receive UDP data from a peer. | |
| std::vector< uint8_t > | receive_udp_data_with_timeout (socket_t socket, size_t buffer_size, int timeout_ms, std::string *sender_ip=nullptr, int *sender_port=nullptr) |
| Receive UDP data with timeout support. | |
| void | close_socket (socket_t socket, bool force=false) |
| Close a socket. | |
| bool | is_valid_socket (socket_t socket) |
| Check if a socket is valid. | |
| bool | set_socket_nonblocking (socket_t socket) |
| Set socket to non-blocking mode. | |
| bool | set_socket_blocking (socket_t socket) |
| Set socket to blocking mode. | |
| bool | is_tcp_socket (socket_t socket) |
| Check if a socket is a TCP socket. | |
| bool | connect_with_timeout (socket_t socket, struct sockaddr *addr, socklen_t addr_len, int timeout_ms) |
| Connect to a socket address with timeout. | |
| int | get_ephemeral_port (socket_t socket) |
| Get the ephemeral port that a socket is bound to. | |
| bool | file_or_directory_exists (const char *path) |
| bool | directory_exists (const char *path) |
| bool | file_exists (const char *path) |
| bool | create_file (const char *path, const char *content) |
| bool | create_file_binary (const char *path, const void *data, size_t size) |
| bool | append_to_file (const char *path, const char *content) |
| char * | read_file_text (const char *path, size_t *size_out=nullptr) |
| void * | read_file_binary (const char *path, size_t *size_out) |
| bool | create_directory (const char *path) |
| bool | create_directories (const char *path) |
| int64_t | get_file_size (const char *path) |
| bool | is_file (const char *path) |
| bool | is_directory (const char *path) |
| bool | delete_file (const char *path) |
| bool | delete_directory (const char *path) |
| bool | copy_file (const char *src_path, const char *dest_path) |
| bool | move_file (const char *src_path, const char *dest_path) |
| uint64_t | get_file_modified_time (const char *path) |
| std::string | get_file_extension (const char *path) |
| std::string | get_filename_from_path (const char *path) |
| std::string | get_parent_directory (const char *path) |
| bool | write_file_chunk (const char *path, uint64_t offset, const void *data, size_t size) |
| bool | read_file_chunk (const char *path, uint64_t offset, void *buffer, size_t size) |
| bool | create_file_with_size (const char *path, uint64_t size) |
| bool | rename_file (const char *old_path, const char *new_path) |
| bool | list_directory (const char *path, std::vector< DirectoryEntry > &entries) |
| std::string | combine_paths (const std::string &base, const std::string &relative) |
| bool | validate_path (const char *path, bool check_write_access=false) |
| void | free_file_buffer (void *buffer) |
| bool | get_current_directory (char *buffer, size_t buffer_size) |
| bool | set_current_directory (const char *path) |
| bool | file_or_directory_exists (const std::string &path) |
| bool | file_exists (const std::string &path) |
| bool | directory_exists (const std::string &path) |
| bool | create_file (const std::string &path, const std::string &content) |
| std::string | read_file_text_cpp (const std::string &path) |
| uint64_t | get_file_modified_time (const std::string &path) |
| std::string | get_file_extension (const std::string &path) |
| std::string | get_filename_from_path (const std::string &path) |
| std::string | get_parent_directory (const std::string &path) |
| bool | write_file_chunk (const std::string &path, uint64_t offset, const void *data, size_t size) |
| bool | read_file_chunk (const std::string &path, uint64_t offset, void *buffer, size_t size) |
| bool | create_file_with_size (const std::string &path, uint64_t size) |
| bool | rename_file (const std::string &old_path, const std::string &new_path) |
| bool | validate_path (const std::string &path, bool check_write_access=false) |
| SystemInfo | get_system_info () |
| std::string | get_os_name () |
| std::string | get_os_version () |
| std::string | get_architecture () |
| std::string | get_hostname () |
| std::string | get_cpu_model () |
| int | get_cpu_cores () |
| int | get_cpu_logical_cores () |
| uint64_t | get_total_memory_mb () |
| uint64_t | get_available_memory_mb () |
| bool | supports_unicode () |
| void | print_system_info () |
Variables | |
| constexpr size_t | NODE_ID_SIZE = 20 |
| constexpr size_t | K_BUCKET_SIZE = 8 |
| constexpr size_t | ALPHA = 3 |
| constexpr int | DHT_PORT = 6881 |
| constexpr uint32_t | STUN_MAGIC_COOKIE = 0x2112A442 |
| STUN Magic Cookie (fixed value per RFC 5389) | |
| constexpr size_t | STUN_HEADER_SIZE = 20 |
| STUN header size in bytes. | |
| constexpr size_t | STUN_TRANSACTION_ID_SIZE = 12 |
| STUN transaction ID size in bytes. | |
| constexpr uint16_t | STUN_DEFAULT_PORT = 3478 |
| Default STUN port. | |
| constexpr uint16_t | STUNS_DEFAULT_PORT = 5349 |
| STUN over TLS default port. | |
| constexpr size_t | STUN_MAX_MESSAGE_SIZE = 1500 |
| Maximum STUN message size (RFC 5389 recommends path MTU, typically ~1500) | |
| constexpr int | STUN_DEFAULT_RTO_MS = 500 |
| Default retransmission timeout (ms) | |
| constexpr int | STUN_MAX_RETRANSMISSIONS = 7 |
| Maximum retransmissions. | |
| constexpr uint32_t | ICE_PRIORITY_HOST = 126 |
| Default ICE candidate priority for host candidates. | |
| constexpr uint32_t | ICE_PRIORITY_SRFLX = 100 |
| Default ICE candidate priority for server-reflexive candidates | |
| constexpr uint32_t | ICE_PRIORITY_RELAY = 0 |
| Default ICE candidate priority for relay candidates. | |
| constexpr int | ICE_CHECK_TIMEOUT_MS = 500 |
| Connectivity check timeout (ms) | |
| constexpr int | ICE_CHECK_MAX_RETRIES = 5 |
| Maximum connectivity check retries. | |
| const uint16_t | MDNS_PORT = 5353 |
| const std::string | MDNS_MULTICAST_IPv4 = "224.0.0.251" |
| const std::string | MDNS_MULTICAST_IPv6 = "ff02::fb" |
| const std::string | LIBRATS_SERVICE_TYPE = "_librats._tcp.local." |
| const std::string | LIBRATS_SERVICE_INSTANCE_SUFFIX = ".local." |
| using librats::BencodeDict = typedef std::unordered_map<std::string, BencodeValue> |
| using librats::BencodeList = typedef std::vector<BencodeValue> |
| using librats::DirectoryRequestCallback = typedef std::function<bool(const std::string& peer_id, const std::string& directory_path, bool recursive, const std::string& transfer_id)> |
Definition at line 179 of file file_transfer.h.
| using librats::DirectoryTransferProgressCallback = typedef std::function<void(const std::string& transfer_id, const std::string& current_file, uint64_t files_completed, uint64_t total_files, uint64_t bytes_completed, uint64_t total_bytes)> |
Definition at line 177 of file file_transfer.h.
| using librats::FileRequestCallback = typedef std::function<bool(const std::string& peer_id, const std::string& file_path, const std::string& transfer_id)> |
Definition at line 178 of file file_transfer.h.
| using librats::FileTransferCompletedCallback = typedef std::function<void(const std::string& transfer_id, bool success, const std::string& error_message)> |
Definition at line 175 of file file_transfer.h.
| using librats::FileTransferProgressCallback = typedef std::function<void(const FileTransferProgress&)> |
Callback function types for file transfer events.
Definition at line 174 of file file_transfer.h.
| using librats::FileTransferRequestCallback = typedef std::function<bool(const std::string& peer_id, const FileMetadata& metadata, const std::string& transfer_id)> |
Definition at line 176 of file file_transfer.h.
| using librats::IceCandidatesCallback = typedef std::function<void(const std::vector<IceCandidate>&)> |
| using librats::IceConnectionStateCallback = typedef std::function<void(IceConnectionState)> |
| using librats::IceGatheringStateCallback = typedef std::function<void(IceGatheringState)> |
| using librats::IceNewCandidateCallback = typedef std::function<void(const IceCandidate&)> |
| using librats::IceSelectedPairCallback = typedef std::function<void(const IceCandidatePair&)> |
| typedef std::array< uint8_t, 20 > librats::InfoHash |
| using librats::MdnsServiceCallback = typedef std::function<void(const MdnsService& service, bool is_new)> |
| using librats::MessageHandler = typedef std::function<void(const std::string& topic, const std::string& message, const std::string& sender_peer_id)> |
Definition at line 160 of file gossipsub.h.
| using librats::MessageValidator = typedef std::function<ValidationResult(const std::string& topic, const std::string& message, const std::string& sender_peer_id)> |
Callback types for GossipSub.
Definition at line 159 of file gossipsub.h.
| typedef std::array< uint8_t, 20 > librats::NodeId |
| using librats::PeerDiscoveryCallback = typedef std::function<void(const std::vector<Peer>& peers, const InfoHash& info_hash)> |
| using librats::PeerJoinedHandler = typedef std::function<void(const std::string& topic, const std::string& peer_id)> |
Definition at line 161 of file gossipsub.h.
| using librats::PeerLeftHandler = typedef std::function<void(const std::string& topic, const std::string& peer_id)> |
Definition at line 162 of file gossipsub.h.
| using librats::SpiderAnnounceCallback = typedef std::function<void(const InfoHash& info_hash, const Peer& peer)> |
|
strong |
|
strong |
|
strong |
|
strong |
File transfer status codes.
| Enumerator | |
|---|---|
| PENDING | |
| STARTING | |
| IN_PROGRESS | |
| PAUSED | |
| COMPLETED | |
| FAILED | |
| CANCELLED | |
| RESUMING | |
Definition at line 25 of file file_transfer.h.
|
strong |
GossipSub message types.
| Enumerator | |
|---|---|
| SUBSCRIBE | |
| UNSUBSCRIBE | |
| PUBLISH | |
| GOSSIP | |
| GRAFT | |
| PRUNE | |
| IHAVE | |
| IWANT | |
| HEARTBEAT | |
Definition at line 25 of file gossipsub.h.
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
Combined STUN message type (method + class)
|
strong |
|
strong |
Message validation result.
| Enumerator | |
|---|---|
| ACCEPT | |
| REJECT | |
| IGNORE_MSG | |
Definition at line 150 of file gossipsub.h.
Accept a client connection on a server socket.
| server_socket | The server socket handle |
| bool librats::append_to_file | ( | const char * | path, |
| const char * | content | ||
| ) |
| void librats::cleanup_socket_library | ( | ) |
Cleanup the socket library.
| void librats::close_socket | ( | socket_t | socket, |
| bool | force = false |
||
| ) |
Close a socket.
| socket | The socket handle to close |
| std::string librats::combine_paths | ( | const std::string & | base, |
| const std::string & | relative | ||
| ) |
| bool librats::connect_with_timeout | ( | socket_t | socket, |
| struct sockaddr * | addr, | ||
| socklen_t | addr_len, | ||
| int | timeout_ms | ||
| ) |
Connect to a socket address with timeout.
| socket | The socket handle (should be non-blocking) |
| addr | The socket address structure |
| addr_len | Length of the address structure |
| timeout_ms | Connection timeout in milliseconds |
| bool librats::copy_file | ( | const char * | src_path, |
| const char * | dest_path | ||
| ) |
| bool librats::create_directories | ( | const char * | path | ) |
| bool librats::create_directory | ( | const char * | path | ) |
| bool librats::create_file | ( | const char * | path, |
| const char * | content | ||
| ) |
Referenced by create_file().
|
inline |
Definition at line 77 of file fs.h.
References create_file().
| bool librats::create_file_binary | ( | const char * | path, |
| const void * | data, | ||
| size_t | size | ||
| ) |
| bool librats::create_file_with_size | ( | const char * | path, |
| uint64_t | size | ||
| ) |
Referenced by create_file_with_size().
|
inline |
Definition at line 100 of file fs.h.
References create_file_with_size().
| std::unique_ptr< RatsClient > librats::create_rats_client | ( | int | listen_port | ) |
| socket_t librats::create_tcp_client | ( | const std::string & | host, |
| int | port, | ||
| int | timeout_ms = 0 |
||
| ) |
Create a TCP client socket and connect to a server using dual stack (IPv6 with IPv4 fallback)
| host | The hostname or IP address to connect to |
| port | The port number to connect to |
| timeout_ms | Connection timeout in milliseconds (0 for blocking) |
| socket_t librats::create_tcp_client_v4 | ( | const std::string & | host, |
| int | port, | ||
| int | timeout_ms = 0 |
||
| ) |
Create a TCP client socket and connect to a server using IPv4 only.
| host | The hostname or IP address to connect to |
| port | The port number to connect to |
| timeout_ms | Connection timeout in milliseconds (0 for blocking) |
| socket_t librats::create_tcp_client_v6 | ( | const std::string & | host, |
| int | port, | ||
| int | timeout_ms = 0 |
||
| ) |
Create a TCP client socket and connect to a server using IPv6 only.
| host | The hostname or IPv6 address to connect to |
| port | The port number to connect to |
| timeout_ms | Connection timeout in milliseconds (0 for blocking) |
| socket_t librats::create_tcp_server | ( | int | port, |
| int | backlog = 5, |
||
| const std::string & | bind_address = "" |
||
| ) |
Create a TCP server socket and bind to a port using dual stack (IPv6 with IPv4 support)
| port | The port number to bind to |
| backlog | The maximum number of pending connections |
| bind_address | The interface IP address to bind to (empty for all interfaces) |
| socket_t librats::create_tcp_server_v4 | ( | int | port, |
| int | backlog = 5, |
||
| const std::string & | bind_address = "" |
||
| ) |
Create a TCP server socket and bind to a port using IPv4 only.
| port | The port number to bind to |
| backlog | The maximum number of pending connections |
| bind_address | The interface IP address to bind to (empty for all interfaces) |
| socket_t librats::create_tcp_server_v6 | ( | int | port, |
| int | backlog = 5, |
||
| const std::string & | bind_address = "" |
||
| ) |
Create a TCP server socket and bind to a port using IPv6 only.
| port | The port number to bind to |
| backlog | The maximum number of pending connections |
| bind_address | The interface IP address to bind to (empty for all interfaces) |
| socket_t librats::create_udp_socket | ( | int | port = 0, |
| const std::string & | bind_address = "" |
||
| ) |
Create a UDP socket with dual stack support (IPv6 with IPv4 support)
| port | The port to bind to (0 for any available port) |
| bind_address | The interface IP address to bind to (empty for all interfaces) |
| socket_t librats::create_udp_socket_v4 | ( | int | port = 0, |
| const std::string & | bind_address = "" |
||
| ) |
Create a UDP socket with IPv4 support only.
| port | The port to bind to (0 for any available port) |
| bind_address | The interface IP address to bind to (empty for all interfaces) |
| socket_t librats::create_udp_socket_v6 | ( | int | port = 0, |
| const std::string & | bind_address = "" |
||
| ) |
Create a UDP socket with IPv6 support only.
| port | The port to bind to (0 for any available port) |
| bind_address | The interface IP address to bind to (empty for all interfaces) |
| bool librats::delete_directory | ( | const char * | path | ) |
| bool librats::delete_file | ( | const char * | path | ) |
| bool librats::directory_exists | ( | const char * | path | ) |
Referenced by directory_exists().
|
inline |
Definition at line 76 of file fs.h.
References directory_exists().
| bool librats::file_exists | ( | const char * | path | ) |
Referenced by file_exists().
|
inline |
Definition at line 75 of file fs.h.
References file_exists().
| bool librats::file_or_directory_exists | ( | const char * | path | ) |
Referenced by file_or_directory_exists().
|
inline |
Definition at line 74 of file fs.h.
References file_or_directory_exists().
| void librats::free_file_buffer | ( | void * | buffer | ) |
Referenced by read_file_text_cpp().
| std::string librats::get_architecture | ( | ) |
| uint64_t librats::get_available_memory_mb | ( | ) |
| int librats::get_cpu_cores | ( | ) |
| int librats::get_cpu_logical_cores | ( | ) |
| std::string librats::get_cpu_model | ( | ) |
| bool librats::get_current_directory | ( | char * | buffer, |
| size_t | buffer_size | ||
| ) |
| int librats::get_ephemeral_port | ( | socket_t | socket | ) |
Get the ephemeral port that a socket is bound to.
| socket | The socket handle to get the ephemeral port for |
| std::string librats::get_file_extension | ( | const char * | path | ) |
Referenced by get_file_extension().
|
inline |
Definition at line 91 of file fs.h.
References get_file_extension().
| uint64_t librats::get_file_modified_time | ( | const char * | path | ) |
Referenced by get_file_modified_time().
|
inline |
Definition at line 90 of file fs.h.
References get_file_modified_time().
| int64_t librats::get_file_size | ( | const char * | path | ) |
| std::string librats::get_filename_from_path | ( | const char * | path | ) |
Referenced by get_filename_from_path().
|
inline |
Definition at line 92 of file fs.h.
References get_filename_from_path().
| std::string librats::get_hostname | ( | ) |
| std::string librats::get_os_name | ( | ) |
| std::string librats::get_os_version | ( | ) |
| std::string librats::get_parent_directory | ( | const char * | path | ) |
Referenced by get_parent_directory().
|
inline |
Definition at line 93 of file fs.h.
References get_parent_directory().
| std::string librats::get_peer_address | ( | socket_t | socket | ) |
Get the peer address (IP:port) from a connected socket.
| socket | The connected socket handle |
| std::vector< std::pair< std::string, uint16_t > > librats::get_public_stun_servers | ( | ) |
Get a list of well-known public STUN servers.
| SystemInfo librats::get_system_info | ( | ) |
| uint64_t librats::get_total_memory_mb | ( | ) |
| NodeId librats::hex_to_node_id | ( | const std::string & | hex | ) |
Convert hex string to NodeId.
| hex | The hex string to convert (must be 40 characters) |
| bool librats::init_socket_library | ( | ) |
Initialize the socket library.
| bool librats::is_directory | ( | const char * | path | ) |
| bool librats::is_file | ( | const char * | path | ) |
| bool librats::is_tcp_socket | ( | socket_t | socket | ) |
Check if a socket is a TCP socket.
| socket | The socket handle to check |
| bool librats::is_valid_socket | ( | socket_t | socket | ) |
Check if a socket is valid.
| socket | The socket handle to check |
| bool librats::list_directory | ( | const char * | path, |
| std::vector< DirectoryEntry > & | entries | ||
| ) |
| bool librats::move_file | ( | const char * | src_path, |
| const char * | dest_path | ||
| ) |
| std::string librats::node_id_to_hex | ( | const NodeId & | id | ) |
Convert NodeId to hex string.
| id | The NodeId to convert |
| std::string librats::node_id_to_string | ( | const NodeId & | id | ) |
Convert NodeId to string.
| id | The NodeId to convert |
| void librats::print_system_info | ( | ) |
| uint32_t librats::rats_get_library_abi | ( | ) |
| const char * librats::rats_get_library_git_describe | ( | ) |
| void librats::rats_get_library_version | ( | int * | major, |
| int * | minor, | ||
| int * | patch, | ||
| int * | build | ||
| ) |
| const char * librats::rats_get_library_version_string | ( | ) |
| void * librats::read_file_binary | ( | const char * | path, |
| size_t * | size_out | ||
| ) |
| bool librats::read_file_chunk | ( | const char * | path, |
| uint64_t | offset, | ||
| void * | buffer, | ||
| size_t | size | ||
| ) |
Referenced by read_file_chunk().
|
inline |
Definition at line 97 of file fs.h.
References read_file_chunk().
| char * librats::read_file_text | ( | const char * | path, |
| size_t * | size_out = nullptr |
||
| ) |
Referenced by read_file_text_cpp().
|
inline |
Definition at line 80 of file fs.h.
References free_file_buffer(), and read_file_text().
| std::vector< uint8_t > librats::receive_exact_bytes | ( | socket_t | socket, |
| size_t | num_bytes | ||
| ) |
Receive exact number of bytes from a TCP socket (blocking until complete)
| socket | The socket handle |
| num_bytes | Number of bytes to receive |
| std::vector< uint8_t > librats::receive_tcp_data | ( | socket_t | socket, |
| size_t | buffer_size = 1024 |
||
| ) |
Receive data from a TCP socket.
| socket | The socket handle |
| buffer_size | Maximum number of bytes to receive |
| std::vector< uint8_t > librats::receive_tcp_message_framed | ( | socket_t | socket | ) |
Receive a complete framed message from a TCP socket.
| socket | The socket handle |
| std::string librats::receive_tcp_string | ( | socket_t | socket, |
| size_t | buffer_size = 1024 |
||
| ) |
Receive data from a TCP socket as string.
| socket | The socket handle |
| buffer_size | Maximum number of bytes to receive |
| std::string librats::receive_tcp_string_framed | ( | socket_t | socket | ) |
Receive a complete framed string message from a TCP socket.
| socket | The socket handle |
| std::vector< uint8_t > librats::receive_udp_data | ( | socket_t | socket, |
| size_t | buffer_size, | ||
| Peer & | sender_peer | ||
| ) |
Receive UDP data from a peer.
| socket | The UDP socket handle |
| buffer_size | Maximum number of bytes to receive |
| sender_peer | Output parameter for the sender's peer info |
| std::vector< uint8_t > librats::receive_udp_data_with_timeout | ( | socket_t | socket, |
| size_t | buffer_size, | ||
| int | timeout_ms, | ||
| std::string * | sender_ip = nullptr, |
||
| int * | sender_port = nullptr |
||
| ) |
Receive UDP data with timeout support.
| socket | The UDP socket handle |
| buffer_size | Maximum number of bytes to receive |
| timeout_ms | Timeout in milliseconds (0 for non-blocking, -1 for blocking) |
| sender_ip | Optional output parameter for sender IP address |
| sender_port | Optional output parameter for sender port |
| bool librats::rename_file | ( | const char * | old_path, |
| const char * | new_path | ||
| ) |
Referenced by rename_file().
|
inline |
Definition at line 101 of file fs.h.
References rename_file().
| int librats::send_tcp_data | ( | socket_t | socket, |
| const std::vector< uint8_t > & | data | ||
| ) |
Send data through a TCP socket.
| socket | The socket handle |
| data | The binary data to send |
| int librats::send_tcp_message_framed | ( | socket_t | socket, |
| const std::vector< uint8_t > & | message | ||
| ) |
Send a framed message with length prefix through a TCP socket.
| socket | The socket handle |
| message | The binary message to send |
| int librats::send_tcp_string | ( | socket_t | socket, |
| const std::string & | data | ||
| ) |
Send string data through a TCP socket (converts to binary)
| socket | The socket handle |
| data | The string data to send |
| int librats::send_tcp_string_framed | ( | socket_t | socket, |
| const std::string & | message | ||
| ) |
Send a framed string message through a TCP socket.
| socket | The socket handle |
| message | The string message to send |
| int librats::send_udp_data | ( | socket_t | socket, |
| const std::vector< uint8_t > & | data, | ||
| const Peer & | peer | ||
| ) |
Send UDP data to a peer.
| socket | The UDP socket handle |
| data | The data to send |
| peer | The destination peer |
| int librats::send_udp_data_to | ( | socket_t | socket, |
| const std::vector< uint8_t > & | data, | ||
| const std::string & | hostname, | ||
| int | port | ||
| ) |
Send UDP data to a hostname and port directly.
| socket | The UDP socket handle |
| data | The data to send |
| hostname | The destination hostname or IP address |
| port | The destination port |
| bool librats::set_current_directory | ( | const char * | path | ) |
| bool librats::set_socket_blocking | ( | socket_t | socket | ) |
Set socket to blocking mode.
| socket | The socket handle |
| bool librats::set_socket_nonblocking | ( | socket_t | socket | ) |
Set socket to non-blocking mode.
| socket | The socket handle |
| NodeId librats::string_to_node_id | ( | const std::string & | str | ) |
Utility functions.
Convert string to NodeId
| str | The string to convert (must be 20 bytes) |
| std::vector< uint8_t > librats::stun_compute_long_term_key | ( | const std::string & | username, |
| const std::string & | realm, | ||
| const std::string & | password | ||
| ) |
Compute long-term credential key: MD5(username:realm:password)
| uint32_t librats::stun_crc32 | ( | const uint8_t * | data, |
| size_t | length | ||
| ) |
Compute CRC32 for STUN FINGERPRINT attribute Uses CRC-32 as defined in RFC 5389 (ISO 3309)
| std::array< uint8_t, 20 > librats::stun_hmac_sha1 | ( | const std::vector< uint8_t > & | key, |
| const std::vector< uint8_t > & | data | ||
| ) |
Compute HMAC-SHA1 for MESSAGE-INTEGRITY attribute.
| key | The key (typically: MD5(username:realm:password)) |
| data | The message data to authenticate |
| StunMappedAddress librats::stun_xor_address | ( | const StunMappedAddress & | addr, |
| const std::array< uint8_t, STUN_TRANSACTION_ID_SIZE > & | transaction_id | ||
| ) |
XOR an address with the magic cookie and transaction ID Used for XOR-MAPPED-ADDRESS encoding/decoding.
| bool librats::supports_unicode | ( | ) |
| bool librats::validate_path | ( | const char * | path, |
| bool | check_write_access = false |
||
| ) |
Referenced by validate_path().
|
inline |
Definition at line 104 of file fs.h.
References validate_path().
| bool librats::write_file_chunk | ( | const char * | path, |
| uint64_t | offset, | ||
| const void * | data, | ||
| size_t | size | ||
| ) |
Referenced by write_file_chunk().
|
inline |
Definition at line 94 of file fs.h.
References write_file_chunk().
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
| const std::string librats::LIBRATS_SERVICE_INSTANCE_SUFFIX = ".local." |
| const std::string librats::LIBRATS_SERVICE_TYPE = "_librats._tcp.local." |
| const std::string librats::MDNS_MULTICAST_IPv4 = "224.0.0.251" |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |