feat(spr): Add server-side kill switch.

This commit is contained in:
MiniBioOne
2025-03-19 15:26:21 +01:00
parent 00ceec5b46
commit 6489084385
3 changed files with 123 additions and 56 deletions

View File

@@ -31,7 +31,8 @@ if (process.env.PN_BOSS_CONFIG_MONGOOSE_CONNECT_OPTIONS_PATH?.trim()) {
}
export const disabledFeatures: DisabledFeatures = {
s3: false
s3: false,
spr: false
};
export const config: Config = {
@@ -78,6 +79,9 @@ export const config: Config = {
secret: process.env.PN_BOSS_CONFIG_S3_ACCESS_SECRET?.trim() || ''
},
disk_path: process.env.PN_BOSS_CONFIG_CDN_DISK_PATH?.trim() || ''
},
spr: {
enabled: process.env.PN_BOSS_CONFIG_STREETPASS_RELAY_ENABLED?.trim().toLowerCase() === 'true'
}
};
@@ -174,6 +178,15 @@ if (!config.cdn.s3.secret) {
disabledFeatures.s3 = true;
}
if (!config.spr.enabled) {
warnings.push('PN_BOSS_CONFIG_STREETPASS_RELAY_ENABLED is not set or disabled. Disabling feature. To enable feature set the PN_BOSS_CONFIG_STREETPASS_RELAY_ENABLED environment variable');
disabledFeatures.spr = true;
}
if (config.spr.enabled) {
disabledFeatures.spr = false;
}
if (disabledFeatures.s3) {
if (!config.cdn.disk_path) {
errors.push('s3 file storage is disabled and no CDN disk path was set. Set the PN_BOSS_CONFIG_CDN_DISK_PATH environment variable');

View File

@@ -2,6 +2,7 @@ import xmlbuilder from 'xmlbuilder';
import moment from 'moment';
import express from 'express';
import subdomain from 'express-subdomain';
import { disabledFeatures } from '@/config-manager';
import type { PolicyList } from '@/types/common/policylist';
const nppl = express.Router();
@@ -39,61 +40,110 @@ function get3DSPolicyList(countryCode: string, majorVersion: string): { PolicyLi
return null;
}
// TODO - Pull this from the DB and use the country code
return {
PolicyList: {
MajorVersion: Number(majorVersion),
MinorVersion: 0,
ListId: 1891,
DefaultStop: false,
ForceVersionUp: false,
UpdateTime: moment().utc().format('YYYY-MM-DDTHH:MM:SS+0000'),
Priority: [
{
TitleId: '0004003000008f02',
TaskId: 'basho0',
Level: 'HIGH',
Persistent: true, // TODO - What's this?
Revive: true // TODO - What's this?
},
{
TitleId: '000400300000bc00',
TaskId: 'OlvNotf',
Level: 'HIGH',
Persistent: true, // TODO - What's this?
Revive: true // TODO - What's this?
},
{
TitleId: '000400300000bd00',
TaskId: 'OlvNotf',
Level: 'HIGH',
Persistent: true, // TODO - What's this?
Revive: true // TODO - What's this?
},
{
TitleId: '000400300000be00',
TaskId: 'OlvNotf',
Level: 'HIGH',
Persistent: true, // TODO - What's this?
Revive: true // TODO - What's this?
},
{
TitleId: '0004003000008f02',
TaskId: 'pl',
Level: 'HIGH',
Persistent: true, // TODO - What's this?
Revive: true // TODO - What's this?
},
{
TitleId: '0004013000003400',
TaskId: 'sprelay',
Level: 'HIGH',
Persistent: true, // TODO - What's this?
Revive: true // TODO - What's this?
}
]
}
};
if (!disabledFeatures.spr) {
return {
PolicyList: {
MajorVersion: Number(majorVersion),
MinorVersion: 0,
ListId: 1891,
DefaultStop: false,
ForceVersionUp: false,
UpdateTime: moment().utc().format('YYYY-MM-DDTHH:MM:SS+0000'),
Priority: [
{
TitleId: '0004003000008f02',
TaskId: 'basho0',
Level: 'HIGH',
Persistent: true, // TODO - What's this?
Revive: true // TODO - What's this?
},
{
TitleId: '000400300000bc00',
TaskId: 'OlvNotf',
Level: 'HIGH',
Persistent: true, // TODO - What's this?
Revive: true // TODO - What's this?
},
{
TitleId: '000400300000bd00',
TaskId: 'OlvNotf',
Level: 'HIGH',
Persistent: true, // TODO - What's this?
Revive: true // TODO - What's this?
},
{
TitleId: '000400300000be00',
TaskId: 'OlvNotf',
Level: 'HIGH',
Persistent: true, // TODO - What's this?
Revive: true // TODO - What's this?
},
{
TitleId: '0004003000008f02',
TaskId: 'pl',
Level: 'HIGH',
Persistent: true, // TODO - What's this?
Revive: true // TODO - What's this?
},
{
TitleId: '0004013000003400',
TaskId: 'sprelay',
Level: 'HIGH',
Persistent: true, // TODO - What's this?
Revive: true // TODO - What's this?
}
]
}
};
} else {
return {
PolicyList: {
MajorVersion: Number(majorVersion),
MinorVersion: 0,
ListId: 1891,
DefaultStop: false,
ForceVersionUp: false,
UpdateTime: moment().utc().format('YYYY-MM-DDTHH:MM:SS+0000'),
Priority: [
{
TitleId: '0004003000008f02',
TaskId: 'basho0',
Level: 'HIGH',
Persistent: true, // TODO - What's this?
Revive: true // TODO - What's this?
},
{
TitleId: '000400300000bc00',
TaskId: 'OlvNotf',
Level: 'HIGH',
Persistent: true, // TODO - What's this?
Revive: true // TODO - What's this?
},
{
TitleId: '000400300000bd00',
TaskId: 'OlvNotf',
Level: 'HIGH',
Persistent: true, // TODO - What's this?
Revive: true // TODO - What's this?
},
{
TitleId: '000400300000be00',
TaskId: 'OlvNotf',
Level: 'HIGH',
Persistent: true, // TODO - What's this?
Revive: true // TODO - What's this?
},
{
TitleId: '0004003000008f02',
TaskId: 'pl',
Level: 'HIGH',
Persistent: true, // TODO - What's this?
Revive: true // TODO - What's this?
}
]
}
};
}
}
function getWiiUPolicyList(countryCode: string, majorVersion: string): { PolicyList: PolicyList } | null {

View File

@@ -2,6 +2,7 @@ import type mongoose from 'mongoose';
export interface DisabledFeatures {
s3: boolean;
spr: boolean;
}
export interface Config {
@@ -49,4 +50,7 @@ export interface Config {
};
disk_path: string;
};
spr: {
enabled: boolean;
};
}