1
0
Fork 0
hscloud/games/factorio/modproxy
q3k 97b5cd7b58 go: re-do the entire thing
This is a mega-change, but attempting to split this up further is
probably not worth the effort.

Summary:

1. Bump up bazel, rules_go, and others.
2. Switch to new go target naming (bye bye go_default_library)
3. Move go deps to go.mod/go.sum, use make gazelle generate from that
4. Bump up Python deps a bit

And also whatever was required to actually get things to work - loads of
small useless changes.

Tested to work on NixOS and Ubuntu 20.04:

   $ bazel build //...
   $ bazel test //...

Change-Id: I8364bdaa1406b9ae4d0385a6b607f3e7989f98a9
Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/1583
Reviewed-by: q3k <q3k@hackerspace.pl>
2023-09-22 21:50:19 +00:00
..
client go: re-do the entire thing 2023-09-22 21:50:19 +00:00
modportal go: re-do the entire thing 2023-09-22 21:50:19 +00:00
proto go: re-do the entire thing 2023-09-22 21:50:19 +00:00
BUILD.bazel go: re-do the entire thing 2023-09-22 21:50:19 +00:00
README.md games/factorio: add modproxy 2020-08-14 13:03:46 +02:00
main.go games/factorio: add modproxy 2020-08-14 13:03:46 +02:00

README.md

Factorio modproxy

The modproxy is a microservice that caches Factorio mods.

Usually, Factorio mods from the mod portal need credentials in order to be downloaded. As nobody is willing to share their credentials, or buy a HSWAW factorio license, this proxy got implemented.

.-------------------.        .----------.                  .----------.
| mods.factorio.com |<-------| modproxy |<-------------.---|.----------.
'-------------------'  HTTP  '----------'     gRPC     :----| factorio |
                                  | Local              |   '| server   |
                                  | files              |    '----------'
                                  V                    |    .----------.
                               .-'''-.                 '----| Account  |
                               |-___-|                      | holder   |
                               | CAS | Cached mods          '----------'
                               '-___-'

Factorio servers run a client binary that attempts to synchronize local mods with a specified intent of wanted Factorio mods. Any mods that are missing are downloaded from the modproxy over gRPC. Regardless of the success of the downloads, the modproxy client will then continue running the Factorio server.

The modproxy, when asked for a mod (via a ModProxy.Download gRPC call), will either serve it (if it has a copy of it), or record that this selected mod was missing and store this request in memory.

Then, when an Account Holder connects and calls ModProxy.Mirror, the modproxy will go through its saved list of pending mods to download, and use the credentials provided to download them.

Deployment

Factorio servers and the modproxy live in the factorio namespace on k0. Factorio servers created via jsonnet will automatically spawn a modproxy client on startup that will attempt to download whatever mods havve been specified in the jsonnet configuration (which is serialized to config.pb.text).

Synchronizing Mods as an Account Holder

If you have a Factorio account, you can connect over to the modproxy to feed it any mods that it wanted to download but couldn't. Currently this is done via a manual grpcurl call, an admin client might be introduced at some later point:

kubectl -n factorio port-forward deployment/proxy 4200
grpcurl -plaintext -format text -d 'username: "q3k" token: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"' 127.0.0.1:4200 modproxy.ModProxy.Mirror

The reuslt will be empty if no mods had to be synchronized.