Skip to content

Commit

Permalink
fix blacklist check in server update
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyrAhmady committed Oct 22, 2023
1 parent 4523bad commit b364b4c
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions app/resources/server/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package server
import (
"context"
"os"
"strings"
"time"

"github.com/goccy/go-json"
Expand Down Expand Up @@ -30,14 +31,10 @@ func (s *DB) Upsert(ctx context.Context, e All) error {

// Check whether an IP is blocked or not, not port specific
blockedServer, err := s.client.ServerIPBlacklist.
FindUnique(db.ServerIPBlacklist.IP.Equals(e.IP)).
FindUnique(db.ServerIPBlacklist.IP.Equals(strings.Split(e.IP, ":")[0])).
Exec(ctx)

if err != nil {
return err
}

if blockedServer == nil {
if blockedServer != nil {
return errors.Wrapf(err, "IP address is blocked")
}

Expand Down

0 comments on commit b364b4c

Please sign in to comment.