Skip to content

Commit

Permalink
fix: tweak errors.As call
Browse files Browse the repository at this point in the history
Signed-off-by: nscuro <[email protected]>
  • Loading branch information
nscuro committed Apr 3, 2022
1 parent be49915 commit 5d29822
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (p Plugin) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
for _, ip := range p.GetRemoteIPs(req) {
err := p.CheckAllowed(ip)
if err != nil {
var notAllowedErr *NotAllowedError
var notAllowedErr NotAllowedError
if errors.As(err, &notAllowedErr) {
log.Printf("%s: %v", p.name, err)
rw.WriteHeader(p.disallowedStatusCode)
Expand Down Expand Up @@ -169,7 +169,7 @@ func (p Plugin) CheckAllowed(ip string) error {
return nil
}

return &NotAllowedError{
return NotAllowedError{
IP: ip,
Reason: "private address",
}
Expand All @@ -183,7 +183,7 @@ func (p Plugin) CheckAllowed(ip string) error {
}
}
if !allowed {
return &NotAllowedError{
return NotAllowedError{
Country: country,
IP: ip,
}
Expand Down

0 comments on commit 5d29822

Please sign in to comment.