Skip to content

Commit 3e71630

Browse files
committed
removed dns_transport from Context
1 parent 989e628 commit 3e71630

File tree

4 files changed

+11
-130
lines changed

4 files changed

+11
-130
lines changed

context.c

Lines changed: 9 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ context_set_resolution_type(getdns_context *context, PyObject *py_value)
146146
}
147147

148148

149+
#if 0 /* commenting this out for the time being, delete later */
149150
int
150151
context_set_dns_transport(getdns_context *context, PyObject *py_value)
151152
{
@@ -183,7 +184,7 @@ context_set_dns_transport(getdns_context *context, PyObject *py_value)
183184
}
184185
return 0;
185186
}
186-
187+
#endif
187188

188189
int
189190
context_set_limit_outstanding_queries(getdns_context *context, PyObject *py_value)
@@ -848,6 +849,7 @@ context_getattro(PyObject *self, PyObject *nameobj)
848849
}
849850
return py_transports;
850851
}
852+
#if 0
851853
if (!strncmp(attrname, "dns_transport", strlen("dns_transport"))) {
852854
uint32_t dns_transport;
853855
if ((ret = getdns_dict_get_int(all_context, "dns_transport", &dns_transport)) !=
@@ -861,6 +863,7 @@ context_getattro(PyObject *self, PyObject *nameobj)
861863
return PyInt_FromLong((long)dns_transport);
862864
#endif
863865
}
866+
#endif
864867
if (!strncmp(attrname, "limit_outstanding_queries", strlen("limit_outstanding_queries"))) {
865868
uint32_t limit_outstanding_queries;
866869
if ((ret = getdns_dict_get_int(all_context, "limit_outstanding_queries",
@@ -1094,9 +1097,11 @@ context_setattro(PyObject *self, PyObject *attrname, PyObject *py_value)
10941097
if (!strncmp(name, "dns_transport_list", strlen("dns_transport_list"))) {
10951098
return(context_set_dns_transport_list(context, py_value));
10961099
}
1100+
#if 0
10971101
if (!strncmp(name, "dns_transport", strlen("dns_transport"))) {
10981102
return(context_set_dns_transport(context, py_value));
10991103
}
1104+
#endif
11001105
return 0;
11011106
}
11021107

@@ -1562,12 +1567,7 @@ context_get_api_information(getdns_ContextObject *self, PyObject *unused)
15621567
uint32_t resolution_type;
15631568
getdns_dict *all_context;
15641569
PyObject *py_all_context;
1565-
size_t ncontexts;
1566-
getdns_list *context_names;
1567-
getdns_bindata *a_name;
1568-
uint32_t context_value;
15691570
getdns_return_t ret;
1570-
int i;
15711571

15721572

15731573
if ((context = PyCapsule_GetPointer(self->py_context, "context")) == NULL) {
@@ -1616,122 +1616,10 @@ context_get_api_information(getdns_ContextObject *self, PyObject *unused)
16161616
PyErr_SetString(getdns_error, getdns_get_errorstr_by_id(ret));
16171617
return NULL;
16181618
}
1619-
if ((ret = getdns_dict_get_names(all_context, &context_names)) != GETDNS_RETURN_GOOD) {
1620-
PyErr_SetString(getdns_error, getdns_get_errorstr_by_id(ret));
1619+
if ((py_all_context = gdict_to_pdict(all_context)) == NULL) {
1620+
PyErr_SetString(getdns_error, "Unable to convert all_context dict");
16211621
return NULL;
16221622
}
1623-
if ((ret = getdns_list_get_length(context_names, &ncontexts)) != GETDNS_RETURN_GOOD) {
1624-
PyErr_SetString(getdns_error, getdns_get_errorstr_by_id(ret));
1625-
return NULL;
1626-
}
1627-
py_all_context = PyDict_New();
1628-
for ( i = 0 ; i < ncontexts ; i++ ) {
1629-
if ((ret = getdns_list_get_bindata(context_names, (size_t)i, &a_name)) != GETDNS_RETURN_GOOD) {
1630-
PyErr_SetString(getdns_error, getdns_get_errorstr_by_id(ret));
1631-
return NULL;
1632-
}
1633-
if (!strncmp((char *)a_name->data, "namespaces", strlen("namespaces"))) {
1634-
getdns_list *namespaces = getdns_list_create();
1635-
PyObject *py_namespaces;
1636-
size_t n_spaces;
1637-
uint32_t space;
1638-
int j;
1639-
1640-
if ((ret = getdns_dict_get_list(all_context, (char *)a_name->data, &namespaces)) != GETDNS_RETURN_GOOD) {
1641-
PyErr_SetString(getdns_error, getdns_get_errorstr_by_id(ret));
1642-
return NULL;
1643-
}
1644-
(void)getdns_list_get_length(namespaces, &n_spaces);
1645-
py_namespaces = PyList_New((Py_ssize_t)n_spaces);
1646-
for ( j = 0 ; j < n_spaces ; j++ ) {
1647-
(void)getdns_list_get_int(namespaces, j, &space);
1648-
#if PY_MAJOR_VERSION >= 3
1649-
PyList_SetItem(py_namespaces, (Py_ssize_t)j, PyLong_FromLong((long)space));
1650-
#else
1651-
PyList_SetItem(py_namespaces, (Py_ssize_t)j, PyInt_FromLong((long)space));
1652-
#endif
1653-
}
1654-
PyDict_SetItemString(py_all_context, "namespaces", py_namespaces);
1655-
} else if (!strncmp((char *)a_name->data, "suffix", strlen("suffix"))) {
1656-
getdns_list *suffixes = getdns_list_create();
1657-
PyObject *py_suffixes;
1658-
size_t n_suffixes;
1659-
getdns_bindata *suffix;
1660-
int j;
1661-
1662-
if ((ret = getdns_dict_get_list(all_context, (char *)a_name->data, &suffixes)) != GETDNS_RETURN_GOOD) {
1663-
PyErr_SetString(getdns_error, getdns_get_errorstr_by_id(ret));
1664-
return NULL;
1665-
}
1666-
(void)getdns_list_get_length(suffixes, &n_suffixes);
1667-
py_suffixes = PyList_New((Py_ssize_t)n_suffixes);
1668-
for ( j = 0 ; j < n_suffixes ; j++ ) {
1669-
(void)getdns_list_get_bindata(suffixes, j, &suffix);
1670-
#if PY_MAJOR_VERSION >= 3
1671-
PyList_SetItem(py_suffixes, (Py_ssize_t)j, PyUnicode_FromString((char *)suffix->data));
1672-
#else
1673-
PyList_SetItem(py_suffixes, (Py_ssize_t)j, PyString_FromString((char *)suffix->data));
1674-
#endif
1675-
}
1676-
PyDict_SetItemString(py_all_context, "suffix", py_suffixes);
1677-
} else if (!strncmp((char *)a_name->data, "upstream_recursive_servers",
1678-
strlen("upstream_recursive_servers"))) {
1679-
getdns_list *upstream_list;
1680-
PyObject *py_upstream_list;
1681-
PyObject *py_upstream;
1682-
size_t n_upstreams;
1683-
getdns_dict *upstream;
1684-
getdns_bindata *upstream_data;
1685-
getdns_bindata *upstream_type;
1686-
char *paddr_buf[256];
1687-
int domain;
1688-
int j;
1689-
1690-
if ((ret = getdns_dict_get_list(all_context, (char *)a_name->data, &upstream_list)) != GETDNS_RETURN_GOOD) {
1691-
PyErr_SetString(getdns_error, getdns_get_errorstr_by_id(ret));
1692-
return NULL;
1693-
}
1694-
(void)getdns_list_get_length(upstream_list, &n_upstreams);
1695-
py_upstream_list = PyList_New((Py_ssize_t)n_upstreams);
1696-
for ( j = 0 ; j < n_upstreams ; j++ ) {
1697-
(void)getdns_list_get_dict(upstream_list, j, &upstream);
1698-
(void)getdns_dict_get_bindata(upstream, "address_data", &upstream_data);
1699-
(void)getdns_dict_get_bindata(upstream, "address_type", &upstream_type);
1700-
if (!strncasecmp((char *)upstream_type->data, "IPv4", 4))
1701-
domain = AF_INET;
1702-
else if (!strncasecmp((char *)upstream_type->data, "IPv6", 6))
1703-
domain = AF_INET6;
1704-
else {
1705-
PyErr_SetString(getdns_error, GETDNS_RETURN_GENERIC_ERROR_TEXT);
1706-
return NULL;
1707-
}
1708-
py_upstream = PyDict_New();
1709-
PyDict_SetItemString(py_upstream, "address_data",
1710-
#if PY_MAJOR_VERSION >= 3
1711-
PyUnicode_FromString(inet_ntop(domain, (void *)upstream_data->data, (char *)paddr_buf, 256)));
1712-
#else
1713-
PyString_FromString(inet_ntop(domain, (void *)upstream_data->data, (char *)paddr_buf, 256)));
1714-
#endif
1715-
#if PY_MAJOR_VERSION >= 3
1716-
PyDict_SetItemString(py_upstream, "address_type", PyUnicode_FromString((domain == AF_INET ? "IPv4" : "IPv6")));
1717-
#else
1718-
PyDict_SetItemString(py_upstream, "address_type", PyString_FromString((domain == AF_INET ? "IPv4" : "IPv6")));
1719-
#endif
1720-
PyList_SetItem(py_upstream_list, j, py_upstream);
1721-
}
1722-
PyDict_SetItemString(py_all_context, (char *)a_name->data, py_upstream_list);
1723-
} else {
1724-
if ((ret = getdns_dict_get_int(all_context, (char *)a_name->data, &context_value)) != GETDNS_RETURN_GOOD) {
1725-
PyErr_SetString(getdns_error, getdns_get_errorstr_by_id(ret));
1726-
return NULL;
1727-
}
1728-
#if PY_MAJOR_VERSION >= 3
1729-
PyDict_SetItemString(py_all_context, (char *)a_name->data, PyLong_FromLong((long)context_value));
1730-
#else
1731-
PyDict_SetItemString(py_all_context, (char *)a_name->data, PyInt_FromLong((long)context_value));
1732-
#endif
1733-
}
1734-
PyDict_SetItemString(py_api, "all_context", py_all_context);
1735-
}
1623+
PyDict_SetItemString(py_api, "all_context", py_all_context);
17361624
return(py_api);
17371625
}

doc/functions.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,6 @@ as its methods and attributes.
6868
``getdns.TRANSPORT_TCP``, ``getdns.TRANSPORT_TLS``,
6969
and ``getdns.TRANSPORT_STARTTLS``.
7070

71-
.. py:attribute:: dns_transport
72-
73-
Specifies what transport is used for DNS lookups. The
74-
value must be one of ``getdns.TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP``,
75-
``getdns.TRANSPORT_UDP_ONLY``, ``getdns.TRANSPORT_TCP_ONLY``, or
76-
``getdns.TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN``.
77-
7871
.. py:attribute:: limit_outstanding_queries
7972
8073
Specifies `limit` (an integer value) on the number of outstanding DNS

getdns.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ PyMemberDef Context_members[] = {
165165
{ "timeout", T_INT, offsetof(getdns_ContextObject, timeout), 0, "timeout in milliseconds" },
166166
{ "resolution_type", T_INT, offsetof(getdns_ContextObject, resolution_type), 0,
167167
"lookup as recursive or stub resolver" },
168-
{ "dns_transport", T_INT, offsetof(getdns_ContextObject, dns_transport),
169-
0, "dns transport" },
170168
{ "dns_transport_list", T_OBJECT, offsetof(getdns_ContextObject, dns_transport_list), 0,
171169
"ordered list of dns transports" },
172170
{ "limit_outstanding_queries", T_INT, offsetof(getdns_ContextObject, limit_outstanding_queries),

pygetdns.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ typedef struct {
7474
PyObject *py_context; /* Python capsule containing getdns_context */
7575
uint64_t timeout; /* timeout attribute (milliseconds) */
7676
getdns_resolution_t resolution_type; /* stub or recursive? */
77+
#if 0
7778
getdns_transport_t dns_transport; /* udp/tcp/etc */
79+
#endif
7880
uint16_t limit_outstanding_queries;
7981
getdns_redirects_t follow_redirects;
8082
getdns_append_name_t append_name;

0 commit comments

Comments
 (0)