Hi,

first of all thanks a lot for your replay.

I will certainly try to fix my work. Especially regarding the parts that are 
easily done.
However so far I am not 100% certain how to implement two of your suggestions 
(see below). I'll have to do some research regarding them.

Sorry about the style. (I could hit myself. I meant to check that before 
sending it but I forgot. (Might be that I was a little too eager to submit 
it...))

So here is a commented copy of the ToDo list I deduced from your mail. I 
already did some parts.
The parts I haven't done yet and/or where I am unsure how to do them are at 
the end.

Additionally I have attached a copy of the code I have so far.


Cheers,
    Cryptkiddy




###TODO:##############


#Fix style - (done)

#Check use of Memoize or other - (done)
#       (also consider setting global variable to compute it only once)  - 
(done)

    I used 'use feature "state" ' and made the $routerPort static. If the 
function was called before now it simply returns the old value.

    use feature "state";    #(l. 4)
    state $routerPort = 0;      #(ll. 12 ff)
    if($routerPort) {
    # If we found the Port before there should be no need to recheck it.
        return $routerPort;
    }



#Indirect filehandle - (done)
#three arguments open -(done)

    if(! open($conffile, "<", "/etc/i2p/clients.config")) {     #(l. 23)


#Replace $string by $line - (done)

#put $I2pDefPort in variable for easier change - (done)

    my $I2pDefaultPort = 7657;          #(line 20)


#   only one line for "return $routerPort" check - (done)

        #(ll. 57 ff)
        if (($routerPort) = ($line =~ m/$regex/)) {
            return $routerPort;
        }


# fix 2. RegEx - (done)
#   wrongly escaped chars - (done)
#   regarding last part always being " ./webapps/" -(done)
#               ->need to check whether there is optional whitespace behind 
"./webapps/" in i2pConf - (done)

    my $regex = '^clientApp\.' . $ClientAppNo . '\.args=([0-9]{1,5})\ [0-9s:,. 
\-]+ \.\/webapps\/[\s]*$';

################NOT DONE YET###################################

#get rid of ugly namespace - (ask whether solution is OK)
#   (probably easiest to just use "return $defPort;" multiple times - 
shouldn't be too much code repetition) - (done?)
#   (is errorhandlig with GoTo better??)

    I inlined the errorhandling (I hope that is alright?) as e.g. in (ll. 23 
ff):

        if(! open($conffile, "<", "/etc/i2p/clients.config")) { 
            warn "Can not open i2p config file '/etc/i2p/client.config'.".
            " Using default port ". $I2pDefaultPort." for I2P webinterface 
instead.";
            return $I2pDefaultPort;
        }



#change code around "$ClientAppNo = -1" - ()
#   unsure how to (maybe check whole file at once and include "\n" in regex?)
                        ->should then do the same for the other regex (might 
even turn out to be faster)






#Doublecheck style before submit - ()
#       +check variable naming scheme - ()
#Doublecheck ToDos before submit - ()
#Test in TAILS whether it works - ()

Attachment: i2p_starter_v02
Description: Perl program

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
tails-dev mailing list
[email protected]
https://boum.org/mailman/listinfo/tails-dev

Reply via email to