1/*- 2 * Copyright (c) 1998-2004 Dag-Erling Co�dan Sm�rgrav 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/lib/libfetch/common.c 174752 2007-12-18 11:03:07Z des $"); |
31 32#include <sys/param.h> 33#include <sys/socket.h> 34#include <sys/time.h> 35#include <sys/uio.h> |
36 |
37#include <netinet/in.h> 38 |
39#include <ctype.h> |
40#include <errno.h> 41#include <netdb.h> 42#include <pwd.h> 43#include <stdarg.h> 44#include <stdlib.h> 45#include <stdio.h> 46#include <string.h> 47#include <unistd.h> --- 683 unchanged lines hidden (view full) --- 731 } 732 } 733 fclose(f); 734 return (0); 735 ferr: 736 fclose(f); 737 return (-1); 738} |
739 740/* 741 * The no_proxy environment variable specifies a set of domains for 742 * which the proxy should not be consulted; the contents is a comma-, 743 * or space-separated list of domain names. A single asterisk will 744 * override all proxy variables and no transactions will be proxied 745 * (for compatability with lynx and curl, see the discussion at 746 * <http://curl.haxx.se/mail/archive_pre_oct_99/0009.html>). 747 */ 748int 749fetch_no_proxy_match(const char *host) 750{ 751 const char *no_proxy, *p, *q; 752 size_t h_len, d_len; 753 754 if ((no_proxy = getenv("NO_PROXY")) == NULL && 755 (no_proxy = getenv("no_proxy")) == NULL) 756 return (0); 757 758 /* asterisk matches any hostname */ 759 if (strcmp(no_proxy, "*") == 0) 760 return (1); 761 762 h_len = strlen(host); 763 p = no_proxy; 764 do { 765 /* position p at the beginning of a domain suffix */ 766 while (*p == ',' || isspace((int)*p)) 767 p++; 768 769 /* position q at the first separator character */ 770 for (q = p; *q; ++q) 771 if (*q == ',' || isspace((int)*q)) 772 break; 773 774 d_len = q - p; 775 if (d_len > 0 && h_len > d_len && 776 strncasecmp(host + h_len - d_len, 777 p, d_len) == 0) { 778 /* domain name matches */ 779 return (1); 780 } 781 782 p = q + 1; 783 } while (*q); 784 785 return (0); 786} |