a small libp2p-ish stack in c. solo-maintained; scope is a lot for one person but here we are.
two entrypoints (same repo, different wire):
| api | wire | peers |
|---|---|---|
speer.h |
udp + speer packet.c format (noise xx embedded; not libp2p tcp/quic) |
native speer only |
speer_libp2p_tcp.h |
tcp + multistream + noise xx + yamux | kubo, py-libp2p, rust-libp2p, … on tcp |
examples/libp2p_tcp_full_session.c dials a normal libp2p tcp host (noise → yamux
→ stream proto); it has been checked against py-libp2p.
it has noise xx, libp2p over tcp, yamux, mdns, dht bits, partial quic, and a tls 1.3 core. no external deps.
source size: 19,180 lines across 121 .c/.h files in src/ and include/
(16,747 nonblank). tests, examples, rust, and build output are not counted.
more detail:
make
make examples
make testwindows with mingw:
mingw32-make
.\tests\run_tests.ps1native speer host over udp (speer-to-speer only on the wire):
#include "speer.h"
speer_host_t* host = speer_host_new(seed, NULL);
speer_peer_t* peer = speer_connect(host, peer_pk, "1.2.3.4:4242");
speer_stream_t* s = speer_stream_open(peer, 0);
speer_stream_write(s, (uint8_t*)"hello", 5);
while (running) speer_host_poll(host, 100);libp2p-over-tcp session (interop with other libp2p implementations on tcp):
#include "speer_libp2p_tcp.h"
#include "transport_tcp.h"
speer_libp2p_identity_t id;
/* fill id from keys - copy pattern in examples/libp2p_tcp_full_session.c */
int fd;
speer_tcp_dial(&fd, "127.0.0.1", 4001);
speer_libp2p_tcp_session_t session;
speer_libp2p_tcp_session_init_dialer(&session, fd, &id);
/* then yamux + multistream per stream - same example file */full bootstrap including yamux + protocol open is in
examples/libp2p_tcp_full_session.c.
./examples/echo_server
./examples/chat <peer_pubkey> <host:port>
./examples/libp2p_ping demo
./examples/libp2p_quic_pingthe terminal chat demo with mdns/tcp/noise/yamux lives in the rust workspace crate
speer-chat (rust/speer-chat).
cmake install exports both cmake and pkg-config metadata:
cmake -S . -B build -DSPEER_BUILD_TESTS=OFF
cmake --build build
cmake --install buildthen consumers can use either find_package(speer) or pkg-config speer.
rust repos:
speer-sys-rust- raw ffispeer-rust- safe rust wrapperspeer-rust-chat- terminal chat app
- noise xx: full
- yamux: full
- mdns: full, but treat records as hints
- dht: practical core
- tls 1.3: core pieces
- quic v1: packet codec, not a full connection stack yet
- relay / dcutr: partial; v2 hop reserve:
relay_public_hop_check(network, public relays).
MIT