X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FExtMsg.pm;h=74a2cfcd0dc8ea0c18956b005574899930ad91f2;hb=a24cc09d8262093df92c767d3010c0a5fd6e42d7;hp=44846c53312f12a370b2babd6cd5acd888605c4d;hpb=fb131e2b2e5ba8f3481e2f78ce224dadf8ba8f43;p=spider.git diff --git a/perl/ExtMsg.pm b/perl/ExtMsg.pm index 44846c53..74a2cfcd 100644 --- a/perl/ExtMsg.pm +++ b/perl/ExtMsg.pm @@ -19,6 +19,8 @@ use Msg; use DXVars; use DXUtil; use DXDebug; +use DXTimer; + use IO::File; use IO::Socket; use IPC::Open3; @@ -64,6 +66,24 @@ sub echo $conn->{echo} = shift; } +sub _rcv +{ + my $conn = shift; # $rcv_now complement of $flush + my $msg = shift; + my $sock = $conn->{sock}; + return unless defined($sock); + return if $conn->{disconnecting}; + + if ($conn->{state} eq 'WL' && $conn->{sort} =~ /^I/ && $msg =~ /^PROXY/) { + my $echo = $conn->{echo}; + $conn->{echo} = 0; + $conn->SUPER::_rcv($msg); + $conn->{echo} = $echo; + } else { + $conn->SUPER::_rcv($msg); + } +} + sub dequeue { my $conn = shift; @@ -89,6 +109,8 @@ sub dequeue } else { $conn->{msg} =~ s/([^\cM\cJ]*)\cM?\cJ//g; } + $conn->{linesin} += @lines; + $Msg::total_lines_in += @lines; while (defined ($msg = shift @lines)) { dbg("connect $conn->{cnum}: $msg") if $conn->{state} ne 'C' && isdbg('connect'); @@ -99,7 +121,19 @@ sub dequeue &{$conn->{rproc}}($conn, "I$conn->{call}|$msg"); } elsif ($conn->{state} eq 'WL' ) { $msg = uc $msg; - if (is_callsign($msg)) { + if ($conn->{sort} =~ /^I/ && (my ($ip, $from) = $msg =~ /^PROXY TCP[46] ([\da-fA-F:\.]+) ([\da-fA-F:\.]+)/) ) { + # SOMEONE appears to have affixed an HA Proxy to my connection + $ip =~ s|^::ffff:||; # chop off leading pseudo IPV6 stuff on dual stack listeners + $from =~ s|^::ffff:||; + if ($from eq $conn->{peerhost}) { + dbg("ExtMsg: connect - PROXY IP change from '$conn->{peerhost}' -> '$ip'"); + $conn->{peerhost} = $ip; + } else { + dbg("ExtMsg: connect - PROXY someone ($from) is trying to spoof '$ip'"); + $conn->send_now("Sorry $msg is an invalid callsign"); + $conn->disconnect; + } + } elsif (is_callsign($msg)) { if ($main::allowslashcall || $msg !~ m|/|) { my $sort = $conn->{csort}; $sort = 'local' if $conn->{peerhost} =~ /127\.\d+\.\d+\.\d+$/ || $conn->{peerhost} eq '::1'; @@ -170,7 +204,7 @@ sub new_client { $conn->_send_file(localdata("issue")); $conn->send_raw("login: "); $conn->_dotimeout(60); - $conn->{echo} = 1; +# $conn->{echo} = 1; } sub start_connect @@ -270,7 +304,7 @@ sub _dotimeout dbg("connect $conn->{cnum}: timeout set to $val") if isdbg('connect'); $conn->{timeout}->del if $conn->{timeout}; $conn->{timeval} = $val; - $conn->{timeout} = Timer->new($val, sub{ &_timedout($conn) }); + $conn->{timeout} = DXTimer->new($val, sub{ &_timedout($conn) }); } sub _dolineend