]> scm.dxcluster.org Git - spider.git/commitdiff
Add HAProxy type 1 "real ip" address changes
authorDirk Koopman <djk@tobit.co.uk>
Sun, 5 Jul 2020 15:21:43 +0000 (16:21 +0100)
committerDirk Koopman <djk@tobit.co.uk>
Sun, 5 Jul 2020 15:21:43 +0000 (16:21 +0100)
Changes
perl/DXUser.pm
perl/ExtMsg.pm

diff --git a/Changes b/Changes
index 8c663a2a9c428f0d79ec773060c849e948c39e52..919971b9de1feb20fea217c1dcb459a0cf47ac73 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,6 @@
 05Jul20=======================================================================
 1. Fix show/dxcc.
+2. Add HAPROXY "real ip" type 1 handling for incoming connections.
 04Jul20=======================================================================
 1. Give console.pl (or dx) a good going over with a bog brush to *finally*
    (cough) make it work correctly with a full 80 column window (and not just
index 642649e844e45567d07557f7a9f8630dbaf43d45..bfc06b75801d34fb22348dd5b0860785175ca174 100644 (file)
@@ -107,7 +107,7 @@ my $json;
                  maxconnect => '1,Max Connections',
                  startt => '0,Start Time,cldatetime',
                  connlist => '1,Connections,parraydifft',
-                 width => '0,Preferred Width'
+                 width => '0,Preferred Width',
                 );
 
 #no strict;
index 44846c53312f12a370b2babd6cd5acd888605c4d..c5d6d85486ff5092ec958e89f4714ded0ae2743b 100644 (file)
@@ -99,7 +99,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';