File: adc-redirector

package info (click to toggle)
uhub 0.4.1-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,420 kB
  • ctags: 2,241
  • sloc: ansic: 18,124; xml: 575; perl: 568; sh: 368; makefile: 24
file content (48 lines) | stat: -rwxr-xr-x 887 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/perl -w

# Setup using inetd/xinetd or similar.
# In /etc/inetd.conf add:
# 1511  stream  tcp nowait nobody  /usr/bin/adc-redirector adc://target:port
#
# Change port to whatever you want.
# Make sure the path and the target:port is correct, then you should be good 
# to go!

use strict;
use IO::Handle;
autoflush STDIN;
autoflush STDOUT;

my $target = $ARGV[0];

eval
{
	local %SIG;
	$SIG{ALRM}= sub { exit 0; };
        alarm 30;
};

while (my $line = <STDIN>)
{
	chomp($line);

	if ($line =~ /^HSUP /)
	{
		print "ISUP ADBASE ADPING ADTIGR\n";
		print "ISID AAAX\n";
		print "IINF CT32 NIRedirector VEadc-redirector/0.1\n";
		next;
	}

	if ($line =~ /^BINF /)
	{
		print "$line\n";
		print "IMSG This\\sserver\\shas\\smoved\\sto:\\s" . $target . "\n";
		print "IMSG You\\sare\\sbeing\\sredirected...\n";
		print "IQUI AAAX RD" . $target . "\n";
		alarm 5;
	}
}

alarm 0;