go-nft

module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2023 License: Apache-2.0

README

go-nft

Licensed under Apache License version 2.0 Build Workflow Go Report Card

Go bindings for nft utility.

go-nft wraps invocation of the nft utility with functions to append and delete rules; create, clear and delete tables and chains.

To start using go-nft

go-nft is a library that provides a structured API to nftables.

go-nft uses the libnftables-json specification and exposes a subset of its structures.

  • Apply the configuration:
config := nft.NewConfig()
config.AddTable(nft.NewTable("mytable", nft.FamilyIP))
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
err := nft.ApplyConfigContext(ctx, config)
  • Read the configuration:
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
config, err := nft.ReadConfigContext(ctx)
nftVersion := config.Nftables[0].Metainfo.Version

For full setup example, see the integration test examples.

Contribution

We welcome contribution of any kind! Read CONTRIBUTING to learn how to contribute to the project.

Changelog

Please refer to CHANGELOG

Directories

Path Synopsis
nft
Package nft provides a GO API to nftables.
Package nft provides a GO API to nftables.
lib
* This file is part of the go-nft project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* This file is part of the go-nft project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
tests

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL