curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

DOH: design notes: gathering additional host attributes

From: Niall O'Reilly via curl-library <curl-library_at_cool.haxx.se>
Date: Wed, 20 Nov 2019 15:57:54 +0000

Hello.

A host’s IPv4 or IPv6 address is needed in order to establish a connection.
If DOH is enabled, the function *Curl_doh()* is used to retrieve these
from the DNS. *Curl_doh()* has two dedicated “probe slots” for holding DOH
query state independently for each of the DNS QTYPEs, A and AAAA.

In some use cases (such as ESNI), additional host attributes, which may be
available from the DNS, are needed as connection parameters. Defining an
additional “probe slot” for each such attribute seems the simplest way to
hold the corresponding query state.

In order to avoid collisions where a slot is inadvertently used for more
than one purpose, it may be useful to assign symbolic names to the slot
positions. Defining these conditionally at build-time will obviate
keeping yet another registry of code-points in some header file.

The code snippets below show how I’m thinking of doing this.

/Niall

```
/* in lib/urldata.h */

/* ... */

enum doh_slots {
  /* Explicit values for first two symbols so as to match hard-coded
   * constants in existing code
   */
  DOH_PROBE_SLOT_IPADDR_V4 = 0, /* make 'V4' stand out for readability */
  DOH_PROBE_SLOT_IPADDR_V6 = 1, /* 'V6' likewise */

  /* Space here for (possibly build-specific) additional slot definitions */

#ifdef WANT_DOH_FOOBAR_TXT
  DOH_PROBE_SLOT_FOOBAR_TXT, /* for example */
#endif

#ifdef WANT_DOH_FOOBAR_SVCB
  DOH_PROBE_SLOT_FOOBAR_SVCB, /* another example */
#endif

  /* AFTER all slot definitions, establish how many we have */
  DOH_PROBE_SLOTS
};

/* ... */

struct dohdata {
  struct curl_slist *headers;
  struct dnsprobe probe[DOH_PROBE_SLOTS];
  unsigned int pending; /* still outstanding requests */
  const char *host;
  int port;
};

/* ... */
```

— Ends —

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2019-11-20