=== modified file 'TODO' --- TODO 2011-07-25 18:47:45 +0000 +++ TODO 2011-07-31 13:05:34 +0000 @@ -11,7 +11,6 @@ ** TODO [#B] Use struct sockaddr_storage instead of a union ** TODO [#B] Use getaddrinfo(hints=AI_NUMERICHOST) instead of inet_pton() ** TODO [#B] Use getnameinfo(serv=NULL, NI_NUMERICHOST) instead of inet_ntop() -** TODO [#B] Accept [] around IPv6 address in --connect option; see [[http://tools.ietf.org/html/rfc5952][RFC 5952 - A Recommendation for IPv6 Address Text Representation]] * splashy ** TODO [#B] use scandir(3) instead of readdir(3) === modified file 'plugins.d/mandos-client.c' --- plugins.d/mandos-client.c 2011-07-16 00:29:19 +0000 +++ plugins.d/mandos-client.c 2011-07-31 13:05:34 +0000 @@ -187,6 +187,7 @@ return buffer_capacity; } +/* Add server to set of servers to retry periodically */ int add_server(const char *ip, uint16_t port, AvahiIfIndex if_index, int af){ @@ -204,12 +205,12 @@ perror_plus("strdup"); return -1; } - /* unique case of first server */ + /* Special case of first server */ if (mc.current_server == NULL){ new_server->next = new_server; new_server->prev = new_server; mc.current_server = new_server; - /* Placing the new server last in the list */ + /* Place the new server last in the list */ } else { new_server->next = mc.current_server; new_server->prev = mc.current_server->prev; @@ -1205,7 +1206,7 @@ struct timespec now; struct timespec waited_time; intmax_t block_time; - + while(true){ if(mc.current_server == NULL){ if (debug){ @@ -1236,11 +1237,11 @@ block_time = ((retry_interval - ((intmax_t)waited_time.tv_sec * 1000)) - ((intmax_t)waited_time.tv_nsec / 1000000)); - + if (debug){ - fprintf(stderr, "Blocking for %ld ms\n", block_time); + fprintf(stderr, "Blocking for %" PRIdMAX " ms\n", block_time); } - + if(block_time <= 0){ ret = start_mandos_communication(mc.current_server->ip, mc.current_server->port, @@ -1411,7 +1412,8 @@ errno = 0; retry_interval = strtod(arg, &tmp); if(errno != 0 or tmp == arg or *tmp != '\0' - or (retry_interval * 1000) > INT_MAX){ + or (retry_interval * 1000) > INT_MAX + or retry_interval < 0){ argp_error(state, "Bad retry interval"); } break; @@ -1829,25 +1831,35 @@ port = (uint16_t)tmpmax; *address = '\0'; - address = connect_to; /* Colon in address indicates IPv6 */ int af; - if(strchr(address, ':') != NULL){ + if(strchr(connect_to, ':') != NULL){ af = AF_INET6; + /* Accept [] around IPv6 address - see RFC 5952 */ + if(connect_to[0] == '[' and address[-1] == ']') + { + connect_to++; + address[-1] = '\0'; + } } else { af = AF_INET; } + address = connect_to; if(quit_now){ goto end; } - + while(not quit_now){ ret = start_mandos_communication(address, port, if_index, af); if(quit_now or ret == 0){ break; } - sleep((int)retry_interval or 1); + if(debug){ + fprintf(stderr, "Retrying in %d seconds\n", + (int)retry_interval); + } + sleep((int)retry_interval); }; if (not quit_now){ === modified file 'plugins.d/mandos-client.xml' --- plugins.d/mandos-client.xml 2011-06-23 22:27:15 +0000 +++ plugins.d/mandos-client.xml 2011-07-31 13:05:34 +0000 @@ -137,9 +137,9 @@ using TLS with an OpenPGP key to ensure authenticity and confidentiality. This client program keeps running, trying all servers on the network, until it receives a satisfactory reply - or a TERM signal is received. If no servers are found, or after - all servers have been tried, it waits indefinitely for new - servers to appear. + or a TERM signal. After all servers have been tried, all + servers are periodically retried. If no servers are found it + will wait indefinitely for new servers to appear. This program is not meant to be run directly; it is really meant @@ -303,10 +303,10 @@ >SECONDS - All Mandos servers servers are tried repeatedly until a - password is received. This value specifies, in seconds, - how long between each successive try for the - same server. The default is 10 seconds. + All Mandos servers are tried repeatedly until a password + is received. This value specifies, in seconds, how long + between each successive try for the same + server. The default is 10 seconds. @@ -388,9 +388,9 @@ server could be found and the password received from it could be successfully decrypted and output on standard output. The program will exit with a non-zero exit status only if a critical - error occurs. Otherwise, it will forever connect to new - Mandos servers as they appear, trying - to get a decryptable password and print it. + error occurs. Otherwise, it will forever connect to any + discovered Mandos servers, trying to + get a decryptable password and print it.