Roxen.git / server / base_server / roxen.pike

version» Context lines:

Roxen.git/server/base_server/roxen.pike:1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2004, Roxen IS.   //   // The Roxen WebServer main program.   //   // Per Hedbor, Henrik Grubbström, Pontus Hagland, David Hedbor and others.   // ABS and suicide systems contributed freely by Francesco Chemolli    - constant cvs_version="$Id: roxen.pike,v 1.891 2005/02/10 17:50:00 mast Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.892 2005/02/23 13:42:41 grubba Exp $";      //! @appears roxen   //!   //! The Roxen WebServer main program.      // The argument cache. Used by the image cache.   ArgCache argcache;      // Some headerfiles   #define IN_ROXEN
Roxen.git/server/base_server/roxen.pike:1957:   // prot:ip:port ==> Protocol.   mapping(string:mapping(string:mapping(int:Protocol))) open_ports = ([ ]);      // url:"port" ==> Protocol.   mapping(string:mapping(string:Configuration)) urls = ([]);   array sorted_urls = ({});      array(string) find_ips_for( string what )   {    if( what == "*" || lower_case(what) == "any" ) -  return ({ 0 }); // ANY +  return ({ 0, "::" }); // ANY       if( is_ip( what ) )    return ({ what }); -  +  else if (has_suffix(lower_case(what), ".ipv6")) { +  // draft-masinter-url-ipv6-00 3 +  // +  // a) replace every colon ":" with a "-" +  // b) append ".ipv6" to the end. +  return ({ replace(what[..sizeof(what)-6], "-", ":") }); +  }    array res = gethostbyname( what );    if( res && sizeof( res[1] ) )    return Array.uniq(res[1]);       report_error(LOC_M(46, "Cannot possibly bind to %O, that host is "    "unknown. Substituting with ANY")+"\n", what);    return 0; // FAIL   }      string normalize_url(string url)
Roxen.git/server/base_server/roxen.pike:2148:       if (!required_hosts) {    // FIXME: Used to fallback to ANY.    // Will this work with glob URLs?    report_error(LOC_M(23, "Cannot register URL %s!")+"\n", url);    return 0;    }       mapping m;    if( !( m = open_ports[ protocol ] ) ) -  // always add 'ANY' (0) here, as an empty mapping, for speed reasons. +  // always add 'ANY' (0) and 'IPv6_ANY' (::) here, as empty mappings, +  // for speed reasons.    // There is now no need to check for both open_ports[prot][0] and    // open_ports[prot][0][port], we can go directly to the latter    // test. -  m = open_ports[ protocol ] = ([ 0:([]) ]); +  m = open_ports[ protocol ] = ([ 0:([]), "::":([]) ]);    -  if( sizeof( required_hosts - ({ 0 }) ) // not ANY -  && m[ 0 ][ port ] -  && prot->supports_ipless ) -  // The ANY port is already open for this port, and since this +  if (prot->supports_ipless ) { +  // Check if the ANY port is already open for this port, since this    // protocol supports IP-less virtual hosting, there is no need to -  // open yet another port, that would mosts probably only conflict -  // with the ANY port anyway. (this is true on most OSes, it works -  // on Solaris, but fails on linux) -  required_hosts = ({ 0 }); +  // open yet another port if it is, since that would mosts probably +  // only conflict with the ANY port anyway. (this is true on most +  // OSes, it works on Solaris, but fails on linux) +  array(string) ipv6 = filter(required_hosts - ({ 0 }), has_value, ":"); +  array(string) ipv4 = required_hosts - ipv6; +  if (m[0][port] && sizeof(ipv4 - ({ 0 }))) { +  // We have a non-ANY IPv4 IP number. +  ipv4 = ({ 0 }); +  } +  if (m["::"][port] && sizeof(ipv6 - ({ "::" }))) { +  // We have a non-ANY IPv6 IP number. +  ipv6 = ({ "::" }); +  } +  required_hosts = ipv4 + ipv6; +  }       int failures;       foreach(required_hosts, string required_host)    {    if( m[ required_host ] && m[ required_host ][ port ] )    {    m[required_host][port]->ref(url, urls[url]);       urls[url]->port = m[required_host][port];
Roxen.git/server/base_server/roxen.pike:4855: Inside #if defined(SNMP_AGENT)
   snmpagent = 0;    }    break;   #endif // SNMP_AGENT       }   }      int is_ip(string s)   { -  return s&&(sscanf(s,"%*d.%*d.%*d.%*d")==4 && s[-1]>47 && s[-1]<58); +  return s && +  ((sscanf(s,"%*d.%*d.%*d.%*d")==4 && s[-1]>='0' && s[-1]<='9') || // IPv4 +  (sizeof(s/":") > 1)); // IPv6   }      static string _sprintf( )   {    return "roxen";   }      // Support for logging in configurations and modules.      class LogFormat