Merge pull request #74 from preeperkiller/add-stealth-mode
added stealth mode
This commit is contained in:
@@ -147,6 +147,7 @@ There are some additional configuration options you can change, for example the
|
|||||||
| `showGalleryTitle` | Show a title on the gallery page. |
|
| `showGalleryTitle` | Show a title on the gallery page. |
|
||||||
| `allowDownloadAll` | Allow visitors to download all files as a zip. |
|
| `allowDownloadAll` | Allow visitors to download all files as a zip. |
|
||||||
| `showHomePage` | Set to `false` to remove the IPP shield page at `/` and at `/share` |
|
| `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`:
|
For example, to disable the home page at `/` and at `/share` you need to change `showHomePage` to `false`:
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -9,7 +9,8 @@
|
|||||||
"downloadOriginalPhoto": true,
|
"downloadOriginalPhoto": true,
|
||||||
"showGalleryTitle": false,
|
"showGalleryTitle": false,
|
||||||
"allowDownloadAll": false,
|
"allowDownloadAll": false,
|
||||||
"showHomePage": true
|
"showHomePage": true,
|
||||||
|
"stealthMode": false
|
||||||
},
|
},
|
||||||
"lightGallery": {
|
"lightGallery": {
|
||||||
"controls": true,
|
"controls": true,
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ class Immich {
|
|||||||
// Check that the key is a valid format
|
// Check that the key is a valid format
|
||||||
if (!immich.isKey(request.key)) {
|
if (!immich.isKey(request.key)) {
|
||||||
log('Invalid share key ' + request.key)
|
log('Invalid share key ' + request.key)
|
||||||
|
if (getConfigOption('ipp.stealthMode', true)) {
|
||||||
|
res.destroy();
|
||||||
|
}
|
||||||
res.status(404).send()
|
res.status(404).send()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -57,6 +60,9 @@ class Immich {
|
|||||||
const sharedLinkRes = await immich.getShareByKey(request.key, request.password)
|
const sharedLinkRes = await immich.getShareByKey(request.key, request.password)
|
||||||
if (!sharedLinkRes.valid) {
|
if (!sharedLinkRes.valid) {
|
||||||
// This isn't a valid request - check the console for more information
|
// This isn't a valid request - check the console for more information
|
||||||
|
if (getConfigOption('ipp.stealthMode', true)) {
|
||||||
|
res.destroy();
|
||||||
|
}
|
||||||
res.status(404).send()
|
res.status(404).send()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,6 +107,9 @@ app.get('/share/:type(photo|video)/:key/:id/:size?', decodeCookie, async (req, r
|
|||||||
// Check for valid key and ID
|
// Check for valid key and ID
|
||||||
if (!immich.isKey(req.params.key) || !immich.isId(req.params.id)) {
|
if (!immich.isKey(req.params.key) || !immich.isId(req.params.id)) {
|
||||||
log('Invalid key or ID for ' + req.path)
|
log('Invalid key or ID for ' + req.path)
|
||||||
|
if (getConfigOption('ipp.stealthMode', true)) {
|
||||||
|
res.destroy();
|
||||||
|
}
|
||||||
res.status(404).send()
|
res.status(404).send()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -114,6 +117,9 @@ app.get('/share/:type(photo|video)/:key/:id/:size?', decodeCookie, async (req, r
|
|||||||
// Validate the size parameter
|
// Validate the size parameter
|
||||||
if (req.params.size && !Object.values(ImageSize).includes(req.params.size as ImageSize)) {
|
if (req.params.size && !Object.values(ImageSize).includes(req.params.size as ImageSize)) {
|
||||||
log('Invalid size parameter ' + req.path)
|
log('Invalid size parameter ' + req.path)
|
||||||
|
if (getConfigOption('ipp.stealthMode', true)) {
|
||||||
|
res.destroy();
|
||||||
|
}
|
||||||
res.status(404).send()
|
res.status(404).send()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -135,6 +141,9 @@ app.get('/share/:type(photo|video)/:key/:id/:size?', decodeCookie, async (req, r
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log('No asset found for ' + req.path)
|
log('No asset found for ' + req.path)
|
||||||
|
if (getConfigOption('ipp.stealthMode', true)) {
|
||||||
|
res.destroy();
|
||||||
|
}
|
||||||
res.status(404).send()
|
res.status(404).send()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -160,6 +169,9 @@ if (getConfigOption('ipp.showHomePage', true)) {
|
|||||||
*/
|
*/
|
||||||
app.get('*', (req, res) => {
|
app.get('*', (req, res) => {
|
||||||
log('Invalid route ' + req.path)
|
log('Invalid route ' + req.path)
|
||||||
|
if (getConfigOption('ipp.stealthMode', true)) {
|
||||||
|
res.destroy();
|
||||||
|
}
|
||||||
res.status(404).send()
|
res.status(404).send()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ class Render {
|
|||||||
)
|
)
|
||||||
res.end()
|
res.end()
|
||||||
} else {
|
} else {
|
||||||
|
if (getConfigOption('ipp.stealthMode', true)) {
|
||||||
|
res.destroy();
|
||||||
|
}
|
||||||
res.status(404).send()
|
res.status(404).send()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user