Skip Menu |

This queue is for tickets about the AnyEvent-XMPP CPAN distribution.

Report information
The Basics
Id: 42808
Status: resolved
Priority: 0/
Queue: AnyEvent-XMPP

People
Owner: elmex [...] ta-sa.org
Requestors: cpan [...] pennewiss.de
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.2
Fixed in: 0.3



Subject: SRV-Support from Net::XMPP2::Connection missed
This patch adds SRV-Support from Net::XMPP2::Connection (0.14) to AnyEvent::XMPP::Connection
Subject: Connection.pm.patch
--- /usr/lib/perl5/vendor_perl/5.8.8/AnyEvent/XMPP/Connection.pm 2009-01-26 16:59:30.647720000 +0100 +++ Connection.pm 2009-01-26 16:55:14.539813905 +0100 @@ -2,6 +2,7 @@ use strict; use AnyEvent; use IO::Socket::INET; +use Net::DNS::Resolver; use AnyEvent::XMPP::Parser; use AnyEvent::XMPP::Writer; use AnyEvent::XMPP::Util qw/split_jid join_jid simxml/; @@ -285,10 +286,18 @@ return $self; } -=item B<connect ()> +=item B<connect ($no_srv_rr)> Try to connect (non blocking) to the domain and port passed in C<new>. +A SRV RR lookup will be performed on the domain to discover +the host and port to use. If you don't want this set C<$no_srv_rr> +to a true value. C<$no_srv_rr> is false by default. + +As the SRV RR lookup might return multiple host and you fail to +connect to one you might just call this function again to try a +different host. + The connection is performed non blocking, so this method will just trigger the connection process. The event C<connect> will be emitted when the connection was successfully established. @@ -302,9 +311,30 @@ =cut sub connect { - my ($self) = @_; + my ($self, $no_srv_rr) = @_; my ($host, $port) = ($self->{domain}, defined $self->{port} ? $self->{port} : 5222); + if ($self->{override_host}) { + $host = $self->{override_host}; + + } else { + unless ($no_srv_rr) { + my $res = Net::DNS::Resolver->new; + my $p = $res->query ('_xmpp-client._tcp.'.$host, 'SRV'); + if ($p) { + my @srvs = grep { $_->type eq 'SRV' } $p->answer; + if (@srvs) { + @srvs = sort { $a->priority <=> $b->priority } @srvs; + @srvs = sort { $b->weight <=> $a->weight } @srvs; # TODO + $port = $srvs[0]->port; + $host = $srvs[0]->target; + } + } + } + } + + $port = $self->{override_port} if defined $self->{override_port}; + $self->SUPER::connect ($host, $port, $self->{connect_timeout}); }
On Mon Jan 26 11:34:06 2009, mape2k wrote: Show quoted text
> This patch adds SRV-Support from Net::XMPP2::Connection (0.14) to > AnyEvent::XMPP::Connection
Why did you re implement SRV? AnyEvent::XMPP uses AnyEvent::Socket to do DNS SRV records, like I wrote in the Changes: - Using the better tested AnyEvent::Handle and AnyEvent::Socket for DNS resolution, TCP connect and TLS now. Did you have any problems with DNS SRV? Could you try the latest version from the git repository if you experienced any DNS SRV problems? Greetings, Robin
From: cpan [...] pennewiss.de
On Mo. 26. Jan. 2009, 12:10:36, ELMEX wrote: Show quoted text
> Why did you re implement SRV? AnyEvent::XMPP uses AnyEvent::Socket > to do DNS SRV records, like I wrote in the Changes: > > - Using the better tested AnyEvent::Handle and > AnyEvent::Socket for DNS resolution, TCP connect and TLS now.
hmm, i did not read it accurate enough, sorry ;) Show quoted text
> Did you have any problems with DNS SRV?
In version 0.2 it dit now work. Show quoted text
> Could you try the latest version from the git repository if you > experienced any DNS SRV problems?
Works perfectly. i think the bug is fixed with your commit of 2009-01-14. THX for your work. Marcel
Subject: Re: [rt.cpan.org #42808] SRV-Support from Net::XMPP2::Connection missed
Date: Mon, 26 Jan 2009 20:39:18 +0100
To: Marcel Pennewiß via RT <bug-AnyEvent-XMPP [...] rt.cpan.org>
From: Robin Redeker <elmex [...] ta-sa.org>
Hi! On Mon, Jan 26, 2009 at 01:15:29PM -0500, Marcel Pennewiß via RT wrote: Show quoted text
> Queue: AnyEvent-XMPP > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=42808 > > > On Mo. 26. Jan. 2009, 12:10:36, ELMEX wrote:
> > Why did you re implement SRV? AnyEvent::XMPP uses AnyEvent::Socket > > to do DNS SRV records, like I wrote in the Changes: > > > > - Using the better tested AnyEvent::Handle and > > AnyEvent::Socket for DNS resolution, TCP connect and TLS now.
> > > hmm, i did not read it accurate enough, sorry ;) >
> > Did you have any problems with DNS SRV?
> > In version 0.2 it dit now work. >
> > Could you try the latest version from the git repository if you > > experienced any DNS SRV problems?
> > Works perfectly. i think the bug is fixed with your commit of 2009-01-14. > > THX for your work. >
Thats great, thanks for testing the git version. I'll release it soon. Many people already stumbled over the brokeness in 0.2 :) Greetings, Robin -- Robin Redeker | Deliantra, the free code+content MORPG elmex@ta-sa.org / r.redeker@gmail.com | http://www.deliantra.net http://www.ta-sa.org/ |
Version 0.3 is now released.