ConfigurationSettings and wildcards in ip address

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

i read the http "maxconnection" value from machine.config (maybe overridden by <app>.config)

<system.net><connectionManagement><add address="*" maxconnection="2"/></connectionManagement></system.net>

with the following code:

object o = ConfigurationSettings.GetConfig("system.net/connectionManagement");
if (o is Hashtable)
{
Hashtable ht = (Hashtable) o;
IDictionaryEnumerator htEnum = ht.GetEnumerator();

while (htEnum.MoveNext())
Console.WriteLine( "\t{0}\t{1}", htEnum.Key, htEnum.Value );
// do something...
}

My problems are:
Normally, where is only one wildcard entry "*" that matches all addresses. But if there are more entries, e.g.

<system.net><connectionManagement><add address="*" maxconnection="2"/><add address="111.222.111.*" maxconnection="10"/><add address="111.222.111.222" maxconnection="20"/><add address="*.222" maxconnection="30"/><add address="*.222.*.222" maxconnection="40"/></connectionManagement></system.net>

which entry has priority if i search for address "111.222.111.222"?
First match? Best match? But what is the best match? Is there code availabe for Ip address matching?

Another problem if the priority depends on the the order in the config-file: the "hashtable" cast does not make sense because the order of entries in the config-file does not match with the order in hashtable. Is there a trick to get the order from file?

Thanks for any help or suggestions.
Ralf
 
Back
Top