pushing code style fixing

This commit is contained in:
htrgouvea 2022-07-04 19:21:59 -03:00
commit 372ee894f1
8 changed files with 18 additions and 31 deletions

View File

@ -14,9 +14,7 @@ Log notice file /var/log/tor/log
ClientOnly 1
TransPort 9051
TransListenAddress 127.0.0.1
DNSPort 9061
DNSListenAddress 127.0.0.1
VirtualAddrNetwork 10.66.0.0/255.255.0.0
AutomapHostsOnResolve 1

View File

@ -14,9 +14,7 @@ Log notice file /var/log/tor/log
ClientOnly 1
TransPort 9051
TransListenAddress 127.0.0.1
DNSPort 9061
DNSListenAddress 127.0.0.1
VirtualAddrNetwork 10.66.0.0/255.255.0.0
AutomapHostsOnResolve 1

View File

@ -14,9 +14,7 @@ Log notice file /var/log/tor/log
ClientOnly 1
TransPort 9051
TransListenAddress 127.0.0.1
DNSPort 9061
DNSListenAddress 127.0.0.1
VirtualAddrNetwork 10.66.0.0/255.255.0.0
AutomapHostsOnResolve 1

View File

@ -2,9 +2,9 @@
## Branches
The `master` branch is used only for holding released code of the project. Any
The `main` branch is used only for holding released code of the project. Any
new feature or bugfix **must** be opened against `develop` branch, where some
additional testing is performed before the code lands `master`.
additional testing is performed before the code lands `main`.
## Testing
@ -25,4 +25,4 @@ the project.
## License
By opening a pull request in this repository, you agree to provide your work
under the [project license](../LICENSE.md).
under the [project license](../LICENSE.md).

View File

@ -6,7 +6,7 @@
<img src="https://img.shields.io/badge/license-MIT-blue.svg">
</a>
<a href="https://github.com/htrgouvea/nipe/releases">
<img src="https://img.shields.io/badge/version-0.9.5-blue.svg">
<img src="https://img.shields.io/badge/version-0.9.6-blue.svg">
</a>
</p>
</p>
@ -70,6 +70,8 @@ All non-local UDP/ICMP traffic is also blocked by the Tor project.
- Your contributions and suggestions are heartily ♥ welcome. [See here the contribution guidelines.](/.github/CONTRIBUTING.md) Please, report bugs via [issues page](https://github.com/htrgouvea/nipe/issues) and for security issues, see here the [security policy.](/SECURITY.md) (✿ ◕‿◕) This project follows the best practices defined by this [style guide](https://heitorgouvea.me/projects/perl-style-guide).
- If you are interested in providing financial support to this project, please visit: [heitorgouvea.me/donate](https://heitorgouvea.me/donate)
---
### License

View File

@ -3,23 +3,12 @@ package Nipe::Engine::Start {
use warnings;
use Nipe::Utils::Device;
sub get_subnets {
my @nets = `ip a s` =~ /inet +(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\d+)/ig;
return @nets if @nets > 0;
while (`ifconfig` =~ /inet +([^ ]+) +netmask +([^ ]+)/ig) {
my ($ip, $mask) = ($1, $2);
my $bin = join '', map { sprintf "%b", $_ } split /\./, $mask;
$mask = length($bin =~ s/0+$//r);
push @nets, "$ip/$mask";
}
@nets
}
sub new {
my %device = Nipe::Utils::Device -> new();
my $dnsPort = "9061";
my $transferPort = "9051";
my @table = ("nat", "filter");
my $network = "10.66.0.0/255.255.0.0";
my $startTor = "systemctl start tor";
if ($device{distribution} eq "void") {
@ -33,8 +22,6 @@ package Nipe::Engine::Start {
system ("tor -f .configs/$device{distribution}-torrc > /dev/null");
system ($startTor);
my @subnets = get_subnets();
foreach my $table (@table) {
my $target = "ACCEPT";
@ -60,11 +47,16 @@ package Nipe::Engine::Start {
$target = "REDIRECT --to-ports $transferPort";
}
system ("iptables -t $table -A OUTPUT -d $network -p tcp -j $target");
if ($table eq "nat") {
$target = "RETURN";
}
system ("iptables -t $table -A OUTPUT -d $_ -j $target") for @subnets;
system ("iptables -t $table -A OUTPUT -d 127.0.0.1/8 -j $target");
system ("iptables -t $table -A OUTPUT -d 192.168.0.0/16 -j $target");
system ("iptables -t $table -A OUTPUT -d 172.16.0.0/12 -j $target");
system ("iptables -t $table -A OUTPUT -d 10.0.0.0/8 -j $target");
if ($table eq "nat") {
$target = "REDIRECT --to-ports $transferPort";
@ -73,10 +65,10 @@ package Nipe::Engine::Start {
system ("iptables -t $table -A OUTPUT -p tcp -j $target");
}
system ("iptables -t filter -A OUTPUT -p udp -j REJECT");
system ("iptables -t filter -A OUTPUT -p icmp -j REJECT");
system ("iptables -t filter -A OUTPUT -p udp -j REJECT");
system ("iptables -t filter -A OUTPUT -p icmp -j REJECT");
# disable IPv6
# disable IPv6
system("sysctl -w net.ipv6.conf.all.disable_ipv6=1 >/dev/null");
system("sysctl -w net.ipv6.conf.default.disable_ipv6=1 >/dev/null");

View File

@ -12,7 +12,7 @@ package Nipe::Utils::Status {
my $data = decode_json ($request -> {content});
my $checkIp = $data -> {"IP"};
my $checkTor = $data -> {"IsTor"} ? "activated" : "disabled";
my $checkTor = $data -> {"IsTor"} ? "true" : "false";
return "\n\r[+] Status: $checkTor. \n\r[+] Ip: $checkIp\n\n";
}

View File

@ -45,5 +45,4 @@ sub main {
return print Nipe::Utils::Helper -> new();
}
main();
exit;
exit main();