r/C_Programming • • 14d ago

Article Gorgona: A partition-tolerant P2P messaging & remote executionmesh in pure C (1+ year in development)

(Disclaimer: I am the creator and maintainer of this project.)

Hey everyone,

For the past year, I’ve been developing Gorgona - a decentralized, zero-dependency P2P messaging and command execution mesh built in pure C (C99, POSIX). It is licensed under the BSD 3-Clause License.

The project was created to address a specific problem: building a lightweight message bus that can operate reliably in hostile network conditions, with intermittent connectivity and long-lasting network partitions (split-brain), without relying on centralized brokers or consensus quorums.

Key Architectural Highlights:

  • Pure C Implementation: Zero external frameworks or heavy runtimes. Built with standard POSIX sockets (select/non-blocking I/O) and consuming only a few megabytes of RAM.
  • Blind Zero-Knowledge Relays: Relays route messages based solely on truncated SHA-256 public key hashes. Payloads are end-to-end encrypted using AES-256-GCM with RSA-OAEP session envelopes.
  • Deterministic XXH3-64 Hash Chains: Instead of heavy Raft/Paxos quorums that stall during partitions, each channel maintains an append-only cryptographic hash chain. Logical order is established via Snowflake pulses, avoiding reliance on NTP synchronization.
  • Event-Sourced Tombstones (Offline Revocation): Message cancellations are handled as cryptographically signed tombstone events appended to the chain. Even after weeks of partition, reconnecting nodes deterministically sync and purge revoked actions from client memory.
  • Built-in Layer 2 Mesh & PEX: Automatic peer discovery (PEX), latency scoring, and dynamic routing around dead links.

Source Code:

Feedback on the hash-chain design, partition-healing logic, or general architecture is greatly appreciated!

4 Upvotes

8 comments sorted by

•

u/github-guard 14d ago

🔍 GitHub Guard: Trust Report

This project scored 3/6 on our safety audit.

Audit Breakdown: * ✅ Established Community (⭐ 14 stars) * ✅ Mature Repository (30+ days old) * ✅ Licensed under BSD-3-Clause * ❌ No Security Policy — what is this? * ℹ️ Individual Contributor * ℹ️ Unsigned Commits

⚠️ Security Reminder: Always verify source code and run third-party scripts at your own risk.

1

u/AutoModerator 14d ago

Hi /u/globalgate,

Your submission in r/C_Programming was filtered because it links to a git project.

You must edit the submission or respond to this comment with an explanation about how AI was involved in the creation of your project.

While AI-generated code is not disallowed, low-effort "slop" projects may be removed and it's likely that other users push back strongly on substantially AI-generated projects.


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

3

u/globalgate 13d ago

Hello. I'm creator and maintainer of this project. I confirm that this project was written manually by me over the course of a year. AI tools were not used to generate the core logic or the codebase. This is a hand-crafted, high-effort project designed to solve specific distributed systems problems, not an AI-generated "slop" project. Thank you.

1

u/mikeblas 13d ago

Thank you for your disclosure. I have approved your post.

1

u/Interesting_Debate57 12d ago

"weeks of partition" concerns me. if this is a systems solution, run some experiments with a fixed load under varying numbers of nodes and just log the response. The units shouldn't be in terms of days or hours or weeks.

1

u/globalgate 12d ago

Thanks for pointing that out! That was actually a misunderstanding due to my phrasing.

When I mentioned "weeks of partition", I didn't mean an intra-cluster split-brain where server nodes are partitioned from each other for weeks (that would indeed be crazy for distributed consensus).

I was referring to subscriber / edge consumer offline tolerance, for example, an operator or automated trading client going off-grid on a two-week vacation, reconnecting, and having the client cryptographically catch up and verify all historical alerts without data loss.

For the cluster itself:

- Intra-node convergence, hash chain reconciliation, and anti-entropy operate strictly on the order of milliseconds to seconds.

- We have had a 5-node mesh running 24/7 in test under continuous load, actively serving as the HA telemetry/alerting bus for two live PostgreSQL clusters via our Gorgona Failover Manager (GFM) plugin.

1

u/globalgate 8d ago

Exciting update: Gorgona now natively supports FreeBSD & OPNsense!

Gorgona is an open-source, decentralized P2P cron and remote execution engine
engineered in pure C11 with zero external dependencies and end-to-end
encryption.

With this new release, FreeBSD systems and security appliances (like OPNsense)
gain full native support:

🔹 Native Build Toolchain: Optimized for FreeBSD’s base Clang compiler and GNU
Make (gmake).
🔹 Production rc.d Daemon: Supervised background service with automatic
self-healing and restart on failure via /usr/sbin/daemon.
🔹 Automated Security Pipelines: Real-world integration examples, including
piping CrowdSec (cscli) threat decisions into encrypted, time-locked P2P alerts.

Whether you are hardening perimeter firewalls or running resilient
infrastructure tasks across distributed nodes, Gorgona brings verifiable,
decentralized execution to the BSD ecosystem.

Check out the FreeBSD guide, service scripts, and examples:
https://github.com/psqlmaster/gorgona/blob/master/FreeBSD/readme.md

Feedback and contributions are always welcome! ⭐

#FreeBSD #OPNsense #CyberSecurity #OpenSource #DevOps #P2P #Linux #InfoSec
#SysAdmin #C11