mirror of
https://github.com/xroche/httrack.git
synced 2026-07-11 11:26:31 +03:00
Compare commits
1 Commits
master
...
fix-181-ba
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
358a7db555 |
@@ -2050,13 +2050,9 @@ int back_add(struct_back * sback, httrackp * opt, cache_back * cache, const char
|
||||
|
||||
if (!back_trylive(opt, cache, sback, p)) {
|
||||
#if HTS_XGETHOST
|
||||
#if HDEBUG
|
||||
printf("back_solve..\n");
|
||||
#endif
|
||||
back[p].status = STATUS_WAIT_DNS; // tentative de résolution du nom de host
|
||||
soc = INVALID_SOCKET; // pas encore ouverte
|
||||
back_solve(opt, &back[p]); // préparer
|
||||
if (host_wait(opt, &back[p])) { // prêt, par ex fichier ou dispo dans dns
|
||||
back[p].status = STATUS_WAIT_DNS; // host name resolution attempt
|
||||
soc = INVALID_SOCKET; // not opened yet
|
||||
if (host_wait(opt, &back[p])) { // ready (file, or cached dns)
|
||||
#if HDEBUG
|
||||
printf("ok, dns cache ready..\n");
|
||||
#endif
|
||||
@@ -2199,37 +2195,9 @@ int back_add(struct_back * sback, httrackp * opt, cache_back * cache, const char
|
||||
}
|
||||
|
||||
#if HTS_XGETHOST
|
||||
// attendre que le host (ou celui du proxy) ait été résolu
|
||||
// si c'est un fichier, la résolution est immédiate
|
||||
// idem pour ftp://
|
||||
void back_solve(httrackp * opt, lien_back * back) {
|
||||
assertf(opt != NULL);
|
||||
assertf(back != NULL);
|
||||
if ((!strfield(back->url_adr, "file://"))
|
||||
&& !strfield(back->url_adr, "ftp://")
|
||||
) {
|
||||
const char *a;
|
||||
|
||||
if (!(back->r.req.proxy.active))
|
||||
a = back->url_adr;
|
||||
else
|
||||
a = back->r.req.proxy.name;
|
||||
assertf(a != NULL);
|
||||
a = jump_protocol_const(a);
|
||||
if (check_hostname_dns(a)) {
|
||||
hts_log_print(opt, LOG_DEBUG, "resolved: %s", a);
|
||||
} else {
|
||||
hts_log_print(opt, LOG_DEBUG, "failed to resolve: %s", a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// détermine si le host a pu être résolu
|
||||
int host_wait(httrackp * opt, lien_back * back) {
|
||||
// Always synchronous. No more background DNS resolution
|
||||
// (does not really improve performances)
|
||||
return 1;
|
||||
}
|
||||
// Resolution is synchronous inside the connect path; no pre-resolve step, so
|
||||
// the host is always immediately ready.
|
||||
int host_wait(httrackp *opt, lien_back *back) { return 1; }
|
||||
#endif
|
||||
|
||||
// élimine les fichiers non html en backing (anticipation)
|
||||
|
||||
@@ -138,7 +138,6 @@ LLint back_transferred(LLint add, struct_back * sback);
|
||||
|
||||
// hostback
|
||||
#if HTS_XGETHOST
|
||||
void back_solve(httrackp * opt, lien_back * sback);
|
||||
int host_wait(httrackp * opt, lien_back * sback);
|
||||
#endif
|
||||
int back_checksize(httrackp * opt, lien_back * eback, int check_only_totalsize);
|
||||
|
||||
@@ -297,6 +297,26 @@ int dns_selftests(httrackp *opt) {
|
||||
IPV6_resolver = 0;
|
||||
}
|
||||
|
||||
/* "host:port" resolves as the bare host: the cache/connect path strips
|
||||
":port" before both the backend and the cache key (#181). */
|
||||
mock_reset_calls();
|
||||
{
|
||||
SOCaddr a;
|
||||
char ip[64];
|
||||
const char *err = NULL;
|
||||
|
||||
/* cache miss: the backend is hit with the stripped host, not "host:port" */
|
||||
CHECK(hts_dns_resolve2(opt, "v6only.test:8080", &a, &err) != NULL);
|
||||
CHECK(mock_find("v6only.test")->calls == 1);
|
||||
/* the bare host shares that one cache entry (stripped key) */
|
||||
CHECK(hts_dns_resolve2(opt, "v6only.test", &a, &err) != NULL);
|
||||
CHECK(mock_find("v6only.test")->calls == 1);
|
||||
/* a port variant of an already-cached host also hits, right address */
|
||||
CHECK(hts_dns_resolve2(opt, "v4only.test:1234", &a, &err) != NULL);
|
||||
SOCaddr_inetntoa(ip, sizeof(ip), a);
|
||||
CHECK(strcmp(ip, "1.2.3.4") == 0);
|
||||
}
|
||||
|
||||
/* newhttp_addr() must connect to the addr_index-th address, not always the
|
||||
first: this is what back_connect_next relies on to reach the fallback. */
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user