Chunked uploads fail when coming from IPv6 addresses
flleeppyy opened this issue · 2 comments
[2023-04-07 22:50:28] [Error: EINVAL: invalid argument, mkdir 'E:\chensafe uploads\chunks\2600:1008:a000:645d:e024:35d4:7ab2:a1d0_a26bea63-2b
4c-44a2-a03e-00ab1719e2d5'] {
errno: -4071,
code: 'EINVAL',
syscall: 'mkdir',
path: 'E:\\chensafe uploads\\chunks\\2600:1008:a000:645d:e024:35d4:7ab2:a1d0_a26bea63-2b4c-44a2-a03e-00ab1719e2d5'
}
My safe is routed through CloudFlare, and they've recently forced IPv6 to be turned on, so uploads from IPv6 addresses have failed, and IPv6 addresses include colons which are illegal characters in filenames.
I've never deeply looked at the codebase for lolisafe, but we can probably create a temporary variable that acts as a cachemap(?)
lolisafe/controllers/uploadController.js
Line 375 in cf38c8a
i.e
// This is declared somewhere in the controller
const cacheMap = {};
// Inside self.actuallyUpload
const idForCache = crypto.randomUUID().split("-")[0];
cacheMap[idForCache] = req.ip
const uuid = `${idForCache}_${req.body.uuid}`
This probably isn't practical, and I don't know what I'm doing.
I'm thinking of just normalizing the semicolons :
into dashes -
Generating UUIDs for the IPs seem redundant, since the IPs themselves already serve as unique identifications
Internally, we separate IPs from the files' UUIDs via the underscore symbol _
alone, so there should be no conflict there
Or in fact, I don't recall the codes actually having to re-parse the directory path, because IP + file's UUID as a whole is already the only identification needed until the file's chunked uploads have all been finalized (meaning, the client reports to server that all chunks have been uploaded, and should then be finalized)
I'll push a commit with said change in a bit, feel free to test it more thoroughly then
Should be okay with commit 2a8901a
Feel free to comment if there's anything else