Deckv is a simple and efficient blocklist implementation for Go applications with support for multiple storage backends.
- Simple and easy-to-use API
- Multiple storage backend support
- In-memory storage (default)
- Redis storage
- Configurable through simple text files
- Context support for all operations
- Thread-safe operations
go get github.com/9ssi7/deckvSee the examples directory for more detailed usage examples.
You can create a blocklist configuration file with the following content:
0-mail.com
1-mail.com
or real and full domain names, use this file disposable-email-domains config file as a reference.
Create a blocklist.conf file with the following content:
0-mail.com
1-mail.com
client := deckv.New(deckv.WithConfFilePath("./blocklist.conf"))
err := client.Load(context.Background())
if err != nil {
panic(err)
}
isBlocked, err := client.Check(context.Background(), "0-mail.com")
if err != nil {
panic(err)
}
fmt.Println(isBlocked)Create a blocklist.conf file with the following content:
0-mail.com
1-mail.com
You can use Redis storage by setting the WithStorage option.
storage := deckvredis.New(deckvredis.Config{
Host: "localhost",
Port: "6379",
Password: "",
DB: 0,
})
client := deckv.New(deckv.WithConfFilePath("./blocklist.conf"), deckv.WithStorage(storage))
err := client.Load(context.Background())
if err != nil {
panic(err)
}
isBlocked, err := client.Check(context.Background(), deckv.FromEmail("test@0-mail.com"))
if err != nil {
panic(err)
}
fmt.Println(isBlocked)The blocklist configuration file is a simple text file with one entry per line:
0-mail.com
1-mail.com
This project is licensed under the MIT License - see the LICENSE file for details.