Skip to content

Commit

Permalink
Assume local network requests come from Belfast
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeshingles committed Dec 6, 2024
1 parent 374a516 commit e7672af
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions atlasserver/forcephot/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ def perform_create(self, serializer) -> None:
else:
ip = self.request.META.get("REMOTE_ADDR")

if ip.startswith(("192.168.", "127.0.", "10.")):
ip = "qub.ac.uk"

geoip = GeoIP2()
with contextlib.suppress(AddressNotFoundError):
location = geoip.city(ip)
Expand Down Expand Up @@ -379,6 +382,10 @@ def get(self, request, pk):
ip = x_forwarded_for.split(",")[0]
else:
ip = self.request.META.get("REMOTE_ADDR")

if ip.startswith(("192.168.", "127.0.", "10.")):
ip = "qub.ac.uk"

geoip = GeoIP2()
with contextlib.suppress(AddressNotFoundError):
location = geoip.city(ip)
Expand Down

0 comments on commit e7672af

Please sign in to comment.