Skip to content

Commit

Permalink
Updated libtor dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorropo-berty-bot committed Jan 13, 2021
1 parent df42a86 commit f43e844
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The `go-libtor` project is a self-contained, fully statically linked Tor library
| Library | Version | Commit |
|:-:|:-:|:-:|
| zlib | 1.2.11 | [`cacf7f1d4e3d44d871b605da3b647f07d718623f`](https://github.com/madler/zlib/commit/cacf7f1d4e3d44d871b605da3b647f07d718623f) |
| libevent | 2.2.0-alpha-dev | [`c5e4391b86ab0198c9878620d566a66043bd1f43`](https://github.com/libevent/libevent/commit/c5e4391b86ab0198c9878620d566a66043bd1f43) |
| libevent | 2.2.0-alpha-dev | [`617ba838746287974505c6a9c4de6c65172ea112`](https://github.com/libevent/libevent/commit/617ba838746287974505c6a9c4de6c65172ea112) |
| openssl | 1.1.1-stable | [`6e3ba20dc49ccbf12ff4c27a4d8b84dcbeb71654`](https://github.com/openssl/openssl/commit/6e3ba20dc49ccbf12ff4c27a4d8b84dcbeb71654) |
| tor | 0.3.5.12-dev | [`5aceb7ca192b42fe1cdd940465a6ee2655d47cd5`](https://gitweb.torproject.org/tor.git/commit/?id=5aceb7ca192b42fe1cdd940465a6ee2655d47cd5) |

Expand Down
42 changes: 34 additions & 8 deletions darwin/libevent/evdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,13 @@ struct evdns_base {
#endif

int disable_when_inactive;

/* Maximum timeout between two probe packets
* will change `global_nameserver_probe_initial_timeout`
* when this value is smaller */
int ns_max_probe_timeout;
/* Backoff factor of probe timeout */
int ns_timeout_backoff_factor;
};

struct hosts_entry {
Expand Down Expand Up @@ -671,21 +678,18 @@ nameserver_probe_failed(struct nameserver *const ns) {
return;
}

#define MAX_PROBE_TIMEOUT 3600
#define TIMEOUT_BACKOFF_FACTOR 3

memcpy(&timeout, &ns->base->global_nameserver_probe_initial_timeout,
sizeof(struct timeval));
for (i=ns->failed_times; i > 0 && timeout.tv_sec < MAX_PROBE_TIMEOUT; --i) {
timeout.tv_sec *= TIMEOUT_BACKOFF_FACTOR;
timeout.tv_usec *= TIMEOUT_BACKOFF_FACTOR;
for (i = ns->failed_times; i > 0 && timeout.tv_sec < ns->base->ns_max_probe_timeout; --i) {
timeout.tv_sec *= ns->base->ns_timeout_backoff_factor;
timeout.tv_usec *= ns->base->ns_timeout_backoff_factor;
if (timeout.tv_usec > 1000000) {
timeout.tv_sec += timeout.tv_usec / 1000000;
timeout.tv_usec %= 1000000;
}
}
if (timeout.tv_sec > MAX_PROBE_TIMEOUT) {
timeout.tv_sec = MAX_PROBE_TIMEOUT;
if (timeout.tv_sec > ns->base->ns_max_probe_timeout) {
timeout.tv_sec = ns->base->ns_max_probe_timeout;
timeout.tv_usec = 0;
}

Expand Down Expand Up @@ -4344,6 +4348,26 @@ evdns_base_set_option_impl(struct evdns_base *base,
val);
memcpy(&base->global_nameserver_probe_initial_timeout, &tv,
sizeof(tv));
} else if (str_matches_option(option, "max-probe-timeout:")) {
const int max_probe_timeout = strtoint_clipped(val, 1, 3600);
if (max_probe_timeout == -1) return -1;
if (!(flags & DNS_OPTION_MISC)) return 0;
log(EVDNS_LOG_DEBUG, "Setting maximum probe timeout to %d",
max_probe_timeout);
base->ns_max_probe_timeout = max_probe_timeout;
if (base->global_nameserver_probe_initial_timeout.tv_sec > max_probe_timeout) {
base->global_nameserver_probe_initial_timeout.tv_sec = max_probe_timeout;
base->global_nameserver_probe_initial_timeout.tv_usec = 0;
log(EVDNS_LOG_DEBUG, "Setting initial probe timeout to %s",
val);
}
} else if (str_matches_option(option, "probe-backoff-factor:")) {
const int backoff_backtor = strtoint_clipped(val, 1, 10);
if (backoff_backtor == -1) return -1;
if (!(flags & DNS_OPTION_MISC)) return 0;
log(EVDNS_LOG_DEBUG, "Setting probe timeout backoff factor to %d",
backoff_backtor);
base->ns_timeout_backoff_factor = backoff_backtor;
} else if (str_matches_option(option, "so-rcvbuf:")) {
int buf = strtoint(val);
if (buf == -1) return -1;
Expand Down Expand Up @@ -4820,6 +4844,8 @@ evdns_base_new(struct event_base *event_base, int flags)
base->global_getaddrinfo_allow_skew.tv_usec = 0;
base->global_nameserver_probe_initial_timeout.tv_sec = 10;
base->global_nameserver_probe_initial_timeout.tv_usec = 0;
base->ns_max_probe_timeout = 3600;
base->ns_timeout_backoff_factor = 3;
base->global_tcp_idle_timeout.tv_sec = CLIENT_IDLE_CONN_TIMEOUT;

TAILQ_INIT(&base->hostsdb);
Expand Down
15 changes: 12 additions & 3 deletions darwin/libevent/include/event2/dns.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ extern "C" {
* - attempts:
* - randomize-case:
* - initial-probe-timeout:
* - max-probe-timeout:
* - probe-backoff-factor:
* - tcp-idle-timeout:
* - edns-udp-size:
* - use-vc
Expand Down Expand Up @@ -470,9 +472,16 @@ void evdns_cancel_request(struct evdns_base *base, struct evdns_request *req);
The currently available configuration options are:
ndots, timeout, max-timeouts, max-inflight, attempts, randomize-case,
bind-to, initial-probe-timeout, getaddrinfo-allow-skew,
so-rcvbuf, so-sndbuf, tcp-idle-timeout, use-vc, ignore-tc,
edns-udp-size.
bind-to, initial-probe-timeout, max-probe-timeout, probe-backoff-factor,
getaddrinfo-allow-skew, so-rcvbuf, so-sndbuf, tcp-idle-timeout, use-vc,
ignore-tc, edns-udp-size.
- probe-backoff-factor
Backoff factor of probe timeout
- max-probe-timeout
Maximum timeout between two probe packets will change initial-probe-timeout
when this value is smaller
In versions before Libevent 2.0.3-alpha, the option name needed to end with
a colon.
Expand Down
42 changes: 34 additions & 8 deletions linux/libevent/evdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,13 @@ struct evdns_base {
#endif

int disable_when_inactive;

/* Maximum timeout between two probe packets
* will change `global_nameserver_probe_initial_timeout`
* when this value is smaller */
int ns_max_probe_timeout;
/* Backoff factor of probe timeout */
int ns_timeout_backoff_factor;
};

struct hosts_entry {
Expand Down Expand Up @@ -671,21 +678,18 @@ nameserver_probe_failed(struct nameserver *const ns) {
return;
}

#define MAX_PROBE_TIMEOUT 3600
#define TIMEOUT_BACKOFF_FACTOR 3

memcpy(&timeout, &ns->base->global_nameserver_probe_initial_timeout,
sizeof(struct timeval));
for (i=ns->failed_times; i > 0 && timeout.tv_sec < MAX_PROBE_TIMEOUT; --i) {
timeout.tv_sec *= TIMEOUT_BACKOFF_FACTOR;
timeout.tv_usec *= TIMEOUT_BACKOFF_FACTOR;
for (i = ns->failed_times; i > 0 && timeout.tv_sec < ns->base->ns_max_probe_timeout; --i) {
timeout.tv_sec *= ns->base->ns_timeout_backoff_factor;
timeout.tv_usec *= ns->base->ns_timeout_backoff_factor;
if (timeout.tv_usec > 1000000) {
timeout.tv_sec += timeout.tv_usec / 1000000;
timeout.tv_usec %= 1000000;
}
}
if (timeout.tv_sec > MAX_PROBE_TIMEOUT) {
timeout.tv_sec = MAX_PROBE_TIMEOUT;
if (timeout.tv_sec > ns->base->ns_max_probe_timeout) {
timeout.tv_sec = ns->base->ns_max_probe_timeout;
timeout.tv_usec = 0;
}

Expand Down Expand Up @@ -4344,6 +4348,26 @@ evdns_base_set_option_impl(struct evdns_base *base,
val);
memcpy(&base->global_nameserver_probe_initial_timeout, &tv,
sizeof(tv));
} else if (str_matches_option(option, "max-probe-timeout:")) {
const int max_probe_timeout = strtoint_clipped(val, 1, 3600);
if (max_probe_timeout == -1) return -1;
if (!(flags & DNS_OPTION_MISC)) return 0;
log(EVDNS_LOG_DEBUG, "Setting maximum probe timeout to %d",
max_probe_timeout);
base->ns_max_probe_timeout = max_probe_timeout;
if (base->global_nameserver_probe_initial_timeout.tv_sec > max_probe_timeout) {
base->global_nameserver_probe_initial_timeout.tv_sec = max_probe_timeout;
base->global_nameserver_probe_initial_timeout.tv_usec = 0;
log(EVDNS_LOG_DEBUG, "Setting initial probe timeout to %s",
val);
}
} else if (str_matches_option(option, "probe-backoff-factor:")) {
const int backoff_backtor = strtoint_clipped(val, 1, 10);
if (backoff_backtor == -1) return -1;
if (!(flags & DNS_OPTION_MISC)) return 0;
log(EVDNS_LOG_DEBUG, "Setting probe timeout backoff factor to %d",
backoff_backtor);
base->ns_timeout_backoff_factor = backoff_backtor;
} else if (str_matches_option(option, "so-rcvbuf:")) {
int buf = strtoint(val);
if (buf == -1) return -1;
Expand Down Expand Up @@ -4820,6 +4844,8 @@ evdns_base_new(struct event_base *event_base, int flags)
base->global_getaddrinfo_allow_skew.tv_usec = 0;
base->global_nameserver_probe_initial_timeout.tv_sec = 10;
base->global_nameserver_probe_initial_timeout.tv_usec = 0;
base->ns_max_probe_timeout = 3600;
base->ns_timeout_backoff_factor = 3;
base->global_tcp_idle_timeout.tv_sec = CLIENT_IDLE_CONN_TIMEOUT;

TAILQ_INIT(&base->hostsdb);
Expand Down
15 changes: 12 additions & 3 deletions linux/libevent/include/event2/dns.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ extern "C" {
* - attempts:
* - randomize-case:
* - initial-probe-timeout:
* - max-probe-timeout:
* - probe-backoff-factor:
* - tcp-idle-timeout:
* - edns-udp-size:
* - use-vc
Expand Down Expand Up @@ -470,9 +472,16 @@ void evdns_cancel_request(struct evdns_base *base, struct evdns_request *req);
The currently available configuration options are:
ndots, timeout, max-timeouts, max-inflight, attempts, randomize-case,
bind-to, initial-probe-timeout, getaddrinfo-allow-skew,
so-rcvbuf, so-sndbuf, tcp-idle-timeout, use-vc, ignore-tc,
edns-udp-size.
bind-to, initial-probe-timeout, max-probe-timeout, probe-backoff-factor,
getaddrinfo-allow-skew, so-rcvbuf, so-sndbuf, tcp-idle-timeout, use-vc,
ignore-tc, edns-udp-size.
- probe-backoff-factor
Backoff factor of probe timeout
- max-probe-timeout
Maximum timeout between two probe packets will change initial-probe-timeout
when this value is smaller
In versions before Libevent 2.0.3-alpha, the option name needed to end with
a colon.
Expand Down
2 changes: 1 addition & 1 deletion lock.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"zlib":"cacf7f1d4e3d44d871b605da3b647f07d718623f","libevent":"c5e4391b86ab0198c9878620d566a66043bd1f43","openssl":"6e3ba20dc49ccbf12ff4c27a4d8b84dcbeb71654","tor":"5aceb7ca192b42fe1cdd940465a6ee2655d47cd5"}
{"zlib":"cacf7f1d4e3d44d871b605da3b647f07d718623f","libevent":"617ba838746287974505c6a9c4de6c65172ea112","openssl":"6e3ba20dc49ccbf12ff4c27a4d8b84dcbeb71654","tor":"5aceb7ca192b42fe1cdd940465a6ee2655d47cd5"}

0 comments on commit f43e844

Please sign in to comment.