Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
GouveaHeitor committed Apr 21, 2017
1 parent 093e328 commit dfccdf2
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 26 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Nipe

[![MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/GouveaHeitor/nipe/blob/master/LICENSE.md)
[![Codewake](https://www.codewake.com/badges/ask_question.svg)](https://www.codewake.com/p/nipe)
[![Version-Program](https://img.shields.io/badge/version-1.0-blue.svg)](https://github.com/GouveaHeitor/nipe/releases)

![Imagem](http://i.imgur.com/1XjfHPb.png)
Expand Down
12 changes: 6 additions & 6 deletions lib/Nipe/CheckIp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ sub new {
my $checkTor = $data -> {'IsTor'};

if ($checkTor) {
print "
\r\033[1;32m[+]\033[1;37m Nipe: Activated
\r\033[1;32m[+]\033[1;37m Ip: $checkIp\n\n";
$checkTor = "activated";
}

else {
print "
\r\033[1;32m[+]\033[1;37m Nipe: Disabled
\r\033[1;32m[+]\033[1;37m Ip: $checkIp\n\n";
$checkTor = "disabled";
}

print "
\r\033[1;32m[+]\033[1;37m Status: $checkTor
\r\033[1;32m[+]\033[1;37m Ip: $checkIp\n\n";
}

else {
Expand Down
26 changes: 26 additions & 0 deletions lib/Nipe/Device.pm
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,30 @@ sub getUsername {
return $username;
}

sub getSystem {
my $mySystem;

if ($operationalSystem =~ /[U,u]buntu/) {
$mySystem = "debian";
}

elsif ($operationalSystem =~ /[D,d]ebian/) {
$mySystem = "debian";
}

elsif ($operationalSystem =~ /[F,f]edora/) {
$mySystem = "fedora";
}

elsif ($operationalSystem =~ /[A,a]rch/) {
$mySystem = "arch";
}

else {
$mySystem = "debian";
}

return $mySystem;
}

1;
10 changes: 4 additions & 6 deletions lib/Nipe/Functions.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,17 @@ sub help {
}

sub install {
my $operationalSystem = `cat /etc/os-release | grep 'ID_LIKE' | cut -d '=' -f 2`;
my $operationalSystem = Nipe::Device -> getSystem();

chomp ($operationalSystem);

if (($operationalSystem =~ /[U,u]buntu/) || ($operationalSystem =~ /[D,d]ebian/)) {
if ($operationalSystem == "debian") {
system ("sudo apt-get install tor iptables");
}

elsif ($operationalSystem =~ /[A,a]rch/) {
elsif ($operationalSystem == "arch") {
system ("sudo pacman -S tor iptables");
}

elsif ($operationalSystem =~ /[F,f]edora/) {
elsif ($operationalSystem == "fedora") {
system ("sudo dnf install tor iptables");
}

Expand Down
3 changes: 0 additions & 3 deletions lib/Nipe/Start.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package Nipe::Start;

use Nipe::Device;
use Nipe::CheckIp;

sub new {
my $dnsPort = "9061";
Expand Down Expand Up @@ -72,8 +71,6 @@ sub new {

system ("sudo iptables -t filter -A OUTPUT -p udp -j REJECT");
system ("sudo iptables -t filter -A OUTPUT -p icmp -j REJECT");

Nipe::CheckIp -> new();
}

1;
4 changes: 0 additions & 4 deletions lib/Nipe/Stop.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@

package Nipe::Stop;

use Nipe::CheckIp;

sub new {
my @table = ("nat", "filter");

foreach my $table (@table) {
system ("sudo iptables -t $table -F OUTPUT");
system ("sudo iptables -t $table -F OUTPUT");
}

Nipe::CheckIp -> new();
}

1;
31 changes: 25 additions & 6 deletions nipe.pl
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,31 @@ sub main {
my $command = $ARGV[0];

switch ($command) {
case "help" { Nipe::Functions -> help(); }
case "stop" { Nipe::Stop -> new(); }
case "start" { Nipe::Start -> new(); }
case "status" { Nipe::CheckIp -> new(); }
case "install" { Nipe::Functions -> install(); }
else { Nipe::Functions -> help(); }
case "help" {
Nipe::Functions -> help();
}

case "stop" {
Nipe::Stop -> new();
Nipe::CheckIp -> new();
}

case "start" {
Nipe::Start -> new();
Nipe::CheckIp -> new();
}

case "status" {
Nipe::CheckIp -> new();
}

case "install" {
Nipe::Functions -> install();
}

else {
Nipe::Functions -> help();
}
}
}

Expand Down

0 comments on commit dfccdf2

Please sign in to comment.