Klaus Demo nginx / ecd6e24
Core: style. Vladimir Homutov 1 year, 6 months ago
1 changed file(s) with 14 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
1717 #define NGX_PP_V2_AF_INET6 2
1818
1919
20 #define ngx_pp_v2_get_u16(p) \
21 ( ((uint16_t) ((u_char *) (p))[0] << 8) \
22 + ( ((u_char *) (p))[1]) )
20 #define ngx_pp_v2_get_u16(p) ((p)[0] << 8 | (p)[1])
2321
2422
2523 typedef struct {
2624 u_char signature[NGX_PP_V2_SIGLEN];
2725 u_char ver_cmd;
28 u_char fam_transp;
26 u_char family_transport;
2927 u_char len[2];
3028 } ngx_pp_v2_header_t;
3129
5654 u_char *last);
5755
5856 static const u_char ngx_pp_v2_signature[NGX_PP_V2_SIGLEN] =
59 { 0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A };
57 { 0x0d, 0x0a, 0x0d, 0x0a, 0x00, 0x0d, 0x0a, 0x51, 0x55, 0x49, 0x54, 0x0a };
6058
6159
6260 u_char *
161159 c->proxy_protocol_port = (in_port_t) n;
162160
163161 ngx_log_debug2(NGX_LOG_DEBUG_CORE, c->log, 0,
164 "PROXY protocol address: %V %i", &c->proxy_protocol_addr, n);
162 "PROXY protocol address: %V %d", &c->proxy_protocol_addr,
163 c->proxy_protocol_port);
165164
166165 skip:
167166
257256
258257 end = buf + len;
259258
260 cmd = hdr->ver_cmd & 0x0F;
259 cmd = hdr->ver_cmd & 0x0f;
261260
262261 if (cmd != NGX_PP_V2_CMD_PROXY) {
263262 ngx_log_debug1(NGX_LOG_DEBUG_CORE, c->log, 0,
264 "PROXY protocol v2 unsupported cmd 0x%xi", cmd);
263 "PROXY protocol v2 unsupported command 0x%xi", cmd);
265264 return end;
266265 }
267266
268 transport = hdr->fam_transp & 0x0F;
267 transport = hdr->family_transport & 0x0f;
269268
270269 if (transport != NGX_PP_V2_STREAM) {
271270 ngx_log_debug1(NGX_LOG_DEBUG_CORE, c->log, 0,
274273 return end;
275274 }
276275
277 family = hdr->fam_transp >> 4;
276 family = hdr->family_transport >> 4;
278277
279278 addrs = (ngx_pp_v2_addrs_t *) buf;
280279
307306
308307 case NGX_PP_V2_AF_INET6:
309308
310 if ((size_t) (end - buf) < sizeof(ngx_pp_v2_inet6_addrs_t)) {
309 if ((size_t) (end - buf) < sizeof(ngx_pp_v2_inet6_addrs_t)) {
311310 return NULL;
312311 }
313312
328327 default:
329328
330329 ngx_log_debug1(NGX_LOG_DEBUG_CORE, c->log, 0,
331 "PROXY_protocol v2 unsupported address family "
332 "0x%xi", family);
330 "PROXY protocol v2 unsupported address family 0x%xi",
331 family);
333332 return end;
334333 }
335334
347346 }
348347
349348 ngx_log_debug2(NGX_LOG_DEBUG_CORE, c->log, 0,
350 "PROXY protocol v2 address: %V %i", name,
351 (ngx_int_t) c->proxy_protocol_port);
349 "PROXY protocol v2 address: %V %d", name,
350 c->proxy_protocol_port);
352351
353352 if (buf < end) {
354353 ngx_log_debug1(NGX_LOG_DEBUG_CORE, c->log, 0,