Update TheFront

This commit is contained in:
TatLead 2024-03-16 00:49:55 +00:00
parent 73290194b1
commit 156158333e
6 changed files with 34 additions and 30 deletions

View file

@ -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=

View file

@ -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=<host>&port=<port>`
- `/factorio/search?host=<host>&port=<port>`
- `/front/search?host=<host>&port=<port>`
- `/palworld/search?host=<host>&port=<port>`
- `/scum/search?host=<host>&port=<port>`
- `/thefront/search?host=<host>&port=<port>`
Replace `<host>` and `<port>` 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)

8
app.py
View file

@ -6,7 +6,7 @@ import flask_monitoringdashboard as dashboard
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'])

View file

@ -5,9 +5,9 @@ from pymongo import UpdateOne
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 @@ class Front(MasterServer):
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)

View file

@ -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

View file

@ -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):