trusteddomainproject / OpenARC

Open source ARC implementation
BSD 2-Clause "Simplified" License
135 stars 45 forks source link

Added ability to use custom resolver #91

Open ghost opened 6 years ago

ghost commented 6 years ago

Hi Murray, I used this to override the internal use of libresolv and such to connect to PowerMTA's internal resolver, as well as to be able to provide test DNS responses.

Since we're really only initializing the resolver library, whatever it may be, once per ARC_LIB, I opted for a simple approach where I passed in the library handle.

Alternatively, we could instead pass in an arc_dns_init function pointer, but in this case I'd need to be able to pass in a "user data" pointer, as in

extern ARC_STAT arc_init_dns __P((ARC_LIB *, void* srv,
                  void *user,
                  void (*arc_dns_init) (void *user),
                  void (*arc_dns_close) (void *srv),
                  int (*arc_dns_start) (void *srv, int type,
                            unsigned char *query,
                            unsigned char *buf,
                            size_t buflen,
                            void **qh),
                 int (*arc_dns_cancel) (void *srv, void *qh),
                 int (*arc_dns_waitreply) (void *srv,
                               void *qh,
                               struct timeval *to,
                               size_t *bytes,
                               int *error,
                               int *dnssec)));
mskucherawy commented 6 years ago

The "user" pointer, as I recall, was used in OpenDKIM to carry a handle to an initialized libunbound instance. It wasn't used for the bind case.