Parcourir la source

Addressed more review comments

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac327@3310 e5f2f494-b856-4b98-b285-d166d9295462
Evan Hunt il y a 14 ans
Parent
commit
2295886f8b

+ 11 - 8
src/bin/auth/auth_srv.cc

@@ -78,24 +78,27 @@ public:
                           OutputBufferPtr buffer);
     bool processNotify(const IOMessage& io_message, MessagePtr message, 
                        OutputBufferPtr buffer);
-    std::string db_file_;
+
+    /// Currently non-configurable, but will be.
+    static const uint16_t DEFAULT_LOCAL_UDPSIZE = 4096;
+
+    /// These members are public because AuthSrv accesses them directly.
     ModuleCCSession* config_session_;
+    bool verbose_mode_;
+    AbstractSession* xfrin_session_;
+
+private:
+    std::string db_file_;
+
     MetaDataSrc data_sources_;
     /// We keep a pointer to the currently running sqlite datasource
     /// so that we can specifically remove that one should the database
     /// file change
     ConstDataSrcPtr cur_datasrc_;
 
-    bool verbose_mode_;
-
-    AbstractSession* xfrin_session_;
-
     bool xfrout_connected_;
     AbstractXfroutClient& xfrout_client_;
 
-    /// Currently non-configurable, but will be.
-    static const uint16_t DEFAULT_LOCAL_UDPSIZE = 4096;
-
     /// Hot spot cache
     isc::datasrc::HotCache cache_;
 };

+ 6 - 3
src/bin/auth/main.cc

@@ -57,6 +57,7 @@ namespace {
 
 static bool verbose_mode = false;
 
+// Default port current 5300 for testing purposes
 static const string PROGRAM = "Auth";
 static const char* DNSPORT = "5300";
 
@@ -89,11 +90,13 @@ my_command_handler(const string& command, ConstElementPtr args) {
 
 void
 usage() {
-    cerr << "Usage:  b10-auth [-a address] [-p port] [-4|-6] [-nv]" << endl;
+    cerr << "Usage:  b10-auth [-a address] [-p port] [-u user] [-4|-6] [-nv]"
+         << endl;
     cerr << "\t-a: specify the address to listen on (default: all) " << endl;
-    cerr << "\t-p: specify the port to listen on (default: 5300)" << endl;
+    cerr << "\t-p: specify the port to listen on (default: " << DNSPORT << ")"
+         << endl;
     cerr << "\t-4: listen on all IPv4 addresses (incompatible with -a)" << endl;
-    cerr << "\t-4: listen on all IPv6 addresses (incompatible with -a)" << endl;
+    cerr << "\t-6: listen on all IPv6 addresses (incompatible with -a)" << endl;
     cerr << "\t-n: do not cache answers in memory" << endl;
     cerr << "\t-u: change process UID to the specified user" << endl;
     cerr << "\t-v: verbose output" << endl;

+ 4 - 4
src/bin/auth/tests/auth_srv_unittest.cc

@@ -387,11 +387,11 @@ TEST_F(AuthSrvTest, notify) {
 
     // An internal command message should have been created and sent to an
     // external module.  Check them.
-    EXPECT_EQ("Zonemgr", notify_session.msg_destination);
+    EXPECT_EQ("Zonemgr", notify_session.getMessageDest());
     EXPECT_EQ("notify",
-              notify_session.sent_msg->get("command")->get(0)->stringValue());
+              notify_session.getSentMessage()->get("command")->get(0)->stringValue());
     ConstElementPtr notify_args =
-        notify_session.sent_msg->get("command")->get(1);
+        notify_session.getSentMessage()->get("command")->get(1);
     EXPECT_EQ("example.com.", notify_args->get("zone_name")->stringValue());
     EXPECT_EQ(DEFAULT_REMOTE_ADDRESS,
               notify_args->get("master")->stringValue());
@@ -420,7 +420,7 @@ TEST_F(AuthSrvTest, notifyForCHClass) {
     // Other conditions should be the same, so simply confirm the RR class is
     // set correctly.
     ConstElementPtr notify_args =
-        notify_session.sent_msg->get("command")->get(1);
+        notify_session.getSentMessage()->get("command")->get(1);
     EXPECT_EQ("CH", notify_args->get("zone_class")->stringValue());
 }
 

+ 8 - 4
src/bin/auth/tests/mockups.h

@@ -45,8 +45,8 @@ public:
                       "mock session send is disabled for test");
         }
 
-        sent_msg = msg;
-        msg_destination = group;
+        sent_msg_ = msg;
+        msg_dest_ = group;
         return (0);
     }
 
@@ -83,13 +83,17 @@ public:
     virtual void setTimeout(size_t timeout UNUSED_PARAM) {};
     virtual size_t getTimeout() const { return 0; };
 
+    // The following methods extent AbstractSession to allow testing:
     void setMessage(isc::data::ConstElementPtr msg) { msg_ = msg; }
     void disableSend() { send_ok_ = false; }
     void disableReceive() { receive_ok_ = false; }
 
-    isc::data::ConstElementPtr sent_msg;
-    std::string msg_destination;
+    isc::data::ConstElementPtr getSentMessage() { return (sent_msg_); }
+    std::string getMessageDest() { return (msg_dest_); }
+
 private:
+    isc::data::ConstElementPtr sent_msg_;
+    std::string msg_dest_;
     isc::data::ConstElementPtr msg_;
     bool send_ok_;
     bool receive_ok_;

+ 5 - 3
src/bin/recurse/main.cc

@@ -59,6 +59,7 @@ namespace {
 
 static bool verbose_mode = false;
 
+// Default port current 5300 for testing purposes
 static const string PROGRAM = "Recurse";
 static const char* DNSPORT = "5300";
 
@@ -87,14 +88,15 @@ my_command_handler(const string& command, ConstElementPtr args) {
 
 void
 usage() {
-    cerr << "Usage:  b10-recurse -f nameserver [-a address] [-p port] "
+    cerr << "Usage:  b10-recurse -f nameserver [-a address] [-p port] [-u user]"
                      "[-4|-6] [-v]" << endl;
     cerr << "\t-f: specify the nameserver to which queries should be forwarded"
          << endl;
     cerr << "\t-a: specify the address to listen on (default: all)" << endl;
-    cerr << "\t-p: specify the port to listen on (default: 5300)" << endl;
+    cerr << "\t-p: specify the port to listen on (default: " << DNSPORT << ")"
+         << endl;
     cerr << "\t-4: listen on all IPv4 addresses (incompatible with -a)" << endl;
-    cerr << "\t-4: listen on all IPv6 addresses (incompatible with -a)" << endl;
+    cerr << "\t-6: listen on all IPv6 addresses (incompatible with -a)" << endl;
     cerr << "\t-u: change process UID to the specified user" << endl;
     cerr << "\t-v: verbose output" << endl;
     exit(1);

+ 5 - 4
src/bin/recurse/recursor.cc

@@ -86,18 +86,19 @@ public:
                             OutputBufferPtr buffer,
                             DNSServer* server);
 
-    ModuleCCSession* config_session_;
+    /// Currently non-configurable, but will be.
+    static const uint16_t DEFAULT_LOCAL_UDPSIZE = 4096;
 
+    /// These members are public because Recursor accesses them directly.
+    ModuleCCSession* config_session_;
     bool verbose_mode_;
 
+private:
     /// Address of the forward nameserver
     const char& forward_;
 
     /// Object to handle upstream queries
     RecursiveQuery* rec_query_;
-
-    /// Currently non-configurable, but will be.
-    static const uint16_t DEFAULT_LOCAL_UDPSIZE = 4096;
 };
 
 class QuestionInserter {

+ 1 - 1
src/lib/asiolink/ioaddress.h

@@ -73,7 +73,7 @@ public:
     /// and if it fails the corresponding standard exception will be thrown.
     ///
     /// \return A string representation of the address.
-    std::string toText() const;
+    virtual std::string toText() const;
 
     /// \brief Returns the address family.
     virtual short getFamily() const;