• Stars
    star
    119
  • Rank 297,930 (Top 6 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created about 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🔥 Go bindings for the IPtables ipset http://ipset.netfilter.org userspace utility

go-ipset

This library is a simple GoLang wrapper to the IPtables ipset userspace utility. It provides an interface to allow Go programs to easily manipulate ipsets. It is currently limited to sets of type hash.

For ipset command documentation: http://ipset.netfilter.org/ipset.man.html

go-ipset requires ipset kernel module and userspace utility version 6.0 or greater.

Installation

Install go-ipset using the "go get" command:

go get github.com/janeczku/go-ipset/ipset

Install dependencies:

go get github.com/Sirupsen/logrus
go get github.com/coreos/go-semver/semver

API Reference

GoDoc

Usage

import "github.com/janeczku/go-ipset/ipset

Create a new set

Construct a new IPset instance (creating the set on the fly), then use the various methods to manipulate the IPset. For example, to create a new ipset "customers" of type hash:ip for storing plain IPv4 addresses:

customers := ipset.New("customers", "hash:ip", &ipset.Params{})

To create a new ipset to store different sized IPv4 network addresses (with /mask).

trustedNetworks := ipset.New("trusted-networks", "hash:net", &ipset.Params{})

Add a single entry to the set

customers.Add("8.8.2.2")

Populate the set with IPv4 addresses (overwriting the previous content)

ips := []string{"8.8.8.8", "8.8.4.4"}
customers.Refresh(ips)

Remove a single entry from that set:

customers.Del("8.8.8.8")

Configure advanced set options

You can configure advanced options when creating a new set by supplying the parameters in the ipset.Params struct.

type Params struct {
  HashFamily string
  HashSize   int
  MaxElem    int
  Timeout    int
}

See http://ipset.netfilter.org/ipset.man.html for their meaning.

For example, to create a set whose entries will expire after 60 seconds, lets say for temporarily limiting abusive clients:

abusers := ipset.New("ratelimited", "hash:ip", &ipset.Params{Timeout: 60})

List entries of a set

// list is []string
list ipset.List("customers")

More Repositories

1

calibre-web

📚 Web app for browsing, reading and downloading eBooks stored in a Calibre database
Python
11,592
star
2

go-dnsmasq

🐬 Lightweight caching DNS server/forwarder
Go
401
star
3

rancher-letsencrypt

🐮 Rancher service that obtains and manages free SSL certificates from the Let's Encrypt CA
Go
326
star
4

haproxy-acme-validation-plugin

🍀 Zero-downtime ACME / Let's Encrypt certificate issuing for HAProxy
Shell
293
star
5

docker-machine-vultr

Ⓜ️ Docker Machine driver for Vultr Cloud
Go
193
star
6

docker-dropbox

🐳 Dropbox in a Docker image. This works.
Shell
148
star
7

docker-alpine-kubernetes

:octocat: Alpine Linux base image with support for DNS service discovery in Docker clusters
Shell
112
star
8

keepalived-ingress-vip

💓 HA/IP failover solution for on-premises and bare-metal Kubernetes clusters.
Smarty
53
star
9

powerdns_exporter

📈 Prometheus metrics exporter for PowerDNS
Go
34
star
10

go-rancher-gen

🐮 Generate configuration files using templates and Rancher Metadata
Go
32
star
11

docker-calibre-web

🐳 Docker image for Calibre Web
Shell
32
star
12

terraform-rancheros-vmware

HCL
23
star
13

go-spinner

GO spinner / activity indicator for command line applications
Go
21
star
14

docker-nfs-ganesha

🐳 🚢 NFS-Ganesha Docker Image
Shell
16
star
15

docker-shipyard-armv7

🐳 Shipyard Docker management for Raspberry Pi 2 / Scaleway C1
JavaScript
11
star
16

docker-alpine-haproxy

🐳 Haproxy docker image based on Alpine Linux
Makefile
10
star
17

go-redwall

🔥 Dockerized distributed dynamic firewall daemon with Redis backend
Go
8
star
18

Docker-RemoteSyslog2

🐳 Forward server or container logs to remote syslog collectors
Shell
8
star
19

meta-k3s

Shell
7
star
20

stdemuxerhook

🔀 A hook for logrus logger that demuxes logs to stderr and stdout based on severity
Go
6
star
21

datadog-rancher-init

🐶 Sidekick container image for running Datadog Agent in Rancher environments
Python
6
star
22

rancher-v2-logging

6
star
23

habitat-plans

Shell
4
star
24

ansible-k3s-2-node-ha

Ansible playbook for setting up a 2-node, high available k3s cluster using an embedded replicated database
Shell
4
star
25

tiny-operators-catalog

Shell
3
star
26

meta-k3s-odroid-c2

Shell
2
star
27

go-ipintel

👮 Go wrapper for the getipintel.net proxy detection API
Go
2
star
28

fleet-demo

2
star
29

nginx-php55

🐳 Nginx/PHP5.5/NodeJS/Ruby Docker image based on CentOS 7
Shell
1
star
30

k8s-nginx-demo

1
star
31

docker-armhf

🐳 Docker in Docker for ARMv7!
Shell
1
star
32

dotfiles

Shell
1
star
33

docker-selfoss-nginx

🐳 Selfoss - http://selfoss.aditu.de Docker image
PHP
1
star
34

helm-charts

Public Helm chart repository
1
star
35

harvester-rke2-cluster-template

Example RKE2 cluster template for Harvester IaaS
1
star
36

k3s-fleet-demos

1
star
37

ndppd-alpine

Shell
1
star
38

blinken-k8s

Shell
1
star
39

docker-debian-nginx

🐳 Nginx 1.8 (Dotdeb) image based on Debian Wheezy
Shell
1
star
40

docker-debian-s6

🐳 Official debian images pimped with the s6 process supervisor
Shell
1
star
41

rancher-hello-world

Python
1
star