A new stub resolver Willem Toorop willem@nlnetlabs.nl API is: A - - PowerPoint PPT Presentation

a new stub resolver
SMART_READER_LITE
LIVE PREVIEW

A new stub resolver Willem Toorop willem@nlnetlabs.nl API is: A - - PowerPoint PPT Presentation

A new stub resolver Willem Toorop willem@nlnetlabs.nl API is: A DNS API specification (for resolving) by and for application developers (for application) First implementation by LABS and From Verisign: From NLnet Labs: Theogene Bucuti,


slide-1
SLIDE 1

A new stub resolver

Willem Toorop

willem@nlnetlabs.nl

slide-2
SLIDE 2

A new stub resolver – vBSDcon 2015 2/113 Willem Toorop (NLnet Labs)

API is:

  • A DNS API specification (for resolving)

by and for application developers (for application)

  • First implementation by LABS and

From NLnet Labs:

Olaf Kolkman, Benno Overeinder, Willem Toorop, Wouter Wijngaards

From Sinodun:

Sara and John Dickinson

From No Mountain Software:

Melinda Shore

From Verisign:

Theogene Bucuti, Craig Despeaux, Angelique Finan, Neel Goyal, Scott Hollenbeck, Shumon Huque, Sanjay Mahurpawar, Allison Mankin, Sai Mogali, Prithvi Ranganath, Rushi Shah, Vinay Soni, Bob Steagall, Gowri Visweswaran, Glen Wiley

slide-3
SLIDE 3

A new stub resolver – vBSDcon 2015 3/113 Willem Toorop (NLnet Labs)

API is:

  • A DNS API specification (for resolving)

by and for application developers (for application)

  • First implementation by LABS and

From NLnet Labs:

Olaf Kolkman, Benno Overeinder, Willem Toorop, Wouter Wijngaards

From Sinodun:

Sara and John Dickinson

From No Mountain Software:

Melinda Shore

From Verisign:

Theogene Bucuti, Craig Despeaux, Angelique Finan, Neel Goyal, Scott Hollenbeck, Shumon Huque, Sanjay Mahurpawar, Allison Mankin, Sai Mogali, Prithvi Ranganath, Rushi Shah, Vinay Soni, Bob Steagall, Gowri Visweswaran, Glen Wiley

  • OpenBSD & FreeBSD already have unbound in system
  • getdns might have a role too
slide-4
SLIDE 4

A new stub resolver – vBSDcon 2015 4/113 Willem Toorop (NLnet Labs)

API is:

  • A DNS API specification (for resolving)

by and for application developers (for application)

  • First implementation by LABS and

B

  • t

s t r a p e n c r y p t e d c h a n n e l ( T L S ) f r

  • m

D N S S E C a u t h e n t i c a t e d k e y s ( D A N E ) e s p e c i a l l y a p p l i c a b l e / s u i t a b l e t

  • s

y s t e m s

  • f

t w a r e !

  • L

a c k

  • f

u s e r i n t e r a c t i

  • n

( w h

  • d
  • y
  • u

t r u s t )

  • P
  • l

i c y p u b l i s h e d

  • v

e r s i d e c h a n n e l ( D N S S E C )

slide-5
SLIDE 5

A new stub resolver – vBSDcon 2015 5/113 Willem Toorop (NLnet Labs)

Why?

Issues with the system stub

  • System's stub accessed by application via

getaddrinfo() & getnameinfo()

slide-6
SLIDE 6

A new stub resolver – vBSDcon 2015 6/113 Willem Toorop (NLnet Labs)

Why?

Issues with the system stub

  • System's stub accessed by application via

getaddrinfo() & getnameinfo()

  • Translate names ↔ numbers (also DNS)

D N S : D

  • m

a i n N a m e S y s t e m T h e p h

  • n

e b

  • k
  • f

t h e I n t e r n e t

slide-7
SLIDE 7

A new stub resolver – vBSDcon 2015 7/113 Willem Toorop (NLnet Labs)

Why?

Issues with the system stub

  • System's stub accessed by application via

getaddrinfo() & getnameinfo()

  • Translate names ↔ numbers (also DNS)
  • What about something other than numbers

(i.e. MX, SPF, SSHFP, TLSA, OPENPGPKEY etc.) D N S : D

  • m

a i n N a m e S y s t e m G l

  • b

a l d e c e n t r a l i z e d d i s t r i b u t e d d a t a b a s e f

  • r

m

  • r

e t h a n j u s t n a m e s a n d n u m b e r s .

slide-8
SLIDE 8

A new stub resolver – vBSDcon 2015 8/113 Willem Toorop (NLnet Labs)

Why?

Issues with the system stub

  • System's stub accessed by application via

getaddrinfo() & getnameinfo()

  • Translate names ↔ numbers (also DNS)
  • What about something other than numbers

(i.e. MX, SPF, SSHFP, TLSA, OPENPGPKEY etc.)

  • libresolv? (res_query(), dn_comp() etc.)
slide-9
SLIDE 9

A new stub resolver – vBSDcon 2015 9/113 Willem Toorop (NLnet Labs)

Why?

Issues with the system stub

  • System's stub accessed by application via

getaddrinfo() & getnameinfo()

  • Translate names ↔ numbers (also DNS)
  • What about something other than numbers

(i.e. MX, SPF, SSHFP, TLSA, OPENPGPKEY etc.)

  • libresolv? (res_query(), dn_comp() etc.)
  • Blocks on I/O (no asynchronous DNS)
slide-10
SLIDE 10

A new stub resolver – vBSDcon 2015 10/113 Willem Toorop (NLnet Labs)

Why?

Issues with the system stub

  • System's stub accessed by application via

getaddrinfo() & getnameinfo()

  • Translate names ↔ numbers (also DNS)
  • What about something other than numbers

(i.e. MX, SPF, SSHFP, TLSA, OPENPGPKEY etc.)

  • libresolv? (res_query(), dn_comp() etc.)
  • Blocks on I/O (no asynchronous DNS)
  • No control over I/O

(upstreams, transport, how to fallback/timeout, privacy)

slide-11
SLIDE 11

A new stub resolver – vBSDcon 2015 11/113 Willem Toorop (NLnet Labs)

Why?

Issues with the system stub

  • DNSSEC!
slide-12
SLIDE 12

A new stub resolver – vBSDcon 2015 12/113 Willem Toorop (NLnet Labs)

Why?

Issues with the system stub

  • DNSSEC!
  • A global distributed database with authenticated data
slide-13
SLIDE 13

A new stub resolver – vBSDcon 2015 13/113 Willem Toorop (NLnet Labs)

Why?

Issues with the system stub

  • DNSSEC!
  • A global distributed database with authenticated data
  • Wasn't it about protecting users against domain hijacking?
  • D

N S : T h e p h

  • n

e b

  • k
  • f

t h e I n t e r n e t

  • D

a t a u n a u t h e n t i c a t e d

  • D

N S S E C t

  • t

h e r e s c u e

slide-14
SLIDE 14

A new stub resolver – vBSDcon 2015 14/113 Willem Toorop (NLnet Labs)

Why?

Issues with the system stub

  • DNSSEC!
  • A global distributed database with authenticated data
  • Wasn't it about protecting users against domain hijacking?
  • Yes, but it does so by giving (origin) authenticated answers

– where origin means that the authoritative party for a zone authenticates the domain names within that zone

  • D

N S : T h e p h

  • n

e b

  • k
  • f

t h e I n t e r n e t

  • D

a t a u n a u t h e n t i c a t e d

  • D

N S S E C t

  • t

h e r e s c u e

slide-15
SLIDE 15

A new stub resolver – vBSDcon 2015 15/113 Willem Toorop (NLnet Labs)

Why?

Issues with the system stub

  • DNSSEC!
  • A global distributed database with authenticated data
  • Wasn't it about protecting users against domain hijacking?
  • Yes, but it does so by giving (origin) authenticated answers
  • D

N S : T h e p h

  • n

e b

  • k
  • f

t h e I n t e r n e t

  • D

a t a u n a u t h e n t i c a t e d

  • D

N S S E C t

  • t

h e r e s c u e

  • How does this concern the stub?

– Authentication is interesting for applications

slide-16
SLIDE 16

A new stub resolver – vBSDcon 2015 16/113 Willem Toorop (NLnet Labs)

DNSSEC - for applications

  • for TLS
  • Transport Layer Security (TLS) uses

both asymmetric and symmetric encryption

  • A symmetric key is sent encrypted with remote public key
  • How is the remote public key authenticated?
slide-17
SLIDE 17

A new stub resolver – vBSDcon 2015 17/113 Willem Toorop (NLnet Labs)

DNSSEC - for applications

  • for TLS
  • How is the remote public key authenticated?
slide-18
SLIDE 18

A new stub resolver – vBSDcon 2015 18/113 Willem Toorop (NLnet Labs)

DNSSEC - for applications

  • for TLS
  • Through Certificate Authorities

(CAs), maintained in OS, browser...

  • Every CA is authorized to

authenticate for any name (as strong as the weakest link)

  • There are 650+ CAs

(See https://www.eff.org/observatory )

slide-19
SLIDE 19

A new stub resolver – vBSDcon 2015 19/113 Willem Toorop (NLnet Labs)

DNSSEC - for applications

  • for TLS
  • DNS-based Authentication of

Named Entities (DANE) RFC6698

slide-20
SLIDE 20

A new stub resolver – vBSDcon 2015 20/113 Willem Toorop (NLnet Labs)

Why?

Issues with the system stub

  • DNSSEC!
  • A global distributed database with authenticated data
  • Wasn't it about protecting users against domain hijacking?
  • Yes, but it does so by giving (origin) authenticated answers
  • D

N S : T h e p h

  • n

e b

  • k
  • f

t h e I n t e r n e t

  • D

a t a i n s e c u r e / u n p r

  • t

e c t e d

  • D

N S S E C t

  • t

h e r e s c u e

  • How does this concern the stub?

– Authentication is interesting for applications

slide-21
SLIDE 21

A new stub resolver – vBSDcon 2015 21/113 Willem Toorop (NLnet Labs)

Why?

Issues with the system stub

  • DNSSEC!
  • A global distributed database with authenticated data
  • Wasn't it about protecting users against domain hijacking?
  • Yes, but it does so by giving (origin) authenticated answers
  • D

N S : T h e p h

  • n

e b

  • k
  • f

t h e I n t e r n e t

  • D

a t a i n s e c u r e / u n p r

  • t

e c t e d

  • D

N S S E C t

  • t

h e r e s c u e

  • How does this concern the stub?

– Authentication is interesting for applications – DNSSEC deployment is not completely finished yet

slide-22
SLIDE 22

A new stub resolver – vBSDcon 2015 22/113 Willem Toorop (NLnet Labs)

DNSSEC - the first mile

  • Is the local network resolver trustworthy?

Application OS

  • s

Validating Recursive Resolver

net . getdnsapi

stub

Authoritatives

getdnsapi.net A net NS net DS net DNSKEY getdnsapi.net A net DNSKEY getdnsapi.net NS getdnsapi.net DS getdnsapi.net DNSKEY getdnsapi.net A getdnsapi.net DNSKEY getdnsapi.net A getdnsapi.net A getdnsapi.net A

malicious resolver

Could be your phone Could be the Wi-Fi

slide-23
SLIDE 23

A new stub resolver – vBSDcon 2015 23/113 Willem Toorop (NLnet Labs)

DNSSEC - the first mile

  • Is the local network resolver trustworthy?
  • Who's to blame?

Application OS

Validating Recursive Resolver

com . hbonow.com

stub

Authoritatives

  • rder.hbonow.com A

com NS com DS com DNSKEY

  • rder.hbonow.com A

com DNSKEY hbonow.com NS hbonow.com DS hbonow.com DNSKEY

  • rder.hbonow.com A

hbonow.com DNSKEY NXDOMAIN

  • rder.hbonow.com A
  • rder.hbonow.com A

slide-24
SLIDE 24

A new stub resolver – vBSDcon 2015 24/113 Willem Toorop (NLnet Labs)

DNSSEC - the first mile

  • Is the local network resolver trustworthy?
  • Who's to blame?

Application OS

Validating Recursive Resolver

com . hbonow.com

stub

Authoritatives

  • rder.hbonow.com A

com NS com DS com DNSKEY

  • rder.hbonow.com A

com DNSKEY hbonow.com NS hbonow.com DS hbonow.com DNSKEY

  • rder.hbonow.com A

hbonow.com DNSKEY NXDOMAIN

  • rder.hbonow.com A
  • rder.hbonow.com A

slide-25
SLIDE 25

A new stub resolver – vBSDcon 2015 25/113 Willem Toorop (NLnet Labs)

DNSSEC - the first mile

  • Is the local network resolver trustworthy?
  • Who's to blame?
  • Application does not know an answer is secure

(AD bit not given with getaddrinfo())

Application OS

Validating Recursive Resolver

net . getdnsapi

stub

Authoritatives

_443._tcp.getdnsapi.net TLSA net NS net DS net DNSKEY _443._tcp.getdnsapi.net TLSA net DNSKEY getdnsapi.net NS getdnsapi.net DS getdnsapi.net DNSKEY _443._tcp.getdnsapi.net TLSA getdnsapi.net DNSKEY _443._tcp.getdnsapi.net TLSA _443._tcp.getdnsapi.net TLSA _443._tcp.getdnsapi.net TLSA

slide-26
SLIDE 26

A new stub resolver – vBSDcon 2015 26/113 Willem Toorop (NLnet Labs)

DNSSEC - the first mile

  • Is the local network resolver trustworthy?
  • Who's to blame?
  • Application does not know an answer is secure
  • Network resolver does not need to validate

net . getdnsapi

Authoritatives

_443._tcp.getdnsapi.net TLSA net NS net DS net DNSKEY _443._tcp.getdnsapi.net TLSA net DNSKEY getdnsapi.net NS getdnsapi.net DS getdnsapi.net DNSKEY _443._tcp.getdnsapi.net TLSA getdnsapi.net DNSKEY _443._tcp.getdnsapi.net TLSA

Application OS

Recursive Resolver

_443._tcp.getdnsapi.net TLSA getdnsapi.net DNSKEY _443._tcp.getdnsapi.net TLSA

  • s

DNSSEC Aware

slide-27
SLIDE 27

A new stub resolver – vBSDcon 2015 27/113 Willem Toorop (NLnet Labs)

DNSSEC - the first mile

  • Is the local network resolver trustworthy?
  • Who's to blame?
  • Application does not know an answer is secure
  • Network resolver does not need to validate
  • And when it is not even DNSSEC-aware

Recursive Resolver

net . getdnsapi

Authoritatives

net NS net DS net DNSKEY _443._tcp.getdnsapi.net TLSA net DNSKEY getdnsapi.net NS getdnsapi.net DS getdnsapi.net DNSKEY _443._tcp.getdnsapi.net TLSA

Application OS

_443._tcp.getdnsapi.net TLSA getdnsapi.net DNSKEY _443._tcp.getdnsapi.net TLSA

  • s

slide-28
SLIDE 28

A new stub resolver – vBSDcon 2015 28/113 Willem Toorop (NLnet Labs)

DNSSEC - the first mile

  • Is the local network resolver trustworthy?
  • Who's to blame?
  • Application does not know an answer is secure
  • Network resolver does not need to validate
  • And when it is not even DNSSEC-aware

Recursive Resolver

net . getdnsapi

Authoritatives

net NS net DS net DNSKEY _443._tcp.getdnsapi.net TLSA net DNSKEY getdnsapi.net NS getdnsapi.net DS getdnsapi.net DNSKEY _443._tcp.getdnsapi.net TLSA

Application OS

_443._tcp.getdnsapi.net TLSA getdnsapi.net DNSKEY _443._tcp.getdnsapi.net TLSA

  • s

  • h

t t p s : / / w w w . u s

  • c

e r t . g

  • v

/ n c a s / a l e r t s / T A 1 5

  • 2

4 A

C

  • n

fj g u r e e n t e r p r i s e p e r i m e t e r n e t w

  • r

k d e v i c e s t

  • b

l

  • c

k a l l

  • u

t b

  • u

n d U s e r D a t a g r a m P r

  • t
  • c
  • l

( U D P ) a n d T r a n s m i s s i

  • n

C

  • n

t r

  • l

P r

  • t
  • c
  • l

( T C P ) t r a ffj c t

  • d

e s t i n a t i

  • n

p

  • r

t 5 3 , e x c e p t f r

  • m

s p e c i fj c , a u t h

  • r

i z e d D N S s e r v e r s ( i n c l u d i n g b

  • t

h a u t h

  • r

i t a t i v e a n d c a c h i n g / f

  • r

w a r d i n g n a m e s e r v e r s ) .

  • h

t t p s : / / w w w . u s

  • c

e r t . g

  • v

/ n c a s / a l e r t s / T A 1 5

  • 2

4 A

C

  • n

fj g u r e e n t e r p r i s e p e r i m e t e r n e t w

  • r

k d e v i c e s t

  • b

l

  • c

k a l l

  • u

t b

  • u

n d U s e r D a t a g r a m P r

  • t
  • c
  • l

( U D P ) a n d T r a n s m i s s i

  • n

C

  • n

t r

  • l

P r

  • t
  • c
  • l

( T C P ) t r a ffj c t

  • d

e s t i n a t i

  • n

p

  • r

t 5 3 , e x c e p t f r

  • m

s p e c i fj c , a u t h

  • r

i z e d D N S s e r v e r s ( i n c l u d i n g b

  • t

h a u t h

  • r

i t a t i v e a n d c a c h i n g / f

  • r

w a r d i n g n a m e s e r v e r s ) .

slide-29
SLIDE 29

A new stub resolver – vBSDcon 2015 29/113 Willem Toorop (NLnet Labs)

Why?

Issues with the system stub

  • DNSSEC!

B

  • t

s t r a p e n c r y p t e d c h a n n e l ( T L S ) f r

  • m

D N S S E C a u t h e n t i c a t e d k e y s ( D A N E ) e s p e c i a l l y a p p l i c a b l e / s u i t a b l e t

  • s

y s t e m s

  • f

t w a r e !

  • L

a c k

  • f

u s e r i n t e r a c t i

  • n

( w h

  • d
  • y
  • u

t r u s t )

  • P
  • l

i c y p u b l i s h e d

  • v

e r s i d e c h a n n e l ( D N S S E C )

F r

  • m

: h t t p s : / / t

  • l

s . i e t f .

  • r

g / h t m l / d r a f t

  • i

e t f

  • d

a n e

  • s

m t p

  • w

i t h

  • d

a n e

  • 1

9

slide-30
SLIDE 30

A new stub resolver – vBSDcon 2015 30/113 Willem Toorop (NLnet Labs)

Why?

Issues with the system stub

  • DNSSEC!

B

  • t

s t r a p e n c r y p t e d c h a n n e l ( T L S ) f r

  • m

D N S S E C a u t h e n t i c a t e d k e y s ( D A N E ) e s p e c i a l l y a p p l i c a b l e / s u i t a b l e t

  • s

y s t e m s

  • f

t w a r e !

  • L

a c k

  • f

u s e r i n t e r a c t i

  • n

( w h

  • d
  • y
  • u

t r u s t )

  • P
  • l

i c y p u b l i s h e d

  • v

e r s i d e c h a n n e l ( D N S S E C )

F r

  • m

: h t t p s : / / t

  • l

s . i e t f .

  • r

g / h t m l / d r a f t

  • i

e t f

  • d

a n e

  • s

m t p

  • w

i t h

  • d

a n e

  • 1

9

slide-31
SLIDE 31

A new stub resolver – vBSDcon 2015 31/113 Willem Toorop (NLnet Labs)

Why?

Issues with the system stub

  • DNSSEC!
  • (Inband policy assertion susceptible to downgrade attacks)

220 getdns.nlnetlabs.nl ESMTP Sendmail 8.14.9/8.14.9; Tue, 1 Sep 2015 11:37:51 +0200 (CEST) EHLO nlnetlabs.nl 250-getdns.nlnetlabs.nl Hello [IPv6:2a04:b900:0:1:14bc:270e:5c12:6e7b], pleased to meet you 250-ENHANCEDSTATUSCODES 250-STARTTLS 250-PIPELINING 250-8BITMIME

B

  • t

s t r a p e n c r y p t e d c h a n n e l ( T L S ) f r

  • m

D N S S E C a u t h e n t i c a t e d k e y s ( D A N E ) e s p e c i a l l y a p p l i c a b l e / s u i t a b l e t

  • s

y s t e m s

  • f

t w a r e !

  • L

a c k

  • f

u s e r i n t e r a c t i

  • n

( w h

  • d
  • y
  • u

t r u s t )

  • P
  • l

i c y p u b l i s h e d

  • v

e r s i d e c h a n n e l ( D N S S E C )

slide-32
SLIDE 32

A new stub resolver – vBSDcon 2015 32/113 Willem Toorop (NLnet Labs)

Why?

Issues with the system stub

B

  • t

s t r a p e n c r y p t e d c h a n n e l ( T L S ) f r

  • m

D N S S E C a u t h e n t i c a t e d k e y s ( D A N E ) e s p e c i a l l y a p p l i c a b l e / s u i t a b l e t

  • s

y s t e m s

  • f

t w a r e !

  • L

a c k

  • f

u s e r i n t e r a c t i

  • n

( w h

  • d
  • y
  • u

t r u s t )

  • P
  • l

i c y p u b l i s h e d

  • v

e r s i d e c h a n n e l ( D N S S E C )

  • https://github.com/phicoh/openssh-getdns/tree/getdns
  • Validates SSHFP with a trust anchor on a default (configurable) location

(opposed to checking AD bit or using non-standard resolv.conf option)

  • -with-trust-anchor=KEYFILE

Default location of the trust anchor file. [default=SYSCONFDIR/unbound/getdns-root.key]

  • Manage default trust anchor with unbound-anchor
slide-33
SLIDE 33

A new stub resolver – vBSDcon 2015 33/113 Willem Toorop (NLnet Labs)

Why?

Motivation by API (spec) designers

  • From Design considerations

… There are other DNS APIs available, but there has been very little uptake … … talking to application developers … … the APIs were developed by and for DNS people, not application developers …

  • Goal

… API design from talking to application developers … … create a natural follow-on to getaddrinfo() ...

slide-34
SLIDE 34

A new stub resolver – vBSDcon 2015 34/113 Willem Toorop (NLnet Labs)

Why?

Motivation by API (spec) designers

  • Goal

… API design from talking to application developers … … create a natural follow-on to getaddrinfo() ...

  • Current spec: https://getdnsapi.net/spec.html
  • Originally edited by Paul Hoffman (publiced April 2013)
  • Mailing-list : https://getdnsapi.net/mailman/listinfo/spec

Archive : https://getdnsapi.net/pipermail/spec/

  • Maintained by the getdnsapi.net team since October 2014
slide-35
SLIDE 35

A new stub resolver – vBSDcon 2015 35/113 Willem Toorop (NLnet Labs)

Features (& implementation)

  • Both stub and full recursive modes

(recusive by default)

– Full recursive via libunbound

slide-36
SLIDE 36

A new stub resolver – vBSDcon 2015 36/113 Willem Toorop (NLnet Labs)

  • -enable-stub-only configure option (no libunbound dependency)

Features (& implementation)

  • Both stub and full recursive modes

(recusive by default)

– Full recursive via libunbound

slide-37
SLIDE 37

A new stub resolver – vBSDcon 2015 37/113 Willem Toorop (NLnet Labs)

  • -enable-stub-only configure option (no libunbound dependency)

Features (& implementation)

  • Both stub and full recursive modes

(recusive by default)

– Full recursive via libunbound

  • Delivers validated DNSSEC even in stub mode

(off by default)

– libldns still (but only) used for

ldns_verify_rrsig() & ldns_rr_compare_ds_dnskey()

– Plan to lift those out before coming major release

slide-38
SLIDE 38

A new stub resolver – vBSDcon 2015 38/113 Willem Toorop (NLnet Labs)

  • -enable-stub-only configure option (no libunbound dependency)

Features (& implementation)

  • Both stub and full recursive modes

(recusive by default)

– Full recursive via libunbound

  • Delivers validated DNSSEC even in stub mode

(off by default)

– libldns still (but only) used for

ldns_verify_rrsig() & ldns_rr_compare_ds_dnskey()

– Plan to lift those out before coming major release

  • Resolves names and gives fine-grained access to the response

with a response dict type:

– Easy to inspect: getdns_pretty_print_dict()

slide-39
SLIDE 39

A new stub resolver – vBSDcon 2015 39/113 Willem Toorop (NLnet Labs)

  • -enable-stub-only configure option (no libunbound dependency)

Features (& implementation)

  • Both stub and full recursive modes

(recusive by default)

– Full recursive via libunbound

  • Delivers validated DNSSEC even in stub mode

(off by default)

– libldns still (but only) used for

ldns_verify_rrsig() & ldns_rr_compare_ds_dnskey()

– Plan to lift those out before coming major release

  • Resolves names and gives fine-grained access to the response

with a response dict type:

– Easy to inspect: getdns_pretty_print_dict()

{ "answer_type": GETDNS_NAMETYPE_DNS, "status": GETDNS_RESPSTATUS_GOOD, "canonical_name": <bindata of "www.getdnsapi.net.">, "just_address_answers": [ { "address_data": <bindata for 185.49.141.37>, "address_type": <bindata of "IPv4"> }, { "address_data": <bindata for 2a04:b900:0:100::37>, "address_type": <bindata of "IPv6"> } ], "replies_full": [ <bindata of 0x00008180000100020004000103777777...>, <bindata of 0x00008180000100020004000903777777...> ], "replies_tree": [ { ... first reply ... }, { ... second reply ... }, { "answer_type": GETDNS_NAMETYPE_DNS, "status": GETDNS_RESPSTATUS_GOOD, "canonical_name": <bindata of "www.getdnsapi.net.">, "just_address_answers": [ { "address_data": <bindata for 185.49.141.37>, "address_type": <bindata of "IPv4"> }, { "address_data": <bindata for 2a04:b900:0:100::37>, "address_type": <bindata of "IPv6"> } ], "replies_full": [ <bindata of 0x00008180000100020004000103777777...>, <bindata of 0x00008180000100020004000903777777...> ], "replies_tree": [ { ... first reply ... }, { ... second reply ... },

slide-40
SLIDE 40

A new stub resolver – vBSDcon 2015 40/113 Willem Toorop (NLnet Labs)

  • -enable-stub-only configure option (no libunbound dependency)

Features (& implementation)

  • Both stub and full recursive modes

(recusive by default)

– Full recursive via libunbound

  • Delivers validated DNSSEC even in stub mode

(off by default)

– libldns still (but only) used for

ldns_verify_rrsig() & ldns_rr_compare_ds_dnskey()

– Plan to lift those out before coming major release

  • Resolves names and gives fine-grained access to the response

with a response dict type:

– Easy to inspect: getdns_pretty_print_dict()

"replies_tree": [ { "header" : { "qdcount": 1, "ancount": 2, "rd": 1, "ra": 1, "opcode": GETDNS_OPCODE_QUERY, "rcode" : GETDNS_RCODE_NOERROR, ... }, "question": { "qname" : <bindata for www.getdnsapi.net.>, "qtype" : GETDNS_RRTYPE_A "qclass": GETDNS_RRCLASS_IN, }, "answer" : [ { "name" : <bindata for www.getdnsapi.net.>, "type" : GETDNS_RRTYPE_A, "class": GETDNS_RRCLASS_IN, "rdata": { "ipv4_address": <bindata for 185.49.141.37>, "rdata_raw": <bindata of 0xb9318d25> }, }, ... "authority": [ ... ], "additional": [], "canonical_name": <bindata of "www.getdnsapi.net.">, "answer_type": GETDNS_NAMETYPE_DNS }, { "header" : { ... "replies_tree": [ { "header" : { "qdcount": 1, "ancount": 2, "rd": 1, "ra": 1, "opcode": GETDNS_OPCODE_QUERY, "rcode" : GETDNS_RCODE_NOERROR, ... }, "question": { "qname" : <bindata for www.getdnsapi.net.>, "qtype" : GETDNS_RRTYPE_A "qclass": GETDNS_RRCLASS_IN, }, "answer" : [ { "name" : <bindata for www.getdnsapi.net.>, "type" : GETDNS_RRTYPE_A, "class": GETDNS_RRCLASS_IN, "rdata": { "ipv4_address": <bindata for 185.49.141.37>, "rdata_raw": <bindata of 0xb9318d25> }, }, ... "authority": [ ... ], "additional": [], "canonical_name": <bindata of "www.getdnsapi.net.">, "answer_type": GETDNS_NAMETYPE_DNS }, { "header" : { ...

slide-41
SLIDE 41

A new stub resolver – vBSDcon 2015 41/113 Willem Toorop (NLnet Labs)

  • -enable-stub-only configure option (no libunbound dependency)

Features (& implementation)

  • Both stub and full recursive modes

(recusive by default)

– Full recursive via libunbound

  • Delivers validated DNSSEC even in stub mode

(off by default)

– libldns still (but only) used for

ldns_verify_rrsig() & ldns_rr_compare_ds_dnskey()

– Plan to lift those out before coming major release

  • Resolves names and gives fine-grained access to the response

with a response dict type:

– Easy to inspect: getdns_pretty_print_dict()

  • getdns_print_json_dict()
  • getdns_print_json_list()

– Maps well to popular modern scripting languages

slide-42
SLIDE 42

A new stub resolver – vBSDcon 2015 42/113 Willem Toorop (NLnet Labs)

  • -enable-stub-only configure option (no libunbound dependency)

Features (& implementation)

  • Both stub and full recursive modes

(recusive by default)

– Full recursive via libunbound

  • Delivers validated DNSSEC even in stub mode

(off by default)

– libldns still (but only) used for

ldns_verify_rrsig() & ldns_rr_compare_ds_dnskey()

– Plan to lift those out before coming major release

  • Resolves names and gives fine-grained access to the response

with a response dict type:

– Easy to inspect: getdns_pretty_print_dict()

  • getdns_print_json_dict()
  • getdns_print_json_list()

– Maps well to popular modern scripting languages – Have a look at https://getdnsapi.net/query.html

slide-43
SLIDE 43

A new stub resolver – vBSDcon 2015 43/113 Willem Toorop (NLnet Labs)

Features (& implementation)

DNSSEC extensions

  • On a per query basis by setting extensions
  • dnssec_return_status

– Returns security assertion. Omits bogus answers

– { # This is the response object "replies_tree": [ { # This is the first reply "dnssec_status": GETDNS_DNSSEC_INSECURE, – "dnssec_status" can be GETDNS_DNSSEC_SECURE, GETDNS_DNSSEC_INSECURE or GETDNS_DNSSEC_INDETERMINATE

  • void getdns_context_set_return_dnssec_status(context, enable);
slide-44
SLIDE 44

A new stub resolver – vBSDcon 2015 44/113 Willem Toorop (NLnet Labs)

Features (& implementation)

DNSSEC extensions

  • dnssec_return_only_secure

(The DANE extension)

– Returns security assertion. Omits bogus and insecure answers

– { # This is the response object "replies_tree": [], "status": GETDNS_RESPSTATUS_NO_SECURE_ANSWERS,

– Or "status": GETDNS_RESPSTATUS_ALL_BOGUS_ANSWERS

slide-45
SLIDE 45

A new stub resolver – vBSDcon 2015 45/113 Willem Toorop (NLnet Labs)

Features (& implementation)

DNSSEC extensions

  • dnssec_return_validation_chain

– { # Response object "validation_chain": [ { "name" : <bindata for .>, "type": GETDNS_RRTYPE_DNSKEY, ... }, { "name" : <bindata for .>, "type": GETDNS_RRTYPE_DNSKEY, ... }, { "name" : <bindata for .>, "type": GETDNS_RRTYPE_RRSIG, "rdata": { "signers_name": <bindata for .>, "type_covered": GETDNS_RRTYPE_DNSKEY, ... }, ... }, { "name" : <bindata for net.>, "type": GETDNS_RRTYPE_DS, ... }, { "name" : <bindata for net.>, "type": GETDNS_RRTYPE_RRSIG, "rdata": { "signers_name": <bindata for .>, "type_covered": GETDNS_RRTYPE_DS, ... }, ... },

  • Can be combined with dnssec_return_status and dnssec_return_only_secure
  • No replies omitted! Only now “dnssec_status” can be GETDNS_DNSSEC_BOGUS
slide-46
SLIDE 46

A new stub resolver – vBSDcon 2015 46/113 Willem Toorop (NLnet Labs)

  • Asynchronous modus operandi is the default

– From specification section 1.8: ... there is no standard method to set the event base in the DNS API: those are all added as extensions ... ... Each implementation of the DNS API will specify an extension function that tells the DNS context which event base is being used. – We have provided functions for: libevent, libev, libuv – Or without extension: getdns_context_run()

Features (& implementation)

slide-47
SLIDE 47

A new stub resolver – vBSDcon 2015 47/113 Willem Toorop (NLnet Labs)

  • Asynchronous modus operandi is the default

– From specification section 1.8: ... there is no standard method to set the event base in the DNS API: those are all added as extensions ... ... Each implementation of the DNS API will specify an extension function that tells the DNS context which event base is being used. – We have provided functions for: libevent, libev, libuv – Or without extension: getdns_context_run()

  • Set custom memory management functions

– For example for regions – Beware of heartbleed!

Features (& implementation)

slide-48
SLIDE 48

A new stub resolver – vBSDcon 2015 48/113 Willem Toorop (NLnet Labs)

  • Asynchronous modus operandi is the default

– From specification section 1.8: ... there is no standard method to set the event base in the DNS API: those are all added as extensions ... ... Each implementation of the DNS API will specify an extension function that tells the DNS context which event base is being used. – We have provided functions for: libevent, libev, libuv – Or without extension: getdns_context_run()

  • Set custom memory management functions

– For example for regions – Beware of heartbleed!

  • Hook your app into getdns

– Hook into the applications native event base ( nodejs bindings & iOS grand central dispatch POC example )

Features (& implementation)

slide-49
SLIDE 49

A new stub resolver – vBSDcon 2015 49/113 Willem Toorop (NLnet Labs)

Features (& implementation)

hop-by-hop communication options (for stub)

  • add_opt_parameters extension

– To set arbitrary EDNS0 options – Implement DNS cookies with the library

slide-50
SLIDE 50

A new stub resolver – vBSDcon 2015 50/113 Willem Toorop (NLnet Labs)

Features (& implementation)

hop-by-hop communication options (for stub)

  • add_opt_parameters extension

– To set arbitrary EDNS0 options – Implement DNS cookies with the library

  • DNS cookies by the library
  • -enable-draft-edns-cookies
slide-51
SLIDE 51

A new stub resolver – vBSDcon 2015 51/113 Willem Toorop (NLnet Labs)

Features (& implementation)

hop-by-hop communication options (for stub)

  • add_opt_parameters extension

– To set arbitrary EDNS0 options – Implement DNS cookies with the library

  • DNS cookies by the library
  • -enable-draft-edns-cookies
  • TCP Fast Open (RFC 7413)
  • -enable-tcp-fastopen
slide-52
SLIDE 52

A new stub resolver – vBSDcon 2015 52/113 Willem Toorop (NLnet Labs)

Features (& implementation)

hop-by-hop communication options (for stub)

  • add_opt_parameters extension

– To set arbitrary EDNS0 options – Implement DNS cookies with the library

  • DNS cookies by the library
  • -enable-draft-edns-cookies
  • TCP Fast Open (RFC 7413)
  • -enable-tcp-fastopen
  • Setting of “tried in turn” transport lists

– GETDNS_TRANSPORT_UDP – GETDNS_TRANSPORT_TCP – GETDNS_TRANSPORT_TLS (https://tools.ietf.org/html/draft-ietf-dprive-start-tls-for-dns-01)

slide-53
SLIDE 53

A new stub resolver – vBSDcon 2015 53/113 Willem Toorop (NLnet Labs)

Features (& implementation)

hop-by-hop communication options (for stub)

  • add_opt_parameters extension

– To set arbitrary EDNS0 options – Implement DNS cookies with the library

  • DNS cookies by the library
  • -enable-draft-edns-cookies
  • TCP Fast Open (RFC 7413)
  • -enable-tcp-fastopen
  • Setting of “tried in turn” transport lists

– GETDNS_TRANSPORT_UDP – GETDNS_TRANSPORT_TCP – GETDNS_TRANSPORT_TLS (https://tools.ietf.org/html/draft-ietf-dprive-start-tls-for-dns-01) – getdns_context_set_dns_transport_list();

  • Special Cookies/TCP/TLS only open resolver for experimentation

available on 2a04:b900:0:100::38 and 185.49.141.38

slide-54
SLIDE 54

A new stub resolver – vBSDcon 2015 54/113 Willem Toorop (NLnet Labs)

Features (& implementation)

hop-by-hop communication options (for stub)

  • nsswitch module! by Theogene H. Bucuti, University of North Texas and

Gowri Visweswaran and Allison Mankin, Verisign Labs

slide-55
SLIDE 55

A new stub resolver – vBSDcon 2015 55/113 Willem Toorop (NLnet Labs)

Features (& implementation)

hop-by-hop communication options (for stub)

  • nsswitch module! by Theogene H. Bucuti, University of North Texas and

Gowri Visweswaran and Allison Mankin, Verisign Labs

slide-56
SLIDE 56

A new stub resolver – vBSDcon 2015 56/113 Willem Toorop (NLnet Labs)

Features (& implementation)

hop-by-hop communication options (for stub)

  • nsswitch module! by Theogene H. Bucuti, University of North Texas and

Gowri Visweswaran and Allison Mankin, Verisign Labs

slide-57
SLIDE 57

A new stub resolver – vBSDcon 2015 57/113 Willem Toorop (NLnet Labs)

Features (& implementation)

hop-by-hop communication options (for stub)

  • nsswitch module! by Theogene H. Bucuti, University of North Texas and

Gowri Visweswaran and Allison Mankin, Verisign Labs

Reuse context to reuse statefull transport sessions Reuse context to reuse statefull transport sessions

slide-58
SLIDE 58

A new stub resolver – vBSDcon 2015 58/113 Willem Toorop (NLnet Labs)

Bindings

  • nodejs by Neel Goyal

(integrated with native async event loop)

  • https://github.com/getdnsapi/getdns-node
  • python by Melinda Shore

https://github.com/getdnsapi/getdns-python-bindings

  • java by Vinay Soni, Prithvi Ranganath and Sanjay Mahurpawar

https://github.com/getdnsapi/getdns-java-bindings

  • php by Scott Hollenbeck

https://github.com/getdnsapi/getdns-php-bindings

slide-59
SLIDE 59

A new stub resolver – vBSDcon 2015 59/113 Willem Toorop (NLnet Labs)

Examplequery

full recursion

from getdns import * ctx = Context() ext = { "dnssec_return_only_secure": EXTENSION_TRUE } res = ctx.general( ’_443._tcp.getdnsapi.net’, RRTYPE_TLSA, ext) if res[’status’] == RESPSTATUS_GOOD: # Process TLSA RRs Recursive Resolver

net . getdnsapi

Authoritatives

net NS net DS net DNSKEY _443._tcp.getdnsapi.net TLSA net DNSKEY getdnsapi.net NS getdnsapi.net DS getdnsapi.net DNSKEY _443._tcp.getdnsapi.net TLSA

Application OS

_443._tcp.getdnsapi.net TLSA getdnsapi.net DNSKEY _443._tcp.getdnsapi.net TLSA

  • s

slide-60
SLIDE 60

A new stub resolver – vBSDcon 2015 60/113 Willem Toorop (NLnet Labs)

Examplequery

stub mode

from getdns import * ctx = Context() ctx.resolution_type = RESOLUTION_STUB ext = { "dnssec_return_only_secure": EXTENSION_TRUE } res = ctx.general( ’_443._tcp.getdnsapi.net’, RRTYPE_TLSA, ext) if res[’status’] == RESPSTATUS_GOOD: # Process TLSA RRs

net . getdnsapi

Authoritatives

_443._tcp.getdnsapi.net TLSA net NS net DS net DNSKEY _443._tcp.getdnsapi.net TLSA net DNSKEY getdnsapi.net NS getdnsapi.net DS getdnsapi.net DNSKEY _443._tcp.getdnsapi.net TLSA getdnsapi.net DNSKEY _443._tcp.getdnsapi.net TLSA

Application OS

Recursive Resolver

_443._tcp.getdnsapi.net TLSA getdnsapi.net DNSKEY _443._tcp.getdnsapi.net TLSA

  • s

DNSSEC Aware

slide-61
SLIDE 61

A new stub resolver – vBSDcon 2015 61/113 Willem Toorop (NLnet Labs)

Examplequery

Fall back

from getdns import * ctx = Context() ctx.resolution_type = RESOLUTION_STUB ext = { "dnssec_return_only_secure": EXTENSION_TRUE } res = ctx.general(’_443._tcp.getdnsapi.net’, RRTYPE_TLSA, ext) if res[’status’] == RESPSTATUS_ALL_BOGUS_ANSWERS: ctx.resolution_type = RESOLUTION_RECURSING res = ctx.general(’_443._tcp.getdnsapi.net’, RRTYPE_TLSA, ext) if res[’status’] == RESPSTATUS_GOOD: # Process TLSA Rrs

slide-62
SLIDE 62

A new stub resolver – vBSDcon 2015 62/113 Willem Toorop (NLnet Labs)

Examplequery

Fall back

from getdns import * ctx = Context() ctx.resolution_type = RESOLUTION_STUB ext = { "dnssec_return_only_secure": EXTENSION_TRUE } res = ctx.general(’_443._tcp.getdnsapi.net’, RRTYPE_TLSA, ext) if res[’status’] == RESPSTATUS_ALL_BOGUS_ANSWERS: ctx.resolution_type = RESOLUTION_RECURSING res = ctx.general(’_443._tcp.getdnsapi.net’, RRTYPE_TLSA, ext) if res[’status’] == RESPSTATUS_GOOD: # Process TLSA Rrs

See also : https://tools.ietf.org/html/draft-ietf-dnsop-dnssec-roadblock-avoidance And : Discovery method for a DNSSEC validating stub resolver, Xavier Torrent Gorjón, University of Amsterdam, July 2015 https://nlnetlabs.nl/downloads/publications/os3-2015-rp2-xavier-torrent-gorjon.pdf

slide-63
SLIDE 63

A new stub resolver – vBSDcon 2015 63/113 Willem Toorop (NLnet Labs)

Examplequery

Fall back

from getdns import * ctx = Context() ctx.resolution_type = RESOLUTION_STUB ext = { "dnssec_return_only_secure": EXTENSION_TRUE } res = ctx.general(’_443._tcp.getdnsapi.net’, RRTYPE_TLSA, ext) if res[’status’] == RESPSTATUS_ALL_BOGUS_ANSWERS: ctx.resolution_type = RESOLUTION_RECURSING res = ctx.general(’_443._tcp.getdnsapi.net’, RRTYPE_TLSA, ext) if res[’status’] == RESPSTATUS_GOOD: # Process TLSA Rrs

See also : https://tools.ietf.org/html/draft-ietf-dnsop-dnssec-roadblock-avoidance And : Discovery method for a DNSSEC validating stub resolver, Xavier Torrent Gorjón, University of Amsterdam, July 2015 https://nlnetlabs.nl/downloads/publications/os3-2015-rp2-xavier-torrent-gorjon.pdf

slide-64
SLIDE 64

A new stub resolver – vBSDcon 2015 64/113 Willem Toorop (NLnet Labs)

Examplequery

Fall back

from getdns import * ctx = Context() ctx.resolution_type = RESOLUTION_STUB ext = { "dnssec_return_only_secure": EXTENSION_TRUE } res = ctx.general(’_443._tcp.getdnsapi.net’, RRTYPE_TLSA, ext) if res[’status’] == RESPSTATUS_ALL_BOGUS_ANSWERS: ctx.resolution_type = RESOLUTION_RECURSING res = ctx.general(’_443._tcp.getdnsapi.net’, RRTYPE_TLSA, ext) if res[’status’] == RESPSTATUS_GOOD: # Process TLSA Rrs

See also : https://tools.ietf.org/html/draft-ietf-dnsop-dnssec-roadblock-avoidance And : Discovery method for a DNSSEC validating stub resolver, Xavier Torrent Gorjón, University of Amsterdam, July 2015 https://nlnetlabs.nl/downloads/publications/os3-2015-rp2-xavier-torrent-gorjon.pdf Measurements done at > 8000 RIPE ATLAS probes, +- 10.000 results 64.71% is able to deliver verifiable positive answer 55.67% is able to deliver verifiable negative answer 29.51% is able to deliver verifiable wildcard answer Measurements done at > 8000 RIPE ATLAS probes, +- 10.000 results 64.71% is able to deliver verifiable positive answer 55.67% is able to deliver verifiable negative answer 29.51% is able to deliver verifiable wildcard answer

slide-65
SLIDE 65

A new stub resolver – vBSDcon 2015 65/113 Willem Toorop (NLnet Labs)

Examplequery

Fall back

from getdns import * ctx = Context() ctx.resolution_type = RESOLUTION_STUB ext = { "dnssec_return_only_secure": EXTENSION_TRUE } res = ctx.general(’_443._tcp.getdnsapi.net’, RRTYPE_TLSA, ext) if res[’status’] == RESPSTATUS_ALL_BOGUS_ANSWERS: ctx.resolution_type = RESOLUTION_RECURSING res = ctx.general(’_443._tcp.getdnsapi.net’, RRTYPE_TLSA, ext) if res[’status’] == RESPSTATUS_GOOD: # Process TLSA Rrs

See also : https://tools.ietf.org/html/draft-ietf-dnsop-dnssec-roadblock-avoidance And : Discovery method for a DNSSEC validating stub resolver, Xavier Torrent Gorjón, University of Amsterdam, July 2015 https://nlnetlabs.nl/downloads/publications/os3-2015-rp2-xavier-torrent-gorjon.pdf Query for an A record to echo.v4.nlnetlabs.nl. Server replies with the IP of the recursive resolver! 80% is able to deliver verifiable positive answer Query for an A record to echo.v4.nlnetlabs.nl. Server replies with the IP of the recursive resolver! 80% is able to deliver verifiable positive answer

slide-66
SLIDE 66

A new stub resolver – vBSDcon 2015 66/113 Willem Toorop (NLnet Labs)

Examplequery

Fall back

from getdns import * ctx = Context() ctx.resolution_type = RESOLUTION_STUB ext = { "dnssec_return_only_secure": EXTENSION_TRUE } res = ctx.general(’_443._tcp.getdnsapi.net’, RRTYPE_TLSA, ext) if res[’status’] == RESPSTATUS_ALL_BOGUS_ANSWERS: ctx.resolution_type = RESOLUTION_RECURSING res = ctx.general(’_443._tcp.getdnsapi.net’, RRTYPE_TLSA, ext) if res[’status’] == RESPSTATUS_GOOD: # Process TLSA Rrs

  • Roadblock avoidance extension? Nice to have for the nsswitch module!
slide-67
SLIDE 67

A new stub resolver – vBSDcon 2015 67/113 Willem Toorop (NLnet Labs)

Examplequery

Fall back

from getdns import * ctx = Context() ctx.resolution_type = RESOLUTION_STUB ext = { "dnssec_return_only_secure": EXTENSION_TRUE } res = ctx.general(’_443._tcp.getdnsapi.net’, RRTYPE_TLSA, ext) if res[’status’] == RESPSTATUS_ALL_BOGUS_ANSWERS: ctx.resolution_type = RESOLUTION_RECURSING res = ctx.general(’_443._tcp.getdnsapi.net’, RRTYPE_TLSA, ext) if res[’status’] == RESPSTATUS_GOOD: # Process TLSA Rrs

  • Roadblock avoidance extension? Nice to have for the nsswitch module!
  • Alternatively bypass DNS network operation completely with:

https://tools.ietf.org/html/draft-shore-tls-dnssec-chain-extension

slide-68
SLIDE 68

A new stub resolver – vBSDcon 2015 68/113 Willem Toorop (NLnet Labs)

Examplequery

Fall back

from getdns import * ctx = Context() ctx.resolution_type = RESOLUTION_STUB ext = { "dnssec_return_only_secure": EXTENSION_TRUE } res = ctx.general(’_443._tcp.getdnsapi.net’, RRTYPE_TLSA, ext) if res[’status’] == RESPSTATUS_ALL_BOGUS_ANSWERS: ctx.resolution_type = RESOLUTION_RECURSING res = ctx.general(’_443._tcp.getdnsapi.net’, RRTYPE_TLSA, ext) if res[’status’] == RESPSTATUS_GOOD: # Process TLSA Rrs

  • Roadblock avoidance extension? Nice to have for the nsswitch module!
  • Alternatively bypass DNS network operation completely with:

https://tools.ietf.org/html/draft-shore-tls-dnssec-chain-extension

slide-69
SLIDE 69

A new stub resolver – vBSDcon 2015 69/113 Willem Toorop (NLnet Labs)

Examplequery

Fall back

from getdns import * ctx = Context() ctx.resolution_type = RESOLUTION_STUB ext = { "dnssec_return_only_secure": EXTENSION_TRUE } res = ctx.general(’_443._tcp.getdnsapi.net’, RRTYPE_TLSA, ext) if res[’status’] == RESPSTATUS_ALL_BOGUS_ANSWERS: ctx.resolution_type = RESOLUTION_RECURSING res = ctx.general(’_443._tcp.getdnsapi.net’, RRTYPE_TLSA, ext) if res[’status’] == RESPSTATUS_GOOD: # Process TLSA Rrs

  • Roadblock avoidance extension? Nice to have for the nsswitch module!
  • Alternatively bypass DNS network operation completely with:

https://tools.ietf.org/html/draft-shore-tls-dnssec-chain-extension

  • (good application of the dnssec_return_validation_chain extension!)
slide-70
SLIDE 70

A new stub resolver – vBSDcon 2015 70/113 Willem Toorop (NLnet Labs)

Examplequery

process records

# Correctly query and process DANE records if res['status'] == RESPSTATUS_GOOD: # Process TLSA Rrs tlsas = [ answer for reply in res['replies_tree'] for answer in reply['answer'] if answer[’type’] == RRTYPE_TLSA ] # Setup TLS only if the remote certificate (or CA) # matches one of the TLSA RRs. elif res['status'] == RESPSTATUS_ALL_TIMEOUT or \ res['status'] == RESPSTATUS_ALL_BOGUS_ANSWERS: # DON'T EVEN TRY! else: assert(res['status'] == RESPSTATUS_NO_SECURE_ANSWERS) # Conventional PKIX without DANE processing

slide-71
SLIDE 71

A new stub resolver – vBSDcon 2015 71/113 Willem Toorop (NLnet Labs)

C function primitives

Async lookups

  • context contains configuration parameters

– Stub or recursive modus operandi, timeout values, root-hints, forwarders, trust anchor, search path (+ how to evaluate (not implemented yet) etc.)

  • context contains the resolver cache

(i.e. libunbound context)

getdns_return_t getdns_general( getdns_context *context, const char *name, uint16_t request_type, getdns_dict *extensions, void *userarg, getdns_transaction_t *transaction_id, getdns_callback_t callbackfn );

slide-72
SLIDE 72

A new stub resolver – vBSDcon 2015 72/113 Willem Toorop (NLnet Labs)

C function primitives

Async lookups

  • context contains configuration parameters
  • name and request_type the name and type to lookup

getdns_return_t getdns_general( getdns_context *context, const char *name, uint16_t request_type, getdns_dict *extensions, void *userarg, getdns_transaction_t *transaction_id, getdns_callback_t callbackfn );

slide-73
SLIDE 73

A new stub resolver – vBSDcon 2015 73/113 Willem Toorop (NLnet Labs)

C function primitives

Async lookups

  • context contains configuration parameters
  • name and request_type the name and type to lookup
  • extensions additional parameters specific for this lookup

– return_both_v4_and_v6, specify_class, dnssec_return_status, dnssec_return_only_secure, dnssec_return_validation_chain – add_opt_parameter getdns_return_t getdns_general( getdns_context *context, const char *name, uint16_t request_type, getdns_dict *extensions, void *userarg, getdns_transaction_t *transaction_id, getdns_callback_t callbackfn );

slide-74
SLIDE 74

A new stub resolver – vBSDcon 2015 74/113 Willem Toorop (NLnet Labs)

C function primitives

Async lookups

  • context contains configuration parameters
  • name and request_type the name and type to lookup
  • extensions additional parameters specific for this lookup
  • userarg is passed in on the call to callbackfn
  • transaction_id is set to a unique value that is also

passed in on the call to callbackfn

getdns_return_t getdns_general( getdns_context *context, const char *name, uint16_t request_type, getdns_dict *extensions, void *userarg, getdns_transaction_t *transaction_id, getdns_callback_t callbackfn );

slide-75
SLIDE 75

A new stub resolver – vBSDcon 2015 75/113 Willem Toorop (NLnet Labs)

C function primitives

Async lookups

getdns_return_t getdns_general( getdns_context *context, const char *name, uint16_t request_type, getdns_dict *extensions, void *userarg, getdns_transaction_t *transaction_id, getdns_callback_t callbackfn ); typedef void (*getdns_callback_t)( getdns_context *context, getdns_callback_type_t callback_type, getdns_dict *response, void *userarg, getdns_transaction_t transaction_id ); // callback_type = complete, cancel, timeout or error

slide-76
SLIDE 76

A new stub resolver – vBSDcon 2015 76/113 Willem Toorop (NLnet Labs)

C function primitives

Synchronous lookups

getdns_return_t getdns_general( getdns_context *context, const char *name, uint16_t request_type, getdns_dict *extensions, void *userarg, getdns_transaction_t *transaction_id, getdns_callback_t callbackfn ); getdns_return_t getdns_general_sync( getdns_context *context, const char *name, uint16_t request_type, getdns_dict *extensions, getdns_dict **response );

slide-77
SLIDE 77

A new stub resolver – vBSDcon 2015 77/113 Willem Toorop (NLnet Labs)

C function primitives

Address lookups

getdns_return_t getdns_address( getdns_context *context, const char *name, getdns_dict *extensions, void *userarg, getdns_transaction_t *transaction_id, getdns_callback_t callbackfn );

  • getdns_address also lookups in other name systems

– local files, WINS, mDNS, NIS (only local files implemented)

  • getdns_address returns both IPv4 and IPv6

– like when the return_both_v4_and_v6 extension is set

slide-78
SLIDE 78

A new stub resolver – vBSDcon 2015 78/113 Willem Toorop (NLnet Labs)

C function primitives

Reverse lookups

getdns_return_t getdns_hostname( getdns_context *context, getdns_dict *address, getdns_dict *extensions, void *userarg, getdns_transaction_t *transaction_id, getdns_callback_t callbackfn );

  • With address: { "address_type": <bindata of "IPv4">

"address_data": <bindata for 185.49.141.37> }

will lookup 37.141.49.185.in-addr.arpa PTR

slide-79
SLIDE 79

A new stub resolver – vBSDcon 2015 79/113 Willem Toorop (NLnet Labs)

typedef struct getdns_dict getdns_dict; typedef struct getdns_list getdns_list; typedef struct getdns_bindata { size_t size; uint8_t *data; } getdns_bindata;

  • Used to represent extensions, addresses and response objects

Data structures

slide-80
SLIDE 80

A new stub resolver – vBSDcon 2015 80/113 Willem Toorop (NLnet Labs)

typedef struct getdns_dict getdns_dict; typedef struct getdns_list getdns_list; typedef struct getdns_bindata { size_t size; uint8_t *data; } getdns_bindata;

  • Used to represent extensions, addresses and response objects
  • char *getdns_pretty_print_dict(const getdns_dict *dict);

{ "return_both_v4_and_v6": GETDNS_EXTENSION_TRUE, "add_opt_parameter": { “maximum_udp_payload_size”: 1232, “do_bit”: 1 “options”: [ { “option_code”: 10 “option_data”: <bindata of 0x96bd16564dfb5f5e > } ] } } { "return_both_v4_and_v6": GETDNS_EXTENSION_TRUE, "add_opt_parameter": { “maximum_udp_payload_size”: 1232, “do_bit”: 1 “options”: [ { “option_code”: 10 “option_data”: <bindata of 0x96bd16564dfb5f5e > } ] } }

Extension dict

Data structures

slide-81
SLIDE 81

A new stub resolver – vBSDcon 2015 81/113 Willem Toorop (NLnet Labs)

typedef struct getdns_dict getdns_dict; typedef struct getdns_list getdns_list; typedef struct getdns_bindata { size_t size; uint8_t *data; } getdns_bindata;

  • Used to represent extensions, addresses and response objects

{ "answer_type": GETDNS_NAMETYPE_DNS, "status": GETDNS_RESPSTATUS_GOOD, "canonical_name": <bindata of "www.getdnsapi.net.">, "just_address_answers": [ { "address_data": <bindata for 185.49.141.37>, "address_type": <bindata of "IPv4"> } ], "replies_full": [ <bindata of 0x00008180000100020004...> ], "replies_tree": [ { … first reply … } ], { "answer_type": GETDNS_NAMETYPE_DNS, "status": GETDNS_RESPSTATUS_GOOD, "canonical_name": <bindata of "www.getdnsapi.net.">, "just_address_answers": [ { "address_data": <bindata for 185.49.141.37>, "address_type": <bindata of "IPv4"> } ], "replies_full": [ <bindata of 0x00008180000100020004...> ], "replies_tree": [ { … first reply … } ],

Response object dict

Data structures

slide-82
SLIDE 82

A new stub resolver – vBSDcon 2015 82/113 Willem Toorop (NLnet Labs)

Data structures

Accessor functions

  • reading getdns_dicts:

getdns_return_t getdns_dict_get_dict( const getdns_dict *dict, const char *name, getdns_dict **answer); getdns_return_t getdns_dict_get_list( const getdns_dict *dict, const char *name, getdns_list **answer); getdns_return_t getdns_dict_get_bindata( const getdns_dict *dict, const char *name, getdns_bindata **answer); getdns_return_t getdns_dict_get_int( const getdns_dict *dict, const char *name, uint32_t *answer) getdns_return_t getdns_dict_get_data_type( const getdns_dict *dict, const char *name, getdns_data_type *answer); getdns_return_t getdns_dict_get_names( const getdns_dict *dict, getdns_list **answer);

slide-83
SLIDE 83

A new stub resolver – vBSDcon 2015 83/113 Willem Toorop (NLnet Labs)

Data structures

Accessor functions

  • reading getdns_lists:

getdns_return_t getdns_list_get_dict( const getdns_list *list, size_t index, getdns_dict **answer); getdns_return_t getdns_list_get_list( const getdns_list *list, size_t index, getdns_list **answer); getdns_return_t getdns_list_get_bindata( const getdns_list *list, size_t index, getdns_bindata **answer); getdns_return_t getdns_list_get_int( const getdns_list *list, size_t index, uint32_t *answer); getdns_return_t getdns_list_get_data_type( const getdns_list *list, size_t index, getdns_data_type *answer); getdns_return_t getdns_list_get_length( const getdns_list *this_list, size_t *answer);

slide-84
SLIDE 84

A new stub resolver – vBSDcon 2015 84/113 Willem Toorop (NLnet Labs)

Data structures

Accessor functions

  • Creating/writing to getdns_dicts:

getdns_dict * getdns_dict_create(); getdns_return_t getdns_dict_set_dict( getdns_dict *dict, const char *name, const getdns_dict *child_dict); getdns_return_t getdns_dict_set_list( getdns_dict *dict, const char *name, const getdns_list *child_list); getdns_return_t getdns_dict_set_bindata( getdns_dict *dict, const char *name, const getdns_bindata *child_bindata); getdns_return_t getdns_dict_set_int( getdns_dict *dict, const char *name, uint32_t child_uint32) void getdns_dict_destroy(getdns_dict *dict);

slide-85
SLIDE 85

A new stub resolver – vBSDcon 2015 85/113 Willem Toorop (NLnet Labs)

Data structures

Accessor functions

if ((r = getdns_address_sync(ctx, "getdnsapi.net", ext, &resp))) return r; else if ((r = getdns_dict_get_list(resp, "just_address_answers", &jaa))) return r; else if ((r = getdns_list_get_dict(jaa, 0, &addr_dict))) return r; else if ((r = getdns_list_get_bindata(addr_dict, "address_data", &addr))) return r; { "answer_type": GETDNS_NAMETYPE_DNS, "status": GETDNS_RESPSTATUS_GOOD, "canonical_name": <bindata of "www.getdnsapi.net.">, "just_address_answers": [ { "address_data": <bindata for 185.49.141.37>, "address_type": <bindata of "IPv4"> } ], "replies_full": [ <bindata of 0x00008180000100020004...> ], "replies_tree": [ { … first reply … } ], { "answer_type": GETDNS_NAMETYPE_DNS, "status": GETDNS_RESPSTATUS_GOOD, "canonical_name": <bindata of "www.getdnsapi.net.">, "just_address_answers": [ { "address_data": <bindata for 185.49.141.37>, "address_type": <bindata of "IPv4"> } ], "replies_full": [ <bindata of 0x00008180000100020004...> ], "replies_tree": [ { … first reply … } ],

Response object dict

slide-86
SLIDE 86

A new stub resolver – vBSDcon 2015 86/113 Willem Toorop (NLnet Labs)

Data structures

Accessor functions

  • Not so bad in other languages
  • Python

resp = ctx.address('getdnsapi.net') addr = resp.just_address_answers[0]['address_data']

  • Nodejs

function callback(err, resp) { var addr = resp.just_address_answers[0].address_data; } ctx.getAddress('getdnsapi.net', callback); if ((r = getdns_address_sync(ctx, "getdnsapi.net", ext, &resp))) return r; else if ((r = getdns_dict_get_list(resp, "just_address_answers", &jaa))) return r; else if ((r = getdns_list_get_dict(jaa, 0, &addr_dict))) return r; else if ((r = getdns_list_get_bindata(addr_dict, "address_data", &addr))) return r;

slide-87
SLIDE 87

A new stub resolver – vBSDcon 2015 87/113 Willem Toorop (NLnet Labs)

Data structures

Accessor functions

  • Not so bad in other languages
  • The alternative would introduce a lot of new types:

– Python:

addr = resp.replies_tree[0]['answer'][0]['rdata']['ipv6_address']

– C

getdns_response *resp; getdns_reply *reply; getdns_rrs *rrs; getdns_rr *rrs; getdns_rdata *rdata; struct sockaddr_storage addr; if ((r = getdns_response_get_reply(resp, 0, &reply))) return r; else if ((r = getdns_reply_get_answer_section(reply, &rrs))) return r; else if ((r = getdns_rrs_get_rr(rrs, &rr))) return r; else if ((r = getdns_rr_get_rdata(rr, &rdata))) return r; else if ((r = getdns_rdata_get_rdatafield_address(rdata, 0, &addr))) return r;

slide-88
SLIDE 88

A new stub resolver – vBSDcon 2015 88/113 Willem Toorop (NLnet Labs)

Data structures

Accessor functions

  • Not so bad in other languages
  • The alternative would introduce a lot of new types.
  • With current approach, the library can easily grow
  • New rdata fields or new extensions without a new API

(dns cookies, roadblock avoidance, client subnet, etc.)

slide-89
SLIDE 89

A new stub resolver – vBSDcon 2015 89/113 Willem Toorop (NLnet Labs)

Data structures

Accessor functions

  • Not so bad in other languages
  • The alternative would introduce a lot of new types.
  • With current approach, the library can easily grow
  • New rdata fields or new extensions without a new API

(dns cookies, roadblock avoidance, client subnet, etc.)

  • Just in time parsing of wireformat data on the roadmap

( internally already iterator like accessor types for wireformat data ; they will be part of ldns2 too )

slide-90
SLIDE 90

A new stub resolver – vBSDcon 2015 90/113 Willem Toorop (NLnet Labs)

  • Provide function pointers that getdns will use

to do memory & IO handling/management

Hook into getdns

slide-91
SLIDE 91

A new stub resolver – vBSDcon 2015 91/113 Willem Toorop (NLnet Labs)

Hook into getdns

Custom memory functions

  • Provide function pointers that getdns will use

to do memory & IO handling/management

getdns_return_t getdns_context_create(getdns_context ** context, int set_from_os); getdns_return_t getdns_context_create_with_memory_functions( getdns_context **context, int set_from_os, void *(*malloc) (size_t), void *(*realloc)(void *, size_t), void (*free) (void *) );

Hook into getdns

slide-92
SLIDE 92

A new stub resolver – vBSDcon 2015 92/113 Willem Toorop (NLnet Labs)

Hook into getdns

Custom memory functions

  • Provide function pointers that getdns will use

to do memory & IO handling/management

getdns_return_t getdns_context_create_with_extended_memory_functions( getdns_context **context, int set_from_os, void *userarg, void *(*malloc) (void *userarg, size_t), void *(*realloc)(void *userarg, void *, size_t), void (*free) (void *userarg, void *) );

slide-93
SLIDE 93

A new stub resolver – vBSDcon 2015 93/113 Willem Toorop (NLnet Labs)

Hook into getdns

Custom memory functions

  • Provide function pointers that getdns will use

to do memory & IO handling/management

getdns_return_t getdns_context_create_with_extended_memory_functions( getdns_context **context, int set_from_os, void *userarg, void *(*malloc) (void *userarg, size_t), void *(*realloc)(void *userarg, void *, size_t), void (*free) (void *userarg, void *) ); getdns_dict *getdns_dict_create_with_context( getdns_context *context ); getdns_list *getdns_list_create_with_context( getdns_context *context );

slide-94
SLIDE 94

A new stub resolver – vBSDcon 2015 94/113 Willem Toorop (NLnet Labs)

Hook into getdns

Custom memory functions

  • Provide function pointers that getdns will use

to do memory & IO handling/management

getdns_dict *getdns_dict_create_with_context( getdns_context *context ); getdns_dict *getdns_dict_create_with_memory_functions( void *(*malloc) (size_t), void *(*realloc)(void *, size_t), void (*free) (void *) ); getdns_dict *getdns_dict_create_with_extended_memory_functions( void *userarg, void *(*malloc) (void *userarg, size_t), void *(*realloc)(void *userarg, void *, size_t), void (*free) (void *userarg, void *) );

slide-95
SLIDE 95

A new stub resolver – vBSDcon 2015 95/113 Willem Toorop (NLnet Labs)

Hook into getdns

Custom event loop

  • Poor mans OOP

typedef struct getdns_eventloop_vmt getdns_eventloop_vmt; typedef struct getdns_eventloop { getdns_eventloop_vmt *vmt; /* object data here */ } getdns_eventloop; getdns_return_t getdns_context_set_eventloop( getdns_context* context, getdns_eventloop *eventloop);

<getdns_extra.h>

slide-96
SLIDE 96

A new stub resolver – vBSDcon 2015 96/113 Willem Toorop (NLnet Labs)

Hook into getdns

Custom event loop

  • Poor mans OOP

typedef struct getdns_eventloop_vmt getdns_eventloop_vmt; typedef struct getdns_eventloop { getdns_eventloop_vmt *vmt; /* object data here */ } getdns_eventloop; getdns_return_t getdns_context_set_eventloop( getdns_context* context, getdns_eventloop *eventloop); /* Virtual Method Table */ struct getdns_eventloop_vmt { void (*cleanup) (getdns_eventloop *this); getdns_return_t (*schedule)(getdns_eventloop *this, int fd, uint64_t timeout, getdns_eventloop_event *ev) getdns_return_t (*clear) (getdns_eventloop *this, getdns_eventloop_event *ev) void (*run) (getdns_eventloop *this); void (*run_once)(getdns_eventloop *this, int blocking); };

<getdns_extra.h>

slide-97
SLIDE 97

A new stub resolver – vBSDcon 2015 97/113 Willem Toorop (NLnet Labs)

  • Poor mans OOP

typedef struct getdns_eventloop_vmt getdns_eventloop_vmt; typedef struct getdns_eventloop { getdns_eventloop_vmt *vmt; /* object data here */ } getdns_eventloop; getdns_return_t getdns_context_set_eventloop( getdns_context* context, getdns_eventloop *eventloop); #define MAX_TIMEOUTS FD_SETSIZE /* Eventloop based on select */ typedef struct my_eventloop { getdns_eventloop base; getdns_eventloop_event *fd_events[FD_SETSIZE]; uint64_t fd_timeout_times[FD_SETSIZE]; getdns_eventloop_event *timeout_events[MAX_TIMEOUTS]; uint64_t timeout_times[MAX_TIMEOUTS]; } my_eventloop; my_eventloop my_loop; getdns_context_set_eventloop(context, &my_loop.base)

User program <getdns_extra.h>

Hook into getdns

Custom event loop

slide-98
SLIDE 98

A new stub resolver – vBSDcon 2015 98/113 Willem Toorop (NLnet Labs)

  • Poor mans OOP

typedef struct getdns_eventloop_vmt getdns_eventloop_vmt; typedef struct getdns_eventloop { getdns_eventloop_vmt *vmt; /* object data here */ } getdns_eventloop; getdns_return_t getdns_context_set_eventloop( getdns_context* context, getdns_eventloop *eventloop); #define MAX_TIMEOUTS FD_SETSIZE /* Eventloop based on select */ typedef struct my_eventloop { getdns_eventloop base; getdns_eventloop_event *fd_events[FD_SETSIZE]; uint64_t fd_timeout_times[FD_SETSIZE]; getdns_eventloop_event *timeout_events[MAX_TIMEOUTS]; uint64_t timeout_times[MAX_TIMEOUTS]; } my_eventloop; my_eventloop my_loop; getdns_context_set_eventloop(context, &my_loop.base)

User program <getdns_extra.h>

Hook into getdns

Custom event loop

Timeouts must be a set that may be modified during iteration Timeouts must be a set that may be modified during iteration

slide-99
SLIDE 99

A new stub resolver – vBSDcon 2015 99/113 Willem Toorop (NLnet Labs) #define MAX_TIMEOUTS FD_SETSIZE /* Eventloop based on select */ typedef struct my_eventloop { getdns_eventloop base; getdns_eventloop_event *fd_events[FD_SETSIZE]; uint64_t fd_timeout_times[FD_SETSIZE]; getdns_eventloop_event *timeout_events[MAX_TIMEOUTS]; uint64_t timeout_times[MAX_TIMEOUTS]; } my_eventloop; void my_eventloop_init(my_eventloop *loop) { static getdns_eventloop_vmt my_eventloop_vmt = { my_eventloop_cleanup, my_eventloop_schedule, my_eventloop_clear, NULL, NULL }; (void) memset(loop, 0, sizeof(my_eventloop)); loop->base.vmt = &my_eventloop_vmt; } my_eventloop my_loop; my_eventloop_init(&my_loop); getdns_context_set_eventloop(context, &my_loop.base)

Hook into getdns

Custom event loop

User program

slide-100
SLIDE 100

A new stub resolver – vBSDcon 2015 100/113 Willem Toorop (NLnet Labs) #define MAX_TIMEOUTS FD_SETSIZE /* Eventloop based on select */ typedef struct my_eventloop { getdns_eventloop base; getdns_eventloop_event *fd_events[FD_SETSIZE]; uint64_t fd_timeout_times[FD_SETSIZE]; getdns_eventloop_event *timeout_events[MAX_TIMEOUTS]; uint64_t timeout_times[MAX_TIMEOUTS]; } my_eventloop; void my_eventloop_init(my_eventloop *loop) { static getdns_eventloop_vmt my_eventloop_vmt = { my_eventloop_cleanup, my_eventloop_schedule, my_eventloop_clear, NULL, NULL }; (void) memset(loop, 0, sizeof(my_eventloop)); loop->base.vmt = &my_eventloop_vmt; } my_eventloop my_loop; my_eventloop_init(&my_loop); getdns_context_set_eventloop(context, &my_loop.base)

Hook into getdns

Custom event loop

User program

  • From specification section 1.8:

... Each implementation of the DNS API will specify an extension function that tells the DNS context which event base is being used.

  • libevent

Include : #include <getdns/getdns_ext_libevent.h> Use : getdns_extension_set_libevent_base(context, base); Link : -lgetdns -lgetdns_ext_event struct event_base base ∗ = event_base_new(); getdns_extension_set_libevent_base(context, base); getdns_address(context, ”getdnsapi.net”, 0, 0, 0, callback); event_base_dispatch(base); event_base_free(base);

  • From specification section 1.8:

... Each implementation of the DNS API will specify an extension function that tells the DNS context which event base is being used.

  • libevent

Include : #include <getdns/getdns_ext_libevent.h> Use : getdns_extension_set_libevent_base(context, base); Link : -lgetdns -lgetdns_ext_event struct event_base base ∗ = event_base_new(); getdns_extension_set_libevent_base(context, base); getdns_address(context, ”getdnsapi.net”, 0, 0, 0, callback); event_base_dispatch(base); event_base_free(base);

slide-101
SLIDE 101

A new stub resolver – vBSDcon 2015 101/113 Willem Toorop (NLnet Labs) #define MAX_TIMEOUTS FD_SETSIZE /* Eventloop based on select */ typedef struct my_eventloop { getdns_eventloop base; getdns_eventloop_event *fd_events[FD_SETSIZE]; uint64_t fd_timeout_times[FD_SETSIZE]; getdns_eventloop_event *timeout_events[MAX_TIMEOUTS]; uint64_t timeout_times[MAX_TIMEOUTS]; } my_eventloop; void my_eventloop_init(my_eventloop *loop) { static getdns_eventloop_vmt my_eventloop_vmt = { my_eventloop_cleanup, my_eventloop_schedule, my_eventloop_clear, NULL, NULL }; (void) memset(loop, 0, sizeof(my_eventloop)); loop->base.vmt = &my_eventloop_vmt; } my_eventloop my_loop; my_eventloop_init(&my_loop); getdns_context_set_eventloop(context, &my_loop.base)

Hook into getdns

Custom event loop

  • libevent

Include : #include <getdns/getdns_ext_libevent.h> Use : getdns_extension_set_libevent_base(context, base); Link : -lgetdns -lgetdns_ext_event

  • libev

Include : #include <getdns/getdns_ext_libev.h> Use : getdns_extension_set_libev_loop(context, loop); Link : -lgetdns -lgetdns_ext_ev

  • libuv

Include : #include <getdns/getdns_ext_libuv.h> Use : getdns_extension_set_libuv_loop(context, base); Link : -lgetdns -lgetdns_ext_uv

  • libevent

Include : #include <getdns/getdns_ext_libevent.h> Use : getdns_extension_set_libevent_base(context, base); Link : -lgetdns -lgetdns_ext_event

  • libev

Include : #include <getdns/getdns_ext_libev.h> Use : getdns_extension_set_libev_loop(context, loop); Link : -lgetdns -lgetdns_ext_ev

  • libuv

Include : #include <getdns/getdns_ext_libuv.h> Use : getdns_extension_set_libuv_loop(context, base); Link : -lgetdns -lgetdns_ext_uv

User program

slide-102
SLIDE 102

A new stub resolver – vBSDcon 2015 102/113 Willem Toorop (NLnet Labs) /* Virtual Method Table */ struct getdns_eventloop_vmt { void (*cleanup) (getdns_eventloop *this); getdns_return_t (*schedule)(getdns_eventloop *this, int fd, uint64_t timeout, getdns_eventloop_event *ev) getdns_return_t (*clear) (getdns_eventloop *this, getdns_eventloop_event *ev) void (*run) (getdns_eventloop *this); void (*run_once)(getdns_eventloop *this, int blocking); }; void my_eventloop_cleanup(my_eventloop *loop) { }

<getdns_extra.h> User program

Hook into getdns

Custom event loop

  • Destructor, called on

– getdns_context_destroy() – getdns_context_detach_eventloop() – getdns_context_set_eventloop()

slide-103
SLIDE 103

A new stub resolver – vBSDcon 2015 103/113 Willem Toorop (NLnet Labs) /* event data */ typedef void (*getdns_eventloop_callback)(void *userarg); typedef struct getdns_eventloop_event { void *userarg; getdns_eventloop_callback read_cb; getdns_eventloop_callback write_cb; getdns_eventloop_callback timeout_cb; /* Pointer to the underlying event */ void *ev; } getdns_eventloop_event; getdns_return_t my_eventloop_schedule(getdns_eventloop *loop, int fd, uint64_t timeout, getdns_eventloop_event *event) { my_eventloop *my_loop = (my_eventloop *)loop; assert(loop); assert(event); assert(fd < FD_SETSIZE); if (fd >= 0 && (event->read_cb || event->write_cb)) { assert(my_loop->fd_events[fd] == NULL);

<getdns_extra.h> User program

Hook into getdns

Custom event loop

slide-104
SLIDE 104

A new stub resolver – vBSDcon 2015 104/113 Willem Toorop (NLnet Labs) /* event data */ typedef void (*getdns_eventloop_callback)(void *userarg); typedef struct getdns_eventloop_event { void *userarg; getdns_eventloop_callback read_cb; getdns_eventloop_callback write_cb; getdns_eventloop_callback timeout_cb; /* Pointer to the underlying event */ void *ev; } getdns_eventloop_event; getdns_return_t my_eventloop_schedule(getdns_eventloop *loop, int fd, uint64_t timeout, getdns_eventloop_event *event) { my_eventloop *my_loop = (my_eventloop *)loop; if (fd >= 0 && (event->read_cb || event->write_cb)) { my_loop->fd_events[fd] = event; my_loop->fd_timeout_times[fd] = get_now_plus(timeout); event->ev = (void *) (intptr_t) fd + 1; return GETDNS_RETURN_GOOD; }

<getdns_extra.h> User program

Hook into getdns

Custom event loop

slide-105
SLIDE 105

A new stub resolver – vBSDcon 2015 105/113 Willem Toorop (NLnet Labs) getdns_return_t my_eventloop_schedule(getdns_eventloop *loop, int fd, uint64_t timeout, getdns_eventloop_event *event) { my_eventloop *my_loop = (my_eventloop *)loop; if (fd >= 0 && (event->read_cb || event->write_cb)) { my_loop->fd_events[fd] = event; my_loop->fd_timeout_times[fd] = get_now_plus(timeout); event->ev = (void *) (intptr_t) fd + 1; return GETDNS_RETURN_GOOD; } assert(event->timeout_cb && !event->read_cb && !event->write_cb); for (size_t i = 0; i < MAX_TIMEOUTS; i++) { if (my_loop->timeout_events[i] == NULL) { my_loop->timeout_events[i] = event; my_loop->timeout_times[i] = get_now_plus(timeout); event->ev = (void *) (intptr_t) i + 1; return GETDNS_RETURN_GOOD; } } return GETDNS_RETURN_GENERIC_ERROR; }

User program

Hook into getdns

Custom event loop

slide-106
SLIDE 106

A new stub resolver – vBSDcon 2015 106/113 Willem Toorop (NLnet Labs) getdns_return_t my_eventloop_clear(getdns_eventloop *loop, getdns_eventloop_event *event) { my_eventloop *my_loop = (my_eventloop *)loop; size_t i; i = (intptr_t)event->ev - 1; if (event->timeout_cb && !event->read_cb && !event->write_cb) { my_loop->timeout_events[i] = NULL; } else { my_loop->fd_events[i] = NULL; } event->ev = NULL; return GETDNS_RETURN_GOOD; }

User program

Hook into getdns

Custom event loop

slide-107
SLIDE 107

A new stub resolver – vBSDcon 2015 107/113 Willem Toorop (NLnet Labs) uint64_t now, timeout = (uint64_t)-1; size_t i; now = get_now_plus(0); for (i = 0; i < MAX_TIMEOUTS; i++) { if (!my_loop->timeout_events[i]) continue; if (now > my_loop->timeout_times[i]) my_timeout_cb(my_loop->timeout_events[i]); else if (my_loop->timeout_times[i] < timeout) timeout = my_loop->timeout_times[i]; }

User program

Hook into getdns

Custom event loop

Running the loop

slide-108
SLIDE 108

A new stub resolver – vBSDcon 2015 108/113 Willem Toorop (NLnet Labs) fd_set readfds, writefds; int fd, max_fd = -1; FD_ZERO(&readfds); FD_ZERO(&writefds); for (fd = 0; fd < FD_SETSIZE; fd++) { if (!my_loop->fd_events[fd]) continue; if (my_loop->fd_events[fd]->read_cb) FD_SET(fd, &readfds); if (my_loop->fd_events[fd]->write_cb) FD_SET(fd, &writefds); if (fd > max_fd) max_fd = fd; if (my_loop->fd_timeout_times[fd] < timeout) timeout = my_loop->fd_timeout_times[fd]; } if (max_fd == -1 && timeout == (uint64_t)-1) return;

User program

Hook into getdns

Custom event loop

Running the loop

slide-109
SLIDE 109

A new stub resolver – vBSDcon 2015 109/113 Willem Toorop (NLnet Labs) struct timeval tv; if (now > timeout) { tv.tv_sec = 0; tv.tv_usec = 0; } else { tv.tv_sec = (timeout - now) / 1000000; tv.tv_usec = (timeout - now) % 1000000; } if (select(max_fd + 1, &readfds, &writefds, NULL, &tv) < 0) { perror("select() failed"); exit(EXIT_FAILURE); }

User program

Hook into getdns

Custom event loop

Running the loop

slide-110
SLIDE 110

A new stub resolver – vBSDcon 2015 110/113 Willem Toorop (NLnet Labs) now = get_now_plus(0); for (fd = 0; fd < FD_SETSIZE; fd++) { if (my_loop->fd_events[fd] && my_loop->fd_events[fd]->read_cb && FD_ISSET(fd, &readfds)) my_read_cb(fd, my_loop->fd_events[fd]); if (my_loop->fd_events[fd] && my_loop->fd_events[fd]->write_cb && FD_ISSET(fd, &writefds)) my_write_cb(fd, my_loop->fd_events[fd]); if (my_loop->fd_events[fd] && my_loop->fd_events[fd]->timeout_cb && now > my_loop->fd_timeout_times[fd]) my_timeout_cb(my_loop->fd_events[fd]); i = fd; if (my_loop->timeout_events[i] && my_loop->timeout_events[i]->timeout_cb && now > my_loop->timeout_times[i]) my_timeout_cb(my_loop->timeout_events[i]); }

User program

Hook into getdns

Custom event loop

Running the loop

slide-111
SLIDE 111

A new stub resolver – vBSDcon 2015 111/113 Willem Toorop (NLnet Labs)

nodejs program

Hook into getdns

Custom event loop

var getdns = require('getdns'); function callback(err, result) { console.log(err ? Err : result.canonical_name + ': ' + JSON.stringify(result.just_address_answers)); } ctx = getdns.createContext(); ctx.getAddress('getdnsapi.net', callback); ctx.getAddress('verisignlabs.com', callback); ctx.getAddress('sinodun.com', callback); ctx.getAddress('nomountain.net', callback); ctx.getAddress('vbsdcon.com', callback); willem@bonobo:~/vbsdcon$ nodejs parallel.js getdnsapi.net.: [{"address_data":[42,4,185,0,0,0,1,0,0,0,0,0,0,0,0,55], … sinodun.com.: [{"address_data":[88,98,24,67],"address_type":"IPv4"}] vbsdcon.com.: [{"address_data":[69,58,186,114],"address_type":"IPv4"}] verisignlabs.com.: [{"address_data":[38,32,0,116,0,19,68,0,0,0,0,0,0,0,2 … nomountain.net.: [{"address_data":[38,7,242,152,0,5,16,75,0,0,0,0,11,128 …

Program output

slide-112
SLIDE 112

A new stub resolver – vBSDcon 2015 112/113 Willem Toorop (NLnet Labs)

Roadmap

  • Current release 0.3.3
  • More bindings (ruby (alpha), perl, lua, go (proposed))
  • More platforms (windows, android)
  • Before 1.0 (this year)

– No more dependency on ldns – Just-in-time parsing of response objects – The complete spec implemented

  • add_warning_for_bad_dns & add_call_debugging extensions
  • TSIG
  • After 1.0

– Multi-threading & multi-processes support – statefull session reuse

slide-113
SLIDE 113

A new stub resolver – vBSDcon 2015 113/113 Willem Toorop (NLnet Labs)

Security starts with a name

https://getdnsapi.net https://getdnsapi.net/spec.html https://getdnsapi.net/dist/getdns-0.3.3.tar.gz https://github.com/getdnsapi/getdns https://github.com/getdnsapi/getdns-node https://github.com/getdnsapi/getdns-python-bindings https://github.com/getdnsapi/getdns-java-bindings https://github.com/getdnsapi/getdns-php-bindings https://getdnsapi.net/mailman/listinfo/spec https://getdnsapi.net/mailman/listinfo/users Willem Toorop <willem@nlnetlabs.nl> website API spec latest tarball github repo node repo python repo java repo php repo API list users list me