Open ggondim opened 6 years ago
I've been thinking about how to do it, and have imagined something like this:
CLI Design:
nodes [-f or --file FILE]
: Will be the subcommand to the original nipe
root command, been responsible for holding all the operations related to the exit nodes' configuration. The optional flag --file
can be specified and will be passed to any subcommand, using the default value to /etc/tor/torrc
and will be referred further on simply as $FILE
.
nodes list
: A simple list command, listing in a human-readable way all the exit nodes already configured inside the $FILE
.
nodes add [--validate or -v] {ExitNodes...}
: Receiving a variable amount of exit node's codes, this command will concatenate these given nodes to the already existing inside the $FILE
, and validate against a list of the valid node codes present locally, in an in-memory dictionary, following this source and them print the same output as the list
command.
OBS.: If you guys know a better source of this list, please, this is just a proposal.
nodes rm [--validate or -v] {ExitNodes...}
: The same idea behind the add
command, but this will remove the given nodes.
Implementation:
My first idea was to separately write two functions that will be responsible for handling read and write operations upon the configuration file of the Tor service, named as $FILE
, inside our Nipe::Functions
module since this can be reused in the rest of the application. Then with this function, written and tested, I'll create the new Nipe::Nodes
module, with two more specific functions using this recently created function, one of them will be responsible for reading all the exit nodes inside the $FILE
, and return them in a list of strings, using the exit node's code. The other function will receive a list of strings with the exit node's code, and then write this to the $FILE
. And at the end, write another function to handle the transformation of a list of strings containing the node codes to a human-readable output in the STDOUT
of the process. With this module written and tested, move to the nipe.pl
file, which today handles all the CLI operations, and implement the specified design above.
* To write tests to this functions, I'll use only pure Perl. Test framework suggestions are more than welcome from you Monks :sparkling_heart:
Also, it would be nice to have a command to reconfigure exit nodes countries list.
https://pt.wikihow.com/Definir-um-Pa%C3%ADs-Espec%C3%ADfico-no-Navegador-de-Internet-Tor