use Msg;
use DXVars;
use DXDebug;
+use DXUtil;
+use Net::Telnet qw(TELOPT_ECHO);
use IO::File;
use IO::Socket;
use IPC::Open2;
-use Net::Telnet qw(TELOPT_ECHO);
use Carp qw{cluck};
# cease communications
my $sendz = shift;
if ($conn && $sendz) {
$conn->send_now("Z$call|bye...\n");
+ sleep(1);
}
$stdout->flush if $stdout;
if ($pid) {
dbgclose();
# $SIG{__WARN__} = sub {my $a = shift; cluck($a); };
sleep(1);
+
+ # do we need this ?
+ $conn->disconnect if $conn;
exit(0);
}
$port = 23 if !$port;
# if ($port == 23) {
+
$sock = new Net::Telnet (Timeout => $timeout, Port => $port);
$sock->option_callback(\&optioncb);
$sock->output_record_separator('');
- $sock->option_log('option_log');
- $sock->dump_log('dump');
- $sock->option_accept(Wont => TELOPT_ECHO);
+# $sock->option_log('option_log');
+# $sock->dump_log('dump');
+ $sock->option_accept(Dont => TELOPT_ECHO, Wont => TELOPT_ECHO);
$sock->open($host) or die "Can't connect to $host port $port $!";
# } else {
# $sock = IO::Socket::INET->new(PeerAddr => "$host:$port", Proto => 'tcp')
for (;;) {
if ($csort eq 'telnet') {
$line = $sock->get();
+ cease(11) unless $line; # the socket has gone away?
$line =~ s/\r\n/\n/og;
chomp;
} elsif ($csort eq 'ax25' || $csort eq 'prog') {
$line = <$rfh>;
$line =~ s/\r//og;
}
+ if (length $line == 0) {
+ dbg('connect', "received 0 length line, aborting...");
+ cease(11);
+ }
dbg('connect', "received \"$line\"");
if ($abort && $line =~ /$abort/i) {
dbg('connect', "aborted on /$abort/");
$SIG{'INT'} = \&sig_term;
$SIG{'TERM'} = \&sig_term;
-$SIG{'HUP'} = 'IGNORE';
+$SIG{'HUP'} = \&sig_term;
$SIG{'CHLD'} = \&sig_chld;
$SIG{'ALRM'} = \&timeout;
my $user;
my $s;
+ $connsort = 'telnet' if $connsort eq 'local';
+ setmode();
+
if (-e "$data/issue") {
open(I, "$data/issue") or die;
local $/ = undef;
$stdout->print($issue) if $issue;
}
-
- use DXUser;
-
- DXUser->init($userfn);
-
# allow a login from an existing user. I could create a user but
# I want to check for valid callsigns and I don't have the
# necessary info / regular expression yet
- for ($state = 0; $state < 2; ) {
- alarm($timeout);
+ alarm($timeout);
- if ($state == 0) {
- $stdout->print('login: ');
- $stdout->flush();
- local $\ = $nl;
- $s = $stdin->getline();
- chomp $s;
- $s =~ s/\s+//og;
- $s =~ s/-\d+$//o; # no ssids!
- cease(0) unless $s gt ' ';
- $call = uc $s;
- $user = DXUser->get($call);
- $state = 1;
- } elsif ($state == 1) {
- $stdout->print('password: ');
- $stdout->flush();
- local $\ = $nl;
- $s = $stdin->getline();
- chomp $s;
- $state = 2;
- if (!$user || ($user->passwd && $user->passwd ne $s)) {
- $stdout->print("sorry...$nl");
- cease(0);
- }
- }
- }
+ $stdout->print('login: ');
+ $stdout->flush();
+ local $\ = $mynl;
+ $s = $stdin->getline();
+ chomp $s;
+ $s =~ s/\s+//og;
+ $s =~ s/-\d+$//o; # no ssids!
+ cease(0) unless $s && $s gt ' ';
+ unless (iscallsign($s)) {
+ $stdout->print("Sorry, $s is an invalid callsign");
+ cease(0);
+ }
+ $call = uc $s;
+ alarm(0);
}
# handle callsign and connection type firtling
for (;;) {
my $t;
- Msg->event_loop(1, 0.010);
+ Msg->event_loop(1, 1);
$t = time;
if ($t > $lasttime) {
if ($outqueue) {