Skip to content

Commit 3b46886

Browse files
committed
Cleanup for merge to master
2 parents 9407db4 + a59c4ed commit 3b46886

File tree

15 files changed

+440
-96
lines changed

15 files changed

+440
-96
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ build/
22
_build/
33
*~
44
getdns.so
5+
getdns.cpython-34m.so
56
*.save
67
doc/_build/
78
doc/_build/*

context.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ context_set_dns_transport_list(getdns_context *context, PyObject *py_value)
875875
long transport;
876876
if ((py_transport = PyList_GetItem(py_value, (Py_ssize_t)i)) != NULL) {
877877
transport = PyLong_AsLong(py_transport);
878-
if ((transport < GETDNS_TRANSPORT_UDP) || (transport > GETDNS_TRANSPORT_STARTTLS)) {
878+
if ((transport < GETDNS_TRANSPORT_UDP) || (transport > GETDNS_TRANSPORT_TLS)) {
879879
PyErr_SetString(getdns_error, GETDNS_RETURN_INVALID_PARAMETER_TEXT);
880880
return -1;
881881
}
@@ -947,6 +947,19 @@ context_getattro(PyObject *self, PyObject *nameobj)
947947
}
948948
}
949949

950+
if (!strncmp(attrname, "suffix", strlen("suffix"))) {
951+
PyObject *py_suffix;
952+
getdns_list *suffix;
953+
954+
if ((ret = getdns_context_get_suffix(context, &suffix)) != GETDNS_RETURN_GOOD) {
955+
PyErr_SetString(getdns_error, getdns_get_errorstr_by_id(ret));
956+
return NULL;
957+
}
958+
if ((py_suffix = glist_to_plist(suffix)) == NULL)
959+
PyErr_SetString(getdns_error, GETDNS_RETURN_INVALID_PARAMETER_TEXT);
960+
return py_suffix;
961+
}
962+
950963
api_info = getdns_context_get_api_information(context);
951964
if (!strncmp(attrname, "resolution_type", strlen("resolution_type"))) {
952965
uint32_t resolution_type;
@@ -1198,18 +1211,6 @@ context_getattro(PyObject *self, PyObject *nameobj)
11981211
PyErr_SetString(getdns_error, GETDNS_RETURN_INVALID_PARAMETER_TEXT);
11991212
return py_namespaces;
12001213
}
1201-
if (!strncmp(attrname, "suffix", strlen("suffix"))) {
1202-
PyObject *py_suffix;
1203-
getdns_list *suffix;
1204-
if ((ret = getdns_dict_get_list(all_context, "suffix",
1205-
&suffix)) != GETDNS_RETURN_GOOD) {
1206-
PyErr_SetString(getdns_error, getdns_get_errorstr_by_id(ret));
1207-
return NULL;
1208-
}
1209-
if ((py_suffix = glist_to_plist(suffix)) == NULL)
1210-
PyErr_SetString(getdns_error, GETDNS_RETURN_INVALID_PARAMETER_TEXT);
1211-
return py_suffix;
1212-
}
12131214
if (!strncmp(attrname, "upstream_recursive_servers", strlen("upstream_recursive_servers"))) {
12141215
PyObject *py_upstream_servers;
12151216
getdns_list *upstream_list;

doc/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
# built documents.
4949
#
5050
# The short X.Y version.
51-
version = 'v0.5.0'
51+
version = 'v0.6.0'
5252
# The full version, including alpha/beta/rc tags.
53-
release = 'v0.5.0'
53+
release = 'v0.6.0'
5454

5555
# The language for content autogenerated by Sphinx. Refer to documentation
5656
# for a list of supported languages.

doc/functions.rst

Lines changed: 62 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
getdns contexts
1111
---------------
1212

13-
This section describes the *getdns* Context object, as well as its
13+
This section describes the *getdns* Context object, as well
14+
as its
1415
as its methods and attributes.
1516

1617
.. py:class:: Context([set_from_os])
@@ -22,12 +23,14 @@ as its methods and attributes.
2223
attributes described below.
2324

2425
Context() takes one optional constructor argument.
25-
``set_from_os`` is an integer and may take the value either
26+
``set_from_os`` is an integer and may take the value
27+
either
2628
0 or 1. If 1, which most developers will want, getdns
2729
will populate the context with default values for the
2830
platform on which it's running.
2931

30-
The :class:`Context` class has the following public read/write attributes:
32+
The :class:`Context` class has the following public
33+
read/write attributes:
3134

3235
.. py:attribute:: append_name
3336
@@ -37,7 +40,8 @@ as its methods and attributes.
3740
``getdns.APPEND_NAME_ALWAYS``,
3841
``getdns.APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE``,
3942
``getdns.APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE``,
40-
or ``getdns.APPEND_NAME_NEVER``. This controls whether or not
43+
or ``getdns.APPEND_NAME_NEVER``. This controls whether or
44+
not
4145
to append the suffix given by :attr:`suffix`.
4246

4347
.. py:attribute:: dns_root_servers
@@ -53,8 +57,10 @@ as its methods and attributes.
5357

5458
For example, the addresses list could look like
5559

56-
>>> addrs = [ { 'address_data': '2001:7b8:206:1::4:53', 'address_type': 'IPv6' },
57-
... { 'address_data': '65.22.9.1', 'address_type': 'IPv4' } ]
60+
>>> addrs = [ { 'address_data': '2001:7b8:206:1::4:53',
61+
'address_type': 'IPv6' },
62+
... { 'address_data': '65.22.9.1',
63+
'address_type': 'IPv4' } ]
5864
>>> mycontext.dns_root_servers = addrs
5965

6066
.. py:attribute:: dns_transport_list
@@ -63,8 +69,7 @@ as its methods and attributes.
6369
lookups, ordered by preference (first choice as list
6470
element 0, second as list element 1, and so on). The
6571
possible values are ``getdns.TRANSPORT_UDP``,
66-
``getdns.TRANSPORT_TCP``, ``getdns.TRANSPORT_TLS``,
67-
and ``getdns.TRANSPORT_STARTTLS``.
72+
``getdns.TRANSPORT_TCP``, and ``getdns.TRANSPORT_TLS``.
6873

6974
.. py:attribute:: dnssec_allowed_skew
7075
@@ -84,11 +89,13 @@ as its methods and attributes.
8489

8590
.. py:attribute:: edns_do_bit
8691
87-
Its value must be an integer valued either 0 or 1. The default is 0.
92+
Its value must be an integer valued either 0 or 1. The
93+
default is 0.
8894

8995
.. py:attribute:: edns_extended_rcode
9096
91-
Its value must be an integer between 0 and 255, inclusive.
97+
Its value must be an integer between 0 and 255,
98+
inclusive.
9299
The default is 0.
93100

94101
.. py:attribute:: edns_maximum_udp_payload_size
@@ -98,15 +105,18 @@ as its methods and attributes.
98105

99106
.. py:attribute:: edns_version
100107
101-
Its value must be an integer between 0 and 255, inclusive.
108+
Its value must be an integer between 0 and 255,
109+
inclusive.
102110
The default is 0.
103111

104112
.. py:attribute:: follow_redirects
105113
106114
Specifies whether or not DNS queries follow
107-
redirects. The value must be one of ``getdns.REDIRECTS_FOLLOW`` for
115+
redirects. The value must be one of
116+
``getdns.REDIRECTS_FOLLOW`` for
108117
normal following of redirects though CNAME and DNAME; or
109-
``getdns.REDIRECTS_DO_NOT_FOLLOW`` to cause any lookups that
118+
``getdns.REDIRECTS_DO_NOT_FOLLOW`` to cause any lookups
119+
that
110120
would have gone through CNAME and DNAME to return the
111121
CNAME or DNAME, not the eventual target.
112122

@@ -122,30 +132,36 @@ as its methods and attributes.
122132

123133
.. py:attribute:: limit_outstanding_queries
124134
125-
Specifies `limit` (an integer value) on the number of outstanding DNS
135+
Specifies `limit` (an integer value) on the number of
136+
outstanding DNS
126137
queries. The API will block itself from sending more
127138
queries if it is about to exceed this value, and instead
128139
keep those queries in an internal queue. The a value of 0
129-
indicates that the number of outstanding DNS queries is unlimited.
140+
indicates that the number of outstanding DNS queries is
141+
unlimited.
130142

131143
.. py:attribute:: namespaces
132144
133145
The `namespaces` attribute takes an ordered list of
134-
namespaces that will be queried. (*Important: this context
146+
namespaces that will be queried. (*Important: this
147+
context
135148
setting is ignored for the getdns.general() function;
136149
it is used for the other
137150
functions.*) The allowed values are
138-
``getdns.NAMESPACE_DNS``, ``getdns.NAMESPACE_LOCALNAMES``,
151+
``getdns.NAMESPACE_DNS``,
152+
``getdns.NAMESPACE_LOCALNAMES``,
139153
``getdns.NAMESPACE_NETBIOS``,
140-
``getdns.NAMESPACE_MDNS``, and ``getdns.NAMESPACE_NIS``. When a
154+
``getdns.NAMESPACE_MDNS``, and
155+
``getdns.NAMESPACE_NIS``. When a
141156
normal lookup is done, the API does the lookups in the
142157
order given and stops when it gets the first result; a
143158
different method with the same result would be to run the
144159
queries in parallel and return when it gets the first
145160
result. Because lookups might be done over different
146161
mechanisms because of the different namespaces, there can
147162
be information leakage that is similar to that seen with
148-
POSIX *getaddrinfo()*. The default is determined by the OS.
163+
POSIX *getaddrinfo()*. The default is determined by the
164+
OS.
149165

150166
.. py:attribute:: resolution_type
151167
@@ -166,22 +182,28 @@ as its methods and attributes.
166182

167183
.. py:attribute:: timeout
168184
169-
Its value must be an integer specifying a timeout for a query, expressed
185+
Its value must be an integer specifying a timeout for a
186+
query, expressed
170187
in milliseconds.
171188

172189
.. py:attribute:: tls_authentication
173190
174191
The mechanism to be used for authenticating the TLS
175-
server when using a TLS transport. May be ``getdns.AUTHENTICATION_HOSTNAME`` or
192+
server when using a TLS transport. May be
193+
``getdns.AUTHENTICATION_REQUIRED`` or
176194
``getdns.AUTHENTICATION_NONE``.
195+
(getdns.AUTHENTICATION_HOSTNAME remains as an alias for
196+
getdns.AUTHENTICATION_REQUIRED but is deprecated and will
197+
be removed in a future release)
177198

178199
.. py:attribute:: tls_query_padding_blocksize
179200
180-
Optional padding blocksize for queries when using TLS. Used to
201+
Optional padding blocksize for queries when using TLS.
202+
Used to
181203
increase the difficulty for observers to guess traffic
182204
content.
183205

184-
.. py:attribute:: upstream_recursive_servers
206+
.. py:attribute:: upstream_recursive_servers
185207
186208
A list of dicts defining where a stub resolver will send queries.
187209
Each dict in the list contains at least two names: address_type
@@ -193,11 +215,19 @@ as its methods and attributes.
193215
tsig_algorithm (a bindata) that is the name of the TSIG hash
194216
algorithm, and tsig_secret (a bindata) that is the TSIG key.
195217

218+
There is also now support for pinning an upstream's
219+
certificate's public keys, with pinsets (when using TLS
220+
for transport. Add an element to the
221+
upstream_recursive_server list entry, called
222+
'tls_pubkey_pinset', which is a list of public key pins.
223+
(See the example code in our examples directory).
224+
196225
.. py:attribute:: version_string
197226
198227
The libgetdns version, retrieved from the underlying
199228
getdns library.
200-
229+
230+
201231
The :class:`Context` class includes public methods to execute a DNS query, as well as a
202232
method to return the entire set of context attributes as a Python dictionary. :class:`Context`
203233
methods are described below:
@@ -253,7 +283,7 @@ as its methods and attributes.
253283

254284
* ``version_string``
255285
* ``implementation_string``
256-
* ``resolver_type``
286+
* ``resolution_type``
257287
* ``all_context``
258288

259289
``all_context`` is a dictionary containing the following keys:
@@ -263,13 +293,13 @@ as its methods and attributes.
263293
* ``dnssec_allowed_skew``
264294
* ``edns_do_bit``
265295
* ``edns_extended_rcode``
266-
* ``edns_maximum_udp_payload_size``
267296
* ``edns_version``
268297
* ``follow_redirects``
269298
* ``limit_outstanding_queries``
270299
* ``namespaces``
271300
* ``suffix``
272301
* ``timeout``
302+
* ``tls_authentication``
273303
* ``upstream_recursive_servers``
274304

275305
.. py:method:: get_supported_attributes()
@@ -301,13 +331,7 @@ The extensions currently supported by :py:mod:`getdns` are:
301331
* ``add_opt_parameters``
302332
* ``add_warning_for_bad_dns``
303333
* ``specify_class``
304-
* ``return_call_debugging``
305-
306-
Extensions that are optionally built (see above) include
307-
308-
* ``edns-cookies``
309-
310-
``edns-cookies`` also takes the value ``getdns.EXTENSION_TRUE``.
334+
* ``return_call_reporting``
311335

312336
Extensions for DNSSEC
313337
^^^^^^^^^^^^^^^^^^^^^
@@ -407,6 +431,9 @@ record sets the resource record appropriately, making the
407431
needed changes to the settings from the ``add_opt_parameters``
408432
extension.
409433

434+
The ``client_subnet.py`` program in our example directory
435+
shows how to pack and send an OPT record.
436+
410437
Getting Warnings for Responses that Violate the DNS Standard
411438
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
412439

@@ -444,9 +471,9 @@ Extensions relating to the API
444471

445472
An application might want to see debugging information for
446473
queries, such as the length of time it takes for each query
447-
to return to the API. Use the ``return_call_debugging``
474+
to return to the API. Use the ``return_call_reporting``
448475
extension. The extension's value is set to
449-
``getdns.EXTENSION_TRUE`` to add the name ``call_debugging`` (a
476+
``getdns.EXTENSION_TRUE`` to add the name ``call_reporting`` (a
450477
list) to the top level of the ``response`` object. Each member
451478
of the list is a dict that represents one call made for the
452479
call to the API. Each member has the following names:
@@ -543,21 +570,3 @@ This is an example callback function:
543570
print 'Unknown error'
544571
545572
546-
Utility methods
547-
---------------
548-
549-
At the present time we support one utility method.
550-
551-
.. py:method:: get_errorstr_by_id(id)
552-
553-
``getdns.get_errorstr_by_id`` returns a string containing
554-
text describing a getdns return code, helping to make
555-
reporting errors to users a little easier. For example:
556-
557-
.. code-block:: python
558-
559-
if results.replies_full['status'] != getdns.RESPSTATUS_GOOD:
560-
print(getdns.get_errorstr_by_id(id=results.replies_full['status'])
561-
sys.exit(1)
562-
563-

doc/index.rst

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ getdns implementation developed as a joint project between
1818
and `NLnet Labs <http://nlnetlabs.nl/>`_.
1919

2020
We have tried to keep this interface as Pythonic as we can
21-
while staying true to the getdns architecture. With this
22-
release we are moving towards a design that is more consistent with
21+
while staying true to the getdns architecture, including
22+
trying to maintain consistency with
2323
Python object design.
2424

2525
Dependencies
2626
============
2727

2828
This version of getdns has been built and tested against Python
29-
2.7. We also expect these other prerequisites to be
29+
2.7 and Python 3.4. We also expect these other prerequisites to be
3030
installed:
3131

32-
* `libgetdns <http://getdnsapi.net/>`_, version 0.5.0 or later
32+
* `libgetdns <http://getdnsapi.net/>`_, version 0.9.0 or later
3333
* `libunbound
3434
<http://www.nlnetlabs.nl/projects/unbound/>`_, version
3535
1.4.16 or later
@@ -53,7 +53,8 @@ Building
5353
========
5454

5555
The code repository for getdns is available at:
56-
`<https://github.com/getdnsapi/getdns-python-bindings>`_. If you are building from source you will
56+
`<https://github.com/getdnsapi/getdns-python-bindings>`_.
57+
If you are building from source you will
5758
need the Python development package for Python 2.7. On
5859
Linux systems this is typically something along the lines of
5960
"python-dev" or "python2.7-dev", available through your
@@ -214,13 +215,17 @@ Module-level attributes and methods
214215

215216
.. py:method:: ulabel_to_alabel()
216217
217-
Converts a ulabel to an alabel. Takes one argument (the ulabel)
218+
Converts a ulabel to an alabel. Takes one argument (the
219+
ulabel)
218220

219221
.. py:method:: alabel_to_ulabel()
220222
221223
Converts an alabel to a ulabel. Takes one argument (the
222224
alabel)
223225

226+
.. py:method:: root_trust_anchor()
227+
228+
Returns the default root trust anchor for DNSSEC.
224229

225230
Known issues
226231
============

0 commit comments

Comments
 (0)