--- nut-2.6.0/server/upsd.c.alt-ipv6-optional 2010-12-24 16:24:12.000000000 +0300 +++ nut-2.6.0/server/upsd.c 2011-02-20 15:44:01.508000003 +0300 @@ -539,6 +539,19 @@ static void client_readline(ctype_t *cli return; } +static int ipv6_available(void) +{ + int sock_fd; + + if ((sock_fd = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP)) < 0) { + upsdebug_with_errno(3, "ipv6_available: socket"); + return 0; + } + + close(sock_fd); + return 1; +} + void server_load(void) { stype_t *server; @@ -546,7 +559,9 @@ void server_load(void) /* default behaviour if no LISTEN addres has been specified */ if (!firstaddr) { if (opt_af != AF_INET) { - listen_add("::1", string_const(PORT)); + if (opt_af == AF_INET6 || ipv6_available()) { + listen_add("::1", string_const(PORT)); + } } if (opt_af != AF_INET6) {