Add support for SRV records

This commit is contained in:
Florian Zeitz 2011-05-24 03:01:47 +02:00
parent c52bf728bc
commit dd4022b99c
6 changed files with 383 additions and 3 deletions

View file

@ -31,6 +31,7 @@
#import <ObjOpenSSL/SSLSocket.h>
#import "XMPPConnection.h"
#import "XMPPSRVEnumerator.h"
#import "XMPPSCRAMAuth.h"
#import "XMPPPLAINAuth.h"
#import "XMPPStanza.h"
@ -196,9 +197,27 @@
- (void)connect
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
XMPPSRVEnumerator *SRVEnumerator =
[XMPPSRVEnumerator enumeratorWithDomain: server];
XMPPSRVEntry *candidate;
[sock connectToHost: server
onPort: port];
while ((candidate = [SRVEnumerator nextObject])) {
@try {
[sock connectToHost: [candidate target]
onPort: [candidate port]];
break;
} @catch (id e) {
if (([e class] == [OFAddressTranslationFailedException
class]) || ([e class] ==
[OFConnectionFailedException class]))
continue;
else
@throw e;
}
}
if (!candidate)
[sock connectToHost: server
onPort: port];
[self XMPP_startStream];
[pool release];