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 - 2009, 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.1081 2011/06/15 15:11:08 grubba Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.1082 2011/07/14 12:13:32 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:2631:   //!   //! @item "port://host_glob:port/path/#opt1=val1;opt2=val2"   //! An URL string containing options as stored in the @tt{"URLs"@}   //! configuration variable, and expected as argument by   //! @[register_url()] and @[unregister_url()]. Also known   //! as an ourl.   //! @enddl   //!   //! In both cases the same set of data is stored:   //! @mapping - //! @member mapping(string:Configuration|Protocol|string|array(Protocol)) url + //! @member mapping(string:Configuration|Protocol|string|array(Protocol)|array(string)) url   //! @mapping   //! @member Protocol "port"   //! Representative open port for this URL.   //! @member array(Protocol) "ports"   //! Array of all open ports for this URL.   //! @member Configuration "conf"   //! Configuration that has registered the URL.   //! @member string "path"   //! Path segment of the URL.   //! @member string "host"   //! Hostname segment of the URL. -  + //! @member array(string) "skipped" + //! List of IP numbers not bound due to a corresponding + //! ANY port already being open.   //! @endmapping   //! @endmapping - mapping(string:mapping(string:Configuration|Protocol|string|array(Protocol))) + mapping(string:mapping(string:Configuration|Protocol|string|array(Protocol)|array(string)))    urls = ([]);      array sorted_urls = ({});      array(string) find_ips_for( string what )   {    if( what == "*" || lower_case(what) == "any" )    return ({   #if constant(__ROXEN_SUPPORTS_IPV6__)    "::",
Roxen.git/server/base_server/roxen.pike:2764:    mapping(string:mixed) data = m_delete(urls, ourl);    if (!data) return; // URL not registered.    if (!sizeof(url = normalize_url(url, 1))) return;       report_debug ("Unregister %s%s.\n", normalize_url (ourl),    conf ? sprintf (" for %O", conf->query_name()) : "");       mapping(string:mixed) shared_data = urls[url];    if (!shared_data) return; // Strange case, but URL not registered.    +  int was_any_ip; +  if (!data->skipped && data->port) { +  if (!data->port->ip || (data->port->ip == "::")) { +  was_any_ip = data->port->port; +  report_debug("Unregistering ANY port: %O:%d\n", +  data->port->ip, data->port->port); +  } +  } +     foreach(data->ports, Protocol port) {    shared_data->ports -= ({ port }); -  int was_main_port = (shared_data->port == port); +     port->unref(url);    m_delete(shared_data, "port");    }    if (!sizeof(shared_data->ports)) {    m_delete(urls, url);    } else if (!shared_data->port) {    shared_data->port = shared_data->ports[0];    }    sort_urls(); -  +  +  if (was_any_ip) { +  foreach(urls; string url; mapping(string:mixed) url_info) { +  if (!url_info->skipped || !url_info->conf || +  (url_info->port && (url_info->port->port != was_any_ip))) { +  continue;    } -  +  // Re-register the ports that may have bound to the removed ANY port. +  register_url(url, url_info->conf); +  } +  } + }      array all_ports( )   {    // FIXME: Consider using open_ports instead.    return Array.uniq( values( urls )->ports * ({}) )-({0});   }      Protocol find_port( string name )   {    foreach( all_ports(), Protocol p )
Roxen.git/server/base_server/roxen.pike:2872:    program prot;       if( !( prot = protocols[ protocol ] ) )    {    report_error(LOC_M(21, "Cannot register URL %s - "    "cannot find the protocol %s.")+"\n",    display_url, protocol);    return 0;    }    -  if (!urls[ourl]) +  // FIXME: Do we need to unref the old ports first in case of a reregister?    urls[ ourl ] = ([ "conf":conf, "path":path, "hostname": host ]);    if (!urls[url]) {    urls[ url ] = urls[ourl] + ([]);    sorted_urls += ({ url }); // FIXME: Not exactly sorted...    }       array(string)|int(-1..0) required_hosts;       if (is_ip(host))    required_hosts = ({ host });
Roxen.git/server/base_server/roxen.pike:2912:    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 if it is, since that would most 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. +  // Keep track of the ips in case the ANY port is removed. +  urls[ourl]->skipped = ipv4;    ipv4 = ({ 0 });    }   #if constant(__ROXEN_SUPPORTS_IPV6__)    if (m["::"][port] && sizeof(ipv6 - ({ "::" }))) {    // We have a non-ANY IPv6 IP number. -  +  // Keep track of the ips in case the ANY port is removed. +  urls[ourl]->skipped += ipv6;    ipv6 = ({ "::" });    }    required_hosts = ipv6 + ipv4;   #else    if (sizeof(ipv6)) {    foreach(ipv6, string p) {    report_warning(LOC_M(65, "Cannot open port %s for URL %s - "    "IPv6 support disabled.\n"),    p, display_url);    }