2020-09-23 15:19:29 +00:00
|
|
|
#ifndef GMNISRV_CONFIG
|
|
|
|
#define GMNISRV_CONFIG
|
|
|
|
#include <arpa/inet.h>
|
2020-09-24 21:51:29 +00:00
|
|
|
#include <openssl/x509.h>
|
2020-09-26 19:51:28 +00:00
|
|
|
#include <stdbool.h>
|
2020-10-30 02:47:56 +00:00
|
|
|
#include "regexp.h"
|
2020-09-23 15:19:29 +00:00
|
|
|
|
|
|
|
struct gmnisrv_tls {
|
|
|
|
char *store;
|
|
|
|
char *organization;
|
2020-09-24 23:58:34 +00:00
|
|
|
SSL_CTX *ssl_ctx;
|
2020-09-23 15:19:29 +00:00
|
|
|
};
|
|
|
|
|
2020-10-26 01:46:01 +00:00
|
|
|
enum gmnisrv_routing {
|
2021-01-27 19:57:18 +00:00
|
|
|
ROUTE_EXACT,
|
2020-10-26 01:46:01 +00:00
|
|
|
ROUTE_PATH,
|
|
|
|
ROUTE_REGEX,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct gmnisrv_route {
|
|
|
|
enum gmnisrv_routing routing;
|
|
|
|
char *spec;
|
|
|
|
union {
|
|
|
|
char *path;
|
2020-10-30 02:47:56 +00:00
|
|
|
uint8_t *regex;
|
2020-10-26 01:46:01 +00:00
|
|
|
};
|
|
|
|
|
2020-09-23 15:19:29 +00:00
|
|
|
char *root;
|
2020-09-26 19:51:28 +00:00
|
|
|
char *index;
|
2020-11-01 16:19:51 +00:00
|
|
|
char *rewrite;
|
2020-09-26 19:51:28 +00:00
|
|
|
bool autoindex;
|
2020-10-26 03:16:50 +00:00
|
|
|
bool cgi;
|
2020-09-26 19:51:28 +00:00
|
|
|
|
2020-10-26 01:46:01 +00:00
|
|
|
struct gmnisrv_route *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct gmnisrv_host {
|
|
|
|
char *hostname;
|
2020-09-24 21:55:10 +00:00
|
|
|
X509 *x509;
|
|
|
|
EVP_PKEY *pkey;
|
2020-09-26 19:51:28 +00:00
|
|
|
|
2020-10-26 01:46:01 +00:00
|
|
|
struct gmnisrv_route *routes;
|
|
|
|
|
2020-09-23 15:19:29 +00:00
|
|
|
struct gmnisrv_host *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct gmnisrv_bind {
|
2020-09-23 16:40:28 +00:00
|
|
|
char *name;
|
2020-09-23 15:33:05 +00:00
|
|
|
int family, port;
|
2020-09-23 15:19:29 +00:00
|
|
|
char addr[sizeof(struct in6_addr)];
|
|
|
|
struct gmnisrv_bind *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct gmnisrv_config {
|
|
|
|
struct gmnisrv_tls tls;
|
|
|
|
struct gmnisrv_host *hosts;
|
|
|
|
struct gmnisrv_bind *binds;
|
|
|
|
};
|
|
|
|
|
|
|
|
int load_config(struct gmnisrv_config *conf, const char *path);
|
2020-09-23 16:40:28 +00:00
|
|
|
void config_finish(struct gmnisrv_config *conf);
|
2020-09-23 15:19:29 +00:00
|
|
|
|
|
|
|
struct gmnisrv_host *gmnisrv_config_get_host(
|
2020-09-23 18:19:28 +00:00
|
|
|
struct gmnisrv_config *conf, const char *hostname);
|
2020-09-23 15:19:29 +00:00
|
|
|
|
|
|
|
#endif
|