Changeset 1150

Show
Ignore:
Timestamp:
03/04/08 22:44:35 (7 months ago)
Author:
ahu
Message:

implement 'allow-from-file', based on a patch by Sten Spans, thanks!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/pdns/pdns/docs/pdns.sgml

    r1145 r1150  
    72937293            </listitem> 
    72947294          </varlistentry> 
     7295          <varlistentry> 
     7296            <term>allow-from-file</term> 
     7297            <listitem> 
     7298              <para> 
     7299                Like <command>allow-from</command>, except reading from file. Overrides the 'allow-from' setting.  
     7300                To use this feature, supply one netmask per line, with optional comments preceeded by a #. 
     7301                Available since 3.1.5. 
     7302              </para> 
     7303            </listitem> 
     7304          </varlistentry> 
     7305 
    72957306          <varlistentry> 
    72967307            <term>auth-can-lower-ttl</term> 
  • trunk/pdns/pdns/iputils.hh

    r1075 r1150  
    11/* 
    22    PowerDNS Versatile Database Driven Nameserver 
    3     Copyright (C) 2002 - 2007  PowerDNS.COM BV 
     3    Copyright (C) 2002 - 2008  PowerDNS.COM BV 
    44 
    55    This program is free software; you can redistribute it and/or modify 
     
    263263  } 
    264264 
     265  string toString() const 
     266  { 
     267    return d_network.toString()+"/"+boost::lexical_cast<string>(d_bits); 
     268  } 
     269 
    265270private: 
    266271  ComboAddress d_network; 
     
    295300  } 
    296301 
     302  unsigned int size() 
     303  { 
     304    return (unsigned int)d_masks.size(); 
     305  } 
     306 
     307  string toString() const 
     308  { 
     309    ostringstream str; 
     310    for(container_t::const_iterator iter = d_masks.begin(); iter != d_masks.end(); ++iter) { 
     311      if(iter != d_masks.begin()) 
     312        str <<", "; 
     313      str<<iter->toString(); 
     314    } 
     315    return str.str(); 
     316  } 
     317 
     318 
    297319private: 
    298320  typedef vector<Netmask> container_t; 
  • trunk/pdns/pdns/pdns_recursor.cc

    r1135 r1150  
    15431543      SyncRes::s_domainmap[parts[0]]=ad; 
    15441544    } 
    1545     L<<Logger::Warning<<"Done parsing " << SyncRes::s_domainmap.size() - before<<" forwarding instructions"<<endl; 
     1545    L<<Logger::Warning<<"Done parsing " << SyncRes::s_domainmap.size() - before<<" forwarding instructions from file '"<<::arg()["forward-zones-files"]<<"'"<<endl; 
    15461546  } 
    15471547 
     
    16191619   
    16201620  L<<Logger::Warning<<"Operating in "<<(sizeof(unsigned long)*8) <<" bits mode"<<endl; 
    1621    
    1622   if(!::arg()["allow-from"].empty()) { 
     1621 
     1622  if(!::arg()["allow-from-file"].empty()) { 
     1623    string line; 
     1624    g_allowFrom=new NetmaskGroup; 
     1625    ifstream ifs(::arg()["allow-from-file"].c_str()); 
     1626    if(!ifs) { 
     1627        throw AhuException("Could not open '"+::arg()["allow-from-file"]+"': "+stringerror()); 
     1628    } 
     1629 
     1630    string::size_type pos; 
     1631    while(getline(ifs,line)) { 
     1632      pos=line.find('#'); 
     1633      if(pos!=string::npos) 
     1634        line.resize(pos); 
     1635      trim(line); 
     1636      if(line.empty()) 
     1637        continue; 
     1638 
     1639      g_allowFrom->addMask(line); 
     1640    } 
     1641    L<<Logger::Warning<<"Done parsing " << g_allowFrom->size() <<" allow-from ranges from file '"<<::arg()["allow-from-file"]<<"' - overriding 'allow-from' setting"<<endl; 
     1642  } 
     1643  else if(!::arg()["allow-from"].empty()) { 
    16231644    g_allowFrom=new NetmaskGroup; 
    16241645    vector<string> ips; 
     
    16361657    L<<Logger::Error<<"WARNING: Allowing queries from all IP addresses - this can be a security risk!"<<endl; 
    16371658   
     1659 
    16381660  if(!::arg()["dont-query"].empty()) { 
    16391661    g_dontQuery=new NetmaskGroup; 
     
    18611883    ::arg().set("version-string", "string reported on version.pdns or version.bind")="PowerDNS Recursor "VERSION" $Id$"; 
    18621884    ::arg().set("allow-from", "If set, only allow these comma separated netmasks to recurse")="127.0.0.0/8, 10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12, ::1/128, fe80::/10"; 
     1885    ::arg().set("allow-from-file", "If set, load allowed netmasks from this file")=""; 
    18631886    ::arg().set("dont-query", "If set, do not query these netmasks for DNS data")="127.0.0.0/8, 10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12, ::1/128, fe80::/10"; 
    18641887    ::arg().set("max-tcp-per-client", "If set, maximum number of TCP sessions per client (IP address)")="0";