Skip to content

nickgarlis/nftdesk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nftdesk

PkgGoDev GitHub Go Report Card

This is a thin wrapper around Google's nftables to simplify the programmatic creation of nftables rules by communicating directly with netfilter.

Note: This library is under development. The API might change as I tinker with the design. 🚧

Installation

go get github.com/nickgarlis/nftdesk@v0.0.1

Example Usage

package main

import (
	"github.com/nickgarlis/nftdesk"
	"github.com/nickgarlis/nftdesk/expr"
	"github.com/nickgarlis/nftdesk/models"
)

func main() {
	d, err := nftdesk.New()
	if err != nil {
		panic(err)
	}

	table := d.AddTable("my-table", models.TableFamilyIPv4)

	chain := table.AddChain("my-chain")

	_, err := chain.AddRule(
		expr.ConnTrack().State().In(expr.CtStateESTABLISHED, expr.CtStateRELATED),
		expr.Verdict().Accept(),
	)
	if err != nil {
		t.Error(err)
	}

	err = d.Flush()
	if err != nil {
		panic(err)
	}
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published