| 1 | /* |
| 2 | * This file is part of the go-nft project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | * |
| 16 | * Copyright 2021 Red Hat, Inc. |
| 17 | * |
| 18 | */ |
| 19 | |
| 20 | // Package nft provides a GO API to nftables. |
| 21 | // Together with the schema package, it allows to build, read and apply |
| 22 | // nftables configuration on a supporting system. |
| 23 | // |
| 24 | // The schema structures are based on libnftables-json (https://www.mankier.com/5/libnftables-json) |
| 25 | // and implement a subset of them. |
| 26 | // |
| 27 | // To create a new configuration, use `NewConfig` followed by methods |
| 28 | // which populates the configuration with tables, chains and rules, accompanied |
| 29 | // to specific actions (add, delete, flush). |
| 30 | // |
| 31 | // config := nft.NewConfig() |
| 32 | // table := nft.NewTable("mytable", nft.FamilyIP) |
| 33 | // config.AddTable(table) |
| 34 | // chain := nft.NewRegularChain(table, "mychain") |
| 35 | // config.AddChain(chain) |
| 36 | // rule := nft.NewRule(table, chain, statements, nil, nil, "mycomment") |
| 37 | // |
| 38 | // To apply a configuration on the system, use the `ApplyConfig` function. |
| 39 | // err := nft.ApplyConfig(config) |
| 40 | // |
| 41 | // To read the configuration from the system, use the `ReadConfig` function. |
| 42 | // config, err := nft.ReadConfig() |
| 43 | // |
| 44 | // For full setup example, see the integration test: tests/config_test.go |
| 45 | // |
| 46 | // The nft package is dependent on the `nft` binary and the kernel nftables |
| 47 | // support. |
| 48 | package nft |