[Bps-public-commit] djabberd branch, master, updated. d6a7ae3c7c2dcb1b985335dde1dffa25f0eb1d8a

Alex M Vandiver alexmv at bestpractical.com
Tue Mar 9 00:50:37 EST 2010


The branch, master has been updated
  discards  3a63060af8c05c4dcf7248565a8dcea0202b4ffb (commit)
  discards  5dbb1ae2bdbd5b87f307d71d2ff18bc77d912dfe (commit)
  discards  f2431a189c3282f4ef805548e53d182387c345f2 (commit)
       via  d6a7ae3c7c2dcb1b985335dde1dffa25f0eb1d8a (commit)
       via  d6bca5dafd066231f5a8dbec32f4d373fd0a7721 (commit)
       via  38ae3465f560eadc1955e55254a0eaf145104f00 (commit)
       via  57923f8ec06dbe608daad60894ad894f49aa6ba9 (commit)
       via  2e1c4514e744b680b7d615fb170c0f6179385e5f (commit)
       via  bda0e6d9de4b8b2f8f43a984779d9769c32e57d1 (commit)
       via  a395072954871e6dd6e7862a3688bb56bc3f4211 (commit)
       via  c88824619279eee886fe7b11dc3e4dcd9d1458f5 (commit)

This update added new revisions after undoing existing revisions.  That is
to say, the old revision is not a strict subset of the new revision.  This
situation occurs when you --force push a change and generate a repository
containing something like this:

 * -- * -- B -- O -- O -- O (3a63060af8c05c4dcf7248565a8dcea0202b4ffb)
            \
             N -- N -- N (d6a7ae3c7c2dcb1b985335dde1dffa25f0eb1d8a)

When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.

Summary of changes:
 DJabberd/lib/DJabberd.pm         |    5 +
 DJabberd/lib/DJabberd/Config.pod |   11 +++
 DJabberd/lib/DJabberd/DNS.pm     |  183 +++++++++++++++++++++++++-------------
 3 files changed, 137 insertions(+), 62 deletions(-)

- Log -----------------------------------------------------------------
commit c88824619279eee886fe7b11dc3e4dcd9d1458f5
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri Sep 25 14:21:34 2009 -0400

    Update CHANGES file

diff --git a/DJabberd/CHANGES b/DJabberd/CHANGES
index cc4ca2c..155a9dd 100644
--- a/DJabberd/CHANGES
+++ b/DJabberd/CHANGES
@@ -1,3 +1,12 @@
+  - IMPORTANT: JIDs are now case insensitive, and properly UTF8
+    normalized, as the spec calls for.  If you wish to preserve the
+    old behavior, set 'CaseSensitive' in your configuration.  If you
+    have existing roster storage, you will need to ensure that
+    existing entries with differing case are merged.  If you use the
+    SQLite roster, 'fix-jabber-roster-case' has been provided in the
+    DJabberd::RosterStorage::SQLite distribution.
+    (Alex Vandiver <alexmv at bestpractical.com>)
+
   - Some configuration file docs
     (Alex Vandiver <alexmv at bestpractical.com>)
 

commit a395072954871e6dd6e7862a3688bb56bc3f4211
Author: Martin Atkins <mart at degeneration.co.uk>
Date:   Wed Oct 14 11:14:00 2009 +0100

    Add the SASL modules to MANIFEST.

diff --git a/DJabberd/MANIFEST b/DJabberd/MANIFEST
index 7e52927..7209dff 100644
--- a/DJabberd/MANIFEST
+++ b/DJabberd/MANIFEST
@@ -60,6 +60,7 @@ lib/DJabberd/Stanza/DialbackResult.pm
 lib/DJabberd/Stanza/DialbackVerify.pm
 lib/DJabberd/Stanza/StartTLS.pm
 lib/DJabberd/Stanza/StreamFeatures.pm
+lib/DJabberd/Stanza/SASL.pm
 lib/DJabberd/Stats.pm
 lib/DJabberd/StreamStart.pm
 lib/DJabberd/StreamVersion.pm
@@ -69,6 +70,10 @@ lib/DJabberd/Util.pm
 lib/DJabberd/VHost.pm
 lib/DJabberd/XMLElement.pm
 lib/DJabberd/XMLParser.pm
+lib/DJabberd/SASL/Connection/AuthenSASL.pm
+lib/DJabberd/SASL/Manager/AuthenSASL.pm
+lib/DJabberd/SASL/AuthenSASL.pm
+lib/DJabberd/SASL.pm
 Makefile.PL
 MANIFEST
 MANIFEST.SKIP

commit bda0e6d9de4b8b2f8f43a984779d9769c32e57d1
Author: Martin Atkins <mart at degeneration.co.uk>
Date:   Wed Oct 14 11:14:29 2009 +0100

    Set version for developer preview release.

diff --git a/DJabberd/lib/DJabberd.pm b/DJabberd/lib/DJabberd.pm
index a168fdb..498199e 100644
--- a/DJabberd/lib/DJabberd.pm
+++ b/DJabberd/lib/DJabberd.pm
@@ -42,7 +42,7 @@ use Socket qw(IPPROTO_TCP TCP_NODELAY SOL_SOCKET SOCK_STREAM);
 use Carp qw(croak);
 use DJabberd::Util qw(tsub as_bool as_num as_abs_path as_bind_addr);
 
-our $VERSION = '0.84';
+our $VERSION = '0.85_01';
 
 our $logger = DJabberd::Log->get_logger();
 our $hook_logger = DJabberd::Log->get_logger("DJabberd::Hook");

commit 2e1c4514e744b680b7d615fb170c0f6179385e5f
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Mar 8 22:23:52 2010 -0500

    Refactor resolver to eliminate duplicate code, allow for non A or SRV requests

diff --git a/DJabberd/lib/DJabberd/DNS.pm b/DJabberd/lib/DJabberd/DNS.pm
index 9434601..fd1ec11 100644
--- a/DJabberd/lib/DJabberd/DNS.pm
+++ b/DJabberd/lib/DJabberd/DNS.pm
@@ -6,6 +6,7 @@ use fields (
             'callback',
             'srv',
             'port',
+            'type',
             'recurse_count',
             'became_readable',  # bool
             'timed_out',        # bool
@@ -45,32 +46,12 @@ sub srv {
         }
     }
 
-    my $pkt = Net::DNS::Packet->new("$service.$hostname", "SRV", "IN");
-
-    $logger->debug("pkt = $pkt");
-    my $sock = $resolver->bgsend($pkt);
-    $logger->debug("sock = $sock");
-    my $self = $class->SUPER::new($sock);
-
-    $self->{hostname} = $hostname;
-    $self->{callback} = $callback;
-    $self->{srv}      = $service;
-    $self->{port}     = $port;
-    $self->{recurse_count} = $recurse_count;
-
-    $self->{became_readable} = 0;
-    $self->{timed_out}       = 0;
-
-    # TODO: make DNS timeout configurable
-    Danga::Socket->AddTimer(5.0, sub {
-        return if $self->{became_readable};
-        $self->{timed_out} = 1;
-        $logger->debug("DNS 'SRV' lookup for '$hostname' timed out");
-        $callback->();
-        $self->close;
-    });
-
-    $self->watch_read(1);
+    $class->resolve(
+        type     => 'SRV',
+        domain   => "$service.$hostname",
+        callback => $callback,
+        port     => $port,
+    );
 }
 
 sub new {
@@ -93,23 +74,52 @@ sub new {
         return;
     }
 
+    $class->resolve(
+        type     => 'A',
+        domain   => $hostname,
+        callback => $callback,
+        port     => $port,
+    );
+}
 
-    my $sock = $resolver->bgsend($hostname);
+sub resolve {
+    my ($class, %opts) = @_;
+
+    foreach (qw(callback domain type port)) {
+        croak("No '$_' field") unless $opts{$_};
+    }
+
+    my $hostname = delete $opts{'domain'};
+    my $callback = delete $opts{'callback'};
+    my $type     = delete $opts{'type'};
+    my $port     = delete $opts{'port'};
+    my $recurse_count = delete($opts{'recurse_count'}) || 0;
+    croak "unknown opts" if %opts;
+
+    my $method = "event_read_" . lc $type;
+    croak "unknown type $type" unless $class->can($method);
+
+    my $pkt = Net::DNS::Packet->new($hostname, $type, "IN");
+
+    $logger->debug("pkt = $pkt");
+    my $sock = $resolver->bgsend($pkt);
+    $logger->debug("sock = $sock");
     my $self = $class->SUPER::new($sock);
 
     $self->{hostname} = $hostname;
     $self->{callback} = $callback;
     $self->{port}     = $port;
+    $self->{type}     = $type;
     $self->{recurse_count} = $recurse_count;
 
     $self->{became_readable} = 0;
     $self->{timed_out}       = 0;
 
-    # TODO: make DNS timeout configurable, remove duplicate code
+    # TODO: make DNS timeout configurable
     Danga::Socket->AddTimer(5.0, sub {
         return if $self->{became_readable};
         $self->{timed_out} = 1;
-        $logger->debug("DNS 'A' lookup for '$hostname' timed out");
+        $logger->debug("DNS '$type' lookup for '$hostname' timed out");
         $callback->();
         $self->close;
     });
@@ -128,24 +138,22 @@ sub event_read {
     }
     $self->{became_readable} = 1;
 
-    if ($self->{srv}) {
-        $logger->debug("DNS socket $self->{sock} became readable for 'srv'");
-        return $self->event_read_srv;
-    } else {
-        $logger->debug("DNS socket $self->{sock} became readable for 'a'");
-        return $self->event_read_a;
-    }
+    $logger->debug("DNS socket $self->{sock} became readable for '$self->{type}'");
+
+    my $method = "event_read_" . lc $self->{type};
+    return $self->$method;
 }
 
-sub event_read_a {
+sub read_packets {
     my $self = shift;
+    return $resolver->bgread($self->{sock})->answer;
+}
 
-    my $sock = $self->{sock};
-    my $cb   = $self->{callback};
-
-    my $packet = $resolver->bgread($sock);
+sub event_read_a {
+    my $self = shift;
 
-    my @ans = $packet->answer;
+    my $cb = $self->{callback};
+    my @ans = $self->read_packets;
 
     for my $ans (@ans) {
         my $rv = eval {
@@ -187,11 +195,8 @@ sub event_read_a {
 sub event_read_srv {
     my $self = shift;
 
-    my $sock = $self->{sock};
-    my $cb   = $self->{callback};
-
-    my $packet = $resolver->bgread($sock);
-    my @ans = $packet->answer;
+    my $cb = $self->{callback};
+    my @ans = $self->read_packets;
 
     # FIXME: is this right?  right order and direction?
     my @targets = sort {
@@ -202,7 +207,7 @@ sub event_read_srv {
     unless (@targets) {
         # no result, fallback to an A lookup
         $self->close;
-        $logger->debug("DNS socket $sock for 'srv' had nothing, falling back to 'a' lookup");
+        $logger->debug("DNS socket for 'srv' had nothing, falling back to 'a' lookup");
         DJabberd::DNS->new(hostname => $self->{hostname},
                            port     => $self->{port},
                            callback => $cb);
@@ -210,7 +215,7 @@ sub event_read_srv {
     }
 
     # FIXME:  we only do the first target now.  should do a chain.
-    $logger->debug("DNS socket $sock for 'srv' found stuff, now doing hostname lookup on " . $targets[0]->target);
+    $logger->debug("DNS socket for 'srv' found stuff, now doing hostname lookup on " . $targets[0]->target);
     DJabberd::DNS->new(hostname => $targets[0]->target,
                        port     => $targets[0]->port,
                        callback => $cb);

commit 57923f8ec06dbe608daad60894ad894f49aa6ba9
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Mar 8 23:28:27 2010 -0500

    Move "A" record fallback to calling function, where we have the right hostname value

diff --git a/DJabberd/lib/DJabberd/DNS.pm b/DJabberd/lib/DJabberd/DNS.pm
index fd1ec11..44af40c 100644
--- a/DJabberd/lib/DJabberd/DNS.pm
+++ b/DJabberd/lib/DJabberd/DNS.pm
@@ -46,10 +46,21 @@ sub srv {
         }
     }
 
+    my $try_a = sub {
+        my @values = @_;
+        return $callback->(@values) if @values;
+        $logger->debug("DNS socket for 'srv' had nothing, falling back to 'a' lookup");
+        DJabberd::DNS->new(
+            hostname => $hostname,
+            port     => $port,
+            callback => $callback,
+        );
+    };
+
     $class->resolve(
         type     => 'SRV',
         domain   => "$service.$hostname",
-        callback => $callback,
+        callback => $try_a,
         port     => $port,
     );
 }
@@ -204,15 +215,9 @@ sub event_read_srv {
         $a->weight   <=> $b->weight
     } grep { ref $_ eq "Net::DNS::RR::SRV" && $_->port } @ans;
 
-    unless (@targets) {
-        # no result, fallback to an A lookup
-        $self->close;
-        $logger->debug("DNS socket for 'srv' had nothing, falling back to 'a' lookup");
-        DJabberd::DNS->new(hostname => $self->{hostname},
-                           port     => $self->{port},
-                           callback => $cb);
-        return;
-    }
+    $self->close;
+
+    return $cb->() unless @targets;
 
     # FIXME:  we only do the first target now.  should do a chain.
     $logger->debug("DNS socket for 'srv' found stuff, now doing hostname lookup on " . $targets[0]->target);

commit 38ae3465f560eadc1955e55254a0eaf145104f00
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Mar 8 23:29:53 2010 -0500

    For debugging, include the domain name which gave the IP in question during DNS lookups

diff --git a/DJabberd/lib/DJabberd/DNS.pm b/DJabberd/lib/DJabberd/DNS.pm
index 44af40c..281499a 100644
--- a/DJabberd/lib/DJabberd/DNS.pm
+++ b/DJabberd/lib/DJabberd/DNS.pm
@@ -186,7 +186,7 @@ sub event_read_a {
                 $logger->debug("Ignoring RR response for $self->{hostname}");
             }
             else {
-                $cb->(DJabberd::IPEndPoint->new($ans->address, $self->{port}));
+                $cb->(DJabberd::IPEndPoint->new($ans->address, $self->{port}, $self->{hostname}));
             }
             $self->close;
             1;
@@ -229,10 +229,15 @@ sub event_read_srv {
 
 package DJabberd::IPEndPoint;
 sub new {
-    my ($class, $addr, $port) = @_;
-    return bless { addr => $addr, port => $port };
+    my ($class, $addr, $port, $name) = @_;
+    if (defined $name) {
+        $name = lc $name;
+        $name =~ s/\.$//;
+    }
+    return bless { addr => $addr, port => $port, name => $name };
 }
 
+sub name { $_[0]{name} }
 sub addr { $_[0]{addr} }
 sub port { $_[0]{port} }
 

commit d6bca5dafd066231f5a8dbec32f4d373fd0a7721
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Mar 8 23:34:36 2010 -0500

    Fix SRV weighting code, and note what the actual FIXME is

diff --git a/DJabberd/lib/DJabberd/DNS.pm b/DJabberd/lib/DJabberd/DNS.pm
index 281499a..5a7e4a1 100644
--- a/DJabberd/lib/DJabberd/DNS.pm
+++ b/DJabberd/lib/DJabberd/DNS.pm
@@ -209,10 +209,12 @@ sub event_read_srv {
     my $cb = $self->{callback};
     my @ans = $self->read_packets;
 
-    # FIXME: is this right?  right order and direction?
+    # FIXME: Should nominally do weighted random choice beteen records
+    # with lowest priority, not just choose the highest weighted.  See
+    # RFC 2782.
     my @targets = sort {
         $a->priority <=> $b->priority ||
-        $a->weight   <=> $b->weight
+        $b->weight   <=> $a->weight
     } grep { ref $_ eq "Net::DNS::RR::SRV" && $_->port } @ans;
 
     $self->close;

commit d6a7ae3c7c2dcb1b985335dde1dffa25f0eb1d8a
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Mar 9 00:03:01 2010 -0500

    Provide a workaround for misconfigured Google Apps domains
    
    Interoperability with Google Apps For Your Domain can cause headaches;
    if the administrator fails to add the requisite SRV records,
    federation with other domains will obviously fail.  However, they will
    be able to chat with other Google Talk users, so jabber will appear to
    "work" from their point of view.
    
    This adds a configuration option to delegate a SRV lookup to
    gmail.com, when a domain lacking SRV records is likely a Google Apps
    domain (judged based on the MX records on it).  As this option is a
    heuristic, and attempts to compensate for flaws in other domains, it
    is disabled by default.

diff --git a/DJabberd/lib/DJabberd.pm b/DJabberd/lib/DJabberd.pm
index 498199e..095020f 100644
--- a/DJabberd/lib/DJabberd.pm
+++ b/DJabberd/lib/DJabberd.pm
@@ -121,6 +121,11 @@ sub set_config_sslcertificatefile {
 sub ssl_private_key_file { return $_[0]{ssl_private_key_file} }
 sub ssl_cert_file        { return $_[0]{ssl_cert_file}        }
 
+sub set_config_intuitgafyd {
+    my ($self, $val) = @_;
+    $DJabberd::GAFYD = as_bool($val);
+}
+
 sub set_config_oldssl {
     my ($self, $val) = @_;
     $self->{old_ssl} = as_bool($val);
diff --git a/DJabberd/lib/DJabberd/Config.pod b/DJabberd/lib/DJabberd/Config.pod
index a312b2b..e99cbfd 100644
--- a/DJabberd/lib/DJabberd/Config.pod
+++ b/DJabberd/lib/DJabberd/Config.pod
@@ -143,6 +143,17 @@ description; this is used for client service auto-discovery.
 If set, requires that clients have negotiated a TLS before
 authentication information is sent.
 
+=head2 IntuitGAFYD C<boolean>
+
+Interoperability with Google Apps For Your Domain can cause headaches;
+if the administrator fails to add the requisite SRV records,
+federation with other domains will obviously fail.  However, they will
+be able to chat with other Google Talk users, so jabber will appear to
+"work" from their point of view.  Turning this boolean on (it defaults
+to off) will detect misconfigured GAFYD domains (detected by examining
+their MX record) and return whatever C<gmail.com> would return for
+that SRV lookup.
+
 
 
 =head1 PLUGIN CONFIGURATION
diff --git a/DJabberd/lib/DJabberd/DNS.pm b/DJabberd/lib/DJabberd/DNS.pm
index 5a7e4a1..c5fcb36 100644
--- a/DJabberd/lib/DJabberd/DNS.pm
+++ b/DJabberd/lib/DJabberd/DNS.pm
@@ -57,10 +57,32 @@ sub srv {
         );
     };
 
+    my $gafyd = sub {
+        my @values = @_;
+        return $callback->(@values) if @values;
+        DJabberd::DNS->resolve(
+            type     => "MX",
+            domain   => $hostname,
+            port     => $port,
+            callback => sub {
+                # If we get nothing, fall back to the A lookup
+                return $try_a->() unless grep {$_->name eq "aspmx.l.google.com"} @_;
+                # Otherwise, reprise on gmail.com
+                $logger->debug("Has a GAFYD MX, trying gtalk's server");
+                return DJabberd::DNS->srv(
+                    domain   => "gmail.com",
+                    service  => $service,
+                    port     => $port,
+                    callback => $callback,
+                );
+            }
+        );
+    };
+
     $class->resolve(
         type     => 'SRV',
         domain   => "$service.$hostname",
-        callback => $try_a,
+        callback => $DJabberd::GAFYD ? $gafyd : $try_a,
         port     => $port,
     );
 }
@@ -226,7 +248,27 @@ sub event_read_srv {
     DJabberd::DNS->new(hostname => $targets[0]->target,
                        port     => $targets[0]->port,
                        callback => $cb);
+}
+
+sub event_read_mx {
+    my $self = shift;
+
+    my $cb = $self->{callback};
+    my @ans = $self->read_packets;
+
+    my @targets = sort {
+        $a->preference <=> $b->preference
+    } grep { ref $_ eq "Net::DNS::RR::MX" } @ans;
+
     $self->close;
+
+    return $cb->() unless @targets;
+
+    # FIXME:  we only do the first target now.  should do a chain.
+    $logger->debug("DNS socket for 'MX' found stuff, now doing hostname lookup on " . $targets[0]->exchange);
+    DJabberd::DNS->new(hostname => $targets[0]->exchange,
+                       port     => $self->{port},
+                       callback => $cb);
 }
 
 package DJabberd::IPEndPoint;

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list