From a95019778cdd503844a37d9e8714e9da96e8489b Mon Sep 17 00:00:00 2001 From: Jonathan Barrow Date: Sun, 23 Nov 2025 13:37:11 -0500 Subject: [PATCH] feat(grpc): allow the send/receive message sizes to be customized --- README.md | 70 +++++++++++++++++++------------------ src/config-manager.ts | 2 ++ src/services/grpc/server.ts | 5 ++- 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 365318c..d24d052 100644 --- a/README.md +++ b/README.md @@ -11,39 +11,41 @@ Handles all BOSS (Background Online Storage Service) related tasks for the Prete Configurations are loaded through environment variables. `.env` files are supported. -| Environment variable | Description | Default | -| ------------------------------------------------ | ----------------------------------------------------------------- | --------------------------------------------- | -| `PN_BOSS_CONFIG_HTTP_PORT` | The HTTP port the server listens on | None | -| `PN_BOSS_CONFIG_LOG_FORMAT` | What logging format to use, possible options: `pretty` or `json` | `pretty` | -| `PN_BOSS_CONFIG_LOG_LEVEL` | What log level to use | `info` | -| `PN_BOSS_CONFIG_BOSS_WIIU_AES_KEY` | The BOSS WiiU AES key, needs to be dumped from a console | None | -| `PN_BOSS_CONFIG_BOSS_WIIU_HMAC_KEY` | The BOSS WiiU HMAC key, needs to be dumped from a console | None | -| `PN_BOSS_CONFIG_BOSS_3DS_AES_KEY` | The BOSS 3DS AES key, needs to be dumped from a console | None | -| `PN_BOSS_CONFIG_MONGO_CONNECTION_STRING` | MongoDB connection string | None | -| `PN_BOSS_CONFIG_GRPC_BOSS_SERVER_ADDRESS` | Address for the GRPC server to listen on | None | -| `PN_BOSS_CONFIG_GRPC_BOSS_SERVER_PORT` | Port for the GRPC server to listen on | None | -| `PN_BOSS_CONFIG_GRPC_BOSS_SERVER_API_KEY` | API key that services will use to connect to the BOSS GRPC server | None | -| `PN_BOSS_CONFIG_GRPC_ACCOUNT_SERVER_ADDRESS` | Address of the account GRPC server | None | -| `PN_BOSS_CONFIG_GRPC_ACCOUNT_SERVER_PORT` | Port of the account GRPC server | None | -| `PN_BOSS_CONFIG_GRPC_ACCOUNT_SERVER_API_KEY` | API key of the account GRPC server | None | -| `PN_BOSS_CONFIG_GRPC_FRIENDS_SERVER_ADDRESS` | Address of the friends GRPC server | None | -| `PN_BOSS_CONFIG_GRPC_FRIENDS_SERVER_PORT` | Port of the friends GRPC server | None | -| `PN_BOSS_CONFIG_GRPC_FRIENDS_SERVER_API_KEY` | API key of the friends GRPC server | None | -| `PN_BOSS_CONFIG_S3_ENDPOINT` | S3 server endpoint | None | -| `PN_BOSS_CONFIG_S3_REGION` | S3 server region | None | -| `PN_BOSS_CONFIG_S3_BUCKET` | S3 server bucket | None | -| `PN_BOSS_CONFIG_S3_ACCESS_KEY` | S3 access key | None | -| `PN_BOSS_CONFIG_S3_ACCESS_SECRET` | S3 access key secret | None | -| `PN_BOSS_CONFIG_CDN_DISK_PATH` | Storage path for the CDN, use as alternative for S3 | None | -| `PN_BOSS_CONFIG_STREETPASS_RELAY_ENABLED` | Should Streetpass Relay be enabled? | `false` | -| `PN_BOSS_CONFIG_STREETPASS_RELAY_CLEAN_OLD_DATA` | Should old Streetpass Relay data be automatically cleaned up? | `false` | -| `PN_BOSS_CONFIG_DOMAINS_NPDI` | What domain should the NPDI component use? | `npdi.cdn.pretendo.cc` | -| `PN_BOSS_CONFIG_DOMAINS_NPDL` | What domain should the NPDL component use? | `npdl.cdn.pretendo.cc` | -| `PN_BOSS_CONFIG_DOMAINS_NPFL` | What domain should the NPFL component use? | `npfl.c.app.pretendo.cc` | -| `PN_BOSS_CONFIG_DOMAINS_NPPL` | What domain should the NPPL component use? | `nppl.app.pretendo.cc,nppl.c.app.pretendo.cc` | -| `PN_BOSS_CONFIG_DOMAINS_NPTS` | What domain should the NPTS component use? | `npts.app.pretendo.cc` | -| `PN_BOSS_CONFIG_DOMAINS_SPR` | What domain should the SPR component use? | `service.spr.app.pretendo.cc` | - +| Environment variable | Description | Default | +|--------------------------------------------------|---------------------------------------------------------------------|-----------------------------------------------| +| `PN_BOSS_CONFIG_HTTP_PORT` | The HTTP port the server listens on | None | +| `PN_BOSS_CONFIG_LOG_FORMAT` | What logging format to use, possible options: `pretty` or `json` | `pretty` | +| `PN_BOSS_CONFIG_LOG_LEVEL` | What log level to use | `info` | +| `PN_BOSS_CONFIG_BOSS_WIIU_AES_KEY` | The BOSS WiiU AES key, needs to be dumped from a console | None | +| `PN_BOSS_CONFIG_BOSS_WIIU_HMAC_KEY` | The BOSS WiiU HMAC key, needs to be dumped from a console | None | +| `PN_BOSS_CONFIG_BOSS_3DS_AES_KEY` | The BOSS 3DS AES key, needs to be dumped from a console | None | +| `PN_BOSS_CONFIG_MONGO_CONNECTION_STRING` | MongoDB connection string | None | +| `PN_BOSS_CONFIG_GRPC_MAX_RECEIVE_MESSAGE_LENGTH` | The maximum size, in megabytes, a message sent to the server can be | 4 | +| `PN_BOSS_CONFIG_GRPC_MAX_SEND_MESSAGE_LENGTH` | The maximum size, in megabytes, a message sent to the client can be | 4 | +| `PN_BOSS_CONFIG_GRPC_BOSS_SERVER_ADDRESS` | Address for the GRPC server to listen on | None | +| `PN_BOSS_CONFIG_GRPC_BOSS_SERVER_PORT` | Port for the GRPC server to listen on | None | +| `PN_BOSS_CONFIG_GRPC_BOSS_SERVER_API_KEY` | API key that services will use to connect to the BOSS GRPC server | None | +| `PN_BOSS_CONFIG_GRPC_ACCOUNT_SERVER_ADDRESS` | Address of the account GRPC server | None | +| `PN_BOSS_CONFIG_GRPC_ACCOUNT_SERVER_PORT` | Port of the account GRPC server | None | +| `PN_BOSS_CONFIG_GRPC_ACCOUNT_SERVER_API_KEY` | API key of the account GRPC server | None | +| `PN_BOSS_CONFIG_GRPC_FRIENDS_SERVER_ADDRESS` | Address of the friends GRPC server | None | +| `PN_BOSS_CONFIG_GRPC_FRIENDS_SERVER_PORT` | Port of the friends GRPC server | None | +| `PN_BOSS_CONFIG_GRPC_FRIENDS_SERVER_API_KEY` | API key of the friends GRPC server | None | +| `PN_BOSS_CONFIG_S3_ENDPOINT` | S3 server endpoint | None | +| `PN_BOSS_CONFIG_S3_REGION` | S3 server region | None | +| `PN_BOSS_CONFIG_S3_BUCKET` | S3 server bucket | None | +| `PN_BOSS_CONFIG_S3_ACCESS_KEY` | S3 access key | None | +| `PN_BOSS_CONFIG_S3_ACCESS_SECRET` | S3 access key secret | None | +| `PN_BOSS_CONFIG_CDN_DISK_PATH` | Storage path for the CDN, use as alternative for S3 | None | +| `PN_BOSS_CONFIG_STREETPASS_RELAY_ENABLED` | Should Streetpass Relay be enabled? | `false` | +| `PN_BOSS_CONFIG_STREETPASS_RELAY_CLEAN_OLD_DATA` | Should old Streetpass Relay data be automatically cleaned up? | `false` | +| `PN_BOSS_CONFIG_DOMAINS_NPDI` | What domain should the NPDI component use? | `npdi.cdn.pretendo.cc` | +| `PN_BOSS_CONFIG_DOMAINS_NPDL` | What domain should the NPDL component use? | `npdl.cdn.pretendo.cc` | +| `PN_BOSS_CONFIG_DOMAINS_NPFL` | What domain should the NPFL component use? | `npfl.c.app.pretendo.cc` | +| `PN_BOSS_CONFIG_DOMAINS_NPPL` | What domain should the NPPL component use? | `nppl.app.pretendo.cc,nppl.c.app.pretendo.cc` | +| `PN_BOSS_CONFIG_DOMAINS_NPTS` | What domain should the NPTS component use? | `npts.app.pretendo.cc` | +| `PN_BOSS_CONFIG_DOMAINS_SPR` | What domain should the SPR component use? | `service.spr.app.pretendo.cc` | + ## S3 server The S3 server is optional, you can set `PN_BOSS_CONFIG_CDN_DISK_PATH` if you want to use a local folder as CDN source instead. @@ -61,7 +63,7 @@ npm run build Configurations are loaded through environment variables. `.env` files are supported. | Environment variable | Description | | -| --------------------------- | ------------------------------------------------------------------------------------------- | -------- | +|-----------------------------|---------------------------------------------------------------------------------------------|----------| | `PN_BOSS_CLI_GRPC_HOST` | The Host that the BOSS GRPC server is on. Example: `localhost:5678` | Required | | `PN_BOSS_CLI_GRPC_APIKEY` | Master API key of the BOSS GRPC server. | Required | | `PN_BOSS_CLI_WIIU_AES_KEY` | The BOSS WiiU AES key, needs to be dumped from a console | Optional | diff --git a/src/config-manager.ts b/src/config-manager.ts index c8e5e23..dc7342f 100644 --- a/src/config-manager.ts +++ b/src/config-manager.ts @@ -45,6 +45,8 @@ export const config = { } }, grpc: { + max_receive_message_length: Number(process.env.PN_BOSS_CONFIG_GRPC_MAX_RECEIVE_MESSAGE_LENGTH_MB?.trim() || '4'), + max_send_message_length: Number(process.env.PN_BOSS_CONFIG_GRPC_MAX_SEND_MESSAGE_LENGTH_MB?.trim() || '4'), boss: { address: process.env.PN_BOSS_CONFIG_GRPC_BOSS_SERVER_ADDRESS?.trim() || '', port: Number(process.env.PN_BOSS_CONFIG_GRPC_BOSS_SERVER_PORT?.trim() || ''), diff --git a/src/services/grpc/server.ts b/src/services/grpc/server.ts index b41b699..0ef5475 100644 --- a/src/services/grpc/server.ts +++ b/src/services/grpc/server.ts @@ -11,7 +11,10 @@ import { config } from '@/config-manager'; import type { Server } from 'nice-grpc'; export async function startGRPCServer(): Promise { - const server: Server = createServer(); + const server: Server = createServer({ + 'grpc.max_receive_message_length': config.grpc.max_receive_message_length * 1024 * 1024, + 'grpc.max_send_message_length': config.grpc.max_send_message_length * 1024 * 1024 + }); server.with(apiKeyMiddlewareV1).with(authenticationMiddlewareV1).add(BossServiceDefinitionV1, bossServiceImplementationV1); server.with(apiKeyMiddlewareV2).with(authenticationMiddlewareV2).add(BossServiceDefinitionV2, bossServiceImplementationV2);