Add SRV record support for win32

This commit is contained in:
倪繁发 2024-04-30 18:21:58 +08:00
parent fff50a7d80
commit 13efdfe86d
2 changed files with 15 additions and 0 deletions

View File

@ -185,6 +185,7 @@ src/edge: $(N2N_LIB)
src/supernode: $(N2N_LIB)
ifneq (,$(findstring mingw,$(CONFIG_HOST_OS)))
LDLIBS+=-ldnsapi
N2N_OBJS+=src/win32/edge_utils_win32.o
N2N_OBJS+=src/win32/getopt1.o
N2N_OBJS+=src/win32/getopt.o

View File

@ -579,6 +579,20 @@ static int setOption (int optkey, char *optargument, n2n_tuntap_priv_config_t *e
case 'l': /* supernode-list */ {
if(optargument) {
#ifdef _WIN32
#include <Winsock2.h>
#include <windns.h>
DNS_RECORDA* pDnsRecord = NULL;
DnsQuery_A(optargument, DNS_TYPE_SRV, DNS_QUERY_STANDARD, NULL, (PDNS_RECORD*)&pDnsRecord, NULL);
while (pDnsRecord != NULL) {
if (pDnsRecord->wType == DNS_TYPE_SRV) {
DNS_SRV_DATAA pSrvData = pDnsRecord->Data.SRV;
sprintf(optargument, "%s:%d\0", pSrvData.pNameTarget, pSrvData.wPort);
break;
}
pDnsRecord = pDnsRecord->pNext;
}
#endif
if(edge_conf_add_supernode(conf, optargument) != 0) {
traceEvent(TRACE_WARNING, "failed to add supernode '%s'", optargument);
}