-
Notifications
You must be signed in to change notification settings - Fork 206
Expand file tree
/
Copy pathngx_stream_lua_phase.c
More file actions
107 lines (77 loc) · 2.19 KB
/
ngx_stream_lua_phase.c
File metadata and controls
107 lines (77 loc) · 2.19 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
* !!! DO NOT EDIT DIRECTLY !!!
* This file was automatically generated from the following template:
*
* src/subsys/ngx_subsys_lua_phase.c.tt2
*/
/*
* Copyright (C) Yichun Zhang (agentzh)
*/
#ifndef DDEBUG
#define DDEBUG 0
#endif
#include "ddebug.h"
#include "ngx_stream_lua_phase.h"
#include "ngx_stream_lua_util.h"
#include "ngx_stream_lua_ctx.h"
static int
ngx_stream_lua_ngx_get_phase(lua_State *L)
{
ngx_stream_lua_request_t *r;
ngx_stream_lua_ctx_t *ctx;
r = ngx_stream_lua_get_req(L);
/* If we have no request object, assume we are called from the "init"
* phase. */
if (r == NULL) {
lua_pushliteral(L, "init");
return 1;
}
ctx = ngx_stream_lua_get_module_ctx(r, ngx_stream_lua_module);
if (ctx == NULL) {
return luaL_error(L, "no request ctx found");
}
switch (ctx->context) {
case NGX_STREAM_LUA_CONTEXT_INIT_WORKER:
lua_pushliteral(L, "init_worker");
break;
case NGX_STREAM_LUA_CONTEXT_SSL_CLIENT_HELLO:
lua_pushliteral(L, "ssl_client_hello");
break;
case NGX_STREAM_LUA_CONTEXT_SSL_CERT:
lua_pushliteral(L, "ssl_cert");
break;
case NGX_STREAM_LUA_CONTEXT_PREREAD:
lua_pushliteral(L, "preread");
break;
case NGX_STREAM_LUA_CONTEXT_CONTENT:
lua_pushliteral(L, "content");
break;
#ifdef HAVE_PROXY_SSL_PATCH
case NGX_STREAM_LUA_CONTEXT_PROXY_SSL_CERT:
lua_pushliteral(L, "proxy_ssl_cert");
break;
case NGX_STREAM_LUA_CONTEXT_PROXY_SSL_VERIFY:
lua_pushliteral(L, "proxy_ssl_verify");
break;
#endif
case NGX_STREAM_LUA_CONTEXT_LOG:
lua_pushliteral(L, "log");
break;
case NGX_STREAM_LUA_CONTEXT_TIMER:
lua_pushliteral(L, "timer");
break;
case NGX_STREAM_LUA_CONTEXT_BALANCER:
lua_pushliteral(L, "balancer");
break;
default:
return luaL_error(L, "unknown phase: %#x", (int) ctx->context);
}
return 1;
}
void
ngx_stream_lua_inject_phase_api(lua_State *L)
{
lua_pushcfunction(L, ngx_stream_lua_ngx_get_phase);
lua_setfield(L, -2, "get_phase");
}
/* vi:set ft=c ts=4 sw=4 et fdm=marker: */