mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 21:45:37 +00:00
[#3696] Updated UT files
This commit is contained in:
@@ -144,16 +144,7 @@ size_t
|
|||||||
D2Process::runIO() {
|
D2Process::runIO() {
|
||||||
// Handle events registered by hooks using external IOService objects.
|
// Handle events registered by hooks using external IOService objects.
|
||||||
IOServiceMgr::instance().pollIOServices();
|
IOServiceMgr::instance().pollIOServices();
|
||||||
// We want to block until at least one handler is called. We'll use
|
// We want to block until at least one handler is called.
|
||||||
// boost::asio::io_service directly for two reasons. First off
|
|
||||||
// asiolink::IOService::runOne is a void and boost::asio::io_service::stopped
|
|
||||||
// is not present in older versions of boost. We need to know if any
|
|
||||||
// handlers ran or if the io_service was stopped. That latter represents
|
|
||||||
// some form of error and the application cannot proceed with a stopped
|
|
||||||
// service. Secondly, asiolink::IOService does not provide the poll
|
|
||||||
// method. This is a handy method which runs all ready handlers without
|
|
||||||
// blocking.
|
|
||||||
|
|
||||||
// Poll runs all that are ready. If none are ready it returns immediately
|
// Poll runs all that are ready. If none are ready it returns immediately
|
||||||
// with a count of zero.
|
// with a count of zero.
|
||||||
size_t cnt = getIOService()->poll();
|
size_t cnt = getIOService()->poll();
|
||||||
|
@@ -44,7 +44,7 @@ namespace ph = std::placeholders;
|
|||||||
namespace isc {
|
namespace isc {
|
||||||
namespace asiodns {
|
namespace asiodns {
|
||||||
|
|
||||||
const boost::asio::ip::address TEST_HOST(boost::asio::ip::address::from_string("127.0.0.1"));
|
const boost::asio::ip::address TEST_HOST(boost::asio::ip::make_address("127.0.0.1"));
|
||||||
const uint16_t TEST_PORT(5301);
|
const uint16_t TEST_PORT(5301);
|
||||||
const int SEND_INTERVAL = 250; // Interval in ms between TCP sends
|
const int SEND_INTERVAL = 250; // Interval in ms between TCP sends
|
||||||
const size_t MAX_SIZE = 64 * 1024; // Should be able to take 64kB
|
const size_t MAX_SIZE = 64 * 1024; // Should be able to take 64kB
|
||||||
|
@@ -82,7 +82,7 @@ public:
|
|||||||
/// connectHandler as a callback function.
|
/// connectHandler as a callback function.
|
||||||
void connect() {
|
void connect() {
|
||||||
boost::asio::ip::tcp::endpoint
|
boost::asio::ip::tcp::endpoint
|
||||||
endpoint(boost::asio::ip::address::from_string(SERVER_ADDRESS),
|
endpoint(boost::asio::ip::make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT);
|
SERVER_PORT);
|
||||||
socket_.async_connect(endpoint,
|
socket_.async_connect(endpoint,
|
||||||
std::bind(&TCPClient::connectHandler, this,
|
std::bind(&TCPClient::connectHandler, this,
|
||||||
@@ -208,7 +208,7 @@ public:
|
|||||||
/// unsuccessful.
|
/// unsuccessful.
|
||||||
TCPAcceptorTest()
|
TCPAcceptorTest()
|
||||||
: io_service_(new IOService()), acceptor_(io_service_),
|
: io_service_(new IOService()), acceptor_(io_service_),
|
||||||
asio_endpoint_(boost::asio::ip::address::from_string(SERVER_ADDRESS),
|
asio_endpoint_(boost::asio::ip::make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT),
|
SERVER_PORT),
|
||||||
endpoint_(asio_endpoint_), test_timer_(io_service_), connections_(),
|
endpoint_(asio_endpoint_), test_timer_(io_service_), connections_(),
|
||||||
clients_(), connections_num_(0), aborted_connections_num_(0),
|
clients_(), connections_num_(0), aborted_connections_num_(0),
|
||||||
|
@@ -83,8 +83,7 @@ public:
|
|||||||
/// connectHandler as a callback function.
|
/// connectHandler as a callback function.
|
||||||
void connect() {
|
void connect() {
|
||||||
ip::tcp::endpoint
|
ip::tcp::endpoint
|
||||||
endpoint(ip::address::from_string(SERVER_ADDRESS),
|
endpoint(ip::make_address(SERVER_ADDRESS), SERVER_PORT);
|
||||||
SERVER_PORT);
|
|
||||||
socket_.async_connect(endpoint,
|
socket_.async_connect(endpoint,
|
||||||
std::bind(&TLSClient::connectHandler, this,
|
std::bind(&TLSClient::connectHandler, this,
|
||||||
ph::_1));
|
ph::_1));
|
||||||
@@ -215,8 +214,7 @@ public:
|
|||||||
/// unsuccessful.
|
/// unsuccessful.
|
||||||
TLSAcceptorTest()
|
TLSAcceptorTest()
|
||||||
: io_service_(new IOService()), acceptor_(io_service_),
|
: io_service_(new IOService()), acceptor_(io_service_),
|
||||||
asio_endpoint_(ip::address::from_string(SERVER_ADDRESS),
|
asio_endpoint_(ip::make_address(SERVER_ADDRESS), SERVER_PORT),
|
||||||
SERVER_PORT),
|
|
||||||
endpoint_(asio_endpoint_), test_timer_(io_service_), connections_(),
|
endpoint_(asio_endpoint_), test_timer_(io_service_), connections_(),
|
||||||
clients_(), connections_num_(0), aborted_connections_num_(0),
|
clients_(), connections_num_(0), aborted_connections_num_(0),
|
||||||
max_connections_(1), running_(true) {
|
max_connections_(1), running_(true) {
|
||||||
|
@@ -772,7 +772,7 @@ TEST_F(TLSTest, noHandshake) {
|
|||||||
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
||||||
|
|
||||||
// Accept a client.
|
// Accept a client.
|
||||||
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT));
|
SERVER_PORT));
|
||||||
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
||||||
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
||||||
@@ -877,7 +877,7 @@ TEST_F(TLSTest, serverNotConfigured) {
|
|||||||
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
||||||
|
|
||||||
// Accept a client.
|
// Accept a client.
|
||||||
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT));
|
SERVER_PORT));
|
||||||
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
||||||
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
||||||
@@ -975,7 +975,7 @@ TEST_F(TLSTest, clientNotConfigured) {
|
|||||||
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
||||||
|
|
||||||
// Accept a client.
|
// Accept a client.
|
||||||
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT));
|
SERVER_PORT));
|
||||||
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
||||||
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
||||||
@@ -1072,7 +1072,7 @@ TEST_F(TLSTest, clientHTTPnoS) {
|
|||||||
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
||||||
|
|
||||||
// Accept a client.
|
// Accept a client.
|
||||||
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT));
|
SERVER_PORT));
|
||||||
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
||||||
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
||||||
@@ -1165,7 +1165,7 @@ TEST_F(TLSTest, unknownClient) {
|
|||||||
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
||||||
|
|
||||||
// Accept a client.
|
// Accept a client.
|
||||||
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT));
|
SERVER_PORT));
|
||||||
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
||||||
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
||||||
@@ -1254,7 +1254,7 @@ TEST_F(TLSTest, anotherClient) {
|
|||||||
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
||||||
|
|
||||||
// Accept a client.
|
// Accept a client.
|
||||||
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT));
|
SERVER_PORT));
|
||||||
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
||||||
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
||||||
@@ -1353,7 +1353,7 @@ TEST_F(TLSTest, selfSigned) {
|
|||||||
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
||||||
|
|
||||||
// Accept a client.
|
// Accept a client.
|
||||||
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT));
|
SERVER_PORT));
|
||||||
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
||||||
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
||||||
@@ -1460,7 +1460,7 @@ TEST_F(TLSTest, noHandshakeCloseonError) {
|
|||||||
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
||||||
|
|
||||||
// Accept a client.
|
// Accept a client.
|
||||||
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT));
|
SERVER_PORT));
|
||||||
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
||||||
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
||||||
@@ -1561,7 +1561,7 @@ TEST_F(TLSTest, serverNotConfiguredCloseonError) {
|
|||||||
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
||||||
|
|
||||||
// Accept a client.
|
// Accept a client.
|
||||||
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT));
|
SERVER_PORT));
|
||||||
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
||||||
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
||||||
@@ -1658,7 +1658,7 @@ TEST_F(TLSTest, clientNotConfiguredCloseonError) {
|
|||||||
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
||||||
|
|
||||||
// Accept a client.
|
// Accept a client.
|
||||||
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT));
|
SERVER_PORT));
|
||||||
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
||||||
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
||||||
@@ -1754,7 +1754,7 @@ TEST_F(TLSTest, clientHTTPnoSCloseonError) {
|
|||||||
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
||||||
|
|
||||||
// Accept a client.
|
// Accept a client.
|
||||||
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT));
|
SERVER_PORT));
|
||||||
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
||||||
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
||||||
@@ -1847,7 +1847,7 @@ TEST_F(TLSTest, anotherClientCloseonError) {
|
|||||||
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
||||||
|
|
||||||
// Accept a client.
|
// Accept a client.
|
||||||
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT));
|
SERVER_PORT));
|
||||||
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
||||||
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
||||||
@@ -1944,7 +1944,7 @@ TEST_F(TLSTest, selfSignedCloseonError) {
|
|||||||
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
||||||
|
|
||||||
// Accept a client.
|
// Accept a client.
|
||||||
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT));
|
SERVER_PORT));
|
||||||
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
||||||
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
||||||
@@ -2048,7 +2048,7 @@ TEST_F(TLSTest, anotherClientNoReq) {
|
|||||||
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
||||||
|
|
||||||
// Accept a client.
|
// Accept a client.
|
||||||
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT));
|
SERVER_PORT));
|
||||||
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
||||||
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
||||||
@@ -2118,7 +2118,7 @@ TEST_F(TLSTest, serverRaw) {
|
|||||||
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
||||||
|
|
||||||
// Accept a client.
|
// Accept a client.
|
||||||
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT));
|
SERVER_PORT));
|
||||||
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
||||||
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
||||||
@@ -2189,7 +2189,7 @@ TEST_F(TLSTest, trustedSelfSigned) {
|
|||||||
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
||||||
|
|
||||||
// Accept a client.
|
// Accept a client.
|
||||||
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT));
|
SERVER_PORT));
|
||||||
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
||||||
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
||||||
@@ -2265,7 +2265,7 @@ TEST_F(TLSTest, shutdownInactive) {
|
|||||||
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
||||||
|
|
||||||
// Accept a client.
|
// Accept a client.
|
||||||
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT));
|
SERVER_PORT));
|
||||||
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
||||||
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
||||||
@@ -2360,7 +2360,7 @@ TEST_F(TLSTest, shutdownActive) {
|
|||||||
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
||||||
|
|
||||||
// Accept a client.
|
// Accept a client.
|
||||||
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT));
|
SERVER_PORT));
|
||||||
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
||||||
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
||||||
@@ -2469,7 +2469,7 @@ TEST_F(TLSTest, shutdownCloseInactive) {
|
|||||||
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
||||||
|
|
||||||
// Accept a client.
|
// Accept a client.
|
||||||
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT));
|
SERVER_PORT));
|
||||||
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
||||||
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
||||||
@@ -2570,7 +2570,7 @@ TEST_F(TLSTest, shutdownCloseActive) {
|
|||||||
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
|
||||||
|
|
||||||
// Accept a client.
|
// Accept a client.
|
||||||
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
|
||||||
SERVER_PORT));
|
SERVER_PORT));
|
||||||
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
|
||||||
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
acceptor.set_option(tcp::acceptor::reuse_address(true));
|
||||||
|
@@ -101,7 +101,7 @@ public:
|
|||||||
class client
|
class client
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
client(boost::asio::io_service& io_context,
|
client(boost::asio::io_context& io_context,
|
||||||
Botan::TLS::Context& context,
|
Botan::TLS::Context& context,
|
||||||
const tcp::endpoint& endpoint)
|
const tcp::endpoint& endpoint)
|
||||||
: socket_(io_context, context)
|
: socket_(io_context, context)
|
||||||
@@ -205,11 +205,11 @@ int main(int argc, char* argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::asio::io_service io_context;
|
boost::asio::io_context io_context;
|
||||||
|
|
||||||
using namespace std; // For atoi.
|
using namespace std; // For atoi.
|
||||||
tcp::endpoint endpoint(
|
tcp::endpoint endpoint(
|
||||||
boost::asio::ip::address::from_string(argv[1]), atoi(argv[2]));
|
boost::asio::ip::make_address(argv[1]), atoi(argv[2]));
|
||||||
Botan::AutoSeeded_RNG rng;
|
Botan::AutoSeeded_RNG rng;
|
||||||
Client_Credentials_Manager creds_mgr(rng);
|
Client_Credentials_Manager creds_mgr(rng);
|
||||||
Client_Session_Manager sess_mgr;
|
Client_Session_Manager sess_mgr;
|
||||||
|
@@ -160,7 +160,7 @@ private:
|
|||||||
class server
|
class server
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
server(boost::asio::io_service& io_context,
|
server(boost::asio::io_contex& io_context,
|
||||||
unsigned short port,
|
unsigned short port,
|
||||||
Botan::Credentials_Manager& creds_mgr,
|
Botan::Credentials_Manager& creds_mgr,
|
||||||
Botan::RandomNumberGenerator& rng,
|
Botan::RandomNumberGenerator& rng,
|
||||||
@@ -201,7 +201,7 @@ int main(int argc, char* argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::asio::io_service io_context;
|
boost::asio::io_context io_context;
|
||||||
|
|
||||||
Botan::AutoSeeded_RNG rng;
|
Botan::AutoSeeded_RNG rng;
|
||||||
Server_Credentials_Manager creds_mgr(rng);
|
Server_Credentials_Manager creds_mgr(rng);
|
||||||
|
@@ -34,7 +34,7 @@ enum { max_length = 1024 };
|
|||||||
class client
|
class client
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
client(boost::asio::io_service& io_context,
|
client(boost::asio::io_context& io_context,
|
||||||
boost::asio::ssl::context& context,
|
boost::asio::ssl::context& context,
|
||||||
const tcp::endpoint& endpoint)
|
const tcp::endpoint& endpoint)
|
||||||
: socket_(io_context, context)
|
: socket_(io_context, context)
|
||||||
@@ -154,11 +154,11 @@ int main(int argc, char* argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::asio::io_service io_context;
|
boost::asio::io_context io_context;
|
||||||
|
|
||||||
using namespace std; // For atoi.
|
using namespace std; // For atoi.
|
||||||
tcp::endpoint endpoint(
|
tcp::endpoint endpoint(
|
||||||
boost::asio::ip::address::from_string(argv[1]), atoi(argv[2]));
|
boost::asio::ip::make_address(argv[1]), atoi(argv[2]));
|
||||||
|
|
||||||
boost::asio::ssl::context ctx(boost::asio::ssl::context::method::tls);
|
boost::asio::ssl::context ctx(boost::asio::ssl::context::method::tls);
|
||||||
ctx.load_verify_file(CA_("kea-ca.crt"));
|
ctx.load_verify_file(CA_("kea-ca.crt"));
|
||||||
|
@@ -32,7 +32,7 @@ typedef boost::asio::ssl::stream<boost::asio::ip::tcp::socket> ssl_socket;
|
|||||||
class session
|
class session
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
session(boost::asio::io_service& io_context,
|
session(boost::asio::io_context& io_context,
|
||||||
boost::asio::ssl::context& context)
|
boost::asio::ssl::context& context)
|
||||||
: socket_(io_context, context)
|
: socket_(io_context, context)
|
||||||
{
|
{
|
||||||
@@ -106,7 +106,7 @@ private:
|
|||||||
class server
|
class server
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
server(boost::asio::io_service& io_context, unsigned short port)
|
server(boost::asio::io_context& io_context, unsigned short port)
|
||||||
: io_context_(io_context),
|
: io_context_(io_context),
|
||||||
acceptor_(io_context,
|
acceptor_(io_context,
|
||||||
boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port)),
|
boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port)),
|
||||||
@@ -152,7 +152,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
boost::asio::io_service& io_context_;
|
boost::asio::io_context& io_context_;
|
||||||
boost::asio::ip::tcp::acceptor acceptor_;
|
boost::asio::ip::tcp::acceptor acceptor_;
|
||||||
boost::asio::ssl::context context_;
|
boost::asio::ssl::context context_;
|
||||||
};
|
};
|
||||||
@@ -167,7 +167,7 @@ int main(int argc, char* argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::asio::io_service io_context;
|
boost::asio::io_context io_context;
|
||||||
|
|
||||||
using namespace std; // For atoi.
|
using namespace std; // For atoi.
|
||||||
server s(io_context, atoi(argv[1]));
|
server s(io_context, atoi(argv[1]));
|
||||||
|
@@ -179,7 +179,7 @@ public:
|
|||||||
|
|
||||||
/// @brief Runs IO service with optional timeout.
|
/// @brief Runs IO service with optional timeout.
|
||||||
///
|
///
|
||||||
/// We iterate over calls to asio::io_service.run(), until
|
/// We iterate over calls to asio::io_context.run(), until
|
||||||
/// all the clients have completed their requests. We do it this way
|
/// all the clients have completed their requests. We do it this way
|
||||||
/// because the test clients stop the io_service when they're
|
/// because the test clients stop the io_service when they're
|
||||||
/// through with a request.
|
/// through with a request.
|
||||||
|
@@ -397,8 +397,7 @@ public:
|
|||||||
socket_.reset(new udp::socket(service_->getInternalIOService(),
|
socket_.reset(new udp::socket(service_->getInternalIOService(),
|
||||||
boost::asio::ip::udp::v4()));
|
boost::asio::ip::udp::v4()));
|
||||||
socket_->set_option(socket_base::reuse_address(true));
|
socket_->set_option(socket_base::reuse_address(true));
|
||||||
socket_->bind(udp::endpoint(address::from_string(TEST_ADDRESS),
|
socket_->bind(udp::endpoint(make_address(TEST_ADDRESS), TEST_PORT));
|
||||||
TEST_PORT));
|
|
||||||
// Once socket is created, we can post an IO request to receive some
|
// Once socket is created, we can post an IO request to receive some
|
||||||
// packet from this socket. This is asynchronous operation and
|
// packet from this socket. This is asynchronous operation and
|
||||||
// nothing is received until another IO request to send a query is
|
// nothing is received until another IO request to send a query is
|
||||||
@@ -469,8 +468,7 @@ public:
|
|||||||
// Setup our "loopback" server.
|
// Setup our "loopback" server.
|
||||||
udp::socket udp_socket(service_->getInternalIOService(), boost::asio::ip::udp::v4());
|
udp::socket udp_socket(service_->getInternalIOService(), boost::asio::ip::udp::v4());
|
||||||
udp_socket.set_option(socket_base::reuse_address(true));
|
udp_socket.set_option(socket_base::reuse_address(true));
|
||||||
udp_socket.bind(udp::endpoint(address::from_string(TEST_ADDRESS),
|
udp_socket.bind(udp::endpoint(make_address(TEST_ADDRESS), TEST_PORT));
|
||||||
TEST_PORT));
|
|
||||||
udp::endpoint remote;
|
udp::endpoint remote;
|
||||||
udp_socket.async_receive_from(boost::asio::buffer(receive_buffer_,
|
udp_socket.async_receive_from(boost::asio::buffer(receive_buffer_,
|
||||||
sizeof(receive_buffer_)),
|
sizeof(receive_buffer_)),
|
||||||
|
@@ -222,7 +222,7 @@ public:
|
|||||||
|
|
||||||
// Create an endpoint pointed at the listener.
|
// Create an endpoint pointed at the listener.
|
||||||
boost::asio::ip::udp::endpoint
|
boost::asio::ip::udp::endpoint
|
||||||
listener_endpoint(boost::asio::ip::address::from_string(TEST_ADDRESS),
|
listener_endpoint(boost::asio::ip::make_address(TEST_ADDRESS),
|
||||||
LISTENER_PORT);
|
LISTENER_PORT);
|
||||||
|
|
||||||
// A response message is now ready to send. Send it!
|
// A response message is now ready to send. Send it!
|
||||||
|
@@ -147,8 +147,7 @@ TEST_F(HttpListenerTest, addressInUse) {
|
|||||||
tcp::acceptor acceptor(io_service_->getInternalIOService());
|
tcp::acceptor acceptor(io_service_->getInternalIOService());
|
||||||
// Use other port than SERVER_PORT to make sure that this TCP connection
|
// Use other port than SERVER_PORT to make sure that this TCP connection
|
||||||
// doesn't affect subsequent tests.
|
// doesn't affect subsequent tests.
|
||||||
tcp::endpoint endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint endpoint(make_address(SERVER_ADDRESS), SERVER_PORT + 1);
|
||||||
SERVER_PORT + 1);
|
|
||||||
acceptor.open(endpoint.protocol());
|
acceptor.open(endpoint.protocol());
|
||||||
acceptor.bind(endpoint);
|
acceptor.bind(endpoint);
|
||||||
|
|
||||||
|
@@ -161,8 +161,7 @@ TEST_F(HttpsListenerTest, addressInUse) {
|
|||||||
tcp::acceptor acceptor(io_service_->getInternalIOService());
|
tcp::acceptor acceptor(io_service_->getInternalIOService());
|
||||||
// Use other port than SERVER_PORT to make sure that this TCP connection
|
// Use other port than SERVER_PORT to make sure that this TCP connection
|
||||||
// doesn't affect subsequent tests.
|
// doesn't affect subsequent tests.
|
||||||
tcp::endpoint endpoint(address::from_string(SERVER_ADDRESS),
|
tcp::endpoint endpoint(make_address(SERVER_ADDRESS), SERVER_PORT + 1);
|
||||||
SERVER_PORT + 1);
|
|
||||||
acceptor.open(endpoint.protocol());
|
acceptor.open(endpoint.protocol());
|
||||||
acceptor.bind(endpoint);
|
acceptor.bind(endpoint);
|
||||||
|
|
||||||
|
@@ -117,7 +117,7 @@ public:
|
|||||||
///
|
///
|
||||||
/// @param request HTTP request in the textual format.
|
/// @param request HTTP request in the textual format.
|
||||||
virtual void startRequest(const std::string& request) {
|
virtual void startRequest(const std::string& request) {
|
||||||
tcp::endpoint endpoint(address::from_string(server_address_), server_port_);
|
tcp::endpoint endpoint(make_address(server_address_), server_port_);
|
||||||
auto ref = shared_from_this();
|
auto ref = shared_from_this();
|
||||||
socket_.async_connect(endpoint,
|
socket_.async_connect(endpoint,
|
||||||
[this, ref, request](const boost::system::error_code& ec) {
|
[this, ref, request](const boost::system::error_code& ec) {
|
||||||
@@ -392,8 +392,7 @@ public:
|
|||||||
///
|
///
|
||||||
/// @param request HTTP request in the textual format.
|
/// @param request HTTP request in the textual format.
|
||||||
virtual void startRequest(const std::string& request) {
|
virtual void startRequest(const std::string& request) {
|
||||||
tcp::endpoint endpoint(address::from_string(server_address_),
|
tcp::endpoint endpoint(make_address(server_address_), server_port_);
|
||||||
server_port_);
|
|
||||||
auto ref = shared_from_this();
|
auto ref = shared_from_this();
|
||||||
stream_.lowest_layer().async_connect(endpoint,
|
stream_.lowest_layer().async_connect(endpoint,
|
||||||
[this, ref, request](const boost::system::error_code& ec) {
|
[this, ref, request](const boost::system::error_code& ec) {
|
||||||
|
@@ -214,7 +214,7 @@ public:
|
|||||||
|
|
||||||
/// @brief Runs IO service with optional timeout.
|
/// @brief Runs IO service with optional timeout.
|
||||||
///
|
///
|
||||||
/// We iterate over calls to asio::io_service.run(), until
|
/// We iterate over calls to asio::io_context.run(), until
|
||||||
/// all the clients have completed their requests. We do it this way
|
/// all the clients have completed their requests. We do it this way
|
||||||
/// because the test clients stop the io_service when they're
|
/// because the test clients stop the io_service when they're
|
||||||
/// through with a request.
|
/// through with a request.
|
||||||
|
@@ -114,7 +114,7 @@ public:
|
|||||||
/// Upon successful connection, carry out the TLS handshake. If the handshake
|
/// Upon successful connection, carry out the TLS handshake. If the handshake
|
||||||
/// completes successful start sending requests.
|
/// completes successful start sending requests.
|
||||||
void start() {
|
void start() {
|
||||||
isc::asiolink::TCPEndpoint endpoint(boost::asio::ip::address::from_string(server_address_), server_port_);
|
isc::asiolink::TCPEndpoint endpoint(boost::asio::ip::make_address(server_address_), server_port_);
|
||||||
SocketCallback socket_cb(
|
SocketCallback socket_cb(
|
||||||
[this](boost::system::error_code ec, size_t /*length */) {
|
[this](boost::system::error_code ec, size_t /*length */) {
|
||||||
receive_done_ = false;
|
receive_done_ = false;
|
||||||
|
Reference in New Issue
Block a user