⚠️ DEPRECATED: Filters have been migrated to multiformats/go-multiaddr.
A library to perform filtering of multiaddrs.
make install
// make a new filterset
f := NewFilters()
// filter out addresses on the 192.168 subnet
_, ipnet, _ := net.ParseCIDR("192.168.0.0/16")
f.AddFilter(ipnet, ActionDeny)
// check if an address is blocked
lanaddr, _ := ma.NewMultiaddr("/ip4/192.168.0.17/tcp/4050")
fmt.Println(f.AddrBlocked(lanaddr))
// the default for a filter is accept, but we can change that
f.RemoveLiteral(ipnet)
f.DefaultAction = ActionDeny
fmt.Println(f.AddrBlocked(lanaddr))
// we can now allow the local LAN, denying everything else
f.AddFilter(ipnet, ActionAccept)
fmt.Println(f.AddrBlocked(lanaddr))
PRs are welcome!
Small note: If editing the Readme, please conform to the standard-readme specification.
MIT © Jeromy Johnson
The last gx published version of this module was: 1.1.13: QmT6C5ebDy92zyRzdmSNyda5q7zkNXy68X47RDJiHpvaxd