Created
June 8, 2021 14:15
-
-
Save sbz/c9873122f9bef25778901d95870187ea to your computer and use it in GitHub Desktop.
Test go pf FreeBSD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module github.com/sbz/pf-test | |
go 1.16 | |
require ( | |
github.com/go-freebsd/kld v0.0.0-20170326221633-78f2bd4a5544 // indirect | |
github.com/go-freebsd/pf v0.0.0-20190318053615-719aae74de40 | |
github.com/stretchr/testify v1.7.0 // indirect | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"github.com/go-freebsd/pf" | |
) | |
func main() { | |
fmt.Println("Test Go-freebsd sbz") | |
pfDevice, err := pf.Open() | |
if err != nil { | |
log.Fatal(err) | |
} | |
defer pfDevice.Close() | |
rules, err := pfDevice.Rules() | |
if err != nil { | |
log.Fatal(err) | |
} | |
var stats pf.RuleStats | |
for i, rule := range rules { | |
rule.Stats(&stats) | |
fmt.Printf("Rule (%d): %s\t%d\t%d\t%d\t%d\t%d\n", i, rule, | |
stats.Evaluations, | |
stats.PacketIn, | |
stats.PacketOut, | |
stats.BytesIn, | |
stats.BytesOut) | |
} | |
fmt.Println("End Test Go-freebsd sbz") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment