Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider interface { // IsBlockedCountry checks if a country is in the blocked list. // isoCode must be an ISO 3166-1 alpha-2 country code. IsBlockedCountry(isoCode string) bool // IsBlockedIP determines if an IP address originates from a blocked country. // Returns false for nil IP addresses or if country lookup fails. IsBlockedIP(ctx context.Context, ip net.IP) bool // GetCountryCode returns the ISO 3166-1 alpha-2 country code for an IP address. // Returns an error if the lookup fails or no country is found. GetCountryCode(ctx context.Context, ip net.IP) (string, error) // Close releases resources associated with the provider. Close() error }
Provider defines the interface for IP-based country blocking operations. It provides methods to check if an IP or country is blocked and to retrieve country codes for given IP addresses.
func NewProvider ¶
func NewProvider(cfg *config.Configuration, logger *slog.Logger) Provider
NewProvider creates a new IP country blocking provider using the provided configuration. It initializes the GeoIP2 database and sets up the blocked countries list. Fatally crashes the entire application if the database cannot be opened.
Click to show internal directories.
Click to hide internal directories.