Class Server
Defined in File server.h
Class Documentation
-
class Server
Public Functions
The default constructor.
- Parameters:
library – The library to serve.
-
virtual ~Server()
-
bool start()
Start serving the content.
-
void stop()
Stop the daemon.
-
void setRoot(const std::string &root)
Set the path of the root URL served by this server instance.
-
void setAddress(const std::string &addr)
Set the IP address on which to listen for incoming connections.
Specifying a non-empty IP address requires that the IpMode is set to
IpMode::AUTO(which is the default). Otherwise, starting the server will fail.
-
inline void setPort(int port)
Set the port on which to listen for incoming connections.
Default port is 80, but using it requires special privileges.
-
inline void setNbThreads(int threads)
-
inline void setMultiZimSearchLimit(unsigned int limit)
-
inline void setIpConnectionLimit(int limit)
-
inline void setVerbose(bool verbose)
-
inline void setIndexTemplateString(const std::string &indexTemplateString)
-
inline void setTaskbar(bool withTaskbar, bool withLibraryButton)
-
inline void setBlockExternalLinks(bool blockExternalLinks)
-
inline void setCatalogOnlyMode(bool enable)
-
inline void setContentServerUrl(std::string url)
-
inline void setIpMode(IpMode mode)
Listen for incoming connections on all IP addresses of the specified IP protocol family.
-
int getPort() const
Get the port on which the server listens for incoming connections
-
IpAddress getAddress() const
Get the IPv4 and/or IPv6 address(es) on which the server can be contacted.
The server may actually be listening on other IP addresses as well (see
setIpMode()). The IP address(es) returned by this method represent the best-guess public IP address(es) accessible by the broadest set of clients.
-
IpMode getIpMode() const
Get the effective IpMode used by this server.
The returned value may be different from the one configured via
setIpMode(), since the server is expected to adjust to the constraints of the environment (e.g.IpMode::ALLcan be converted toIpMode::IPV4on a system that does not support IPv6).
-
std::vector<std::string> getServerAccessUrls() const
Get the list of HTTP URLs through which the server can be contacted.
Each URL is composed of an IP address and optional port and includes the root path component.
In the current implementation at most 2 URLs may be returned - one for IPv4 and another for IPv6 protocol (whichever is available), as returned by
getAddress(). Note, however, that the server may be also accessible via other IP-addresses/URLs (seesetIpMode()).
Protected Attributes
-
std::shared_ptr<NameMapper> mp_nameMapper
-
std::string m_root = ""
-
std::string m_indexTemplateString = ""
-
int m_port = 80
-
int m_nbThreads = 1
-
unsigned int m_multizimSearchLimit = 0
-
bool m_verbose = false
-
bool m_withTaskbar = true
-
bool m_withLibraryButton = true
-
bool m_blockExternalLinks = false
-
int m_ipConnectionLimit = 0
-
bool m_catalogOnlyMode = false
-
std::string m_contentServerUrl
-
std::unique_ptr<InternalServer> mp_server