Skip to content

Solnix is a security-focused, verifier-safe programming language designed for kernel-level policy enforcement, monitoring, and system protection.

License

Notifications You must be signed in to change notification settings

solnix-lang/solnix-compiler

Repository files navigation

Solnix Compiler

A simple compiler for the Solnix programming language. Solnix lets you write eBPF (Extended Berkeley Packet Filter) programs in a high-level, readable syntax instead of low-level C code.

What is Solnix?

Solnix is a domain-specific language for creating eBPF programs. It provides a cleaner way to define maps, packet filters, and network functions that run in the Linux kernel.

🚧 Status: Under Active Development

Installation

Make sure you have Rust installed. Then:

cargo build --release

This will create the solnixc binary in target/release/.

Usage

Compile a .snx source file to an eBPF object file:

./solnixc compile input.snx -o output.o

Example

Here's a simple Solnix program that counts connections by source IP:

map connection_counter {
    type: .hash;
    key: u32;
    value: u64;
    max: 1024;
}

unit filter_packets {
    section: "xdp";
    license: "GPL";

    reg src_ip = ctx.load_u32(26);
    heap count_ptr = connection_counter.lookup(src_ip);

    if guard(count_ptr) {
        *count_ptr += 1;
    }
    
    return 1;
}

Save this as example.snx and compile it with:

./solnixc compile example.snx -o example.o

Features

  • High-level syntax for eBPF development
  • Automatic code generation to eBPF C
  • Support for XDP (eXpress Data Path) programs
  • Hash maps and other eBPF data structures

License

License

About

Solnix is a security-focused, verifier-safe programming language designed for kernel-level policy enforcement, monitoring, and system protection.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published