#pragma once
#include "common.hpp"
#include "sock.hpp"
#include "hooks.hpp"
#include "config.hpp"
#include "hash.hpp"
class DNSResult {
public:
typedef struct {
sa_family_t family;
char host[MAX_SNI_LEN+1];
} cache_key_t;
private:
cache_key_t key;
int fd;
bool wakeup;
tristate_t state;
sockaddr_t result;
DNSResult();
DNSResult(const char*, sa_family_t, int);
~DNSResult();
static void cb(void*, int, int, struct hostent*);
public:
static DNSResult* getInst(const char*, sa_family_t, int); ///< dispatch resolver, wake up fd when done if not got result immediately, not NULL
void delInst(); ///< aborts pending request and/or discards result
tristate_t get(sockaddr_t&) const; ///< get result, if available; overwrites only family and sin addr upon true
};