WIP SIF 9.11 private server written in Python 3.12 using FastAPI.
-
This project is currently in need of funding.
-
Database schema changes constantly. Expect frequent database wipes.
NPPS4 currently supports only Python 3.12 (and possibly later version). Python 3.11 and earlier is not supported.
- Install Python 3.12 or later.
- Create virtual environment.
- Activate it.
pip install -r requirements.txt
Before starting the server, you need 3 things:
- Create configuration file.
- Get private key.
- Get client game database.
Copy out config.sample.toml
to config.toml
and adjust as needed. The file has extensive comments on each
configuration values.
Warning
A private key is required due to internal request-response verification done in the game.
NPPS4 provides default private key which is used to develop other private servers by the community and compatible with community-patched APK.
There's nothing to do to use this private key. This private key is used by default as per the sample configuration
key main.server_private_key
.
The public key of the default server key is:
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDE0RNd6047aeBirzVb61DolatY
YWpaEUIPugOIkobHDc9qVR5iliMLyC0ErXO1siLBwN+U3zaDVOa5uhXbiS7uYq5c
cpxComxTnZtcn/b+mKDpYWLaC0Gv7UoiT8rpNqN3Vko645usz9OFc4VciijsHGRP
XmmmoP6qykfI/vba8wIDAQAB
-----END PUBLIC KEY-----
Important
The private key must be 1024-bit RSA stored in PEM format!
If you already have your existing private key, simply put them as server_key.pem
.
To get the public key, run:
python make_server_key.py -p
To generate a new private key, run:
python make_server_key.py
The public key, for your game client will be printed to stdout in PEM format. Patch your game to use the newly-provided public key.
There's 2 simple methods: Having local copy of SIF client files or loading it directly through internet.
First, follow the instruction at https://gist.github.com/MikuAuahDark/ece4eb73b3396403c6a2f11610a783b8.
Then set the download.backend
to internal
and configure the download.internal.archive_root
directory in the
configuration file to your local copy of SIF client files.
Look at the URL in https://gist.github.com/MikuAuahDark/ece4eb73b3396403c6a2f11610a783b8.
Set the download.backend
to n4dlapi
and configure download.n4dlapi.server
to the URL writen in above gist (not
the gist itself).
Please consult SQLAlchemy supported database backends for more information. If in doubt, SQLite3 is a safe choice if you don't need performance as it's already a part of NPPS4 required dependencies.
Otherwise, install the additional dependencies depending on which backend you want to use. Ensure to install the "async" version of the database packages!
- SQLite3:
aiosqlite
(already installed) - PostgreSQL:
asyncpg
- MySQL/MariaDB:
asyncmy
After all is set, initialize the database:
alembic upgrade head
Then run the server
uvicorn npps4.run.app:main --port 51376 --host <your lan IP or 0.0.0.0>
Caveat: Currently, --workers
option is not supported when using NPPS4-DLAPI download backend.
Before updating, please ensure if database breakage is not happening. See DBBREAKAGE.md for information.
If there's no database breakage or you already know a way to handle the breakage (either by doing stuff manually or destroying the database), run:
git pull --ff-only
alembic upgrade head
Most changes requires a server restart. However, changes that only touch server_data.json
does not require server
restart as that particular file is hot-reloaded by the server.
To get compatible client, please look at https://ethanaobrien.github.io/sif-patcher/. Both iOS and Android are supported.
See CONTRIBUTE.md
zLib license, excluding any files in external/
.
Public domain/unlicense, any files in external/
.