diff --git a/src/XMPPConnection.m b/src/XMPPConnection.m index 81959ed..d55cd65 100644 --- a/src/XMPPConnection.m +++ b/src/XMPPConnection.m @@ -230,7 +230,7 @@ { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; XMPPSRVEntry *candidate = nil; - XMPPSRVLookup *SRVLookup; + XMPPSRVLookup *SRVLookup = nil; OFEnumerator *enumerator; OFString *domainToASCII; char *cDomainToASCII; @@ -255,16 +255,17 @@ free(cDomainToASCII); } - SRVLookup = [XMPPSRVLookup - lookupWithDomain: domainToASCII]; + @try { + SRVLookup = [XMPPSRVLookup + lookupWithDomain: domainToASCII]; + } @catch (id e) { + [e release]; + } + enumerator = [SRVLookup objectEnumerator]; - // If there are no SRV records connect via A/AAAA record - if ((candidate = [enumerator nextObject]) == nil) - [sock connectToHost: domainToASCII - port: port]; - // Iterate over SRV records - else { + /* Iterate over SRV records, if any */ + if ((candidate = [enumerator nextObject]) != nil) { do { @try { [sock connectToHost: [candidate target] @@ -277,7 +278,10 @@ [e release]; } } while ((candidate = [enumerator nextObject]) != nil); - } + } else + /* No SRV records -> fall back to A / AAAA record */ + [sock connectToHost: domainToASCII + port: port]; } [self XMPP_startStream]; diff --git a/src/XMPPIQ.h b/src/XMPPIQ.h index a629d7a..f54ef7d 100644 --- a/src/XMPPIQ.h +++ b/src/XMPPIQ.h @@ -42,7 +42,7 @@ * * \param type The value for the stanza's type attribute * \param ID The value for the stanza's id attribute - * \return A initialized XMPPIQ + * \return An initialized XMPPIQ */ - initWithType: (OFString*)type ID: (OFString*)ID;