-
Notifications
You must be signed in to change notification settings - Fork 0
/
netconnectinfo-srv.pl
executable file
·117 lines (72 loc) · 2.11 KB
/
netconnectinfo-srv.pl
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env perl
use Mojolicious::Lite;
use Mojo::Message::Request;
use Data::Dumper;
my $domain = 'NetConnectInfo.com';
get '/json' => sub {
my $self = shift;
my $ip = get_ip($self);
$self->render(text => "{\"ip\":\"$ip\",\"info\":\"/info\"}" );
};
get '/raw' => sub {
my $self = shift;
my $ip = get_ip($self);
$self->render(text => "$ip" );
};
get '/ip' => sub {
my $self = shift;
my $ip = get_ip($self);
$self->render(text => "<h1>Your IP: $ip</h1> " );
$self->app->log->debug( $self->dumper );
};
get '/dump' => sub {
my $self = shift;
my $ip = $self->tx;
$self->render(text => Dumper( $ip ));
# $self->app->log->debug( $self->dumper );
};
get '/' => sub {
my $self = shift;
my $ip = get_ip($self);
$self->stash(domain => $domain);
$self->render('template1', ip => $ip);
};
get '/info' => sub {
my $self = shift;
$self->stash(domain => $domain);
my $info = "$domain - developed by QuestorSystems.com (c) 2012";
$self->render('template1', ip => $info );
};
# internal rountines
sub get_ip
{
my $self = shift;
$self->req->headers->header('X-Forwarded-For') ||
$self->tx->remote_address;
}
app->start;
__DATA__
@@ template1.html.ep
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-33853128-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type =
'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ?
'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<p style="color: red; text-align: center; font-size: 65px"> <%= $ip %>
</p>
<p>Welcome to <a href="http://<%= $domain %>"><%= $domain %></a> and your external IP address!
</body>
</html>