--- main.c.orig Sun Sep 14 02:15:14 2003 +++ main.c Sun Sep 14 02:15:54 2003 @@ -102,6 +102,9 @@ #define help() fusage(stdout, 0) #define usage() fusage(stderr, 1) +int ipv4_only = 0; +int ipv6_only = 0; + static void fversion(FILE * f) { @@ -239,6 +242,10 @@ fprintf(f, " -title[=TERM] set buffer name to terminal title string\n"); fprintf(f, " -o opt=value assign value to config option\n"); +#ifdef INET6 + fprintf(f, " -4 IPv4 only\n"); + fprintf(f, " -6 IPv6 only\n"); +#endif fprintf(f, " -show-option print all config options\n"); fprintf(f, " -config file specify config file\n"); fprintf(f, " -help print this usage message\n"); @@ -498,6 +505,16 @@ usage(); if (atoi(argv[i]) > 0) PagerMax = atoi(argv[i]); + } + else if (!strcmp("-4", argv[i])){ + if (ipv6_only) + ipv6_only = 0; + ipv4_only = 1; + } + else if (!strcmp("-6", argv[i])) { + if (ipv4_only) + ipv4_only = 0; + ipv6_only = 1; } #ifdef USE_M17N #ifndef DEBIAN /* XXX: use -o kanjicode={S|J|E} */ --- etc.c.orig Sun Sep 14 02:15:22 2003 +++ etc.c Sun Sep 14 01:21:43 2003 @@ -31,6 +31,8 @@ }; struct auth_pass *passwords = NULL; +extern int ipv4_only; +extern int ipv6_only; int columnSkip(Buffer *buf, int offset) @@ -1965,7 +1967,13 @@ char *namebuf; memset(&hints, 0, sizeof(hints)); - hints.ai_family = *af; + if (ipv4_only) { + hints.ai_family = AF_INET; + } else if (ipv6_only) { + hints.ai_family = AF_INET6; + } else { + hints.ai_family = *af; + } hints.ai_socktype = SOCK_STREAM; error = getaddrinfo(host, NULL, &hints, &res0); if (error) { --- url.c.orig Sun Sep 14 02:15:31 2003 +++ url.c Sun Sep 14 01:46:09 2003 @@ -38,7 +38,13 @@ {PF_INET, PF_INET6, PF_UNSPEC}, /* 1:inet inet6 */ {PF_INET6, PF_INET, PF_UNSPEC} /* 2:inet6 inet */ }; +int ai_family_order_table_only[2][1] = { + {PF_INET}, /* 0: IPv4 only */ + {PF_INET6} /* 1: IPv6 only */ +}; #endif /* INET6 */ +extern int ipv4_only; +extern int ipv6_only; static JMP_BUF AbortLoading; @@ -481,7 +487,13 @@ } for (af = ai_family_order_table[DNS_order];; af++) { memset(&hints, 0, sizeof(hints)); - hints.ai_family = *af; + if (ipv4_only) { + hints.ai_family = PF_INET; + } else if (ipv6_only) { + hints.ai_family = PF_INET6; + } else { + hints.ai_family = *af; + } hints.ai_socktype = SOCK_STREAM; if (remoteport_num != 0) { Str portbuf = Sprintf("%d", remoteport_num); @@ -1956,8 +1968,16 @@ struct addrinfo *res, *res0; char addr[4 * 16]; int *af; + int *af_start; - for (af = ai_family_order_table[DNS_order];; af++) { + if (ipv4_only) { + af_start = ai_family_order_table_only[0]; + } else if (ipv6_only) { + af_start = ai_family_order_table_only[0]; + } else { + af_start = ai_family_order_table[DNS_order]; + } + for (af = af_start;; af++) { memset(&hints, 0, sizeof(hints)); hints.ai_family = *af; error = getaddrinfo(domain, NULL, &hints, &res0);