Add custom character limit to pastes#196
Conversation
66dd581 to
3f900d5
Compare
mtlynch
left a comment
There was a problem hiding this comment.
Cool, thanks for adding this! I just have a small note.
| true, "whether to display usage information on homepage") | ||
| perMinuteLimit := flag.Int("perminutelimit", | ||
| 0, "number of pastes to allow per IP per minute (set to 0 to disable rate limiting)") | ||
| maxCharLimit := flag.Int64("maxsize", 2, "max file size as MiB") |
There was a problem hiding this comment.
Can we reword this to "max files size in MiB"?
And can we change the var name to maxPasteMiB? It's a little confusing to call it maxCharLimit at the point that it represents the MiB limit rather than the character limit.
The conversion from MiB to characters should be the same time we rename it like:
const charactersPerMiB = 1024 * 1024
maxCharLimit := *maxPasteMiB * charactersPerMiBThere was a problem hiding this comment.
Sounds good! For the other files, paste.go and server.go, is maxCharLimit fine in there or should I rename those too?
There was a problem hiding this comment.
Yeah, I think main.go is the only file that should deal in terms of max MiB. main.go should convert it to characters, and then the rest of the code deals in terms of max characters.
There was a problem hiding this comment.
Oh, can we also document the new flag in the README?
There was a problem hiding this comment.
Definitely, I'll be a little busy this weekend but hopefully I'll get those fixed by tomorrow evening!
There was a problem hiding this comment.
Just pushed the changes!
There was a problem hiding this comment.
Thanks, can you document the new flag in the README as well?
Also, can you avoid force-pushing? It makes it hard to review version-to-version changes. The last change you made is probably pretty small, but the only way to see it is mixed in with the single commit of all the changes.
There was a problem hiding this comment.
I'll go ahead and add to the README. Sorry about force pushing, I'm just used to squashing by default.
Some pastebins might wish to have an arbitrary character limit, so this aims to add that with a CLI flag.
3f900d5 to
11548df
Compare
|
No problem! Sorry about the errors, it's been a long weekend haha |
Background
Recently I've been looking at alternatives to the service 0x0.st for pasting log files to. Logpaste seems like the perfect replacement, but it has limits on file size. Adding the ability for administrators to add custom file sizes would allow admins to make the file size the equivalent of 0x0's (512 MiB) or even larger. It would also allow them to set smaller limits as well if resources are limited or if the content being pasted doesn't warrant large sizes.
Changes
2 * 1024 * 1024, or 2 MiB instead of2 * 1000 * 1000, 2 MB-maxsize intto allow admins to set an arbitrary limit on paste file sizes if they would like to-maxsize 512, or for the default 2MiB,-maxsize 2)maxCharLimitto thedefaultServerstruct for storing the given sizehandlers/paste_test.goto use the new struct field in order for tests to passMaxPasteCharacterswiths.maxCharLimit