summaryrefslogtreecommitdiffstats
path: root/httpd/cgi-bin/traceroute
blob: 190f084fd06d3af2fb1cfd241534ab02edd7d9eb (plain)
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
#!/usr/local/bin/perl
#
# traceroute: a CGI script that provides a Web interface to traceroute
#
# Copyright 1998 Gerald Oskoboiny <gerald@w3.org>
#
# This source code is available under the license at:
#     http://www.w3.org/Consortium/Legal/copyright-software
#
# $Id: traceroute,v 1.2 1998-08-12 22:12:45 gerald Exp $

$| = 1;

# accept either traceroute/foo or traceroute?foo; default to REMOTE_ADDR
# if nothing else is specified
$addr = $ENV{PATH_INFO} || $ENV{QUERY_STRING} || $ENV{REMOTE_ADDR};

$addr =~ tr/+/ /;
$addr =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$addr =~ s,^addr=,,;
$addr =~ s/[^A-Za-z0-9\.-]//g;		# for security

print <<"EOF";
Content-Type: text/html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>

<head>
  <title>Traceroute from validator.w3.org to $addr</title>
  <link rev="made" href="mailto:gerald\@w3.org">
</head>

<body bgcolor="#FFFFFF" text="#000000" link="#0000ee" vlink="#551a8b">

<p>
  Here is the result of a traceroute from <code>validator.w3.org</code>
  to <code>$addr</code>:
</p>

<form action="/traceroute">
  <input type=text name=addr size=40 value="$addr">
  <input type=submit value="Traceroute">
  <input type=reset>
</form>

<pre>
EOF

open( TRACEROUTE, "/usr/sbin/traceroute $addr | " ) ||
    die "couldn't open pipe to traceroute! $!";

while (<TRACEROUTE>) {
    chomp;
    s/\&/\&amp;/g;
    s/\</\&lt;/g;
    print "$_\n";
}
close( TRACEROUTE ) || die "couldn't close pipe to traceroute! $!";

print <<"EOF";
</pre>

<hr>
<address>
<a href="http://www.w3.org/People/Gerald/">Gerald Oskoboiny</a><br>
\$Date: 1998-08-12 22:12:45 $ \
</address>

EOF

exit;