-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathngx_http_contrast_connector_common.h
90 lines (74 loc) · 2.16 KB
/
ngx_http_contrast_connector_common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* Copyright (C) Contrast Security, Inc. */
#ifndef _NGX_HTTP_CONTRAST_CONNECTOR_COMMON_H_
#define _NGX_HTTP_CONTRAST_CONNECTOR_COMMON_H_
#include <nginx.h>
#include <ngx_config.h>
#include <ngx_auto_config.h>
#include <ngx_core.h>
#include <ngx_http.h>
#if !(NGX_HAVE_VARIADIC_MACROS)
# error("platform is missing variadic macro support")
#endif
/* debugging code enabled using --with-debug on nginx ./configure */
#if (NGX_DEBUG)
/* easy debug printing used for development and debugging. */
# define dd(fmt, ...) \
fprintf(stderr, "[contrast] %s:%d (%s): " fmt "\n", \
__FILE__, __LINE__, __func__, ## __VA_ARGS__)
#else
# define dd(...)
#endif
#define contrast_log(lvl, log, err, fmt, ...) \
ngx_log_error(NGX_LOG_ ## lvl, log, err, \
"[contrast]: " fmt, ## __VA_ARGS__)
#define contrast_dbg_log(log, err, fmt, ...) \
ngx_log_error(NGX_LOG_DEBUG_HTTP, log, err, \
"[contrast]: " fmt, ## __VA_ARGS__)
typedef struct {
char uuid[32 + 1];
} ngx_contrast_uuid_t;
/*
* structure for context
*/
typedef struct {
/*
* separate pool for buffered outgoing data. Having a separate pool makes
* using the ngx buf/chain functions easier as they won't get confused
* with the buf chain in the request object pool.
*/
ngx_contrast_uuid_t uuid;
ngx_int_t complete;
ngx_pool_t *out_pool;
ngx_chain_t *output_chain;
size_t content_len;
ngx_chain_t *prev_cl;
unsigned waiting_more_body:1;
unsigned body_requested:1;
} ngx_http_contrast_ctx_t;
/*
* structure for configuration
*/
typedef struct {
ngx_flag_t enable;
ngx_flag_t debug;
ngx_str_t socket_path;
ngx_str_t app_name;
} ngx_http_contrast_connector_conf_t;
/*
* extern reference to module definition
*/
extern ngx_module_t ngx_http_contrast_connector_module;
/*
* utility method to get unix millis
*/
int64_t unix_millis();
/*
* utility method to create C strings from ngx strings
*/
char *ngx_str_to_char(const ngx_str_t *a, ngx_pool_t *p);
/*
* parse connection and params for non-request body request
*/
ngx_int_t ngx_http_contrast_connector_preaccess_handler(
ngx_http_request_t * r);
#endif