bac1890bb6
(ie me@example.com) is different from the server's fqdn (ie xmpp.example.com), which is the case of Google Talk. If the SRV records are properly configured (as detailed here: http://wiki.xmpp.org/web/SRV_Records) you dont need to set the server anymore in bitlbee, it will do the dns lookup and automagically connect to the right server. Note that the purple FLAVOR doesn't exhibit this bug. This is needed until someone adds the ns_*parse* family of functions from BIND8 to our resolver (asr? any takers?) From Daniel Levai (thanks!), tested by myself & looks good to sthen@.
118 lines
2.9 KiB
Plaintext
118 lines
2.9 KiB
Plaintext
$OpenBSD: patch-lib_misc_c,v 1.1 2013/03/13 21:42:58 landry Exp $
|
|
http://bugs.bitlbee.org/bitlbee/ticket/421
|
|
needed until ns_parse family of functions are added to lib/libc/asr
|
|
--- lib/misc.c.orig Mon Jan 7 00:41:11 2013
|
|
+++ lib/misc.c Wed Mar 6 19:13:27 2013
|
|
@@ -44,7 +44,10 @@
|
|
#ifdef HAVE_RESOLV_A
|
|
#include <arpa/nameser.h>
|
|
#include <resolv.h>
|
|
+#if defined (__OpenBSD__)
|
|
+#include <netinet/in.h>
|
|
#endif
|
|
+#endif
|
|
|
|
#include "md5.h"
|
|
#include "ssl_client.h"
|
|
@@ -522,19 +525,90 @@ struct ns_srv_reply **srv_lookup( char *service, char
|
|
char name[1024];
|
|
unsigned char querybuf[1024];
|
|
const unsigned char *buf;
|
|
+ int i, n, len, size;
|
|
+#if defined (__OpenBSD__)
|
|
+ char uncomp[MAXDNAME];
|
|
+ int complen = -1;
|
|
+ unsigned int qdcount = 0, ancount = 0;
|
|
+
|
|
+ const unsigned char *comp = NULL;
|
|
+ unsigned char *end = NULL;
|
|
+ HEADER *head = NULL;
|
|
+
|
|
+ int ns_c_in = C_IN, ns_t_srv = T_SRV;
|
|
+ int prio = -1, weight = -1, port = -1;
|
|
+#else
|
|
ns_msg nsh;
|
|
ns_rr rr;
|
|
- int i, n, len, size;
|
|
+#endif
|
|
+
|
|
|
|
g_snprintf( name, sizeof( name ), "_%s._%s.%s", service, protocol, domain );
|
|
|
|
if( ( size = res_query( name, ns_c_in, ns_t_srv, querybuf, sizeof( querybuf ) ) ) <= 0 )
|
|
return NULL;
|
|
|
|
+ n = 0;
|
|
+
|
|
+#if defined (__OpenBSD__)
|
|
+ head = (HEADER *)querybuf;
|
|
+ comp = querybuf + HFIXEDSZ;
|
|
+ end = querybuf + size;
|
|
+
|
|
+ ancount = ntohs(head->ancount);
|
|
+
|
|
+ /* Skip over the Query part */
|
|
+ for (qdcount = ntohs(head->qdcount); qdcount--; comp += size + QFIXEDSZ)
|
|
+ if ((size = dn_skipname(comp, end)) < 0)
|
|
+ return NULL;
|
|
+
|
|
+
|
|
+ /* Get the answers */
|
|
+ while (ancount > 0 && comp < end) {
|
|
+ /* Skip the owner name, to which this resource record pertains. */
|
|
+ complen = dn_expand(querybuf, end, comp, uncomp, sizeof(uncomp));
|
|
+ if (complen < 0)
|
|
+ return NULL;
|
|
+
|
|
+ comp += complen;
|
|
+
|
|
+
|
|
+ /* Get the useful answers. */
|
|
+ /* GETSHORT(type, comp); */
|
|
+ comp += INT16SZ;
|
|
+ /* GETSHORT(class, comp); */
|
|
+ comp += INT16SZ;
|
|
+ /* GETLONG(ttl, comp); */
|
|
+ comp += INT32SZ;
|
|
+ /* GETSHORT(complen, comp); */
|
|
+ comp += INT16SZ;
|
|
+
|
|
+ GETSHORT(prio , comp);
|
|
+ GETSHORT(weight , comp);
|
|
+ GETSHORT(port , comp);
|
|
+ complen = dn_expand(querybuf, end, comp, uncomp, sizeof(uncomp));
|
|
+ if (complen < 0)
|
|
+ return NULL;
|
|
+
|
|
+ comp += complen;
|
|
+
|
|
+ reply = g_malloc( sizeof( struct ns_srv_reply ) + strlen(uncomp) + 1 );
|
|
+
|
|
+ reply->prio = prio;
|
|
+ reply->weight = weight;
|
|
+ reply->port = port;
|
|
+ strlcpy( reply->name, uncomp, strlen(uncomp) + 1 );
|
|
+
|
|
+ n++;
|
|
+ replies = g_renew( struct ns_srv_reply *, replies, n + 1 );
|
|
+ replies[n-1] = reply;
|
|
+
|
|
+ ancount--;
|
|
+ }
|
|
+#else
|
|
if( ns_initparse( querybuf, size, &nsh ) != 0 )
|
|
return NULL;
|
|
|
|
- n = 0;
|
|
while( ns_parserr( &nsh, ns_s_an, n, &rr ) == 0 )
|
|
{
|
|
size = ns_rr_rdlen( rr );
|
|
@@ -567,6 +641,7 @@ struct ns_srv_reply **srv_lookup( char *service, char
|
|
replies = g_renew( struct ns_srv_reply *, replies, n + 1 );
|
|
replies[n-1] = reply;
|
|
}
|
|
+#endif
|
|
if( replies )
|
|
replies[n] = NULL;
|
|
#endif
|