同步操作将从 搜狗开源/workflow 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
Domain Network System (DNS) is a distributed network directory service. It is mainly used for the conversion between a domain name and an IP address.
During the communication access, it is required to perform DNS resolution for a non-IP domain name. DNS resolution is the process that converts a domain name to an IP address.
DNS resolution is resource consuming. The operating systems on both servers and local computers usually have their own DNS Cache to reduce unnecessary requests.
Some programs, including popular browsers and communication frameworks, also have their own DNS Cache in their processes. Workflow is also designed with its own DNS Cache. For convenience purposes, DNS features are completely transparent and “hidden” in the framework.
TTL (Time To Live) refers to the amount of time a DNS record is considered up-to-date in the DNS Cache.
Currently the framework directly calls the system function getaddrinfo to resolve domain names. Some details:
The framework implements a complete DNS protocol resolution. The current version requires the user to manually specify resolv_conf_path
to enable this method. On common Linux distributions, resolv_conf_path
is generally /etc/resolv.conf
, and hosts_path
is generally /etc/hosts
. Leave the above parameters blank, and the synchronous request method will be used.
You can see global settings in WFGlobal.h.
struct WFGlobalSettings
{
EndpointParams endpoint_params;
unsigned int dns_ttl_default;
unsigned int dns_ttl_min;
int dns_threads;
int poller_threads;
int handler_threads;
int compute_threads;
const char *resolv_conf_path;
const char *hosts_path;
};
static constexpr struct WFGlobalSettings GLOBAL_SETTING_DEFAULT =
{
.endpoint_params = ENDPOINT_PARAMS_DEFAULT,
.dns_ttl_default = 12 * 3600, /* in seconds */
.dns_ttl_min = 180, /* reacquire when communication error */
.dns_threads = 4,
.poller_threads = 4,
.handler_threads = 20,
.compute_threads = -1,
.resolv_conf_path = "/etc/resolv.conf",
.hosts_path = "/etc/hosts",
};
where the DNS-related configuration items include:
To put it simply, in every communication, the system will check TTL to decide whether to refresh DNS resolution.
dns_ttl_default is checked by default, and dns_ttl_min is checked in the retry after communication failure.
The global DNS configuration can be overridden by the configuration for an individual address in the upstream.
In Upstream, each AddressParams can also have its own dns_ttl_default and dns_ttl_min, and you can configure them in the same way as you configure the Global items.
For the detailed structures, please see upstream documents.
On the master branch (not available on windows branch), we also supports DNS resolving over SSL (Dot) by extending the format of resolv.conf slightly. You may edit the resolv.conf file and add an SSL dns server like:
nameserver dnss://8.8.8.8/
We use the dnss:// scheme to represent an SSL dns server address. With the config abort, all DNS resolving will use SSL connection to global dns server 8.8.8.8. The global DNS supports SSL perfectly, and you can try this feature right now! But to avoid changing the system resolv.conf file (/etc/resolv.conf), you may need to setup a private resolv.conf path:
#include <workflow/WFGlobal.h>
#include <workflow/WFTaskFactory.h>
int main()
{
struct WFGlobalSettings settings = GLOBAL_SETTINGS_DEFAULT;
settings.resolv_conf_path = "./myresolv.conf";
WORKFLOW_library_init(&settings);
WFHttpTask *task = WFTaskFactory::create_http_task("https://www.example.com", ...);
...
}
At the moment when the TTL is exceeded, if a large number of concurrent requests are sent to a domain name, a large amount of DNS resolution for that domain name may occur at the same time.
The framework uses a self-consistent logic to reasonably avoid/reduce this possibility:
Currently, there are still two scenarios in which the framework has to perform a large number of DNS resolutions for the same domain name at the same time:
We think that these two scenarios are acceptable in the framework. To put it more precisely, a large number of DNS requests in this scenario are completely reasonable and logical.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。