- if ($conn->{state} eq 'C') {
- &{$conn->{rproc}}($conn, "I$conn->{call}|$msg", $!);
- $! = 0;
- } elsif ($conn->{state} eq 'WL' ) {
- $msg = uc $msg;
- if (is_callsign($msg)) {
- _send_file($conn, "$main::data/connected");
- $conn->{call} = $msg;
- &{$conn->{rproc}}($conn, "A$conn->{call}|telnet");
- $conn->{state} = 'C';
- } else {
- $conn->send_now("Sorry $msg is an invalid callsign");
- $conn->disconnect;
- }
- } elsif ($conn->{state} eq 'WC') {
- if (exists $conn->{cmd} && @{$conn->{cmd}}) {
- $conn->_docmd($msg);
- unless (exists $conn->{cmd} && @{$conn->{cmd}}) {
- $conn->{state} = 'C';
- &{$conn->{rproc}}($conn, "O$conn->{call}|telnet");
- delete $conn->{cmd};
- $conn->{timeout}->del_timer if $conn->{timeout};
+ if ($conn->{csort} eq 'ax25' && exists $conn->{msg}) {
+ $conn->{msg} =~ s/\cM/\cJ/g;
+ }
+ if ($conn->{state} eq 'WC') {
+ if (exists $conn->{cmd}) {
+ if (@{$conn->{cmd}}) {
+ dbg("connect $conn->{cnum}: $conn->{msg}") if isdbg('connect');
+ $conn->_docmd($conn->{msg});
+ }
+ }
+ if ($conn->{state} eq 'WC' && exists $conn->{cmd} && @{$conn->{cmd}} == 0) {
+ $conn->to_connected($conn->{call}, 'O', $conn->{csort});
+ }
+ } elsif ($conn->{msg} =~ /\cJ/) {
+ my @lines = $conn->{msg} =~ /([^\cM\cJ]*)\cM?\cJ/g;
+ if ($conn->{msg} =~ /\cJ$/) {
+ delete $conn->{msg};
+ } else {
+ $conn->{msg} =~ s/([^\cM\cJ]*)\cM?\cJ//g;
+ }
+ while (defined ($msg = shift @lines)) {
+ dbg("connect $conn->{cnum}: $msg") if $conn->{state} ne 'C' && isdbg('connect');
+
+ $msg =~ s/\xff\xfa.*\xff\xf0|\xff[\xf0-\xfe].//g; # remove telnet options
+ $msg =~ s/[\x00-\x08\x0a-\x19\x1b-\x1f\x80-\x9f]/./g; # immutable CSI sequence + control characters
+
+ if ($conn->{state} eq 'C') {
+ &{$conn->{rproc}}($conn, "I$conn->{call}|$msg");
+ } elsif ($conn->{state} eq 'WL' ) {
+ $msg = uc $msg;
+ if (is_callsign($msg)) {
+ my $sort = $conn->{csort};
+ $sort = 'local' if $conn->{peerhost} eq "127.0.0.1";
+ $conn->to_connected($msg, 'A', $sort);
+ } else {
+ $conn->send_now("Sorry $msg is an invalid callsign");
+ $conn->disconnect;
+ }
+ } elsif ($conn->{state} eq 'WC') {
+ if (exists $conn->{cmd} && @{$conn->{cmd}}) {
+ $conn->_docmd($msg);
+ if ($conn->{state} eq 'WC' && exists $conn->{cmd} && @{$conn->{cmd}} == 0) {
+ $conn->to_connected($conn->{call}, 'O', $conn->{csort});
+ }