{"id":17913245,"url":"https://github.com/florianl/go-nflog","last_synced_at":"2025-04-08T08:13:14.322Z","repository":{"id":32995738,"uuid":"148295515","full_name":"florianl/go-nflog","owner":"florianl","description":"c-binding free API for golang to communicate with the log subsystem of netfilter","archived":false,"fork":false,"pushed_at":"2025-02-15T18:16:37.000Z","size":122,"stargazers_count":63,"open_issues_count":0,"forks_count":21,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-01T05:34:09.280Z","etag":null,"topics":["golang","hacktoberfest","kernel","netfilter","nflog"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/florianl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-11T09:45:48.000Z","updated_at":"2025-03-12T06:04:40.000Z","dependencies_parsed_at":"2023-11-06T07:45:14.737Z","dependency_job_id":"fabab699-f8a7-4148-8693-5b0dd58525a2","html_url":"https://github.com/florianl/go-nflog","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florianl%2Fgo-nflog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florianl%2Fgo-nflog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florianl%2Fgo-nflog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florianl%2Fgo-nflog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/florianl","download_url":"https://codeload.github.com/florianl/go-nflog/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247801169,"owners_count":20998339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","hacktoberfest","kernel","netfilter","nflog"],"created_at":"2024-10-28T19:50:36.262Z","updated_at":"2025-04-08T08:13:14.293Z","avatar_url":"https://github.com/florianl.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"go-nflog [![PkgGoDev](https://pkg.go.dev/badge/github.com/florianl/go-nflog/v2)](https://pkg.go.dev/github.com/florianl/go-nflog/v2) [![Go Report Card](https://goreportcard.com/badge/github.com/florianl/go-nflog/v2)](https://goreportcard.com/report/github.com/florianl/go-nflog/v2) [![Go](https://github.com/florianl/go-nflog/actions/workflows/go.yml/badge.svg)](https://github.com/florianl/go-nflog/actions/workflows/go.yml)\n============\n\nThis is `go-nflog` and it is written in [golang](https://golang.org/). It provides a [C](https://en.wikipedia.org/wiki/C_(programming_language))-binding free API to the netfilter based log subsystem of the [Linux kernel](https://www.kernel.org).\n\n## Example\n\n```golang\nfunc main() {\n\t// Send outgoing pings to nflog group 100\n\t// # sudo iptables -I OUTPUT -p icmp -j NFLOG --nflog-group 100\n\n\t//Set configuration parameters\n\tconfig := nflog.Config{\n\t\tGroup:       100,\n\t\tCopymode:    nflog.CopyPacket,\n\t}\n\n\tnf, err := nflog.Open(\u0026config)\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"could not open nflog socket:\", err)\n\t\treturn\n\t}\n\tdefer nf.Close()\n\n\t// Avoid receiving ENOBUFS errors.\n\tif err := nf.SetOption(netlink.NoENOBUFS, true); err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"failed to set netlink option %v: %v\",\n\t\t\tnetlink.NoENOBUFS, err)\n\t\treturn\n\t}\n\n\tctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n\tdefer cancel()\n\n\t// hook that is called for every received packet by the nflog group\n\thook := func(attrs nflog.Attribute) int {\n\t\t// Just print out the payload of the nflog packet\n\t\tfmt.Fprintf(os.Stdout, \"%#v\\n\", attrs.Payload)\n\t\treturn 0\n\t}\n\n\t// errFunc that is called for every error on the registered hook\n\terrFunc := func(e error) int {\n\t\t// Just log the error and return 0 to continue receiving packets\n\t\tfmt.Fprintf(os.Stderr, \"received error on hook: %v\", e)\n\t\treturn 0\n\t}\n\n\t// Register your function to listen on nflog group 100\n\terr = nf.RegisterWithErrorFunc(ctx, hook, errFunc)\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"failed to register hook function: %v\", err)\n\t\treturn\n\t}\n\n\t// Block till the context expires\n\t\u003c-ctx.Done()\n}\n```\n\n## Privileges\n\nThis package processes information directly from the kernel and therefore it requires special privileges. You\ncan provide this privileges by adjusting the `CAP_NET_ADMIN` capabilities.\n```\n\tsetcap 'cap_net_admin=+ep' /your/executable\n```\n\nFor documentation and more examples please take a look at [![PkgGoDev](https://pkg.go.dev/badge/github.com/florianl/go-nflog)](https://pkg.go.dev/github.com/florianl/go-nflog)\n\n## Requirements\n\n* A version of Go that is [supported by upstream](https://golang.org/doc/devel/release.html#policy)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorianl%2Fgo-nflog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflorianl%2Fgo-nflog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorianl%2Fgo-nflog/lists"}