Skip to content

Commit

Permalink
Enhance warnings with compiler flags
Browse files Browse the repository at this point in the history
The use of both "strict" and "warnings" is a well known practice in Perl code
for generating further warnings for common cases where future misbehaviors
may happen. With this patch, every Perl file has both compiler flags enabled.

Alongside the flags enablement, this patch also bring the necessary
modifications to allow the program to run normally.
  • Loading branch information
bmeneg committed Jan 24, 2020
1 parent 43e5f4f commit 210860b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 29 deletions.
3 changes: 2 additions & 1 deletion lib/Nipe/Device.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env perl
use strict;
use warnings;

package Nipe::Device;

Expand Down
7 changes: 3 additions & 4 deletions lib/Nipe/Helper.pm
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env perl
use strict;
use warnings;

package Nipe::Helper;

sub new {
print "
\r\Core Commands
\rCore Commands
\r==============
\r\tCommand Description
\r\t------- -----------
Expand All @@ -18,8 +19,6 @@ sub new {
\r\tstatus See status
\rCopyright (c) 2015 - 2020 | Heitor Gouvêa\n\n";

return true;
}

1;
5 changes: 2 additions & 3 deletions lib/Nipe/Install.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env perl
use strict;
use warnings;

package Nipe::Install;

Expand Down Expand Up @@ -55,8 +56,6 @@ sub new {
else {
print "[.] Refer to our custom Tor config files in project home\n";
}

return true;
}

1;
5 changes: 2 additions & 3 deletions lib/Nipe/Start.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env perl
use strict;
use warnings;

package Nipe::Start;

Expand All @@ -24,8 +25,6 @@ sub new {
callIptables(\%parsed_cfg);
print "[.] Firewall rules set with success\n";
print "[.] Nipe initialized with success\n";

return true;
}

# Due to non-standard ways to call tor throughout Linux distros from start
Expand Down
5 changes: 2 additions & 3 deletions lib/Nipe/Stop.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env perl
use strict;
use warnings;

package Nipe::Stop;

Expand Down Expand Up @@ -28,8 +29,6 @@ sub new {
system ("sudo -u $user rm -f $lock_file > /dev/null");
print "[.] Tor instance with PID=$pid terminated\n";
}

return true;
}

1;
36 changes: 21 additions & 15 deletions nipe.pl
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#!/usr/bin/env perl

use strict;
use warnings;
use 5.018;
use Switch;

use lib "./lib/";

use Switch;
use Nipe::Stop;
use Nipe::Start;
use Nipe::Status;
Expand All @@ -20,11 +24,11 @@ sub main {
case "start" {
my $custom_cfg = undef;

if ($ARGV[1] eq "-c") {
if (length($ARGV[2]) <= 0) {
if (defined($ARGV[1]) and $ARGV[1] eq "-c") {
if (!defined($ARGV[2])) {
print "[!] Invalid argument\n";
Nipe::Helper -> new();
exit;
exit 1;
}

$custom_cfg = $ARGV[2];
Expand All @@ -42,19 +46,21 @@ sub main {
my $force_cfg = undef;
my $custom_cfg = undef;

if ($ARGV[1] eq "-f") {
$force_cfg = 1;
}

elsif ($ARGV[1] eq "-c") {
if (length($ARGV[2]) <= 0) {
print "[!] Invalid argument\n";
Nipe::Helper -> new();
exit;
if (defined($ARGV[1])) {
if ($ARGV[1] eq "-f") {
$force_cfg = 1;
}

$force_cfg = 1;
$custom_cfg = $ARGV[2];
elsif ($ARGV[1] eq "-c") {
if (!defined($ARGV[2])) {
print "[!] Invalid argument\n";
Nipe::Helper -> new();
exit 1;
}

$force_cfg = 1;
$custom_cfg = $ARGV[2];
}
}

Nipe::Install -> new($force_cfg, $custom_cfg);
Expand Down

0 comments on commit 210860b

Please sign in to comment.