1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2024-10-27 20:44:10 +00:00
falk-werner_webfuse-provider/include/webfuse/adapter/server_config.h

154 lines
6.0 KiB
C
Raw Normal View History

2020-02-17 20:53:42 +00:00
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/server_config.h
/// \brief Server configuration.
////////////////////////////////////////////////////////////////////////////////
2019-03-26 22:04:53 +00:00
#ifndef WF_ADAPTER_SERVER_CONFIG_H
#define WF_ADAPTER_SERVER_CONFIG_H
#include "webfuse/adapter/api.h"
#include "webfuse/adapter/authenticate.h"
2020-02-13 20:48:42 +00:00
#include "webfuse/adapter/mountpoint_factory.h"
2019-03-26 22:04:53 +00:00
#ifdef __cplusplus
extern "C"
{
#endif
2020-02-17 20:53:42 +00:00
//------------------------------------------------------------------------------
/// \struct wf_server_config
/// \brief Holds configuration of webfuse adapter server.
//------------------------------------------------------------------------------
2019-03-26 22:04:53 +00:00
struct wf_server_config;
2020-02-17 20:53:42 +00:00
//------------------------------------------------------------------------------
/// \brief Creates a new server configuration.
///
/// \return newly created server configuration
//------------------------------------------------------------------------------
2019-03-26 22:04:53 +00:00
extern WF_API struct wf_server_config * wf_server_config_create(void);
2020-02-17 20:53:42 +00:00
//------------------------------------------------------------------------------
/// \brief Disposes a server configuration.
///
/// \note Contexts of mounpoint factory and added authenticators are not
/// disposed by default.
///
/// \param config pointer of configuration object
///
/// \see wf_server_config_set_mountpoint_factory
/// \see wf_server_config_add_authenticator
//------------------------------------------------------------------------------
2019-03-26 22:04:53 +00:00
extern WF_API void wf_server_config_dispose(
struct wf_server_config * config);
2020-02-17 20:53:42 +00:00
//------------------------------------------------------------------------------
/// \brief Sets the mountpoint factory of the configuration.
///
/// The mountpoint factory is called when a authenticated user adds a
/// filesystem.
///
/// \note The user is responsible to manage the lifetime of the mountpoint
/// factory.
///
/// \note A valid configuration needs either a mountpoint or a mounpoint
/// factory.
///
/// \param config pointer of configuration object
/// \param create_mountpoint factory function to create a mountpoint
/// \param user_data context of mountpoint factory
//------------------------------------------------------------------------------
2020-02-13 20:48:42 +00:00
extern WF_API void wf_server_config_set_mountpoint_factory(
struct wf_server_config * config,
wf_create_mountpoint_fn * create_mountpoint,
void * user_data);
2020-02-17 20:53:42 +00:00
//------------------------------------------------------------------------------
/// \brief Sets the path of HTTP servers root context.
///
/// Webfuse adapter server is capable of serving static HTTP context. This
/// function is used to specify the path of HTTP servers root context.
/// If not specified, no HTTP content is served.
///
/// \param config pointer of configuration object
/// \param document_root path to static HTTP content
//------------------------------------------------------------------------------
2019-03-26 22:04:53 +00:00
extern WF_API void wf_server_config_set_documentroot(
struct wf_server_config * config,
char const * document_root);
2020-02-17 20:53:42 +00:00
//------------------------------------------------------------------------------
/// \brief Sets the path to the servers private key.
///
/// \note To enable TLS, private key and server certificate must be set.
/// Otherwise, only plain HTTP is supported.
///
/// \param config pointer of configuration object
/// \param key_path path to servers private key (pem file)
//------------------------------------------------------------------------------
2019-03-26 22:04:53 +00:00
extern WF_API void wf_server_config_set_keypath(
struct wf_server_config * config,
char const * key_path);
2020-02-17 20:53:42 +00:00
//------------------------------------------------------------------------------
/// \brief Sets path to servers certificate.
///
/// \note To enable TLS, private key and server certificate must be set.
/// Otherwise, only plain HTTP is supported.
///
/// \param config pointer of configuration object
/// \param cert_path path to servers certificate (pem file)
//------------------------------------------------------------------------------
2019-03-26 22:04:53 +00:00
extern WF_API void wf_server_config_set_certpath(
struct wf_server_config * config,
char const * cert_path);
2020-02-17 20:53:42 +00:00
//------------------------------------------------------------------------------
/// \brief Sets the virtual hostname of the websockets server.
///
/// \param config pointer of configuration object
/// \param vhost_name virtual hostname of the websockets server
//------------------------------------------------------------------------------
2019-03-26 22:04:53 +00:00
extern WF_API void wf_server_config_set_vhostname(
struct wf_server_config * config,
char const * vhost_name);
2020-02-17 20:53:42 +00:00
//------------------------------------------------------------------------------
/// \brief Sets the port number of the websockets server.
///
/// \param config pointer of configuration object
/// \param port port number of the websockets server
//------------------------------------------------------------------------------
2019-03-26 22:04:53 +00:00
extern WF_API void wf_server_config_set_port(
struct wf_server_config * config,
int port);
2020-02-17 20:53:42 +00:00
//------------------------------------------------------------------------------
/// \brief Adds an authenticator.
///
/// Authenticators are used to authenticate users by some provided credentials.
/// Multiple providers can be specified to support different types of
/// credentials.
///
/// \note Adding multiple providers for the same credentials type results
/// in undefined behavior.
///
/// \note The user is responsible to manage the lifetime of user data.
///
/// \param config pointer to configuration object
/// \param type type of the credentials the authenticator supports
/// \param authenticate function called to authenticate a user
/// \param user_data context of authenticate function
//------------------------------------------------------------------------------
2019-03-26 22:04:53 +00:00
extern WF_API void wf_server_config_add_authenticator(
struct wf_server_config * config,
char const * type,
wf_authenticate_fn * authenticate,
2020-02-17 20:53:42 +00:00
void * user_data);
2019-03-26 22:04:53 +00:00
#ifdef __cplusplus
}
#endif
#endif