core

package
v0.0.0-...-6641a51 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Whitelist = "whitelist"
	Blacklist = "blacklist"
)

Variables

View Source
var BlacklistFunc = func(ip string) bool {
	appLogger.Debug("Entering BlacklistFunc")
	if !isValidCIDR(ip) {
		appLogger.Warnf("Invalid IP format: %s", ip)
		return false
	}

	inBlacklist, err := db.CheckInRedis(Blacklist, ip)
	if err != nil {
		appLogger.Warnf("Error checking blacklist for %s: %v", ip, err)
		return false
	}
	appLogger.Debugf("IP %s blacklisted: %v", ip, inBlacklist)
	return inBlacklist
}
View Source
var ManageListFunc = func(subnet string, listType string, add bool) bool {
	if !isValidCIDR(subnet) {
		appLogger.Warnf("Invalid subnet format: %s", subnet)
		return false
	}
	return db.UpdateRedis(listType, subnet, add)
}
View Source
var ResetBucketFunc = func(login, ip string) bool {
	if !isValidCIDR(ip) {
		appLogger.Warnf("Invalid IP format: %s", ip)
		return false
	}
	limiter.Delete(login)
	limiter.Delete(ip)
	return true
}
View Source
var WhitelistFunc = func(ip string) bool {
	appLogger.Debug("Entering WhitelistFunc")
	if !isValidCIDR(ip) {
		appLogger.Warnf("Invalid IP format: %s", ip)
		return false
	}

	inWhitelist, err := db.CheckInRedis(Whitelist, ip)
	if err != nil {
		appLogger.Warnf("Error checking whitelist for %s: %v", ip, err)
		return false
	}
	appLogger.Debugf("IP %s whitelisted: %v", ip, inWhitelist)
	return inWhitelist
}

Functions

func CheckAuthorization

func CheckAuthorization(login, password, ip string) bool

func InitLogger

func InitLogger(log *logger.Logger)

func InitRateLimiter

func InitRateLimiter(config config.RateLimiterConfig)

func ManageList

func ManageList(subnet string, listType string, add bool) bool

func ResetBucket

func ResetBucket(login, ip string) bool

Types

type Bucket

type Bucket struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL