Add linux/unix version of SRV lookup.
Add some extra debugging when SRV lookup fails.
This commit is contained in:
@@ -102,6 +102,8 @@ exenv.Append(LIBS=["strophe", "expat"])
|
|||||||
exenv.Append(LIBPATH=["."])
|
exenv.Append(LIBPATH=["."])
|
||||||
if exenv["PLATFORM"] == "win32":
|
if exenv["PLATFORM"] == "win32":
|
||||||
exenv.Append(LIBS=["ws2_32", "winmm"])
|
exenv.Append(LIBS=["ws2_32", "winmm"])
|
||||||
|
if exenv["PLATFORM"] != "win32":
|
||||||
|
exenv.Append(LIBS=["resolv"])
|
||||||
for e in path("examples", Examples):
|
for e in path("examples", Examples):
|
||||||
example = exenv.Program(e)
|
example = exenv.Program(e)
|
||||||
Default(example)
|
Default(example)
|
||||||
|
|||||||
@@ -361,8 +361,10 @@ int xmpp_connect_client(xmpp_conn_t * const conn,
|
|||||||
|
|
||||||
if (!sock_srv_lookup("xmpp-client", "tcp", conn->domain, connectdomain, 2048, &connectport))
|
if (!sock_srv_lookup("xmpp-client", "tcp", conn->domain, connectdomain, 2048, &connectport))
|
||||||
{
|
{
|
||||||
|
xmpp_debug(conn->ctx, "xmpp", "SRV lookup failed.");
|
||||||
if (altdomain)
|
if (altdomain)
|
||||||
{
|
{
|
||||||
|
xmpp_debug(conn->ctx, "xmpp", "Using alternate domain %s, port %d", altdomain, altport);
|
||||||
strcpy(connectdomain, altdomain);
|
strcpy(connectdomain, altdomain);
|
||||||
connectport = altport;
|
connectport = altport;
|
||||||
}
|
}
|
||||||
|
|||||||
43
src/sock.c
43
src/sock.c
@@ -34,6 +34,8 @@
|
|||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <arpa/nameser.h>
|
||||||
|
#include <resolv.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
@@ -859,6 +861,47 @@ int sock_srv_lookup(const char *service, const char *proto, const char *domain,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
if (!set)
|
||||||
|
{
|
||||||
|
char buf[65535];
|
||||||
|
int len;
|
||||||
|
|
||||||
|
if ((len = res_query(fulldomain, C_IN, T_SRV, buf, 65535)) > 0)
|
||||||
|
{
|
||||||
|
int offset;
|
||||||
|
int i;
|
||||||
|
struct dnsquery_header header;
|
||||||
|
struct dnsquery_question question;
|
||||||
|
struct dnsquery_resourcerecord rr;
|
||||||
|
|
||||||
|
offset = 0;
|
||||||
|
netbuf_get_dnsquery_header(buf, 65536, &offset, &header);
|
||||||
|
|
||||||
|
for (i = 0; i < header.qdcount; i++)
|
||||||
|
{
|
||||||
|
netbuf_get_dnsquery_question(buf, 65536, &offset, &question);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < header.ancount; i++)
|
||||||
|
{
|
||||||
|
netbuf_get_dnsquery_resourcerecord(buf, 65536, &offset, &rr);
|
||||||
|
|
||||||
|
if (rr.type == 33)
|
||||||
|
{
|
||||||
|
struct dnsquery_srvrdata *srvrdata = &(rr.rdata);
|
||||||
|
|
||||||
|
snprintf(resulttarget, resulttargetlength, srvrdata->target);
|
||||||
|
*resultport = srvrdata->port;
|
||||||
|
set = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < header.ancount; i++)
|
||||||
|
{
|
||||||
|
netbuf_get_dnsquery_resourcerecord(buf, 65536, &offset, &rr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!set)
|
if (!set)
|
||||||
|
|||||||
Reference in New Issue
Block a user