Kea 3.3.1
cmd_http_listener.h
Go to the documentation of this file.
1// Copyright (C) 2021-2022 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef CMD_HTTP_LISTENER_H
8#define CMD_HTTP_LISTENER_H
9
10#include <asiolink/io_address.h>
11#include <asiolink/io_service.h>
13#include <http/auth_config.h>
14#include <http/listener.h>
15#include <thread>
16#include <vector>
17
18namespace isc {
19namespace config {
20
34public:
36 CmdHttpListener(const asiolink::IOAddress& address, const uint16_t port,
37 const uint16_t thread_pool_size = 1,
40 std::unordered_set<std::string> command_accept_list = {});
41
43 virtual ~CmdHttpListener();
44
50 void checkPermissions();
51
53 void start();
54
58 void pause();
59
63 void resume();
64
66 void stop();
67
72 bool isRunning();
73
78 bool isStopped();
79
84 bool isPaused();
85
90 return (address_);
91 }
92
96 uint16_t getPort() const {
97 return (port_);
98 }
99
103 uint16_t getThreadPoolSize() const {
104 return (thread_pool_size_);
105 }
106
111 return (tls_context_);
112 }
113
117 uint16_t getThreadCount() const {
118 if (!thread_pool_) {
119 return (0);
120 }
121
122 return (thread_pool_->getThreadCount());
123 }
124
131 return (thread_io_service_);
132 }
133
138 return (http_auth_config_);
139 }
140
144 std::unordered_set<std::string> getCommandAcceptList() const {
145 return (command_accept_list_);
146 }
147
148private:
151
153 uint16_t port_;
154
156 isc::asiolink::IOServicePtr thread_io_service_;
157
159 http::HttpListenerPtr http_listener_;
160
162 std::size_t thread_pool_size_;
163
166
168 asiolink::TlsContextPtr tls_context_;
169
171 http::HttpAuthConfigPtr http_auth_config_;
172
174 std::unordered_set<std::string> command_accept_list_;
175};
176
178typedef boost::shared_ptr<CmdHttpListener> CmdHttpListenerPtr;
179
180} // namespace isc::config
181} // namespace isc
182
183#endif // CMD_HTTP_LISTENER_H
CmdHttpListener(const asiolink::IOAddress &address, const uint16_t port, const uint16_t thread_pool_size=1, asiolink::TlsContextPtr context=asiolink::TlsContextPtr(), http::HttpAuthConfigPtr http_auth_config=http::HttpAuthConfigPtr(), std::unordered_set< std::string > command_accept_list={})
Constructor.
uint16_t getThreadCount() const
Fetches the number of threads in the pool.
std::unordered_set< std::string > getCommandAcceptList() const
Fetches the command accept list.
http::HttpAuthConfigPtr getAuthConfig() const
Fetches the authentication configuration.
uint16_t getThreadPoolSize() const
Fetches the maximum size of the thread pool.
uint16_t getPort() const
Fetches the port number on which to listen.
void checkPermissions()
Check if the current thread can perform thread pool state transition.
isc::asiolink::IOAddress getAddress() const
Fetches the IP address on which to listen.
void start()
Starts running the listener's thread pool.
virtual ~CmdHttpListener()
Destructor.
asiolink::TlsContextPtr getTlsContext() const
Fetches the TLS context.
bool isPaused()
Indicates if the thread pool is paused.
asiolink::IOServicePtr getThreadIOService() const
Fetches a pointer to the internal IOService used to drive the thread-pool in multi-threaded mode.
void pause()
Pauses the listener's thread pool.
void resume()
Resumes running the listener's thread pool.
bool isRunning()
Indicates if the thread pool is running.
void stop()
Stops the listener's thread pool.
bool isStopped()
Indicates if the thread pool is stopped.
boost::shared_ptr< CmdHttpListener > CmdHttpListenerPtr
Defines a shared pointer to CmdHttpListener.
boost::shared_ptr< HttpAuthConfig > HttpAuthConfigPtr
Type of shared pointers to HTTP authentication configuration.
Definition auth_config.h:97
boost::shared_ptr< HttpListener > HttpListenerPtr
Pointer to the HttpListener.
Definition listener.h:156
Defines the logger used by the top-level component of kea-lfc.