public void WriteReport( Blacklist[] blacklists ) { XmlWriter x = XmlWriter.Create( "bopr-" + DateTime.Now.ToString( "yyyyMMddHHmmss" ) + ".xml" ); x.WriteRaw( "<?xml-stylesheet type=\"text/xsl\" href=\"bopr-xslt.xslt\"?>" ); x.WriteStartElement( "boprbot" ); x.WriteStartElement( "boprblacklist" ); foreach( Blacklist bl in blacklists ) { x.WriteStartElement( "blacklist" ); x.WriteStartElement( "suffix" ); x.WriteString( bl.getSuffix() ); x.WriteEndElement( ); x.WriteStartElement( "hitip" ); x.WriteString( bl.getHitIpAddress().ToString() ); x.WriteEndElement( ); x.WriteEndElement( ); } x.WriteEndElement( ); x.WriteStartElement( "bopri" ); foreach( BlackListCheckResult item in blocks ) { x.WriteStartElement( "ipblock" ); x.WriteStartElement( "ip" ); x.WriteString( item.blockInfo.IP.ToString() ); x.WriteEndElement( ); x.WriteStartElement( "timestamp" ); x.WriteString( item.blockInfo.Date.ToString("yyyy-MM-dd HH:mm:ss" ) ); x.WriteEndElement( ); x.WriteStartElement( "id" ); x.WriteString( item.blockInfo.ID.ToString() ); x.WriteEndElement( ); x.WriteStartElement( "expiry" ); x.WriteString( item.blockInfo.Expiry ); x.WriteEndElement( ); x.WriteStartElement( "blocker" ); x.WriteString( item.blockInfo.By ); x.WriteEndElement( ); x.WriteStartElement( "hits" ); x.WriteString( item.blackListCount.ToString() ); x.WriteEndElement( ); x.WriteEndElement( ); } x.WriteEndElement( ); x.WriteEndElement( ); x.Flush( ); }
Blacklist[] initialiseBlacklists( ) { Blacklist[ ] bl = new Blacklist[ BLCOUNT ]; bl[ 0 ] = new Blacklist( Utility.Net.IPAddress.newFromString( "127.0.0.9" ), "dnsbl.njabl.org" ); bl[ 1 ] = new Blacklist( Utility.Net.IPAddress.newFromString( "127.0.0.2" ), "dnsbl.proxybl.org" ); bl[ 2 ] = new Blacklist( Utility.Net.IPAddress.newFromString( "127.0.0.2" ), "http.dnsbl.sorbs.net" ); bl[ 3 ] = new Blacklist( Utility.Net.IPAddress.newFromString( "127.0.0.3" ), "socks.dnsbl.sorbs.net" ); bl[ 4 ] = new Blacklist( Utility.Net.IPAddress.newFromString( "127.0.0.4" ), "misc.dnsbl.sorbs.net" ); return bl; }