Skip to content

Commit

Permalink
Exempt loopback address from geoip
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanw committed Jun 3, 2020
1 parent fce6bc1 commit f976bc6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions froide/foisite/models.py
Expand Up @@ -57,6 +57,8 @@ def refresh(self):
def get_site(self, ip):
if self.sites is None:
self.update()
if ip == '127.0.0.1':
return None
try:
if self.geoip is None:
self.geoip = self.get_geoip()
Expand Down
6 changes: 5 additions & 1 deletion froide/helper/spam.py
Expand Up @@ -19,7 +19,11 @@ def suspicious_ip(request):
return False
try:
g = GeoIP2()
info = g.country(get_client_ip(request))
ip = get_client_ip(request)
if ip == '127.0.0.1':
# Consider suspicious
return True
info = g.country(ip)
if info['country_code'] not in target_countries:
return True
except Exception as e:
Expand Down

0 comments on commit f976bc6

Please sign in to comment.