Merge pull request #19 from MiniBioOne/feature/disable-spr
Some checks failed
Build and Publish Docker Image / build-publish (push) Has been cancelled

feat(spr): Add server-side kill switch.
This commit is contained in:
Jonathan Barrow 2025-03-29 17:36:04 -04:00 committed by GitHub
commit 550e96c4e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 3 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,11 @@ 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 (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,7 +40,6 @@ 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),
@ -87,7 +87,7 @@ function get3DSPolicyList(countryCode: string, majorVersion: string): { PolicyLi
{
TitleId: '0004013000003400',
TaskId: 'sprelay',
Level: 'HIGH',
Level: disabledFeatures.spr ? 'STOPPED' : 'HIGH',
Persistent: true, // TODO - What's this?
Revive: true // TODO - What's this?
}

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;
};
}