mirror of
https://github.com/matrix-construct/construct
synced 2024-10-19 22:18:53 +02:00
44 lines
1.3 KiB
C
44 lines
1.3 KiB
C
|
// Matrix Construct
|
||
|
//
|
||
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
||
|
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
||
|
//
|
||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||
|
// purpose with or without fee is hereby granted, provided that the above
|
||
|
// copyright notice and this permission notice is present in all copies. The
|
||
|
// full license for this software is available in the LICENSE file.
|
||
|
|
||
|
#pragma once
|
||
|
#define HAVE_IRCD_NET_DNS_H
|
||
|
|
||
|
namespace ircd::net
|
||
|
{
|
||
|
struct dns extern dns;
|
||
|
}
|
||
|
|
||
|
/// DNS resolution suite.
|
||
|
///
|
||
|
/// This is a singleton class; public usage is to make calls on the singleton
|
||
|
/// object like `ircd::net::dns()` etc.
|
||
|
///
|
||
|
struct ircd::net::dns
|
||
|
{
|
||
|
struct resolver;
|
||
|
|
||
|
struct resolver static *resolver;
|
||
|
|
||
|
public:
|
||
|
using callback_one = std::function<void (std::exception_ptr, const ipport &)>;
|
||
|
using callback_many = std::function<void (std::exception_ptr, std::vector<ipport>)>;
|
||
|
using callback_reverse = std::function<void (std::exception_ptr, std::string)>;
|
||
|
|
||
|
// Callback-based interface
|
||
|
void operator()(const hostport &, callback_one);
|
||
|
void operator()(const hostport &, callback_many);
|
||
|
void operator()(const ipport &, callback_reverse);
|
||
|
|
||
|
// Future-based interface
|
||
|
ctx::future<ipport> operator()(const hostport &);
|
||
|
ctx::future<std::string> operator()(const ipport &);
|
||
|
};
|