diff --git a/server/insert.go b/server/insert.go index 8df5cee..5273ea2 100644 --- a/server/insert.go +++ b/server/insert.go @@ -15,6 +15,7 @@ import ( func InsertPut(c *gin.Context) { if blacklist.IsBlocked(c.ClientIP()) { + c.Error(fault.ErrBlocked) c.JSON(http.StatusForbidden, fault.ErrBlocked) return } diff --git a/server/lookup.go b/server/lookup.go index a4e54a1..c6245a3 100644 --- a/server/lookup.go +++ b/server/lookup.go @@ -15,6 +15,7 @@ func LookupGet(c *gin.Context) { // Block blacklisted IPs if blacklist.IsBlocked(c.ClientIP()) { + c.Error(fault.ErrBlocked) if c.GetHeader("Accept") == "text/plain" { c.String(http.StatusForbidden, fault.ErrBlocked.Err) } else { @@ -49,6 +50,7 @@ func LookupGet(c *gin.Context) { } if len(subs) == 0 { + c.Error(fault.ErrNotFound) if c.GetHeader("Accept") == "text/plain" { c.String(http.StatusNotFound, fault.ErrNotFound.Err) } else { diff --git a/server/other.go b/server/other.go index b75ac88..784e33c 100644 --- a/server/other.go +++ b/server/other.go @@ -16,6 +16,7 @@ import ( func OtherGet(c *gin.Context) { if blacklist.IsBlocked(c.ClientIP()) { + c.Error(fault.ErrBlocked) c.JSON(http.StatusForbidden, fault.ErrBlocked) return } @@ -88,6 +89,7 @@ func OtherGet(c *gin.Context) { func OtherKeyPatch(c *gin.Context) { if blacklist.IsBlocked(c.ClientIP()) { + c.Error(fault.ErrBlocked) c.JSON(http.StatusForbidden, fault.ErrBlocked) return } @@ -167,6 +169,7 @@ func OtherKeyPatch(c *gin.Context) { func OtherNamePatch(c *gin.Context) { if blacklist.IsBlocked(c.ClientIP()) { + c.Error(fault.ErrBlocked) c.JSON(http.StatusForbidden, fault.ErrBlocked) return } @@ -274,6 +277,7 @@ func OtherNamePatch(c *gin.Context) { func OtherAdminPatch(c *gin.Context) { if blacklist.IsBlocked(c.ClientIP()) { + c.Error(fault.ErrBlocked) c.JSON(http.StatusForbidden, fault.ErrBlocked) return } diff --git a/server/stat.go b/server/stat.go index 893dd09..ea021f9 100644 --- a/server/stat.go +++ b/server/stat.go @@ -87,6 +87,7 @@ func StatGet(c *gin.Context) { } if blacklist.IsBlocked(c.ClientIP()) { + c.Error(fault.ErrBlocked) c.JSON(http.StatusForbidden, fault.ErrBlocked) return } diff --git a/server/static.go b/server/static.go index 2e321ab..3c92b38 100644 --- a/server/static.go +++ b/server/static.go @@ -15,6 +15,7 @@ var openApiYaml []byte func StaticOpenApiYamlGet(c *gin.Context) { if blacklist.IsBlocked(c.ClientIP()) { + c.Error(fault.ErrBlocked) c.JSON(http.StatusForbidden, fault.ErrBlocked) return } @@ -28,6 +29,7 @@ var indexHtml []byte func StaticIndexHtmlGet(c *gin.Context) { if blacklist.IsBlocked(c.ClientIP()) { + c.Error(fault.ErrBlocked) c.JSON(http.StatusForbidden, fault.ErrBlocked) return } @@ -41,6 +43,7 @@ var faviconIco []byte func StaticFaviconIcoGet(c *gin.Context) { if blacklist.IsBlocked(c.ClientIP()) { + c.Error(fault.ErrBlocked) c.JSON(http.StatusForbidden, fault.ErrBlocked) return } @@ -54,6 +57,7 @@ var indexCss []byte func StaticIndexCssGet(c *gin.Context) { if blacklist.IsBlocked(c.ClientIP()) { + c.Error(fault.ErrBlocked) c.JSON(http.StatusForbidden, fault.ErrBlocked) return } @@ -67,6 +71,7 @@ var indexJs []byte func StaticIndexJsGet(c *gin.Context) { if blacklist.IsBlocked(c.ClientIP()) { + c.Error(fault.ErrBlocked) c.JSON(http.StatusForbidden, fault.ErrBlocked) return } @@ -80,6 +85,7 @@ var logoWhiteSvg []byte func StaticLogoWhiteSvgGet(c *gin.Context) { if blacklist.IsBlocked(c.ClientIP()) { + c.Error(fault.ErrBlocked) c.JSON(http.StatusForbidden, fault.ErrBlocked) return } diff --git a/server/user.go b/server/user.go index 8ade18d..b9f7a85 100644 --- a/server/user.go +++ b/server/user.go @@ -16,6 +16,7 @@ import ( func UserGet(c *gin.Context) { if blacklist.IsBlocked(c.ClientIP()) { + c.Error(fault.ErrBlocked) c.JSON(http.StatusForbidden, fault.ErrBlocked) return } @@ -42,7 +43,6 @@ func UserGet(c *gin.Context) { } c.Error(err) - c.JSON(code, gin.H{"error": err.Error()}) return @@ -56,6 +56,7 @@ func UserGet(c *gin.Context) { func UserPut(c *gin.Context) { if blacklist.IsBlocked(c.ClientIP()) { + c.Error(fault.ErrBlocked) c.JSON(http.StatusForbidden, fault.ErrBlocked) return } @@ -84,7 +85,6 @@ func UserPut(c *gin.Context) { } c.Error(err) - c.JSON(code, gin.H{"error": err.Error()}) return @@ -150,6 +150,7 @@ func UserPut(c *gin.Context) { func UserDelete(c *gin.Context) { if blacklist.IsBlocked(c.ClientIP()) { + c.Error(fault.ErrBlocked) c.JSON(http.StatusForbidden, fault.ErrBlocked) return } @@ -210,6 +211,7 @@ func UserDelete(c *gin.Context) { func UserKeyPatch(c *gin.Context) { if blacklist.IsBlocked(c.ClientIP()) { + c.Error(fault.ErrBlocked) c.JSON(http.StatusForbidden, fault.ErrBlocked) return } @@ -257,6 +259,7 @@ func UserKeyPatch(c *gin.Context) { func UserNamePatch(c *gin.Context) { if blacklist.IsBlocked(c.ClientIP()) { + c.Error(fault.ErrBlocked) c.JSON(http.StatusForbidden, fault.ErrBlocked) return } @@ -326,6 +329,7 @@ func UserNamePatch(c *gin.Context) { func UsersGet(c *gin.Context) { if blacklist.IsBlocked(c.ClientIP()) { + c.Error(fault.ErrBlocked) c.JSON(http.StatusForbidden, fault.ErrBlocked) return }