Skip to content

Commit 7a9867a

Browse files
committed
added validation_chain attribute to Result(), removed more dead code
1 parent 0bcd80d commit 7a9867a

File tree

4 files changed

+22
-49
lines changed

4 files changed

+22
-49
lines changed

getdns.c

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ PyMemberDef Result_members[] = {
6161
{ "answer_type", T_OBJECT_EX, offsetof(getdns_ResultObject, answer_type), READONLY, "Answer type" },
6262
{ "canonical_name", T_OBJECT_EX, offsetof(getdns_ResultObject, canonical_name), READONLY,
6363
"Canonical name" },
64+
{ "validation_chain", T_OBJECT_EX, offsetof(getdns_ResultObject, validation_chain),
65+
READONLY, "DNSSEC certificate chain" },
6466
{ NULL },
6567
};
6668

@@ -205,54 +207,6 @@ PyTypeObject getdns_ContextType = {
205207
(initproc)context_init, /* tp_init */
206208
};
207209

208-
#if 0
209-
PyMethodDef Result_methods[] = {
210-
{ NULL },
211-
};
212-
#endif
213-
214-
215-
216-
/*
217-
* A shim to sit between the event callback function
218-
* and the python callback. This is a wee bit hacky
219-
*/
220-
221-
222-
void
223-
callback_shim(getdns_context *context, getdns_callback_type_t type, getdns_dict *resp,
224-
void *u, getdns_transaction_t tid)
225-
{
226-
pygetdns_libevent_callback_data *callback_data;
227-
PyObject *response;
228-
PyObject *getdns_runner;
229-
PyGILState_STATE state;
230-
231-
callback_data = (pygetdns_libevent_callback_data *)u;
232-
getdns_runner = callback_data->callback_func;
233-
if (!PyCallable_Check(getdns_runner)) {
234-
printf("callback not runnable\n");
235-
return;
236-
}
237-
if ((response = getFullResponse(resp)) == 0) {
238-
PyErr_SetString(getdns_error, "Unable to decode response");
239-
return;
240-
/* need to throw exceptiion XXX */
241-
}
242-
/* Python callback prototype: */
243-
/* callback(context, callback_type, response, userarg, tid) */
244-
state = PyGILState_Ensure();
245-
PyObject_CallFunction(getdns_runner, "OHOsL", context, type, response,
246-
callback_data->userarg, tid);
247-
PyGILState_Release(state);
248-
}
249-
250-
251-
/*
252-
* called from pthread_create. Pull out the query arguments,
253-
* get the Python callback function from the dictionary for
254-
* __main__
255-
*/
256210

257211

258212
static struct PyMethodDef getdns_methods[] = {

pygetdns.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ typedef struct {
7070
PyObject *replies_tree;
7171
PyObject *canonical_name;
7272
PyObject *replies_full;
73+
PyObject *validation_chain;
7374
} getdns_ResultObject;
7475

7576

@@ -108,6 +109,7 @@ int get_answer_type(struct getdns_dict *result_dict);
108109
char *get_canonical_name(struct getdns_dict *result_dict);
109110
PyObject *get_just_address_answers(struct getdns_dict *result_dict);
110111
PyObject *get_replies_tree(struct getdns_dict *result_dict);
112+
PyObject *get_validation_chain(struct getdns_dict *result_dict);
111113

112114
int context_init(getdns_ContextObject *self, PyObject *args, PyObject *keywds);
113115
PyObject *context_getattro(PyObject *self, PyObject *nameobj);

pygetdns_util.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ get_replies_tree(struct getdns_dict *result_dict)
103103
}
104104

105105

106+
PyObject *
107+
get_validation_chain(struct getdns_dict *result_dict)
108+
{
109+
struct getdns_list *validation_chain;
110+
getdns_return_t ret;
111+
112+
if ((ret = getdns_dict_get_list(result_dict, "validation_chain", &validation_chain)) !=
113+
GETDNS_RETURN_GOOD)
114+
Py_RETURN_NONE;
115+
else
116+
return glist_to_plist(validation_chain);
117+
}
118+
119+
106120
struct getdns_dict *
107121
extensions_to_getdnsdict(PyDictObject *pydict)
108122
{

result.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ result_init(getdns_ResultObject *self, PyObject *args, PyObject *keywds)
5656
Py_DECREF(self);
5757
return -1;
5858
}
59-
59+
if ((self->validation_chain = get_validation_chain(result_dict)) == NULL) {
60+
Py_DECREF(self);
61+
return -1;
62+
}
6063
return 0;
6164
}
6265

0 commit comments

Comments
 (0)