1
0
Fork 0
mirror of https://github.com/yarrick/iodine.git synced 2025-04-04 05:43:33 +03:00

Use int for timeouts

This commit is contained in:
frekky 2016-03-13 13:03:11 +08:00
parent ac60bf66a9
commit 93dbe94f60
3 changed files with 23 additions and 23 deletions

View file

@ -284,16 +284,16 @@ client_set_compression(int up, int down)
}
void
client_set_dnstimeout(double timeout, double servertimeout, double downfrag, int autodetect)
client_set_dnstimeout(int timeout, int servertimeout, int downfrag, int autodetect)
{
max_timeout_ms = timeout * 1000;
server_timeout_ms = servertimeout * 1000;
downstream_timeout_ms = downfrag * 1000;
max_timeout_ms = timeout;
server_timeout_ms = servertimeout;
downstream_timeout_ms = downfrag;
autodetect_server_timeout = autodetect;
}
void
client_set_interval(double interval_msec, double mininterval_msec)
client_set_interval(int interval_msec, int mininterval_msec)
{
send_interval_ms = interval_msec;
min_send_interval_ms = mininterval_msec;

View file

@ -44,11 +44,11 @@ int client_set_qtype(char *qtype);
char *client_get_qtype();
void client_set_downenc(char *encoding);
void client_set_compression(int up, int down);
void client_set_dnstimeout(double, double, double, int);
void client_set_dnstimeout(int, int, int, int);
void client_set_lazymode(int lazy_mode);
void client_set_windowsize(size_t, size_t);
void client_set_hostname_maxlen(size_t i);
void client_set_interval(double, double);
void client_set_interval(int, int);
int client_handshake(int dns_fd, int raw_mode, int autodetect_frag_size, int fragsize);
int client_tunnel(int tun_fd, int dns_fd);

View file

@ -162,9 +162,9 @@ main(int argc, char **argv)
int retval;
int raw_mode;
int lazymode;
double target_interval_sec;
double server_timeout_sec;
double downstream_timeout_sec;
int target_interval_ms;
int server_timeout_ms;
int downstream_timeout_ms;
int min_interval_ms;
int autodetect_server_timeout;
int up_compression;
@ -211,10 +211,10 @@ main(int argc, char **argv)
retval = 0;
raw_mode = 1;
lazymode = 1;
target_interval_sec = 5; /* DNS RFC says 5 seconds minimum */
target_interval_ms = 5000; /* DNS RFC says 5 seconds minimum */
min_interval_ms = 0;
server_timeout_sec = 4; /* Safe value for RTT <1s */
downstream_timeout_sec = 2;
server_timeout_ms = 4000; /* Safe value for RTT <1s */
downstream_timeout_ms = 2000;
autodetect_server_timeout = 1;
hostname_maxlen = 0xFF;
nameserv_family = AF_UNSPEC;
@ -322,17 +322,17 @@ main(int argc, char **argv)
lazymode = 0;
break;
case 'I':
target_interval_sec = strtod(optarg, NULL);
target_interval_ms = strtod(optarg, NULL) * 1000;
break;
case 'i':
server_timeout_sec = strtod(optarg, NULL);
server_timeout_ms = strtod(optarg, NULL) * 1000;
autodetect_server_timeout = 0;
break;
case 'j':
downstream_timeout_sec = strtod(optarg, NULL);
downstream_timeout_ms = strtod(optarg, NULL) * 1000;
if (autodetect_server_timeout) {
autodetect_server_timeout = 0;
server_timeout_sec = 4;
server_timeout_ms = 4000;
}
break;
case 's':
@ -424,29 +424,29 @@ main(int argc, char **argv)
usage();
}
if (target_interval_sec < 0.1) {
if (target_interval_ms < 100) {
warnx("Target interval must be greater than 0.1 seconds!");
usage();
}
if (server_timeout_sec < 0.1 || server_timeout_sec >= target_interval_sec) {
if (server_timeout_ms < 100 || server_timeout_ms >= target_interval_ms) {
warnx("Server timeout must be greater than 0.1 sec and less than target interval!");
usage();
}
if (downstream_timeout_sec < 0.1) {
if (downstream_timeout_ms < 100) {
warnx("Downstream fragment timeout must be more than 0.1 sec to prevent excessive retransmits.");
usage();
}
if (!lazymode && target_interval_sec > 1) {
if (!lazymode && target_interval_ms > 1000) {
warnx("Warning: Target interval of >1 second in immediate mode will cause high latency.");
usage();
}
client_set_compression(up_compression, down_compression);
client_set_dnstimeout(target_interval_sec, server_timeout_sec, downstream_timeout_sec, autodetect_server_timeout);
client_set_interval(target_interval_sec * 1000.0, min_interval_ms);
client_set_dnstimeout(target_interval_ms, server_timeout_ms, downstream_timeout_ms, autodetect_server_timeout);
client_set_interval(target_interval_ms, min_interval_ms);
client_set_lazymode(lazymode);
client_set_topdomain(topdomain);
client_set_hostname_maxlen(hostname_maxlen);