Skip to content

Commit

Permalink
Update TheFront
Browse files Browse the repository at this point in the history
  • Loading branch information
BattlefieldDuck committed Mar 16, 2024
1 parent 7329019 commit 1561583
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 30 deletions.
14 changes: 8 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
@@ -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=
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.

Expand Down Expand Up @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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
Expand All @@ -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'])
Expand Down
10 changes: 5 additions & 5 deletions protocols/Front.py → protocols/TheFront.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion protocols/__init__.py
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions tests/test_front.py → tests/test_thefront.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down

0 comments on commit 1561583

Please sign in to comment.