Hi,

I noticed that Net::XMPP doesn't have support for SRV records (as it
is explained in rt.cpan.org). I have put together a patch that I hope
fixes the problem. I have tested that at least my pet application
connects correctly to gmail.com server.

Can you review it and apply it?

Thanks
Pablo


-- 
"When in doubt, use brute force" -- Ken Thompson
--- /usr/share/perl5/Net/XMPP/Connection.pm     2004-08-18 14:21:23.000000000 
+0100
+++ Connection.pm       2006-08-28 15:24:44.882378576 +0100
@@ -127,6 +127,21 @@
 
     while($#_ >= 0) { $self->{SERVER}{ lc pop(@_) } = pop(@_); }
 
+    use Net::DNS qw(rrsort);
+    my $res   = Net::DNS::Resolver->new;
+    my $query = $res->query("_xmpp-client._tcp." . 
$self->{SERVER}->{hostname}, "SRV");
+
+    if ($query) {
+      foreach my $rr ($query->answer) {
+       #printf "DEBUG::: RR %s:%s %d %d\n", 
$rr->target,$rr->port,$rr->priority,$rr->weight;
+       #my @prioritysorted = rrsort("SRV","priority", $query->answer);
+       $self->{SERVER}->{realserver} = ($query->answer)[0]->target;
+       $self->{SERVER}->{port} = ($query->answer)[0]->port;
+      }
+    } else {
+      warn "DEBUG ::: query failed: ", $res->errorstring, "\n";
+    }
+
     $self->{SERVER}->{timeout} = 10 unless exists($self->{SERVER}->{timeout});
 
     $self->{DEBUG}->Log1("Connect: 
host($self->{SERVER}->{hostname}:$self->{SERVER}->{port}) 
namespace($self->{SERVER}->{namespace})");
@@ -135,7 +150,8 @@
     delete($self->{SESSION});
     $self->{SESSION} =
         $self->{STREAM}->
-            Connect(hostname       => $self->{SERVER}->{hostname},
+            Connect(hostname       => $self->{SERVER}->{realserver},
+                   to             => $self->{SERVER}->{hostname},
                     port           => $self->{SERVER}->{port},
                     namespace      => $self->{SERVER}->{namespace},
                     connectiontype => $self->{SERVER}->{connectiontype},

Reply via email to