Skip to content

Commit

Permalink
remove: all references to mmdb (#17)
Browse files Browse the repository at this point in the history
i am NOT waitifing fro len
  • Loading branch information
RealistikDash committed Jun 16, 2024
1 parent 8a6f21d commit d1d8576
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 34 deletions.
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ PS_PY_COMMAND_WHITELIST=1000,1180

# Data Directory Configuration
DATA_BEATMAP_DIRECTORY=/path/to/your/beatmap/directory
DATA_GEOLOCATION_PATH=/path/to/geoloc/db
DATA_BIBLE_PATH=/path/to/bible

# Misc Configuration.
Expand Down
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @RealistikDash @lenforiee
* @RealistikDash @lenforiee
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ WORKDIR /app
COPY ./resources/geolocation_database.mmdb /app/resources/geolocation_database.mmdb
COPY ./resources/bible.txt /app/resources/bible.txt

ENV DATA_GEOLOCATION_PATH=/app/resources/geolocation_database.mmdb
ENV DATA_BIBLE_PATH=/app/resources/bible.txt

# Requirements
Expand Down
1 change: 0 additions & 1 deletion peppy/events/loginEvent.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from constants import serverPackets
from helpers import chatHelper as chat
from helpers import geo_helper
from helpers.geo_helper import get_full
from helpers.timing import Timer
from helpers.user_helper import get_country
from helpers.user_helper import set_country
Expand Down
29 changes: 0 additions & 29 deletions peppy/helpers/geo_helper.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
from __future__ import annotations

import settings
from geoip2 import database

db_reader = database.Reader(settings.DATA_GEOLOCATION_PATH)

countryCodes = {
"IO": 104,
"PS": 178,
Expand Down Expand Up @@ -280,27 +275,3 @@ def getCountryLetters(code: int) -> str:
:return: country letters (XX if not found)
"""
return countryIds.get(code, "XX")


def get_full(ip: str) -> tuple[float, float, str]:
"""Fetches the user's full geolocation data and returns the imperative
info retrieved.
Note:
This uses a really quick IP lookup database. use as a replacement to
full on API requests.
Args:
ip (str): The IP of the user to fetch the info for.
Returns:
Tuple of data in order of `(lat, long, country)`
"""

try:
city = db_reader.city(ip)

return city.location.latitude, city.location.longitude, city.country.iso_code # type: ignore L

except Exception:
return 0.0, 0.0, "XX"
1 change: 0 additions & 1 deletion peppy/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def _parse_int_list(value: str) -> list[int]:
PS_PY_COMMAND_WHITELIST = _parse_int_list(os.environ["PS_PY_COMMAND_WHITELIST"])

DATA_BEATMAP_DIRECTORY = os.environ["DATA_BEATMAP_DIRECTORY"]
DATA_GEOLOCATION_PATH = os.environ["DATA_GEOLOCATION_PATH"]
DATA_BIBLE_PATH = os.environ["DATA_BIBLE_PATH"]

IP2LOCATION_API_KEY = os.environ["IP2LOCATION_API_KEY"]

0 comments on commit d1d8576

Please sign in to comment.