Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove: all references to mmdb #17

Merged
merged 2 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]
Loading