A maintainable, extensible BitTorrent client (C11, Linux/io_uring) targeting 10 GbE saturation. All torrent functionality is built from scratch; liburing is the only linked third-party dependency on the data path. Implements Phases 1-7 of the roadmap: - core: page-aligned buffer pool, MPMC/Treiber queues, bitfields, worker pool - crypto: SHA-1/256 (SHA-NI + scalar), Merkle (BEP-52), RC4 (MSE) - bencode/metainfo: zero-copy parser, v1/v2/hybrid .torrent + magnet - peer: sans-IO wire codec, MSE/PE handshake state machine, BEP-10, ut_metadata, PEX - piece/storage: block-level multi-peer engine, rarest-first + endgame, per-file completion events + single-file relocate (move-as-you-finish) - tracker/dht: HTTP + UDP (BEP-15) trackers, BEP-5 KRPC iterative lookup - platform: io_uring reactor (SQPOLL, registered buffers, SEND_ZC) - surface: versioned RPC, native plugin ABI, sandboxed Lua scripting, nautd/nautctl Verified against libtorrent (single/multi/hybrid, MSE, magnet-via-DHT, swarm); unit + interop tests green; ASan/UBSan/TSan clean. Scripting reference in docs/scripting.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
49 lines
1.9 KiB
C
49 lines
1.9 KiB
C
/* naut_plugin.h - stable versioned native plugin ABI. */
|
|
#ifndef NAUT_PLUGIN_H
|
|
#define NAUT_PLUGIN_H
|
|
|
|
#include "naut/common.h"
|
|
#include "naut/event.h"
|
|
|
|
#define NAUT_PLUGIN_ABI_VERSION 1u
|
|
|
|
typedef struct {
|
|
uint32_t abi_version;
|
|
uint32_t struct_size;
|
|
const char *name;
|
|
void *(*open)(const char *root, naut_err *error);
|
|
void (*close)(void *storage);
|
|
naut_err (*read)(void *storage, int64_t offset, void *buffer, size_t length);
|
|
naut_err (*write)(void *storage, int64_t offset,
|
|
const void *buffer, size_t length);
|
|
} naut_storage_backend_v1;
|
|
|
|
/* request_json is a JSON object or null. response_json must be malloc-owned
|
|
* compact JSON on success; the host frees it after parsing. */
|
|
typedef naut_err (*naut_plugin_rpc_fn)(void *context,
|
|
const char *request_json,
|
|
char **response_json);
|
|
typedef void (*naut_plugin_event_fn)(void *context,
|
|
const naut_event *event);
|
|
|
|
typedef struct naut_host_api {
|
|
uint32_t abi_version;
|
|
uint32_t struct_size;
|
|
void *host_context;
|
|
|
|
naut_err (*set_plugin_name)(void *host_context, const char *name);
|
|
naut_err (*register_rpc)(void *host_context, const char *method,
|
|
naut_plugin_rpc_fn callback, void *context);
|
|
naut_err (*register_storage_backend)(
|
|
void *host_context, const naut_storage_backend_v1 *backend);
|
|
naut_err (*subscribe_event)(void *host_context,
|
|
naut_plugin_event_fn callback,
|
|
void *context);
|
|
void (*emit_event)(void *host_context, const naut_event *event);
|
|
void (*log)(void *host_context, int level, const char *message);
|
|
} naut_host_api;
|
|
|
|
/* Every plugin exports this exact symbol. */
|
|
typedef naut_err (*naut_plugin_register_fn)(const naut_host_api *host);
|
|
|
|
#endif /* NAUT_PLUGIN_H */
|