Browse Source

corrected the behavior of -6 (trac ticket #98)

git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1460 e5f2f494-b856-4b98-b285-d166d9295462
JINMEI Tatuya 15 years ago
parent
commit
8e4cabcb06
1 changed files with 9 additions and 11 deletions
  1. 9 11
      src/bin/auth/main.cc

+ 9 - 11
src/bin/auth/main.cc

@@ -619,16 +619,20 @@ int
 main(int argc, char* argv[]) {
     int ch;
     const char* port = DNSPORT;
-    bool ipv4_only = false, ipv6_only = false;
-    bool use_ipv4 = false, use_ipv6 = false;
+    bool use_ipv4 = true, use_ipv6 = true;
 
     while ((ch = getopt(argc, argv, "46p:v")) != -1) {
         switch (ch) {
         case '4':
-            ipv4_only = true;
+            // Note that -4 means "ipv4 only", we need to set "use_ipv6" here,
+            // not "use_ipv4".  We could use something like "ipv4_only", but
+            // we found the negatively named variable could confuse the code
+            // logic.
+            use_ipv6 = false;
             break;
         case '6':
-            ipv6_only = true;
+            // The same note as -4 applies.
+            use_ipv4 = false;
             break;
         case 'p':
             port = optarg;
@@ -646,16 +650,10 @@ main(int argc, char* argv[]) {
         usage();
     }
 
-    if (ipv4_only && ipv6_only) {
+    if (!use_ipv4 && !use_ipv6) {
         cerr << "-4 and -6 can't coexist" << endl;
         usage();
     }
-    if (!ipv6_only) {
-        use_ipv4 = true;
-    }
-    if (!ipv4_only) {
-        use_ipv4 = true;
-    }
 
     auth_server = new AuthSrv;
     auth_server->setVerbose(verbose_mode);