2016-11-02 18:58:14 +01:00
|
|
|
#include <civetweb.h>
|
|
|
|
#include <openssl/ts.h>
|
|
|
|
#include <pthread.h>
|
2016-08-24 23:14:15 +02:00
|
|
|
#include <stdbool.h>
|
2016-08-24 22:37:05 +02:00
|
|
|
#include <stddef.h> /* for offsetof() macro */
|
2016-11-02 18:58:14 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
2016-08-24 22:37:05 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
2016-08-25 23:04:26 +02:00
|
|
|
#define HTTP_OPTIONS 1
|
|
|
|
#define LOGLEVEL_OPTIONS 2
|
|
|
|
#define TSA_OPTIONS 3
|
2016-09-11 23:55:38 +02:00
|
|
|
#define PATH_HTTP_OPTIONS 4
|
2016-08-25 23:04:26 +02:00
|
|
|
#define MAIN_CONF_SECTION "main"
|
|
|
|
|
|
|
|
#define RFC3161_OPTIONS_LEN \
|
|
|
|
sizeof(rfc3161_options) / sizeof(struct rfc3161_option)
|
|
|
|
|
2016-09-08 23:21:53 +02:00
|
|
|
typedef struct {
|
|
|
|
TS_RESP_CTX *ts_ctx;
|
|
|
|
bool available;
|
|
|
|
pthread_mutex_t lock;
|
|
|
|
} ts_resp_ctx_wrapper;
|
|
|
|
|
2016-08-24 22:37:05 +02:00
|
|
|
typedef struct {
|
|
|
|
uint64_t query_counter;
|
2016-09-11 23:55:38 +02:00
|
|
|
// flag for debugging
|
2016-08-24 23:14:15 +02:00
|
|
|
bool stdout_dbg;
|
2016-09-11 23:55:38 +02:00
|
|
|
// log level
|
2016-08-24 23:41:55 +02:00
|
|
|
int loglevel;
|
2016-09-11 23:55:38 +02:00
|
|
|
// number of threads
|
2016-09-08 23:21:53 +02:00
|
|
|
int numthreads;
|
2016-09-11 23:55:38 +02:00
|
|
|
// civetweb http parameters
|
2016-08-25 23:04:26 +02:00
|
|
|
const char *http_options[40];
|
2016-09-08 23:21:53 +02:00
|
|
|
ts_resp_ctx_wrapper *ts_ctx_pool;
|
2016-09-11 23:55:38 +02:00
|
|
|
|
|
|
|
// just to track for freeing later
|
2016-09-05 20:24:47 +02:00
|
|
|
CONF *conf;
|
2016-09-11 23:55:38 +02:00
|
|
|
char *cust_conf[20];
|
2016-08-24 22:37:05 +02:00
|
|
|
} rfc3161_context;
|
2016-08-25 23:04:26 +02:00
|
|
|
|
2016-09-11 23:55:38 +02:00
|
|
|
// definition of structure to describe
|
|
|
|
// section [ main ] attributes (name, type and default value)
|
2016-08-25 23:04:26 +02:00
|
|
|
struct rfc3161_option {
|
|
|
|
const char *name;
|
|
|
|
int type;
|
|
|
|
const char *default_value;
|
|
|
|
};
|
|
|
|
|
2016-09-11 23:55:38 +02:00
|
|
|
// declaration of section [ main ] parameters and their default values
|
2016-08-25 23:04:26 +02:00
|
|
|
static struct rfc3161_option rfc3161_options[] = {
|
2016-09-08 23:21:53 +02:00
|
|
|
{"num_threads", HTTP_OPTIONS, "10"},
|
2016-08-25 23:04:26 +02:00
|
|
|
{"run_as_user", HTTP_OPTIONS, NULL},
|
|
|
|
{"throttle", HTTP_OPTIONS, NULL},
|
|
|
|
{"enable_keep_alive", HTTP_OPTIONS, "no"},
|
|
|
|
{"listening_ports", HTTP_OPTIONS, "8080"},
|
|
|
|
{"request_timeout_ms", HTTP_OPTIONS, "30000"},
|
|
|
|
{"ssl_verify_peer", HTTP_OPTIONS, "yes"},
|
|
|
|
{"ssl_verify_depth", HTTP_OPTIONS, "9"},
|
|
|
|
{"ssl_default_verify_paths", HTTP_OPTIONS, "yes"},
|
|
|
|
{"ssl_cipher_list", HTTP_OPTIONS, NULL},
|
|
|
|
{"ssl_protocol_version", HTTP_OPTIONS, "0"},
|
|
|
|
{"ssl_short_trust", HTTP_OPTIONS, "no"},
|
|
|
|
{"access_control_allow_origin", HTTP_OPTIONS, "*"},
|
|
|
|
{"tcp_nodelay", HTTP_OPTIONS, "0"},
|
|
|
|
{"log_level", LOGLEVEL_OPTIONS, "info"},
|
2016-09-11 23:55:38 +02:00
|
|
|
{"ssl_certificate", PATH_HTTP_OPTIONS, NULL},
|
|
|
|
{"ssl_ca_path", PATH_HTTP_OPTIONS, NULL},
|
|
|
|
{"ssl_ca_file", PATH_HTTP_OPTIONS, NULL},
|
2016-08-25 23:04:26 +02:00
|
|
|
};
|