From 156158333e5d2e87aedc67217c21ee6ea9090cec Mon Sep 17 00:00:00 2001 From: TatLead Date: Sat, 16 Mar 2024 00:49:55 +0000 Subject: [PATCH] Update TheFront --- .env.example | 14 ++++++------ README.md | 26 ++++++++++++----------- app.py | 8 +++---- protocols/{Front.py => TheFront.py} | 10 ++++----- protocols/__init__.py | 2 +- tests/{test_front.py => test_thefront.py} | 4 ++-- 6 files changed, 34 insertions(+), 30 deletions(-) rename protocols/{Front.py => TheFront.py} (92%) rename tests/{test_front.py => test_thefront.py} (84%) diff --git a/.env.example b/.env.example index 3f45175..c7b139a 100644 --- a/.env.example +++ b/.env.example @@ -1,15 +1,17 @@ -# The URL of your mongodb database. +# The URL of your mongodb database. (Required) DATABASE_URL= -# Flask application +# The port number on which the Flask application will run. PORT=8000 -SECRET_KEY=0a431f4a5f5851adfa37107a9035e6644c2b0124f9c3d1c1 -# Factorio username and token -FACTORIO_USERNAME= -FACTORIO_TOKEN= +# Flask application secret key. +SECRET_KEY= # Flask-MonitoringDashboard USERNAME=admin PASSWORD=admin SECURITY_TOKEN=cc83733cb0af8b884ff6577086b87909 + +# Factorio username and token +FACTORIO_USERNAME= +FACTORIO_TOKEN= diff --git a/README.md b/README.md index 9b91a14..f384019 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![GitHub release](https://img.shields.io/github/release/opengsq/opengsq-master-server)](https://github.com/opengsq/opengsq-master-server/releases/) [![GitHub license](https://img.shields.io/github/license/opengsq/opengsq-master-server)](https://github.com/opengsq/opengsq-master-server/blob/main/LICENSE) -This is an application that provides an API for searching game servers. The application supports the following games: BeamMP, Factorio, Palworld, and Scum. +This is an application that provides an API for searching game servers. The application supports the following games: BeamMP, Factorio, Palworld, Scum and The Front. Try now: https://master-server.opengsq.com @@ -15,9 +15,9 @@ The application provides the following endpoints: - `/beammp/search?host=&port=` - `/factorio/search?host=&port=` -- `/front/search?host=&port=` - `/palworld/search?host=&port=` - `/scum/search?host=&port=` +- `/thefront/search?host=&port=` Replace `` and `` with the host and port of the game server you want to search. @@ -61,16 +61,18 @@ cp .env.example .env Here's what each variable in the `.env` file represents: -| Variable | Description | -| --- | --- | -| `DATABASE_URL` | The URL of your mongodb database. | -| `PORT` | The port number on which the Flask application will run. | -| `SECRET_KEY` | Flask application secret key. | -| `FACTORIO_USERNAME` | Your Factorio username. | -| `FACTORIO_TOKEN` | Your Factorio token. | -| `USERNAME` | The username for the Flask-MonitoringDashboard. | -| `PASSWORD` | The password for the Flask-MonitoringDashboard. | -| `SECURITY_TOKEN` | The security token for the Flask-MonitoringDashboard. | +| Variable | Description | Default Value | Best Practice | +| --- | --- | --- | --- | +| `DATABASE_URL` | The URL of your MongoDB database. | None | This is required. Make sure to keep this value secure and do not share it publicly. | +| `PORT` | The port number on which the Flask application will run. | `8000` | Choose a port that is not being used by other services. | +| `SECRET_KEY` | Flask application secret key. | None | This should be a random string. It is used for session management in Flask. Keep this value secure. | +| `USERNAME` | The username for Flask-MonitoringDashboard. | `admin` | Change this to a unique username. | +| `PASSWORD` | The password for Flask-MonitoringDashboard. | `admin` | Change this to a strong, unique password. | +| `SECURITY_TOKEN` | The security token for Flask-MonitoringDashboard. | `cc83733cb0af8b884ff6577086b87909` | This should be a random string. Keep this value secure. | +| `FACTORIO_USERNAME` | The username for Factorio. | None | Set this to your Factorio username. | +| `FACTORIO_TOKEN` | The token for Factorio. | None | This should be your Factorio token. Keep this value secure. | + +Remember, it's important to keep all sensitive information such as `DATABASE_URL`, `SECRET_KEY`, `PASSWORD`, `SECURITY_TOKEN`, and `FACTORIO_TOKEN` secure and not to share them publicly or commit them to version control. It's a good practice to use environment variables or a secure method to store these values. ## Running the Application (Development) diff --git a/app.py b/app.py index 7755906..b163819 100644 --- a/app.py +++ b/app.py @@ -6,7 +6,7 @@ import markdown from config import build_config_file -from protocols import MasterServer, BeamMP, Factorio, Front, Palworld, Scum +from protocols import MasterServer, BeamMP, Factorio, Palworld, Scum, TheFront from version import __version__ app = Flask(__name__) @@ -112,11 +112,11 @@ def factorio_search(): return search(request.args, Factorio()) -@app.route('/front/search', methods=['GET']) +@app.route('/thefront/search', methods=['GET']) def front_search(): """ Front Search - This endpoint allows you to search for a Front server using its host and port. + This endpoint allows you to search for a The Front server using its host and port. --- tags: - Search EndPoint @@ -137,7 +137,7 @@ def front_search(): 404: description: No server was found with the provided host and port. """ - return search(request.args, Front()) + return search(request.args, TheFront()) @app.route('/palworld/search', methods=['GET']) diff --git a/protocols/Front.py b/protocols/TheFront.py similarity index 92% rename from protocols/Front.py rename to protocols/TheFront.py index 271238d..57a0142 100644 --- a/protocols/Front.py +++ b/protocols/TheFront.py @@ -5,9 +5,9 @@ from protocols.MasterServer import MasterServer -class Front(MasterServer): +class TheFront(MasterServer): def __init__(self) -> None: - super().__init__('Front') + super().__init__('TheFront') def create_index(self): self.collection.create_index({'addr': 1, 'port': 1}) @@ -75,7 +75,7 @@ def _upsert_bulk_write(self, server_list: list): if __name__ == "__main__": - front = Front() - # front.job() - server = front.find(host='45.137.244.52', port=28100) + the_front = TheFront() + # the_front.job() + server = the_front.find(host='45.137.244.52', port=28100) print(server) diff --git a/protocols/__init__.py b/protocols/__init__.py index ce205a1..ff8633f 100644 --- a/protocols/__init__.py +++ b/protocols/__init__.py @@ -1,6 +1,6 @@ from .BeamMP import BeamMP # noqa: F401 from .Factorio import Factorio # noqa: F401 -from .Front import Front # noqa: F401 from .MasterServer import MasterServer # noqa: F401 from .Palworld import Palworld # noqa: F401 from .Scum import Scum # noqa: F401 +from .TheFront import TheFront # noqa: F401 diff --git a/tests/test_front.py b/tests/test_thefront.py similarity index 84% rename from tests/test_front.py rename to tests/test_thefront.py index a0411a4..efc03b1 100644 --- a/tests/test_front.py +++ b/tests/test_thefront.py @@ -1,11 +1,11 @@ import pytest -from protocols import MasterServer, Front +from protocols import MasterServer, TheFront @pytest.fixture def instance(): - return Front() + return TheFront() def test_job(instance: MasterServer):