Go client for apiban.org
go get github.com/cgrates/baningo
Join CGRateS on Google Groups here.
baningo is released under the MIT License. Copyright (C) ITsysCOM GmbH. All Rights Reserved.
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")
}
}