From 747c80fbb1efa0630fefa173b81806c45d6f5bb4 Mon Sep 17 00:00:00 2001 From: Richard Nyberg Date: Fri, 30 Jan 2009 12:03:00 +0100 Subject: [PATCH] Use only IPv4 by default. Unfortunately there are some useless IPv6 trackers that will be used instead of their more usefull IPv4 counterparts when IPv6 is enabled. The -4 and -6 options are tweaked once again. If -6 is given only IPv6 will be used. If both are given both will be used and otherwise only IPv4 will be used. The IPvX stuff should probably be set per torrent in the future. --- btpd/main.c | 22 +++++++++++++--------- btpd/opts.c | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/btpd/main.c b/btpd/main.c index f735ec2..41ddb05 100644 --- a/btpd/main.c +++ b/btpd/main.c @@ -103,10 +103,11 @@ usage(void) "\n" "Options:\n" "-4\n" - "\tOnly use IPv4. Both IPv4 and IPv6 are enabled by default.\n" + "\tUse IPv4. If given in conjunction with -6, " + "both versions are used.\n" "\n" "-6\n" - "\tOnly use IPv6. Both IPv4 and IPv6 are enabled by default.\n" + "\tUse IPv6. By default IPv4 is used.\n" "\n" "--bw-in n\n" "\tLimit incoming BitTorrent traffic to n kB/s.\n" @@ -184,17 +185,17 @@ int main(int argc, char **argv) { char *dir = NULL, *log = NULL; - int daemonize = 1; + int daemonize = 1, opt4 = 0, opt6 = 0; for (;;) { switch (getopt_long(argc, argv, "46d:p:", longopts, NULL)) { case -1: goto args_done; - case '6': - net_ipv4 = 0; - break; case '4': - net_ipv6 = 0; + opt4 = 1; + break; + case '6': + opt6 = 1; break; case 'd': dir = optarg; @@ -247,8 +248,11 @@ args_done: argc -= optind; argv += optind; - if (!net_ipv4 && !net_ipv6) - btpd_err("You need to enable at least one ip version.\n"); + if (opt6) { + net_ipv6 = 1; + if (!opt4) + net_ipv4 = 0; + } if (argc > 0) usage(); diff --git a/btpd/opts.c b/btpd/opts.c index 398aa8a..31f7e25 100644 --- a/btpd/opts.c +++ b/btpd/opts.c @@ -16,4 +16,4 @@ int ipcprot = 0600; int empty_start = 0; const char *tr_ip_arg; int net_ipv4 = 1; -int net_ipv6 = 1; +int net_ipv6 = 0;