libnavajo
web server for static and dynamic pages developement in C++
Public Member Functions | Static Public Member Functions | List of all members
WebServer Class Reference

Public Member Functions

void setWebServerName (const std::string &name)
 
void setThreadsPoolSize (const size_t nbThread)
 
void setServerPort (const ushort p)
 
void setDevice (const char *d)
 
void setUseSSL (bool ssl, const char *certFile="", const char *certPwd="")
 
void setAuthPeerSSL (const bool a=true, const char *caFile="")
 
void addAuthPeerDN (const char *dn)
 
void addLoginPass (const char *login, const char *pass)
 
void setMutipartTempDirForFileUpload (const std::string &pathdir)
 
void setMutipartMaxCollectedDataLength (const long &max)
 
void addRepository (WebRepository *repo)
 
void addWebSocket (const std::string endPoint, WebSocket *websocket)
 
void listenIpV4only ()
 
void listenIpV6only ()
 
void addHostsAllowed (const IpNetwork &ipnet)
 
std::map< IpAddress, time_t > & getPeerIpHistory ()
 
std::map< std::string, time_t > & getPeerDnHistory ()
 
void startService ()
 
void stopService ()
 
void wait ()
 
bool isRunning ()
 

Static Public Member Functions

static bool httpSend (ClientSockData *client, const void *buf, size_t len)
 
static void freeClientSockData (ClientSockData *c)
 

Member Function Documentation

void WebServer::addAuthPeerDN ( const char *  dn)
inline

Restricted X509 authentification to a DN user list. Add this given DN.

Parameters
dnuser certificate DN
void WebServer::addHostsAllowed ( const IpNetwork ipnet)
inline

set network access restriction to webserver.

Parameters
ipnetan IpNetwork of allowed web client to add
void WebServer::addLoginPass ( const char *  login,
const char *  pass 
)
inline

Enabled http authentification for a given login/password list

Parameters
loginuser login
pass: user password
void WebServer::addRepository ( WebRepository repo)
inline

Add a web repository (containing web pages)

Parameters
repo: a pointer to a WebRepository instance
void WebServer::addWebSocket ( const std::string  endPoint,
WebSocket websocket 
)
inline

Add a websocket

Parameters
endpoint: websocket endpoint
websocket: WebSocket instance
std::map<std::string,time_t>& WebServer::getPeerDnHistory ( )
inline

Get the list of http client DN (work with X509 authentification)

Returns
a map of every DN and last connection to the webserver
std::map<IpAddress,time_t>& WebServer::getPeerIpHistory ( )
inline

Get the list of http client peer IP address.

Returns
a map of every IP address and last connection to the webserver
bool WebServer::isRunning ( )
inline

is the webserver runnning ?

void WebServer::listenIpV4only ( )
inline

IpV4 hosts only

void WebServer::listenIpV6only ( )
inline

IpV6 hosts only

void WebServer::setAuthPeerSSL ( const bool  a = true,
const char *  caFile = "" 
)
inline

Enabled or disabled X509 authentification

Parameters
aboolean. X509 authentification is required if a is true.
caFilethe path to cachain file
void WebServer::setDevice ( const char *  d)
inline

Set the device to use (work on linux only).

Parameters
dthe device name
void WebServer::setMutipartMaxCollectedDataLength ( const long &  max)
inline

Set the size of internal MPFD buffer. The buffer is used to store temporary information while parsing field names and other data that identified by any boundaries. In theory some bad man can give you lots of unboundered and eat all your memory. To except this situation you should tell Parser maximum buffer size. Note that file content is transferred directly to disk (of selected) without any buffering.

Parameters
maxthe internal buffer size
void WebServer::setMutipartTempDirForFileUpload ( const std::string &  pathdir)
inline

Set the path to store uploaded files on disk. Used to set the MPFD function.

Parameters
pathdirpath to a writtable directory
void WebServer::setServerPort ( const ushort  p)
inline

Set the tcp port to listen.

Parameters
pthe port number, from 1 to 65535 (Default value: 8080)
void WebServer::setThreadsPoolSize ( const size_t  nbThread)
inline

Set the size of the listener thread pool.

Parameters
nbThreadthe number of thread available (Default value: 5)
void WebServer::setUseSSL ( bool  ssl,
const char *  certFile = "",
const char *  certPwd = "" 
)
inline

Enabled or disabled HTTPS

Parameters
sslboolean. SSL connections are used if ssl is true.
certFilethe path to cert file
certPwdoptional certificat password
void WebServer::setWebServerName ( const std::string &  name)
inline

Set the web server name in the http header

Parameters
namethe new name
void WebServer::startService ( )
inline

startService: the webserver starts

void WebServer::stopService ( )
inline

stopService: the webserver stops

void WebServer::wait ( )
inline

wait until the webserver is stopped


The documentation for this class was generated from the following files: