File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -19,29 +19,30 @@ func withBanlist(c *gin.Context) {
1919
2020 if archivist != "" {
2121 wg .Go (func () {
22- r := valkeyClient .Do (context .Background (), valkeyClient .B ().Get ().Key ("banlist:archivist:" + archivist ).Build ())
22+ r := valkeyClient .Do (context .Background (), valkeyClient .B ().Exists ().Key ("banlist:archivist:" + archivist ).Build ())
2323 if r .Error () != nil {
2424 log .Printf ("valkey get banlist: %v" , r .Error ()) // passthrough on error
25- } else {
25+ } else if k , _ := r . AsInt64 (); k > 0 {
2626 archivistBan = true
27- c .AbortWithStatusJSON (http .StatusForbidden , gin.H {"error" : "NO means NO! (A)" })
2827 }
2928 })
3029 }
3130 if ip != "" {
3231 wg .Go (func () {
33- r := valkeyClient .Do (context .Background (), valkeyClient .B ().Get ().Key ("banlist:ip:" + ip ).Build ())
32+ r := valkeyClient .Do (context .Background (), valkeyClient .B ().Exists ().Key ("banlist:ip:" + ip ).Build ())
3433 if r .Error () != nil {
3534 log .Printf ("valkey get banlist: %v" , r .Error ()) // passthrough on error
36- } else {
35+ } else if k , _ := r . AsInt64 (); k > 0 {
3736 ipBan = true
38- c .AbortWithStatusJSON (http .StatusForbidden , gin.H {"error" : "NO means NO! (I)" })
3937 }
4038 })
4139 }
4240 wg .Wait ()
4341
4442 if archivistBan || ipBan {
43+ log .Println ("Blocked request from" , ip , "archivist:" , archivist )
44+ c .JSON (http .StatusForbidden , gin.H {"error" : "No means No!" })
45+ c .Abort ()
4546 return
4647 }
4748
You can’t perform that action at this time.
0 commit comments