-
-
Notifications
You must be signed in to change notification settings - Fork 339
Expand file tree
/
Copy pathStatus.pm
More file actions
29 lines (21 loc) · 687 Bytes
/
Copy pathStatus.pm
File metadata and controls
29 lines (21 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package Nipe::Component::Utils::Status {
use JSON;
use strict;
use warnings;
use HTTP::Tiny;
use Readonly;
Readonly my $SUCCESS_CODE => 200;
our $VERSION = '0.0.5';
sub new {
my $api_check = 'https://check.torproject.org/api/ip';
my $request = HTTP::Tiny -> new(verify_SSL => 1) -> get($api_check);
if ($request -> {status} == $SUCCESS_CODE) {
my $data = decode_json($request -> {content});
my $check_ip = $data -> {'IP'};
my $check_tor = $data -> {'IsTor'} ? 'true' : 'false';
return "\n\r[+] Status: $check_tor \n\r[+] Ip: $check_ip\n\n";
}
return "\n[!] ERROR: sorry, it was not possible to establish a connection to the server.\n\n";
}
}
1;