Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client Quirks Support - Miranda #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions lib/DJabberd/Connection.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use fields (
'counted_close', # bool: temporary here to track down the overcounting of disconnects
'disconnect_handlers', # array of coderefs to call when this connection is closed for any reason
'sasl', # the sasl connection object, when sasl has been or is being negotiated
'client_info', # array containing the 'node' and 'ver' fields from a presence stanza, for quirk handling
);

our $connection_id = 1;
Expand Down Expand Up @@ -268,6 +269,39 @@ sub set_version {
$self->{version} = $verob;
}

sub set_client_info {
my ($self, $client, $version) = @_;
if ($self->{client_info}) {
my ($oclient, $oversion) = @{$self->{client_info}};
warn "CLIENT INFO CHANGED $oclient -> $client, $oversion -> $version\n"
unless ($oclient eq $client and $oversion eq $version);
}
$self->{client_info} = [$client, $version];
}

# check if the client is known to have any quirky behaviour
#
# SendsIqWithoutId - some clients have bugs that make them send
# iq messages without an ID. Accept them here.
sub client_has_quirk {
my ($self, $quirk) = @_;

return undef unless $self->{client_info}; # unknown

my ($client, $version) = @{$self->{client_info}};

# As a bugfix for trillian clients, djabberd discarded all
# iq stanzas without an id, but Miranda sends roster updates
# with no ID, so they don't apply. Check for this.
if ($quirk eq 'SendsIqWithoutId') {
# fixed in svn, but not in the current stable clients
return 1 if $client =~ m/miranda-im/ and $version =~ m/^0\.7/;
}

# we don't know of this quirk existing on this client
return 0;
}

sub version {
my $self = shift;
return $self->{version} or
Expand Down
13 changes: 12 additions & 1 deletion lib/DJabberd/IQ.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use Digest::SHA;

use DJabberd::Log;
our $logger = DJabberd::Log->get_logger();
our $NULLID = 1;

sub on_recv_from_client {
my ($self, $conn) = @_;
Expand Down Expand Up @@ -45,7 +46,17 @@ sub process {
# Trillian Jabber 3.1 is stupid and sends a lot of IQs (but non-important ones)
# without ids. If we respond to them (also without ids, or with id='', rather),
# then Trillian crashes. So let's just ignore them.
return unless defined($self->id) && length($self->id);
#
# ... unless this is Miranda because, at least up until 0.78, it sends
# roster updates without an id, oops.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://www.miranda-im.org/download/ says the latest version is 0.10.4, is this still relevant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Thu, Oct 11, 2012, at 09:13 PM, Ask Bjørn Hansen wrote:

In lib/DJabberd/IQ.pm:

@@ -45,7 +46,17 @@ sub process {
# Trillian Jabber 3.1 is stupid and sends a lot of IQs (but non-important
ones)
# without ids. If we respond to them (also without ids, or with id='', r
ather),
# then Trillian crashes. So let's just ignore them.

  • return unless defined($self->id) && length($self->id);
  • ... unless this is Miranda because, at least up until 0.78, it sends

  • roster updates without an id, oops.

[1]http://www.miranda-im.org/download/ says the latest version is
0.10.4, is this still relevant?


Reply to this email directly or [2]view it on GitHub.
[J6T91GIPIyhU-8ti4GCGP5NqroswussYHXjwGAe6TA5tGDkGY_zFHhDlYCs5jmFL.gi
f]

Probably not. I guess nobody is running it any more :)
Bron.

References

  1. http://www.miranda-im.org/download/

2. https://github.com/djabberd/DJabberd/pull/23/files#r1822466

Bron Gondwana
[email protected]

unless (defined($self->id) && length($self->id)) {
if ($conn->client_has_quirk('SendsIqWithoutId')) {
$self->{attrs}{"{}id"} = 'null' . $NULLID++;
}
else {
return;
}
}

$conn->vhost->run_hook_chain(phase => "c2s-iq",
args => [ $self ],
Expand Down
10 changes: 10 additions & 0 deletions lib/DJabberd/Presence.pm
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,16 @@ sub _process_outbound_available {

if ($conn->is_initial_presence) {
$conn->on_initial_presence;

# capture the client information for quirks detection, since the
# presence notification seems to be the cleanest way to find this.
foreach my $child ($self->children()) {
next unless ref $child;
next unless $child->element() eq '{http://jabber.org/protocol/caps}c';
my $client = $child->attr('{}node');
my $version = $child->attr('{}ver');
$conn->set_client_info($client, $version);
}
}

$self->broadcast_from($conn);
Expand Down