Skip to content

Commit

Permalink
fix blacklist reloading
Browse files Browse the repository at this point in the history
increase ban threshold
  • Loading branch information
nikooo777 committed Feb 15, 2025
1 parent 6fc18e7 commit 0809aef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions firewall/firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ func ReloadBlacklist() {
var bl blacklist
err = json.Unmarshal(f, &bl)
if err != nil {
Logger.Errorf("failed to unmarshal blacklist: %v", err)
return
}
blacklistedAsn.Clear()
bannedIPs = bart.Table[int]{}
bannedIPs = &bart.Table[int]{}
for _, v := range bl.BlacklistedAsn {
blacklistedAsn.Store(v, true)
}
Expand All @@ -60,14 +61,14 @@ func ReloadBlacklist() {

var WindowSize = 120 * time.Second

const MaxStringsPerIp = 3
const MaxStringsPerIp = 4

var resourcesForIPCache = gcache.New(1000).Simple().Build()
var whitelist = map[string]bool{
"51.210.0.171": true,
}

var bannedIPs = bart.Table[int]{}
var bannedIPs = &bart.Table[int]{}
var blacklistedAsn = xsync.NewMapOf[int, bool]()
var Logger = logger.GetLogger()

Expand Down
1 change: 1 addition & 0 deletions firewall/firewall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@ func Test_checkBannedIp(t *testing.T) {
}
ip = "1.1.1.1"
assert.False(t, CheckBans(ip))

}

0 comments on commit 0809aef

Please sign in to comment.