From 5ce650382352c1503f40abf08129ada69402af55 Mon Sep 17 00:00:00 2001 From: bitflash-coin Date: Tue, 4 Aug 2026 06:34:32 -0700 Subject: public commit --- src/bitflashd.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/bitflashd.cpp (limited to 'src/bitflashd.cpp') diff --git a/src/bitflashd.cpp b/src/bitflashd.cpp new file mode 100644 index 0000000..d4ced77 --- /dev/null +++ b/src/bitflashd.cpp @@ -0,0 +1,45 @@ +// Copyright (c) 2026 Bitflash developers +// Distributed under the MIT/X11 software license. +// +// bitflashd -- the headless Bitflash rendezvous relay (the "meeting node"). +// Runs on a machine with a public IP (a cheap VPS) and lets nodes behind CGNAT +// reach each other: both sides connect OUT to this relay, which pairs them by +// `.btf` pubkey and forwards ciphertext (it holds no keys and reads nothing). +// +// Build on the VPS (Linux): +// g++ -std=gnu++14 -O2 -pthread bitflashd.cpp btfrv.cpp -o bitflashd +// Run: +// ./bitflashd 8434 # or any port you open in the firewall +// +// Cross-builds unchanged on Windows (for local testing): +// g++ -std=gnu++14 -O2 -pthread bitflashd.cpp btfrv.cpp -lws2_32 -o bitflashd.exe + +#include "btfrv.h" +#include +#include +#include + +int main(int argc, char* argv[]) +{ + unsigned short port = 8434; + if (argc >= 2) + port = (unsigned short)atoi(argv[1]); + + printf("bitflashd -- Bitflash rendezvous relay\n"); + printf("listening on 0.0.0.0:%u (open this port in your firewall)\n", port); + fflush(stdout); + + if (!btf::RvInit()) + { + fprintf(stderr, "bitflashd: socket init failed\n"); + return 1; + } + + // Blocks forever, forwarding between paired peers. + if (!btf::RvRelayRun(port)) + { + fprintf(stderr, "bitflashd: could not bind/listen on port %u\n", port); + return 1; + } + return 0; +} -- cgit v1.2.3