nginxtra 1.8.1.12 → 1.10.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (238) hide show
  1. checksums.yaml +4 -4
  2. data/bin/nginxtra +1 -1
  3. data/bin/nginxtra_rails +1 -1
  4. data/lib/nginxtra/version.rb +1 -1
  5. data/vendor/nginx/CHANGES +363 -25
  6. data/vendor/nginx/CHANGES.ru +365 -21
  7. data/vendor/nginx/LICENSE +2 -2
  8. data/vendor/nginx/auto/cc/conf +32 -0
  9. data/vendor/nginx/auto/cc/gcc +1 -1
  10. data/vendor/nginx/auto/cc/icc +2 -2
  11. data/vendor/nginx/auto/cc/msvc +29 -8
  12. data/vendor/nginx/auto/cc/name +2 -25
  13. data/vendor/nginx/auto/cc/sunc +3 -0
  14. data/vendor/nginx/auto/endianness +7 -2
  15. data/vendor/nginx/auto/install +60 -26
  16. data/vendor/nginx/auto/lib/conf +4 -4
  17. data/vendor/nginx/auto/lib/geoip/conf +6 -1
  18. data/vendor/nginx/auto/lib/libgd/conf +6 -1
  19. data/vendor/nginx/auto/lib/libxslt/conf +11 -2
  20. data/vendor/nginx/auto/lib/make +1 -1
  21. data/vendor/nginx/auto/lib/md5/conf +2 -2
  22. data/vendor/nginx/auto/lib/md5/make +2 -2
  23. data/vendor/nginx/auto/lib/openssl/conf +52 -3
  24. data/vendor/nginx/auto/lib/openssl/make +1 -1
  25. data/vendor/nginx/auto/lib/pcre/conf +2 -2
  26. data/vendor/nginx/auto/lib/pcre/make +2 -2
  27. data/vendor/nginx/auto/lib/perl/conf +6 -3
  28. data/vendor/nginx/auto/lib/perl/make +4 -1
  29. data/vendor/nginx/auto/lib/sha1/conf +2 -2
  30. data/vendor/nginx/auto/lib/sha1/make +2 -2
  31. data/vendor/nginx/auto/lib/zlib/conf +2 -2
  32. data/vendor/nginx/auto/lib/zlib/make +2 -2
  33. data/vendor/nginx/auto/make +281 -16
  34. data/vendor/nginx/auto/module +122 -0
  35. data/vendor/nginx/auto/modules +909 -178
  36. data/vendor/nginx/auto/options +81 -19
  37. data/vendor/nginx/auto/os/conf +9 -0
  38. data/vendor/nginx/auto/os/darwin +3 -0
  39. data/vendor/nginx/auto/os/freebsd +0 -20
  40. data/vendor/nginx/auto/os/linux +0 -12
  41. data/vendor/nginx/auto/os/win32 +5 -1
  42. data/vendor/nginx/auto/sources +11 -311
  43. data/vendor/nginx/auto/summary +1 -0
  44. data/vendor/nginx/auto/types/sizeof +5 -3
  45. data/vendor/nginx/auto/types/typedef +9 -4
  46. data/vendor/nginx/auto/types/uintptr_t +7 -2
  47. data/vendor/nginx/auto/unix +72 -12
  48. data/vendor/nginx/conf/fastcgi.conf +1 -0
  49. data/vendor/nginx/conf/fastcgi_params +1 -0
  50. data/vendor/nginx/conf/scgi_params +1 -0
  51. data/vendor/nginx/conf/uwsgi_params +1 -0
  52. data/vendor/nginx/configure +1 -1
  53. data/vendor/nginx/contrib/vim/syntax/nginx.vim +2 -2
  54. data/vendor/nginx/man/nginx.8 +6 -2
  55. data/vendor/nginx/src/core/nginx.c +281 -114
  56. data/vendor/nginx/src/core/nginx.h +2 -2
  57. data/vendor/nginx/src/core/ngx_conf_file.c +54 -13
  58. data/vendor/nginx/src/core/ngx_conf_file.h +8 -52
  59. data/vendor/nginx/src/core/ngx_config.h +0 -5
  60. data/vendor/nginx/src/core/ngx_connection.c +270 -37
  61. data/vendor/nginx/src/core/ngx_connection.h +35 -12
  62. data/vendor/nginx/src/core/ngx_core.h +4 -0
  63. data/vendor/nginx/src/core/ngx_crypt.c +2 -2
  64. data/vendor/nginx/src/core/ngx_cycle.c +72 -25
  65. data/vendor/nginx/src/core/ngx_cycle.h +28 -39
  66. data/vendor/nginx/src/core/ngx_file.c +14 -5
  67. data/vendor/nginx/src/core/ngx_file.h +2 -0
  68. data/vendor/nginx/src/core/ngx_hash.c +13 -1
  69. data/vendor/nginx/src/core/ngx_inet.c +20 -18
  70. data/vendor/nginx/src/core/ngx_log.c +12 -12
  71. data/vendor/nginx/src/core/ngx_log.h +13 -6
  72. data/vendor/nginx/src/core/ngx_module.c +360 -0
  73. data/vendor/nginx/src/core/ngx_module.h +307 -0
  74. data/vendor/nginx/src/core/ngx_open_file_cache.c +2 -2
  75. data/vendor/nginx/src/core/ngx_output_chain.c +8 -4
  76. data/vendor/nginx/src/core/ngx_palloc.c +42 -44
  77. data/vendor/nginx/src/{http/ngx_http_parse_time.c → core/ngx_parse_time.c} +2 -3
  78. data/vendor/nginx/src/core/ngx_parse_time.h +22 -0
  79. data/vendor/nginx/src/core/ngx_proxy_protocol.c +50 -1
  80. data/vendor/nginx/src/core/ngx_proxy_protocol.h +3 -1
  81. data/vendor/nginx/src/core/ngx_regex.c +1 -38
  82. data/vendor/nginx/src/core/ngx_resolver.c +1814 -320
  83. data/vendor/nginx/src/core/ngx_resolver.h +67 -10
  84. data/vendor/nginx/src/core/ngx_rwlock.c +120 -0
  85. data/vendor/nginx/src/core/ngx_rwlock.h +21 -0
  86. data/vendor/nginx/src/core/ngx_slab.c +6 -5
  87. data/vendor/nginx/src/core/ngx_string.c +1 -1
  88. data/vendor/nginx/src/core/ngx_syslog.c +11 -3
  89. data/vendor/nginx/src/core/ngx_syslog.h +2 -1
  90. data/vendor/nginx/src/core/ngx_thread_pool.c +4 -0
  91. data/vendor/nginx/src/core/ngx_times.c +2 -2
  92. data/vendor/nginx/src/event/modules/ngx_devpoll_module.c +3 -1
  93. data/vendor/nginx/src/event/modules/ngx_epoll_module.c +5 -2
  94. data/vendor/nginx/src/event/modules/ngx_eventport_module.c +5 -5
  95. data/vendor/nginx/src/event/modules/ngx_kqueue_module.c +15 -8
  96. data/vendor/nginx/src/event/modules/ngx_poll_module.c +0 -10
  97. data/vendor/nginx/src/event/modules/ngx_select_module.c +0 -10
  98. data/vendor/nginx/src/event/ngx_event.c +60 -103
  99. data/vendor/nginx/src/event/ngx_event.h +22 -26
  100. data/vendor/nginx/src/event/ngx_event_accept.c +414 -88
  101. data/vendor/nginx/src/event/ngx_event_connect.c +27 -18
  102. data/vendor/nginx/src/event/ngx_event_connect.h +1 -0
  103. data/vendor/nginx/src/event/ngx_event_openssl.c +65 -25
  104. data/vendor/nginx/src/event/ngx_event_openssl.h +17 -0
  105. data/vendor/nginx/src/event/ngx_event_openssl_stapling.c +73 -7
  106. data/vendor/nginx/src/event/ngx_event_pipe.c +85 -27
  107. data/vendor/nginx/src/event/ngx_event_pipe.h +10 -0
  108. data/vendor/nginx/src/http/modules/ngx_http_auth_basic_module.c +1 -1
  109. data/vendor/nginx/src/http/modules/ngx_http_auth_request_module.c +2 -2
  110. data/vendor/nginx/src/http/modules/ngx_http_chunked_filter_module.c +2 -2
  111. data/vendor/nginx/src/http/modules/ngx_http_dav_module.c +6 -6
  112. data/vendor/nginx/src/http/modules/ngx_http_fastcgi_module.c +17 -11
  113. data/vendor/nginx/src/http/modules/ngx_http_gzip_filter_module.c +2 -2
  114. data/vendor/nginx/src/http/modules/ngx_http_headers_filter_module.c +9 -9
  115. data/vendor/nginx/src/http/modules/ngx_http_image_filter_module.c +2 -2
  116. data/vendor/nginx/src/http/modules/ngx_http_limit_conn_module.c +2 -2
  117. data/vendor/nginx/src/http/modules/ngx_http_limit_req_module.c +0 -7
  118. data/vendor/nginx/src/http/modules/ngx_http_map_module.c +6 -6
  119. data/vendor/nginx/src/http/modules/ngx_http_memcached_module.c +2 -1
  120. data/vendor/nginx/src/http/modules/ngx_http_mp4_module.c +13 -13
  121. data/vendor/nginx/src/http/modules/ngx_http_not_modified_filter_module.c +2 -2
  122. data/vendor/nginx/src/http/modules/ngx_http_proxy_module.c +26 -21
  123. data/vendor/nginx/src/http/modules/ngx_http_random_index_module.c +1 -1
  124. data/vendor/nginx/src/http/modules/ngx_http_range_filter_module.c +26 -8
  125. data/vendor/nginx/src/http/modules/ngx_http_realip_module.c +73 -3
  126. data/vendor/nginx/src/http/modules/ngx_http_referer_module.c +1 -1
  127. data/vendor/nginx/src/http/modules/ngx_http_rewrite_module.c +6 -6
  128. data/vendor/nginx/src/http/modules/ngx_http_scgi_module.c +5 -3
  129. data/vendor/nginx/src/http/modules/ngx_http_slice_filter_module.c +526 -0
  130. data/vendor/nginx/src/http/modules/ngx_http_ssi_filter_module.c +7 -7
  131. data/vendor/nginx/src/http/modules/ngx_http_ssl_module.c +19 -16
  132. data/vendor/nginx/src/http/modules/ngx_http_static_module.c +1 -1
  133. data/vendor/nginx/src/http/modules/ngx_http_stub_status_module.c +1 -1
  134. data/vendor/nginx/src/http/modules/ngx_http_sub_filter_module.c +373 -173
  135. data/vendor/nginx/src/http/modules/ngx_http_upstream_hash_module.c +72 -46
  136. data/vendor/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +18 -30
  137. data/vendor/nginx/src/http/modules/ngx_http_upstream_keepalive_module.c +50 -39
  138. data/vendor/nginx/src/http/modules/ngx_http_upstream_least_conn_module.c +38 -129
  139. data/vendor/nginx/src/http/modules/ngx_http_upstream_zone_module.c +246 -0
  140. data/vendor/nginx/src/http/modules/ngx_http_uwsgi_module.c +6 -5
  141. data/vendor/nginx/src/http/modules/perl/nginx.xs +9 -9
  142. data/vendor/nginx/src/http/ngx_http.c +46 -43
  143. data/vendor/nginx/src/http/ngx_http.h +4 -9
  144. data/vendor/nginx/src/http/ngx_http_cache.h +4 -0
  145. data/vendor/nginx/src/http/ngx_http_copy_filter_module.c +13 -5
  146. data/vendor/nginx/src/http/ngx_http_core_module.c +92 -91
  147. data/vendor/nginx/src/http/ngx_http_core_module.h +12 -8
  148. data/vendor/nginx/src/http/ngx_http_file_cache.c +61 -10
  149. data/vendor/nginx/src/http/ngx_http_request.c +37 -50
  150. data/vendor/nginx/src/http/ngx_http_request.h +10 -15
  151. data/vendor/nginx/src/http/ngx_http_request_body.c +64 -88
  152. data/vendor/nginx/src/http/ngx_http_script.c +3 -3
  153. data/vendor/nginx/src/http/ngx_http_special_response.c +1 -4
  154. data/vendor/nginx/src/http/ngx_http_upstream.c +245 -109
  155. data/vendor/nginx/src/http/ngx_http_upstream.h +11 -5
  156. data/vendor/nginx/src/http/ngx_http_upstream_round_robin.c +212 -65
  157. data/vendor/nginx/src/http/ngx_http_upstream_round_robin.h +66 -5
  158. data/vendor/nginx/src/http/ngx_http_variables.c +28 -15
  159. data/vendor/nginx/src/http/ngx_http_write_filter_module.c +1 -1
  160. data/vendor/nginx/src/http/v2/ngx_http_v2.c +4349 -0
  161. data/vendor/nginx/src/http/v2/ngx_http_v2.h +337 -0
  162. data/vendor/nginx/src/http/v2/ngx_http_v2_filter_module.c +1391 -0
  163. data/vendor/nginx/src/http/v2/ngx_http_v2_huff_decode.c +2714 -0
  164. data/vendor/nginx/src/http/v2/ngx_http_v2_huff_encode.c +254 -0
  165. data/vendor/nginx/src/http/v2/ngx_http_v2_module.c +469 -0
  166. data/vendor/nginx/src/http/{ngx_http_spdy_module.h → v2/ngx_http_v2_module.h} +10 -9
  167. data/vendor/nginx/src/http/v2/ngx_http_v2_table.c +349 -0
  168. data/vendor/nginx/src/mail/ngx_mail.c +49 -82
  169. data/vendor/nginx/src/mail/ngx_mail.h +16 -23
  170. data/vendor/nginx/src/mail/ngx_mail_auth_http_module.c +1 -1
  171. data/vendor/nginx/src/mail/ngx_mail_core_module.c +60 -34
  172. data/vendor/nginx/src/mail/ngx_mail_handler.c +17 -12
  173. data/vendor/nginx/src/mail/ngx_mail_proxy_module.c +1 -14
  174. data/vendor/nginx/src/mail/ngx_mail_smtp_handler.c +1 -1
  175. data/vendor/nginx/src/mail/ngx_mail_ssl_module.c +5 -5
  176. data/vendor/nginx/src/os/unix/ngx_atomic.h +10 -10
  177. data/vendor/nginx/src/os/unix/ngx_channel.h +4 -4
  178. data/vendor/nginx/src/os/unix/ngx_darwin_config.h +2 -0
  179. data/vendor/nginx/src/os/unix/ngx_darwin_init.c +1 -0
  180. data/vendor/nginx/src/os/unix/ngx_dlopen.c +28 -0
  181. data/vendor/nginx/src/os/unix/ngx_dlopen.h +31 -0
  182. data/vendor/nginx/src/os/unix/ngx_errno.h +1 -0
  183. data/vendor/nginx/src/os/unix/ngx_file_aio_read.c +1 -1
  184. data/vendor/nginx/src/os/unix/ngx_files.c +313 -80
  185. data/vendor/nginx/src/os/unix/ngx_files.h +5 -2
  186. data/vendor/nginx/src/os/unix/ngx_freebsd_config.h +3 -1
  187. data/vendor/nginx/src/os/unix/ngx_freebsd_init.c +1 -0
  188. data/vendor/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +13 -0
  189. data/vendor/nginx/src/os/unix/ngx_linux.h +0 -2
  190. data/vendor/nginx/src/os/unix/ngx_linux_aio_read.c +1 -1
  191. data/vendor/nginx/src/os/unix/ngx_linux_config.h +2 -6
  192. data/vendor/nginx/src/os/unix/ngx_linux_init.c +1 -33
  193. data/vendor/nginx/src/os/unix/ngx_linux_sendfile_chain.c +55 -12
  194. data/vendor/nginx/src/os/unix/ngx_os.h +3 -9
  195. data/vendor/nginx/src/os/unix/ngx_posix_config.h +14 -1
  196. data/vendor/nginx/src/os/unix/ngx_posix_init.c +2 -1
  197. data/vendor/nginx/src/os/unix/ngx_process.c +1 -1
  198. data/vendor/nginx/src/os/unix/ngx_process_cycle.c +25 -51
  199. data/vendor/nginx/src/os/unix/ngx_process_cycle.h +1 -0
  200. data/vendor/nginx/src/os/unix/ngx_readv_chain.c +24 -28
  201. data/vendor/nginx/src/os/unix/ngx_recv.c +30 -79
  202. data/vendor/nginx/src/os/unix/ngx_send.c +1 -1
  203. data/vendor/nginx/src/os/unix/ngx_setaffinity.c +14 -30
  204. data/vendor/nginx/src/os/unix/ngx_setaffinity.h +15 -1
  205. data/vendor/nginx/src/os/unix/ngx_solaris_config.h +2 -0
  206. data/vendor/nginx/src/os/unix/ngx_solaris_init.c +1 -0
  207. data/vendor/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +23 -0
  208. data/vendor/nginx/src/os/unix/ngx_sunpro_amd64.il +3 -3
  209. data/vendor/nginx/src/os/unix/ngx_sunpro_x86.il +3 -3
  210. data/vendor/nginx/src/os/unix/ngx_udp_recv.c +5 -48
  211. data/vendor/nginx/src/os/unix/ngx_udp_send.c +56 -0
  212. data/vendor/nginx/src/stream/ngx_stream.c +564 -0
  213. data/vendor/nginx/src/stream/ngx_stream.h +212 -0
  214. data/vendor/nginx/src/stream/ngx_stream_access_module.c +451 -0
  215. data/vendor/nginx/src/stream/ngx_stream_core_module.c +562 -0
  216. data/vendor/nginx/src/stream/ngx_stream_handler.c +344 -0
  217. data/vendor/nginx/src/stream/ngx_stream_limit_conn_module.c +632 -0
  218. data/vendor/nginx/src/stream/ngx_stream_proxy_module.c +1674 -0
  219. data/vendor/nginx/src/stream/ngx_stream_ssl_module.c +460 -0
  220. data/vendor/nginx/src/stream/ngx_stream_ssl_module.h +49 -0
  221. data/vendor/nginx/src/stream/ngx_stream_upstream.c +464 -0
  222. data/vendor/nginx/src/stream/ngx_stream_upstream.h +107 -0
  223. data/vendor/nginx/src/stream/ngx_stream_upstream_hash_module.c +656 -0
  224. data/vendor/nginx/src/stream/ngx_stream_upstream_least_conn_module.c +307 -0
  225. data/vendor/nginx/src/stream/ngx_stream_upstream_round_robin.c +702 -0
  226. data/vendor/nginx/src/stream/ngx_stream_upstream_round_robin.h +139 -0
  227. data/vendor/nginx/src/stream/ngx_stream_upstream_zone_module.c +242 -0
  228. metadata +39 -15
  229. data/vendor/nginx/src/event/modules/ngx_aio_module.c +0 -171
  230. data/vendor/nginx/src/event/modules/ngx_rtsig_module.c +0 -735
  231. data/vendor/nginx/src/http/ngx_http_spdy.c +0 -3701
  232. data/vendor/nginx/src/http/ngx_http_spdy.h +0 -261
  233. data/vendor/nginx/src/http/ngx_http_spdy_filter_module.c +0 -1222
  234. data/vendor/nginx/src/http/ngx_http_spdy_module.c +0 -408
  235. data/vendor/nginx/src/os/unix/ngx_aio_read.c +0 -109
  236. data/vendor/nginx/src/os/unix/ngx_aio_read_chain.c +0 -78
  237. data/vendor/nginx/src/os/unix/ngx_aio_write.c +0 -109
  238. data/vendor/nginx/src/os/unix/ngx_aio_write_chain.c +0 -100
@@ -0,0 +1,562 @@
1
+
2
+ /*
3
+ * Copyright (C) Roman Arutyunyan
4
+ * Copyright (C) Nginx, Inc.
5
+ */
6
+
7
+
8
+ #include <ngx_config.h>
9
+ #include <ngx_core.h>
10
+ #include <ngx_stream.h>
11
+
12
+
13
+ static void *ngx_stream_core_create_main_conf(ngx_conf_t *cf);
14
+ static void *ngx_stream_core_create_srv_conf(ngx_conf_t *cf);
15
+ static char *ngx_stream_core_merge_srv_conf(ngx_conf_t *cf, void *parent,
16
+ void *child);
17
+ static char *ngx_stream_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd,
18
+ void *conf);
19
+ static char *ngx_stream_core_server(ngx_conf_t *cf, ngx_command_t *cmd,
20
+ void *conf);
21
+ static char *ngx_stream_core_listen(ngx_conf_t *cf, ngx_command_t *cmd,
22
+ void *conf);
23
+
24
+
25
+ static ngx_command_t ngx_stream_core_commands[] = {
26
+
27
+ { ngx_string("server"),
28
+ NGX_STREAM_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
29
+ ngx_stream_core_server,
30
+ 0,
31
+ 0,
32
+ NULL },
33
+
34
+ { ngx_string("listen"),
35
+ NGX_STREAM_SRV_CONF|NGX_CONF_1MORE,
36
+ ngx_stream_core_listen,
37
+ NGX_STREAM_SRV_CONF_OFFSET,
38
+ 0,
39
+ NULL },
40
+
41
+ { ngx_string("error_log"),
42
+ NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_1MORE,
43
+ ngx_stream_core_error_log,
44
+ NGX_STREAM_SRV_CONF_OFFSET,
45
+ 0,
46
+ NULL },
47
+
48
+ { ngx_string("tcp_nodelay"),
49
+ NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_FLAG,
50
+ ngx_conf_set_flag_slot,
51
+ NGX_STREAM_SRV_CONF_OFFSET,
52
+ offsetof(ngx_stream_core_srv_conf_t, tcp_nodelay),
53
+ NULL },
54
+
55
+ ngx_null_command
56
+ };
57
+
58
+
59
+ static ngx_stream_module_t ngx_stream_core_module_ctx = {
60
+ NULL, /* postconfiguration */
61
+
62
+ ngx_stream_core_create_main_conf, /* create main configuration */
63
+ NULL, /* init main configuration */
64
+
65
+ ngx_stream_core_create_srv_conf, /* create server configuration */
66
+ ngx_stream_core_merge_srv_conf /* merge server configuration */
67
+ };
68
+
69
+
70
+ ngx_module_t ngx_stream_core_module = {
71
+ NGX_MODULE_V1,
72
+ &ngx_stream_core_module_ctx, /* module context */
73
+ ngx_stream_core_commands, /* module directives */
74
+ NGX_STREAM_MODULE, /* module type */
75
+ NULL, /* init master */
76
+ NULL, /* init module */
77
+ NULL, /* init process */
78
+ NULL, /* init thread */
79
+ NULL, /* exit thread */
80
+ NULL, /* exit process */
81
+ NULL, /* exit master */
82
+ NGX_MODULE_V1_PADDING
83
+ };
84
+
85
+
86
+ static void *
87
+ ngx_stream_core_create_main_conf(ngx_conf_t *cf)
88
+ {
89
+ ngx_stream_core_main_conf_t *cmcf;
90
+
91
+ cmcf = ngx_pcalloc(cf->pool, sizeof(ngx_stream_core_main_conf_t));
92
+ if (cmcf == NULL) {
93
+ return NULL;
94
+ }
95
+
96
+ if (ngx_array_init(&cmcf->servers, cf->pool, 4,
97
+ sizeof(ngx_stream_core_srv_conf_t *))
98
+ != NGX_OK)
99
+ {
100
+ return NULL;
101
+ }
102
+
103
+ if (ngx_array_init(&cmcf->listen, cf->pool, 4, sizeof(ngx_stream_listen_t))
104
+ != NGX_OK)
105
+ {
106
+ return NULL;
107
+ }
108
+
109
+ return cmcf;
110
+ }
111
+
112
+
113
+ static void *
114
+ ngx_stream_core_create_srv_conf(ngx_conf_t *cf)
115
+ {
116
+ ngx_stream_core_srv_conf_t *cscf;
117
+
118
+ cscf = ngx_pcalloc(cf->pool, sizeof(ngx_stream_core_srv_conf_t));
119
+ if (cscf == NULL) {
120
+ return NULL;
121
+ }
122
+
123
+ /*
124
+ * set by ngx_pcalloc():
125
+ *
126
+ * cscf->handler = NULL;
127
+ * cscf->error_log = NULL;
128
+ */
129
+
130
+ cscf->file_name = cf->conf_file->file.name.data;
131
+ cscf->line = cf->conf_file->line;
132
+ cscf->tcp_nodelay = NGX_CONF_UNSET;
133
+
134
+ return cscf;
135
+ }
136
+
137
+
138
+ static char *
139
+ ngx_stream_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
140
+ {
141
+ ngx_stream_core_srv_conf_t *prev = parent;
142
+ ngx_stream_core_srv_conf_t *conf = child;
143
+
144
+ if (conf->handler == NULL) {
145
+ ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
146
+ "no handler for server in %s:%ui",
147
+ conf->file_name, conf->line);
148
+ return NGX_CONF_ERROR;
149
+ }
150
+
151
+ if (conf->error_log == NULL) {
152
+ if (prev->error_log) {
153
+ conf->error_log = prev->error_log;
154
+ } else {
155
+ conf->error_log = &cf->cycle->new_log;
156
+ }
157
+ }
158
+
159
+ ngx_conf_merge_value(conf->tcp_nodelay, prev->tcp_nodelay, 1);
160
+
161
+ return NGX_CONF_OK;
162
+ }
163
+
164
+
165
+ static char *
166
+ ngx_stream_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
167
+ {
168
+ ngx_stream_core_srv_conf_t *cscf = conf;
169
+
170
+ return ngx_log_set_log(cf, &cscf->error_log);
171
+ }
172
+
173
+
174
+ static char *
175
+ ngx_stream_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
176
+ {
177
+ char *rv;
178
+ void *mconf;
179
+ ngx_uint_t m;
180
+ ngx_conf_t pcf;
181
+ ngx_stream_module_t *module;
182
+ ngx_stream_conf_ctx_t *ctx, *stream_ctx;
183
+ ngx_stream_core_srv_conf_t *cscf, **cscfp;
184
+ ngx_stream_core_main_conf_t *cmcf;
185
+
186
+ ctx = ngx_pcalloc(cf->pool, sizeof(ngx_stream_conf_ctx_t));
187
+ if (ctx == NULL) {
188
+ return NGX_CONF_ERROR;
189
+ }
190
+
191
+ stream_ctx = cf->ctx;
192
+ ctx->main_conf = stream_ctx->main_conf;
193
+
194
+ /* the server{}'s srv_conf */
195
+
196
+ ctx->srv_conf = ngx_pcalloc(cf->pool,
197
+ sizeof(void *) * ngx_stream_max_module);
198
+ if (ctx->srv_conf == NULL) {
199
+ return NGX_CONF_ERROR;
200
+ }
201
+
202
+ for (m = 0; cf->cycle->modules[m]; m++) {
203
+ if (cf->cycle->modules[m]->type != NGX_STREAM_MODULE) {
204
+ continue;
205
+ }
206
+
207
+ module = cf->cycle->modules[m]->ctx;
208
+
209
+ if (module->create_srv_conf) {
210
+ mconf = module->create_srv_conf(cf);
211
+ if (mconf == NULL) {
212
+ return NGX_CONF_ERROR;
213
+ }
214
+
215
+ ctx->srv_conf[cf->cycle->modules[m]->ctx_index] = mconf;
216
+ }
217
+ }
218
+
219
+ /* the server configuration context */
220
+
221
+ cscf = ctx->srv_conf[ngx_stream_core_module.ctx_index];
222
+ cscf->ctx = ctx;
223
+
224
+ cmcf = ctx->main_conf[ngx_stream_core_module.ctx_index];
225
+
226
+ cscfp = ngx_array_push(&cmcf->servers);
227
+ if (cscfp == NULL) {
228
+ return NGX_CONF_ERROR;
229
+ }
230
+
231
+ *cscfp = cscf;
232
+
233
+
234
+ /* parse inside server{} */
235
+
236
+ pcf = *cf;
237
+ cf->ctx = ctx;
238
+ cf->cmd_type = NGX_STREAM_SRV_CONF;
239
+
240
+ rv = ngx_conf_parse(cf, NULL);
241
+
242
+ *cf = pcf;
243
+
244
+ return rv;
245
+ }
246
+
247
+
248
+ static char *
249
+ ngx_stream_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
250
+ {
251
+ size_t len, off;
252
+ in_port_t port;
253
+ ngx_str_t *value;
254
+ ngx_url_t u;
255
+ ngx_uint_t i, backlog;
256
+ struct sockaddr *sa;
257
+ struct sockaddr_in *sin;
258
+ ngx_stream_listen_t *ls;
259
+ ngx_stream_core_main_conf_t *cmcf;
260
+ #if (NGX_HAVE_INET6)
261
+ struct sockaddr_in6 *sin6;
262
+ #endif
263
+
264
+ value = cf->args->elts;
265
+
266
+ ngx_memzero(&u, sizeof(ngx_url_t));
267
+
268
+ u.url = value[1];
269
+ u.listen = 1;
270
+
271
+ if (ngx_parse_url(cf->pool, &u) != NGX_OK) {
272
+ if (u.err) {
273
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
274
+ "%s in \"%V\" of the \"listen\" directive",
275
+ u.err, &u.url);
276
+ }
277
+
278
+ return NGX_CONF_ERROR;
279
+ }
280
+
281
+ cmcf = ngx_stream_conf_get_module_main_conf(cf, ngx_stream_core_module);
282
+
283
+ ls = cmcf->listen.elts;
284
+
285
+ for (i = 0; i < cmcf->listen.nelts; i++) {
286
+
287
+ sa = &ls[i].u.sockaddr;
288
+
289
+ if (sa->sa_family != u.family) {
290
+ continue;
291
+ }
292
+
293
+ switch (sa->sa_family) {
294
+
295
+ #if (NGX_HAVE_INET6)
296
+ case AF_INET6:
297
+ off = offsetof(struct sockaddr_in6, sin6_addr);
298
+ len = 16;
299
+ sin6 = &ls[i].u.sockaddr_in6;
300
+ port = sin6->sin6_port;
301
+ break;
302
+ #endif
303
+
304
+ #if (NGX_HAVE_UNIX_DOMAIN)
305
+ case AF_UNIX:
306
+ off = offsetof(struct sockaddr_un, sun_path);
307
+ len = sizeof(((struct sockaddr_un *) sa)->sun_path);
308
+ port = 0;
309
+ break;
310
+ #endif
311
+
312
+ default: /* AF_INET */
313
+ off = offsetof(struct sockaddr_in, sin_addr);
314
+ len = 4;
315
+ sin = &ls[i].u.sockaddr_in;
316
+ port = sin->sin_port;
317
+ break;
318
+ }
319
+
320
+ if (ngx_memcmp(ls[i].u.sockaddr_data + off, u.sockaddr + off, len)
321
+ != 0)
322
+ {
323
+ continue;
324
+ }
325
+
326
+ if (port != u.port) {
327
+ continue;
328
+ }
329
+
330
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
331
+ "duplicate \"%V\" address and port pair", &u.url);
332
+ return NGX_CONF_ERROR;
333
+ }
334
+
335
+ ls = ngx_array_push(&cmcf->listen);
336
+ if (ls == NULL) {
337
+ return NGX_CONF_ERROR;
338
+ }
339
+
340
+ ngx_memzero(ls, sizeof(ngx_stream_listen_t));
341
+
342
+ ngx_memcpy(&ls->u.sockaddr, u.sockaddr, u.socklen);
343
+
344
+ ls->socklen = u.socklen;
345
+ ls->backlog = NGX_LISTEN_BACKLOG;
346
+ ls->type = SOCK_STREAM;
347
+ ls->wildcard = u.wildcard;
348
+ ls->ctx = cf->ctx;
349
+
350
+ #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
351
+ ls->ipv6only = 1;
352
+ #endif
353
+
354
+ backlog = 0;
355
+
356
+ for (i = 2; i < cf->args->nelts; i++) {
357
+
358
+ #if !(NGX_WIN32)
359
+ if (ngx_strcmp(value[i].data, "udp") == 0) {
360
+ ls->type = SOCK_DGRAM;
361
+ continue;
362
+ }
363
+ #endif
364
+
365
+ if (ngx_strcmp(value[i].data, "bind") == 0) {
366
+ ls->bind = 1;
367
+ continue;
368
+ }
369
+
370
+ if (ngx_strncmp(value[i].data, "backlog=", 8) == 0) {
371
+ ls->backlog = ngx_atoi(value[i].data + 8, value[i].len - 8);
372
+ ls->bind = 1;
373
+
374
+ if (ls->backlog == NGX_ERROR || ls->backlog == 0) {
375
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
376
+ "invalid backlog \"%V\"", &value[i]);
377
+ return NGX_CONF_ERROR;
378
+ }
379
+
380
+ backlog = 1;
381
+
382
+ continue;
383
+ }
384
+
385
+ if (ngx_strncmp(value[i].data, "ipv6only=o", 10) == 0) {
386
+ #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
387
+ u_char buf[NGX_SOCKADDR_STRLEN];
388
+
389
+ sa = &ls->u.sockaddr;
390
+
391
+ if (sa->sa_family == AF_INET6) {
392
+
393
+ if (ngx_strcmp(&value[i].data[10], "n") == 0) {
394
+ ls->ipv6only = 1;
395
+
396
+ } else if (ngx_strcmp(&value[i].data[10], "ff") == 0) {
397
+ ls->ipv6only = 0;
398
+
399
+ } else {
400
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
401
+ "invalid ipv6only flags \"%s\"",
402
+ &value[i].data[9]);
403
+ return NGX_CONF_ERROR;
404
+ }
405
+
406
+ ls->bind = 1;
407
+
408
+ } else {
409
+ len = ngx_sock_ntop(sa, ls->socklen, buf,
410
+ NGX_SOCKADDR_STRLEN, 1);
411
+
412
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
413
+ "ipv6only is not supported "
414
+ "on addr \"%*s\", ignored", len, buf);
415
+ }
416
+
417
+ continue;
418
+ #else
419
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
420
+ "bind ipv6only is not supported "
421
+ "on this platform");
422
+ return NGX_CONF_ERROR;
423
+ #endif
424
+ }
425
+
426
+ if (ngx_strcmp(value[i].data, "reuseport") == 0) {
427
+ #if (NGX_HAVE_REUSEPORT)
428
+ ls->reuseport = 1;
429
+ ls->bind = 1;
430
+ #else
431
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
432
+ "reuseport is not supported "
433
+ "on this platform, ignored");
434
+ #endif
435
+ continue;
436
+ }
437
+
438
+ if (ngx_strcmp(value[i].data, "ssl") == 0) {
439
+ #if (NGX_STREAM_SSL)
440
+ ls->ssl = 1;
441
+ continue;
442
+ #else
443
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
444
+ "the \"ssl\" parameter requires "
445
+ "ngx_stream_ssl_module");
446
+ return NGX_CONF_ERROR;
447
+ #endif
448
+ }
449
+
450
+ if (ngx_strncmp(value[i].data, "so_keepalive=", 13) == 0) {
451
+
452
+ if (ngx_strcmp(&value[i].data[13], "on") == 0) {
453
+ ls->so_keepalive = 1;
454
+
455
+ } else if (ngx_strcmp(&value[i].data[13], "off") == 0) {
456
+ ls->so_keepalive = 2;
457
+
458
+ } else {
459
+
460
+ #if (NGX_HAVE_KEEPALIVE_TUNABLE)
461
+ u_char *p, *end;
462
+ ngx_str_t s;
463
+
464
+ end = value[i].data + value[i].len;
465
+ s.data = value[i].data + 13;
466
+
467
+ p = ngx_strlchr(s.data, end, ':');
468
+ if (p == NULL) {
469
+ p = end;
470
+ }
471
+
472
+ if (p > s.data) {
473
+ s.len = p - s.data;
474
+
475
+ ls->tcp_keepidle = ngx_parse_time(&s, 1);
476
+ if (ls->tcp_keepidle == (time_t) NGX_ERROR) {
477
+ goto invalid_so_keepalive;
478
+ }
479
+ }
480
+
481
+ s.data = (p < end) ? (p + 1) : end;
482
+
483
+ p = ngx_strlchr(s.data, end, ':');
484
+ if (p == NULL) {
485
+ p = end;
486
+ }
487
+
488
+ if (p > s.data) {
489
+ s.len = p - s.data;
490
+
491
+ ls->tcp_keepintvl = ngx_parse_time(&s, 1);
492
+ if (ls->tcp_keepintvl == (time_t) NGX_ERROR) {
493
+ goto invalid_so_keepalive;
494
+ }
495
+ }
496
+
497
+ s.data = (p < end) ? (p + 1) : end;
498
+
499
+ if (s.data < end) {
500
+ s.len = end - s.data;
501
+
502
+ ls->tcp_keepcnt = ngx_atoi(s.data, s.len);
503
+ if (ls->tcp_keepcnt == NGX_ERROR) {
504
+ goto invalid_so_keepalive;
505
+ }
506
+ }
507
+
508
+ if (ls->tcp_keepidle == 0 && ls->tcp_keepintvl == 0
509
+ && ls->tcp_keepcnt == 0)
510
+ {
511
+ goto invalid_so_keepalive;
512
+ }
513
+
514
+ ls->so_keepalive = 1;
515
+
516
+ #else
517
+
518
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
519
+ "the \"so_keepalive\" parameter accepts "
520
+ "only \"on\" or \"off\" on this platform");
521
+ return NGX_CONF_ERROR;
522
+
523
+ #endif
524
+ }
525
+
526
+ ls->bind = 1;
527
+
528
+ continue;
529
+
530
+ #if (NGX_HAVE_KEEPALIVE_TUNABLE)
531
+ invalid_so_keepalive:
532
+
533
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
534
+ "invalid so_keepalive value: \"%s\"",
535
+ &value[i].data[13]);
536
+ return NGX_CONF_ERROR;
537
+ #endif
538
+ }
539
+
540
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
541
+ "the invalid \"%V\" parameter", &value[i]);
542
+ return NGX_CONF_ERROR;
543
+ }
544
+
545
+ if (ls->type == SOCK_DGRAM) {
546
+ if (backlog) {
547
+ return "\"backlog\" parameter is incompatible with \"udp\"";
548
+ }
549
+
550
+ #if (NGX_STREAM_SSL)
551
+ if (ls->ssl) {
552
+ return "\"ssl\" parameter is incompatible with \"udp\"";
553
+ }
554
+ #endif
555
+
556
+ if (ls->so_keepalive) {
557
+ return "\"so_keepalive\" parameter is incompatible with \"udp\"";
558
+ }
559
+ }
560
+
561
+ return NGX_CONF_OK;
562
+ }