diff --git a/README.md b/README.md index af9227b..9eb7940 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,7 @@ There are some additional configuration options you can change, for example the | `showGalleryTitle` | Show a title on the gallery page. | | `allowDownloadAll` | Allow visitors to download all files as a zip. | | `showHomePage` | Set to `false` to remove the IPP shield page at `/` and at `/share` | +| `stealthMode` | Set to `true` to stop IPP from responding to malformed or unauthenticated requests. | For example, to disable the home page at `/` and at `/share` you need to change `showHomePage` to `false`: diff --git a/app/config.json b/app/config.json index 900ec3f..4bde1f3 100644 --- a/app/config.json +++ b/app/config.json @@ -9,7 +9,8 @@ "downloadOriginalPhoto": true, "showGalleryTitle": false, "allowDownloadAll": false, - "showHomePage": true + "showHomePage": true, + "stealthMode": false }, "lightGallery": { "controls": true, diff --git a/app/src/immich.ts b/app/src/immich.ts index c8d21bb..b0e259a 100644 --- a/app/src/immich.ts +++ b/app/src/immich.ts @@ -49,6 +49,9 @@ class Immich { // Check that the key is a valid format if (!immich.isKey(request.key)) { log('Invalid share key ' + request.key) + if (getConfigOption('ipp.stealthMode', true)) { + res.destroy(); + } res.status(404).send() return } @@ -57,6 +60,9 @@ class Immich { const sharedLinkRes = await immich.getShareByKey(request.key, request.password) if (!sharedLinkRes.valid) { // This isn't a valid request - check the console for more information + if (getConfigOption('ipp.stealthMode', true)) { + res.destroy(); + } res.status(404).send() return } diff --git a/app/src/index.ts b/app/src/index.ts index 7c566c4..58dea91 100644 --- a/app/src/index.ts +++ b/app/src/index.ts @@ -107,6 +107,9 @@ app.get('/share/:type(photo|video)/:key/:id/:size?', decodeCookie, async (req, r // Check for valid key and ID if (!immich.isKey(req.params.key) || !immich.isId(req.params.id)) { log('Invalid key or ID for ' + req.path) + if (getConfigOption('ipp.stealthMode', true)) { + res.destroy(); + } res.status(404).send() return } @@ -114,6 +117,9 @@ app.get('/share/:type(photo|video)/:key/:id/:size?', decodeCookie, async (req, r // Validate the size parameter if (req.params.size && !Object.values(ImageSize).includes(req.params.size as ImageSize)) { log('Invalid size parameter ' + req.path) + if (getConfigOption('ipp.stealthMode', true)) { + res.destroy(); + } res.status(404).send() return } @@ -135,6 +141,9 @@ app.get('/share/:type(photo|video)/:key/:id/:size?', decodeCookie, async (req, r } } else { log('No asset found for ' + req.path) + if (getConfigOption('ipp.stealthMode', true)) { + res.destroy(); + } res.status(404).send() } }) @@ -160,6 +169,9 @@ if (getConfigOption('ipp.showHomePage', true)) { */ app.get('*', (req, res) => { log('Invalid route ' + req.path) + if (getConfigOption('ipp.stealthMode', true)) { + res.destroy(); + } res.status(404).send() }) diff --git a/app/src/render.ts b/app/src/render.ts index eb64805..bac7903 100644 --- a/app/src/render.ts +++ b/app/src/render.ts @@ -74,6 +74,9 @@ class Render { ) res.end() } else { + if (getConfigOption('ipp.stealthMode', true)) { + res.destroy(); + } res.status(404).send() } }