Add domain prefetch, fix ping issue
This commit is contained in:
@@ -67,6 +67,12 @@ msgstr "双栈IP优选"
|
|||||||
msgid "Enable IP selection between IPV4 and IPV6"
|
msgid "Enable IP selection between IPV4 and IPV6"
|
||||||
msgstr "启用或禁用IPV4,IPV6间的IP优选策略。"
|
msgstr "启用或禁用IPV4,IPV6间的IP优选策略。"
|
||||||
|
|
||||||
|
msgid "Domain prefetch"
|
||||||
|
msgstr "域名预加载"
|
||||||
|
|
||||||
|
msgid "Enable domain prefetch, accelerate domain response speed."
|
||||||
|
msgstr "启用域名预加载,加速域名响应速度。"
|
||||||
|
|
||||||
msgid "Redirect"
|
msgid "Redirect"
|
||||||
msgstr "重定向"
|
msgstr "重定向"
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,14 @@ o.cfgvalue = function(...)
|
|||||||
return Flag.cfgvalue(...) or "0"
|
return Flag.cfgvalue(...) or "0"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---- Domain prefetch load
|
||||||
|
o = s:taboption("settings", Flag, "prefetch_domain", translate("Domain prefetch"), translate("Enable domain prefetch, accelerate domain response speed."))
|
||||||
|
o.rmempty = false
|
||||||
|
o.default = o.disabled
|
||||||
|
o.cfgvalue = function(...)
|
||||||
|
return Flag.cfgvalue(...) or "0"
|
||||||
|
end
|
||||||
|
|
||||||
---- Redirect
|
---- Redirect
|
||||||
o = s:taboption("settings", ListValue, "redirect", translate("Redirect"), translate("SmartDNS redirect mode"))
|
o = s:taboption("settings", ListValue, "redirect", translate("Redirect"), translate("SmartDNS redirect mode"))
|
||||||
o.placeholder = "none"
|
o.placeholder = "none"
|
||||||
|
|||||||
@@ -217,6 +217,11 @@ load_service() {
|
|||||||
conf_append "dualstack-ip-selection" "yes"
|
conf_append "dualstack-ip-selection" "yes"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
config_get "prefetch_domain" "$section" "prefetch_domain" "0"
|
||||||
|
if [ "$prefetch_domain" = "1" ]; then
|
||||||
|
conf_append "prefetch-domain" "yes"
|
||||||
|
fi
|
||||||
|
|
||||||
SMARTDNS_PORT="$port"
|
SMARTDNS_PORT="$port"
|
||||||
|
|
||||||
config_get "cache_size" "$section" "cache_size" ""
|
config_get "cache_size" "$section" "cache_size" ""
|
||||||
|
|||||||
@@ -351,6 +351,7 @@ static int _fast_ping_sendping_v6(struct ping_host_struct *ping_host)
|
|||||||
icmp6->icmp6_seq = htons(ping_host->seq);
|
icmp6->icmp6_seq = htons(ping_host->seq);
|
||||||
|
|
||||||
gettimeofday(&packet->msg.tv, 0);
|
gettimeofday(&packet->msg.tv, 0);
|
||||||
|
gettimeofday(&ping_host->last, 0);
|
||||||
packet->msg.sid = ping_host->sid;
|
packet->msg.sid = ping_host->sid;
|
||||||
packet->msg.cookie = ping_host->cookie;
|
packet->msg.cookie = ping_host->cookie;
|
||||||
packet->msg.seq = ping_host->seq;
|
packet->msg.seq = ping_host->seq;
|
||||||
@@ -397,6 +398,7 @@ static int _fast_ping_sendping_v4(struct ping_host_struct *ping_host)
|
|||||||
icmp->icmp_seq = htons(ping_host->seq);
|
icmp->icmp_seq = htons(ping_host->seq);
|
||||||
|
|
||||||
gettimeofday(&packet->msg.tv, 0);
|
gettimeofday(&packet->msg.tv, 0);
|
||||||
|
gettimeofday(&ping_host->last, 0);
|
||||||
packet->msg.sid = ping_host->sid;
|
packet->msg.sid = ping_host->sid;
|
||||||
packet->msg.seq = ping_host->seq;
|
packet->msg.seq = ping_host->seq;
|
||||||
packet->msg.cookie = ping_host->cookie;
|
packet->msg.cookie = ping_host->cookie;
|
||||||
@@ -447,6 +449,7 @@ static int _fast_ping_sendping_udp(struct ping_host_struct *ping_host)
|
|||||||
memset(&dns_head, 0, sizeof(dns_head));
|
memset(&dns_head, 0, sizeof(dns_head));
|
||||||
dns_head.id = htons(ping_host->sid);
|
dns_head.id = htons(ping_host->sid);
|
||||||
dns_head.flag = flag;
|
dns_head.flag = flag;
|
||||||
|
gettimeofday(&ping_host->last, 0);
|
||||||
len = sendto(fd, &dns_head, sizeof(dns_head), 0, (struct sockaddr *)&ping_host->addr, ping_host->addr_len);
|
len = sendto(fd, &dns_head, sizeof(dns_head), 0, (struct sockaddr *)&ping_host->addr, ping_host->addr_len);
|
||||||
if (len < 0 || len != sizeof(dns_head)) {
|
if (len < 0 || len != sizeof(dns_head)) {
|
||||||
int err = errno;
|
int err = errno;
|
||||||
@@ -502,9 +505,10 @@ static int _fast_ping_sendping_tcp(struct ping_host_struct *ping_host)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gettimeofday(&ping_host->last, 0);
|
||||||
ping_host->fd = fd;
|
ping_host->fd = fd;
|
||||||
memset(&event, 0, sizeof(event));
|
memset(&event, 0, sizeof(event));
|
||||||
event.events = EPOLLIN | EPOLLOUT;
|
event.events = EPOLLIN | EPOLLOUT | EPOLLERR;
|
||||||
event.data.ptr = ping_host;
|
event.data.ptr = ping_host;
|
||||||
if (epoll_ctl(ping.epoll_fd, EPOLL_CTL_ADD, fd, &event) != 0) {
|
if (epoll_ctl(ping.epoll_fd, EPOLL_CTL_ADD, fd, &event) != 0) {
|
||||||
ping_host->fd = -1;
|
ping_host->fd = -1;
|
||||||
@@ -524,6 +528,7 @@ errout:
|
|||||||
static int _fast_ping_sendping(struct ping_host_struct *ping_host)
|
static int _fast_ping_sendping(struct ping_host_struct *ping_host)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
gettimeofday(&ping_host->last, 0);
|
||||||
|
|
||||||
if (ping_host->type == FAST_PING_ICMP) {
|
if (ping_host->type == FAST_PING_ICMP) {
|
||||||
ret = _fast_ping_sendping_v4(ping_host);
|
ret = _fast_ping_sendping_v4(ping_host);
|
||||||
@@ -536,7 +541,6 @@ static int _fast_ping_sendping(struct ping_host_struct *ping_host)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ping_host->send = 1;
|
ping_host->send = 1;
|
||||||
gettimeofday(&ping_host->last, 0);
|
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return ret;
|
return ret;
|
||||||
@@ -1148,6 +1152,7 @@ static int _fast_ping_process_tcp(struct ping_host_struct *ping_host, struct epo
|
|||||||
if (getsockopt(ping_host->fd, SOL_SOCKET, SO_ERROR, (char *)&connect_error, &len) != 0) {
|
if (getsockopt(ping_host->fd, SOL_SOCKET, SO_ERROR, (char *)&connect_error, &len) != 0) {
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connect_error != 0 && connect_error != ECONNREFUSED) {
|
if (connect_error != 0 && connect_error != ECONNREFUSED) {
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
@@ -1160,6 +1165,8 @@ static int _fast_ping_process_tcp(struct ping_host_struct *ping_host, struct epo
|
|||||||
|
|
||||||
ping_host->send = 0;
|
ping_host->send = 0;
|
||||||
|
|
||||||
|
_fast_ping_close_host_sock(ping_host);
|
||||||
|
|
||||||
if (ping_host->count == 1) {
|
if (ping_host->count == 1) {
|
||||||
_fast_ping_host_remove(ping_host);
|
_fast_ping_host_remove(ping_host);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user