comparison src/http/ngx_http_core_module.c @ 252:644510700914 NGINX_0_4_11

nginx 0.4.11 *) Feature: the POP3 proxy supports the AUTH LOGIN PLAIN and CRAM-MD5. *) Feature: the ngx_http_perl_module supports the $r->allow_ranges method. *) Bugfix: if the APOP was enabled in the POP3 proxy, then the USER/PASS commands might not work; bug appeared in 0.4.10.
author Igor Sysoev <http://sysoev.ru>
date Wed, 25 Oct 2006 00:00:00 +0400
parents acd2ec3541cb
children 2e9c57a5e50a
comparison
equal deleted inserted replaced
251:16ffa8ae5759 252:644510700914
2369 static char * 2369 static char *
2370 ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 2370 ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
2371 { 2371 {
2372 ngx_http_core_srv_conf_t *scf = conf; 2372 ngx_http_core_srv_conf_t *scf = conf;
2373 2373
2374 char *err; 2374 ngx_str_t *value, size;
2375 ngx_str_t *value, size; 2375 ngx_url_t u;
2376 ngx_uint_t n; 2376 ngx_uint_t n;
2377 struct hostent *h; 2377 ngx_http_listen_t *ls;
2378 ngx_http_listen_t *ls;
2379 ngx_inet_upstream_t inet_upstream;
2380 2378
2381 /* 2379 /*
2382 * TODO: check duplicate 'listen' directives, 2380 * TODO: check duplicate 'listen' directives,
2383 * add resolved name to server names ??? 2381 * add resolved name to server names ???
2384 */ 2382 */
2385 2383
2386 value = cf->args->elts; 2384 value = cf->args->elts;
2387 2385
2388 ngx_memzero(&inet_upstream, sizeof(ngx_inet_upstream_t)); 2386 ngx_memzero(&u, sizeof(ngx_url_t));
2389 2387
2390 inet_upstream.url = value[1]; 2388 u.url = value[1];
2391 inet_upstream.port_only = 1; 2389 u.listen = 1;
2392 2390 u.default_portn = 80;
2393 err = ngx_inet_parse_host_port(&inet_upstream); 2391
2394 2392 if (ngx_parse_url(cf, &u) != NGX_OK) {
2395 if (err) { 2393 if (u.err) {
2396 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 2394 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
2397 "%s in \"%V\" of the \"listen\" directive", 2395 "%s in \"%V\" of the \"listen\" directive",
2398 err, &inet_upstream.url); 2396 u.err, &u.url);
2397 }
2398
2399 return NGX_CONF_ERROR; 2399 return NGX_CONF_ERROR;
2400 } 2400 }
2401 2401
2402 ls = ngx_array_push(&scf->listen); 2402 ls = ngx_array_push(&scf->listen);
2403 if (ls == NULL) { 2403 if (ls == NULL) {
2405 } 2405 }
2406 2406
2407 ngx_memzero(ls, sizeof(ngx_http_listen_t)); 2407 ngx_memzero(ls, sizeof(ngx_http_listen_t));
2408 2408
2409 ls->family = AF_INET; 2409 ls->family = AF_INET;
2410 ls->port = (in_port_t) (inet_upstream.default_port ? 2410 ls->addr = u.addr.in_addr;
2411 80 : inet_upstream.port); 2411 ls->port = u.portn;
2412 ls->file_name = cf->conf_file->file.name; 2412 ls->file_name = cf->conf_file->file.name;
2413 ls->line = cf->conf_file->line; 2413 ls->line = cf->conf_file->line;
2414 ls->conf.backlog = -1; 2414 ls->conf.backlog = -1;
2415 ls->conf.rcvbuf = -1; 2415 ls->conf.rcvbuf = -1;
2416 ls->conf.sndbuf = -1; 2416 ls->conf.sndbuf = -1;
2417
2418 if (inet_upstream.host.len == 1 && inet_upstream.host.data[0] == '*') {
2419 inet_upstream.host.len = 0;
2420 }
2421
2422 if (inet_upstream.host.len) {
2423 inet_upstream.host.data[inet_upstream.host.len] = '\0';
2424
2425 ls->addr = inet_addr((const char *) inet_upstream.host.data);
2426
2427 if (ls->addr == INADDR_NONE) {
2428 h = gethostbyname((const char *) inet_upstream.host.data);
2429
2430 if (h == NULL || h->h_addr_list[0] == NULL) {
2431 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
2432 "can not resolve host \"%s\" "
2433 "in the \"listen\" directive",
2434 inet_upstream.host.data);
2435 return NGX_CONF_ERROR;
2436 }
2437
2438 ls->addr = *(in_addr_t *)(h->h_addr_list[0]);
2439 }
2440
2441 } else {
2442 ls->addr = INADDR_ANY;
2443 }
2444 2417
2445 n = ngx_inet_ntop(AF_INET, &ls->addr, ls->conf.addr, INET_ADDRSTRLEN + 6); 2418 n = ngx_inet_ntop(AF_INET, &ls->addr, ls->conf.addr, INET_ADDRSTRLEN + 6);
2446 ngx_sprintf(&ls->conf.addr[n], ":%ui", ls->port); 2419 ngx_sprintf(&ls->conf.addr[n], ":%ui", ls->port);
2447 2420
2448 if (cf->args->nelts == 2) { 2421 if (cf->args->nelts == 2) {