Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
ISC Open Source Projects
Kea
Commits
94b50253
Commit
94b50253
authored
Feb 18, 2011
by
Michal 'vorner' Vaner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[trac575] Test and interface to listen addresses
parent
8578607b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
69 additions
and
1 deletion
+69
-1
src/bin/auth/Makefile.am
src/bin/auth/Makefile.am
+1
-0
src/bin/auth/auth_srv.cc
src/bin/auth/auth_srv.cc
+19
-0
src/bin/auth/auth_srv.h
src/bin/auth/auth_srv.h
+14
-0
src/bin/auth/benchmarks/Makefile.am
src/bin/auth/benchmarks/Makefile.am
+1
-0
src/bin/auth/main.cc
src/bin/auth/main.cc
+1
-0
src/bin/auth/tests/Makefile.am
src/bin/auth/tests/Makefile.am
+1
-0
src/bin/auth/tests/auth_srv_unittest.cc
src/bin/auth/tests/auth_srv_unittest.cc
+32
-1
No files found.
src/bin/auth/Makefile.am
View file @
94b50253
...
...
@@ -51,6 +51,7 @@ b10_auth_LDADD += $(top_builddir)/src/lib/cc/libcc.la
b10_auth_LDADD
+=
$(top_builddir)
/src/lib/exceptions/libexceptions.la
b10_auth_LDADD
+=
$(top_builddir)
/src/lib/asiolink/libasiolink.la
b10_auth_LDADD
+=
$(top_builddir)
/src/lib/xfr/libxfr.la
b10_auth_LDADD
+=
$(top_builddir)
/src/lib/server_common/libserver_common.la
b10_auth_LDADD
+=
$(SQLITE_LIBS)
# TODO: config.h.in is wrong because doesn't honor pkgdatadir
...
...
src/bin/auth/auth_srv.cc
View file @
94b50253
...
...
@@ -69,6 +69,7 @@ using namespace isc::data;
using
namespace
isc
::
config
;
using
namespace
isc
::
xfr
;
using
namespace
asiolink
;
using
namespace
isc
::
server_common
::
portconfig
;
class
AuthSrvImpl
{
private:
...
...
@@ -109,6 +110,9 @@ public:
/// Query counters for statistics
AuthCounters
counters_
;
/// Addresses we listen on
AddressList
listen_addresses_
;
private:
std
::
string
db_file_
;
...
...
@@ -750,3 +754,18 @@ uint64_t
AuthSrv
::
getCounter
(
const
AuthCounters
::
CounterType
type
)
const
{
return
(
impl_
->
counters_
.
getCounter
(
type
));
}
const
AddressList
&
AuthSrv
::
getListenAddresses
()
const
{
return
(
impl_
->
listen_addresses_
);
}
void
AuthSrv
::
setListenAddresses
(
const
AddressList
&
addresses
)
{
installListenAddresses
(
addresses
,
impl_
->
listen_addresses_
,
*
dnss_
);
}
void
AuthSrv
::
setDNSService
(
asiolink
::
DNSService
&
dnss
)
{
dnss_
=
&
dnss
;
}
src/bin/auth/auth_srv.h
View file @
94b50253
...
...
@@ -25,6 +25,7 @@
#include <config/ccsession.h>
#include <asiolink/asiolink.h>
#include <server_common/portconfig.h>
#include <auth/statistics.h>
namespace
isc
{
...
...
@@ -353,11 +354,24 @@ public:
/// \return the value of the counter.
uint64_t
getCounter
(
const
AuthCounters
::
CounterType
type
)
const
;
/**
* \brief Set and get the addresses we listen on.
*/
void
setListenAddresses
(
const
isc
::
server_common
::
portconfig
::
AddressList
&
addreses
);
const
isc
::
server_common
::
portconfig
::
AddressList
&
getListenAddresses
()
const
;
/// \brief Assign an ASIO DNS Service queue to this Resolver object
void
setDNSService
(
asiolink
::
DNSService
&
dnss
);
private:
AuthSrvImpl
*
impl_
;
asiolink
::
SimpleCallback
*
checkin_
;
asiolink
::
DNSLookup
*
dns_lookup_
;
asiolink
::
DNSAnswer
*
dns_answer_
;
asiolink
::
DNSService
*
dnss_
;
};
#endif // __AUTH_SRV_H
...
...
src/bin/auth/benchmarks/Makefile.am
View file @
94b50253
...
...
@@ -22,4 +22,5 @@ query_bench_LDADD += $(top_builddir)/src/lib/cc/libcc.la
query_bench_LDADD
+=
$(top_builddir)
/src/lib/xfr/libxfr.la
query_bench_LDADD
+=
$(top_builddir)
/src/lib/log/liblog.la
query_bench_LDADD
+=
$(top_builddir)
/src/lib/asiolink/libasiolink.la
query_bench_LDADD
+=
$(top_builddir)
/src/lib/server_common/libserver_common.la
query_bench_LDADD
+=
$(SQLITE_LIBS)
src/bin/auth/main.cc
View file @
94b50253
...
...
@@ -197,6 +197,7 @@ main(int argc, char* argv[]) {
use_ipv6
,
checkin
,
lookup
,
answer
);
}
auth_server
->
setDNSService
(
*
dns_service
);
cout
<<
"[b10-auth] DNSServices created."
<<
endl
;
cc_session
=
new
Session
(
io_service
.
get_io_service
());
...
...
src/bin/auth/tests/Makefile.am
View file @
94b50253
...
...
@@ -45,6 +45,7 @@ run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.la
run_unittests_LDADD
+=
$(top_builddir)
/src/lib/exceptions/libexceptions.la
run_unittests_LDADD
+=
$(top_builddir)
/src/lib/xfr/libxfr.la
run_unittests_LDADD
+=
$(top_builddir)
/src/lib/log/liblog.la
run_unittests_LDADD
+=
$(top_builddir)
/src/lib/server_common/libserver_common.la
endif
noinst_PROGRAMS
=
$(TESTS)
src/bin/auth/tests/auth_srv_unittest.cc
View file @
94b50253
...
...
@@ -26,6 +26,8 @@
#include <dns/rrttl.h>
#include <dns/rdataclass.h>
#include <server_common/portconfig.h>
#include <datasrc/memory_datasrc.h>
#include <auth/auth_srv.h>
#include <auth/common.h>
...
...
@@ -43,6 +45,7 @@ using namespace isc::data;
using
namespace
isc
::
xfr
;
using
namespace
asiolink
;
using
namespace
isc
::
testutils
;
using
namespace
isc
::
server_common
::
portconfig
;
using
isc
::
UnitTestUtil
;
namespace
{
...
...
@@ -55,7 +58,12 @@ const char* const BADCONFIG_TESTDB =
class
AuthSrvTest
:
public
SrvTestBase
{
protected:
AuthSrvTest
()
:
server
(
true
,
xfrout
),
rrclass
(
RRClass
::
IN
())
{
AuthSrvTest
()
:
dnss_
(
ios_
,
NULL
,
NULL
,
NULL
),
server
(
true
,
xfrout
),
rrclass
(
RRClass
::
IN
())
{
server
.
setDNSService
(
dnss_
);
server
.
setXfrinSession
(
&
notify_session
);
server
.
setStatisticsSession
(
&
statistics_session
);
}
...
...
@@ -63,6 +71,8 @@ protected:
server
.
processMessage
(
*
io_message
,
parse_message
,
response_obuffer
,
&
dnsserv
);
}
IOService
ios_
;
DNSService
dnss_
;
MockSession
statistics_session
;
MockXfroutClient
xfrout
;
AuthSrv
server
;
...
...
@@ -650,4 +660,25 @@ TEST_F(AuthSrvTest, stop) {
// If/when the interval timer has finer granularity we'll probably add
// our own tests here, so we keep this empty test case.
}
TEST_F
(
AuthSrvTest
,
listenAddresses
)
{
// Default value should be not listening to anything
EXPECT_TRUE
(
server
.
getListenAddresses
().
empty
());
// Try putting there some addresses
AddressList
addresses
;
addresses
.
push_back
(
AddressPair
(
"127.0.0.1"
,
5321
));
addresses
.
push_back
(
AddressPair
(
"::1"
,
5321
));
server
.
setListenAddresses
(
addresses
);
ASSERT_EQ
(
2
,
server
.
getListenAddresses
().
size
());
EXPECT_EQ
(
"::1"
,
server
.
getListenAddresses
()[
1
].
first
);
// Is it independent from what we do with the vector later?
addresses
.
clear
();
EXPECT_EQ
(
2
,
server
.
getListenAddresses
().
size
());
// Did it return to empty list if we ask it to?
server
.
setListenAddresses
(
addresses
);
EXPECT_TRUE
(
server
.
getListenAddresses
().
empty
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment