animetosho / Nyuu

Flexible usenet binary posting tool
215 stars 30 forks source link

Feature Request: Accept range in `${rand(N)}` #109

Closed Ravencentric closed 11 months ago

Ravencentric commented 11 months ago

Something like ${rand(10,20)}

animetosho commented 11 months ago

What would that do, and why/what is its purpose?

Ravencentric commented 11 months ago

Further obfuscation. Using a fixed digit for all my uploads still means I'm leaving a pattern behind

animetosho commented 11 months ago

Thanks for the explanation. I'm not convinced it makes any difference, and sounds very niche, but if you believe this is valuable, you can assign custom functions in config.js to get the exact behavior you're looking for.

Ravencentric commented 11 months ago

It might be niche but it's another layer of obfuscation and security. Would be highly appreciative if ${rand(N)} functionality gets extended. Currently rand(10) generates a 10-char long random string. I would like it to generate a random string of random length.

animetosho commented 11 months ago

The design of config.js was done for such niche cases - a Javascript function can be written to cater for any scenario you feel is necessary.

Though I had another idea for your specific scenario. You can use the new --token-eval/-E parameter to evaluate Javascript in a parameter instead, e.g. -E --subject '${rand((10+Math.random()*11)|0)}'

Ravencentric commented 11 months ago

So I've been playing with this today and it's almost perfect, very much appreciate it and thank you for considering it :D

So these are my results (I didn't use '${rand((10+Math.random()*11)|0)}' because windows doesn't like |)

nyuu -C nyuu.json -E --from ${rand(Math.floor(Math.random()*(20-10)+10))}@test.abc --log-time --skip-errors all --subdirs keep --subject ${rand(Math.floor(Math.random()*(20-10)+10))} --yenc-name ${rand(Math.floor(Math.random()*(20-10)+10))} --nzb-subject "[{0filenum}/{files}] - "{filename}" yEnc ({part}/{parts}) {filesize}" -g alt.binaries.boneless -o "helck2.nzb" "helck"

The randomizer works perfectly but the -E also means the nzb-subject now doesn't get evaluated and just writes it as is in the nzb file. Reading the help this does seem expected behavior but not ideal. Apologies since I cant provide much in terms of solution due to my lack of proficiency here. image

animetosho commented 11 months ago

-E affects all token fields, so you'll need to adapt --nzb-subject accordingly (needs to be formatted as a template string.

Ravencentric commented 11 months ago

Thank you!