mhddos_proxy
mhddos_proxy copied to clipboard
Application config file
Application config file overriding defaults
Kindly suggest to consider including application-wide config file. Number of command-line options has inclreased, and personally for me it's more comfortable to handle them as file.
Application config is usually located in the user home directory, full name $HOME/.mhddos.json
.
If present, the config overrides command-line defaults, but itself is overwritten by command-line params.
If does not exist, it does not affect application whatsowever.
For example, if our app config looks like
{
"itarmy": true,
"lang": "UA",
"threads": 2000
}
but if we call the runner with the keys
python3 runner.py --itarmy --table --http-methods GET STRESS --threads 4000
,
command-line param --threads
overrides config, and we start with 4000 threads.
New command-line option --save-config
is introduced.
If the user adds it in the command line (usually in the first run),
the config file would be created with exactly the same parameters user launched the application with.
After that user may remove unnecessary options, and leave with some meaningful defaults,
for example, the one I mentioned above.
Implementation considerations
JSON format has been chosen, because it's native to Python argparse
module.
We can easily convert command line params into Python dictionary (and serialize in JSON)
args_dict = vars(args)
...and with the same ease, we can load JSON right into parsed arguments
defaults_config = read_config()
parser.set_defaults(**defaults_config)
Instruction in README on how to increase number of threads
As I also faced problem of system limitations on Mac, I added a point in README on how to lift these limitations