/baningo

Go client for apiban.org

Primary LanguageGoMIT LicenseMIT

baningo Build Status

Go client for apiban.org

Installation

go get github.com/cgrates/baningo

Support

Join CGRateS on Google Groups here.

License

baningo is released under the MIT License. Copyright (C) ITsysCOM GmbH. All Rights Reserved.

Sample usage code

package main

import (
	"fmt"

	"github.com/cgrates/baningo"
)

func main() {
	apikeys := []string{"APIKey1", "APIKey2"}

	// get all banned IPs
	bannedIps, err := baningo.GetBannedIPs(apikeys...)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(bannedIps)

	// check only one IP
	isBanned, err := baningo.CheckIP("127.168.56.203", apikeys...)
	if err != nil {
		fmt.Println(err)
		return
	}
	if isBanned {
		fmt.Println("The IP is banned")
	} else {
		fmt.Println("The IP is not banned")
	}
}