From: <hs...@us...> - 2010-04-25 01:58:13
|
Revision: 3621 http://tdiary.svn.sourceforge.net/tdiary/?rev=3621&view=rev Author: hsbt Date: 2010-04-25 01:58:06 +0000 (Sun, 25 Apr 2010) Log Message: ----------- added IP based DNSBL filter. Modified Paths: -------------- trunk/core/ChangeLog trunk/core/plugin/10spamfilter.rb trunk/core/plugin/en/10spamfilter.rb trunk/core/plugin/ja/10spamfilter.rb trunk/core/plugin/zh/10spamfilter.rb trunk/core/tdiary/filter/spam.rb trunk/core/tdiary.rb Modified: trunk/core/ChangeLog =================================================================== --- trunk/core/ChangeLog 2010-04-25 00:47:21 UTC (rev 3620) +++ trunk/core/ChangeLog 2010-04-25 01:58:06 UTC (rev 3621) @@ -1,5 +1,6 @@ 2010-04-25 SHIBATA Hiroshi <shi...@gm...> * tdiary/filter/spam.rb: revert r3619. and fix debug message. + * tdiary/filter/spam.rb: added IP based DNSBL filter. 2010-04-21 TADA Tadashi <t...@td...> * added Config#smartphone? calling CGI::smartphone?. And alias as iphone?. Modified: trunk/core/plugin/10spamfilter.rb =================================================================== --- trunk/core/plugin/10spamfilter.rb 2010-04-25 00:47:21 UTC (rev 3620) +++ trunk/core/plugin/10spamfilter.rb 2010-04-25 01:58:06 UTC (rev 3621) @@ -112,6 +112,12 @@ resolv_check_mode = false end + if @cgi.params['spamlookup.ip.list'] && @cgi.params['spamlookup.ip.list'][0] + @conf['spamlookup.ip.list'] = @cgi.params['spamlookup.ip.list'][0] + else + @conf['spamlookup.ip.list'] = nil + end + if @cgi.params['spamlookup.domain.list'] && @cgi.params['spamlookup.domain.list'][0] @conf['spamlookup.domain.list'] = @cgi.params['spamlookup.domain.list'][0] else @@ -128,6 +134,9 @@ @conf['spamfilter.linkcheck'] = (@cgi.params['spamfilter.linkcheck'][0] || '1').to_i end + # initialize IP based DNSBL list + @conf['spamlookup.ip.list'] ||= "dnsbl.spam-champuru.livedoor.com" + # initialize DNSBL list @conf['spamlookup.domain.list'] ||= "bsb.spamlookup.net\nsc.surbl.org\nrbl.bulkfeeds.jp" @@ -140,6 +149,39 @@ spamfilter_conf_html end +add_conf_proc( 'dnsblfilter', @dnsblfilter_label_conf, 'security' ) do + if @mode == 'saveconf' + if @cgi.params['spamlookup.ip.list'] && @cgi.params['spamlookup.ip.list'][0] + @conf['spamlookup.ip.list'] = @cgi.params['spamlookup.ip.list'][0] + else + @conf['spamlookup.ip.list'] = nil + end + + if @cgi.params['spamlookup.domain.list'] && @cgi.params['spamlookup.domain.list'][0] + @conf['spamlookup.domain.list'] = @cgi.params['spamlookup.domain.list'][0] + else + @conf['spamlookup.domain.list'] = nil + end + + if @cgi.params['spamlookup.safe_domain.list'] && @cgi.params['spamlookup.safe_domain.list'][0] + @conf['spamlookup.safe_domain.list'] = @cgi.params['spamlookup.safe_domain.list'][0] + else + @conf['spamlookup.safe_domain.list'] = nil + end + end + + # initialize IP based DNSBL list + @conf['spamlookup.ip.list'] ||= "dnsbl.spam-champuru.livedoor.com" + + # initialize DNSBL list + @conf['spamlookup.domain.list'] ||= "bsb.spamlookup.net\nsc.surbl.org\nrbl.bulkfeeds.jp" + + # initialize safe domain list. + @conf['spamlookup.safe_domain.list'] ||= "www.google.com\nwww.google.co.jp\nsearch.yahoo.co.jp\nwww.bing.com" + + dnsblfilter_conf_html +end + # Local Variables: # mode: ruby # indent-tabs-mode: t Modified: trunk/core/plugin/en/10spamfilter.rb =================================================================== --- trunk/core/plugin/en/10spamfilter.rb 2010-04-25 00:47:21 UTC (rev 3620) +++ trunk/core/plugin/en/10spamfilter.rb 2010-04-25 01:58:06 UTC (rev 3621) @@ -4,6 +4,7 @@ # @spamfilter_label_conf = 'spam filter' +@dnsblfilter_label_conf = 'DNSBL filter' def spamfilter_conf_html r = <<-HTML @@ -54,14 +55,9 @@ <option value="false"#{" selected" unless @conf['spamfilter.resolv_check_mode']}>dispose</option> </select> </p> - <h3>Domain Blacklist Services</h3> - <p>List of Domain Blacklist Services</p> - <p><textarea name="spamlookup.domain.list" cols="70" rows="5">#{h @conf['spamlookup.domain.list']}</textarea></p> - <p>List of Safe Domain. Example for search engine.</p> - <p><textarea name="spamlookup.safe_domain.list" cols="70" rows="5">#{h @conf['spamlookup.safe_domain.list']}</textarea></p> - <h3>Description of TSUKKOMI</h3> - <p>Show messeges and spam conditions for your subscribers.<br><textarea name="comment_description" cols="70" rows="5">#{h comment_description}</textarea></p> - HTML + <h3>Description of TSUKKOMI</h3> + <p>Show messeges and spam conditions for your subscribers.<br><textarea name="comment_description" cols="70" rows="5">#{h comment_description}</textarea></p> + HTML unless @conf.secure then r << <<-HTML @@ -78,6 +74,20 @@ r end +def dnsblfilter_conf_html + r = <<-HTML + <h3>Domain Blacklist Services</h3> + <p>List of IP based Domain Blacklist Services</p> + <p><textarea name="spamlookup.ip.list" cols="70" rows="5">#{h @conf['spamlookup.ip.list']}</textarea></p> + <p>List of Domain Blacklist Services</p> + <p><textarea name="spamlookup.domain.list" cols="70" rows="5">#{h @conf['spamlookup.domain.list']}</textarea></p> + <p>List of Safe Domain. Example for search engine.</p> + <p><textarea name="spamlookup.safe_domain.list" cols="70" rows="10">#{h @conf['spamlookup.safe_domain.list']}</textarea></p> + HTML + + r +end + # Local Variables: # mode: ruby # indent-tabs-mode: t Modified: trunk/core/plugin/ja/10spamfilter.rb =================================================================== --- trunk/core/plugin/ja/10spamfilter.rb 2010-04-25 00:47:21 UTC (rev 3620) +++ trunk/core/plugin/ja/10spamfilter.rb 2010-04-25 01:58:06 UTC (rev 3621) @@ -4,6 +4,7 @@ # @spamfilter_label_conf = 'spamフィルタ' +@dnsblfilter_label_conf = 'DNSBLフィルタ' def spamfilter_conf_html r = <<-HTML @@ -52,16 +53,11 @@ <option value="false"#{" selected" unless @conf['spamfilter.resolv_check_mode']}>捨てる</option> </select> </p> - <h3>ブラックリストサービスを使ったフィルタ</h3> - <p>ブラックリスト問い合わせサーバーを指定します<br> - <textarea name="spamlookup.domain.list" cols="70" rows="5">#{h @conf['spamlookup.domain.list']}</textarea></p> - <p>以下に指定したドメインはブラックリストに問い合わせません。検索エンジン等を指定してください<br> - <textarea name="spamlookup.safe_domain.list" cols="70" rows="5">#{h @conf['spamlookup.safe_domain.list']}</textarea></p> - <h3>ツッコミの注意文</h3> - <p>ツッコミフォームの上に表示する注意文を設定します。spam判定条件を変更した場合に、読者にそれをきちんと知らせましょう<br> - <textarea name="comment_description" cols="70" rows="5">#{h comment_description}</textarea></p> - HTML - + <h3>ツッコミの注意文</h3> + <p>ツッコミフォームの上に表示する注意文を設定します。spam判定条件を変更した場合に、読者にそれをきちんと知らせましょう<br> + <textarea name="comment_description" cols="70" rows="5">#{h comment_description}</textarea></p> + HTML + unless @conf.secure then r << <<-HTML <h3>フィルタのログ</h3> @@ -77,6 +73,20 @@ r end +def dnsblfilter_conf_html + r = <<-HTML + <h3>DNSBL(DNSブラックリスト)サービスを使ったフィルタ</h3> + <p>IPベースのブラックリスト問い合わせサーバーを指定します<br> + <textarea name="spamlookup.ip.list" cols="70" rows="5">#{h @conf['spamlookup.ip.list']}</textarea></p> + <p>ドメインベースのブラックリスト問い合わせサーバーを指定します<br> + <textarea name="spamlookup.domain.list" cols="70" rows="5">#{h @conf['spamlookup.domain.list']}</textarea></p> + <p>以下に指定したドメインはブラックリストに問い合わせません。検索エンジン等を指定してください<br> + <textarea name="spamlookup.safe_domain.list" cols="70" rows="10">#{h @conf['spamlookup.safe_domain.list']}</textarea></p> + HTML + + r +end + # Local Variables: # mode: ruby # indent-tabs-mode: t Modified: trunk/core/plugin/zh/10spamfilter.rb =================================================================== --- trunk/core/plugin/zh/10spamfilter.rb 2010-04-25 00:47:21 UTC (rev 3620) +++ trunk/core/plugin/zh/10spamfilter.rb 2010-04-25 01:58:06 UTC (rev 3621) @@ -4,6 +4,7 @@ # @spamfilter_label_conf = 'spam filter' +@dnsblfilter_label_conf = 'DNSBL filter' def spamfilter_conf_html r = <<-HTML @@ -19,11 +20,11 @@ <p>It is spam when percentage of URI charctors in TSUKKOMI body is over this value.<br> <input type="text" name="spamfilter.max_rate" value="#{h @conf['spamfilter.max_rate']}" size="5"></p> <p>It is spam when TSUKKOMI body has URIs match with these patterns.<br> - <textarea name="spamfilter.bad_uri_patts" cols="70" rows="8">#{h( @conf['spamfilter.bad_uri_patts'] || '' )}</textarea></p> + <textarea name="spamfilter.bad_uri_patts" cols="60" rows="8">#{h( @conf['spamfilter.bad_uri_patts'] || '' )}</textarea></p> <p>It is spam when TSUKKOMI body matches with these patterns.<br> - <textarea name="spamfilter.bad_comment_patts" cols="70" rows="8">#{h( @conf['spamfilter.bad_comment_patts'] || '' )}</textarea></p> + <textarea name="spamfilter.bad_comment_patts" cols="60" rows="8">#{h( @conf['spamfilter.bad_comment_patts'] || '' )}</textarea></p> <p>It is spam when mail address matches with these patterns.<br> - <textarea name="spamfilter.bad_mail_patts" cols="70" rows="8">#{h( @conf['spamfilter.bad_mail_patts'] || '' )}</textarea></p> + <textarea name="spamfilter.bad_mail_patts" cols="60" rows="8">#{h( @conf['spamfilter.bad_mail_patts'] || '' )}</textarea></p> <p>Use patterns of URI for checking mail address.<br> <select name="spamfilter.bad_uri_patts_for_mails"> <option value="true"#{" selected" if @conf['spamfilter.bad_uri_patts_for_mails']}>ON</option> @@ -41,7 +42,7 @@ <h3>IP address filters</h3> <p>It is spam when sender IP address matches these patterns. You have to specify complete IP address or part of IP address ends by '.'.<br> - <textarea name="spamfilter.bad_ip_addrs" cols="70" rows="8">#{h( @conf['spamfilter.bad_ip_addrs'] || '' )}</textarea></p> + <textarea name="spamfilter.bad_ip_addrs" cols="60" rows="8">#{h( @conf['spamfilter.bad_ip_addrs'] || '' )}</textarea></p> </p> <p>It is spam when IP address of TrackBack sender dose not match with IP address of the site.<br> <select name="spamfilter.resolv_check"> @@ -54,14 +55,9 @@ <option value="false"#{" selected" unless @conf['spamfilter.resolv_check_mode']}>dispose</option> </select> </p> - <h3>Domain Blacklist Services</h3> - <p>List of Domain Blacklist Services</p> - <p><textarea name="spamlookup.domain.list" cols="70" rows="5">#{h @conf['spamlookup.domain.list']}</textarea></p> - <p>List of Safe Domain. Example for search engine.</p> - <p><textarea name="spamlookup.safe_domain.list" cols="70" rows="5">#{h @conf['spamlookup.safe_domain.list']}</textarea></p> - <h3>Description of TSUKKOMI</h3> - <p>Show messeges and spam conditions for your subscribers.<br><textarea name="comment_description" cols="70" rows="5">#{h comment_description}</textarea></p> - HTML + <h3>Description of TSUKKOMI</h3> + <p>Show messeges and spam conditions for your subscribers.<br><textarea name="comment_description" cols="70" rows="5">#{h comment_description}</textarea></p> + HTML unless @conf.secure then r << <<-HTML @@ -78,6 +74,20 @@ r end +def dnsblfilter_conf_html + r = <<-HTML + <h3>Domain Blacklist Services</h3> + <p>List of IP based Domain Blacklist Services</p> + <p><textarea name="spamlookup.ip.list" cols="70" rows="5">#{h @conf['spamlookup.ip.list']}</textarea></p> + <p>List of Domain Blacklist Services</p> + <p><textarea name="spamlookup.domain.list" cols="70" rows="5">#{h @conf['spamlookup.domain.list']}</textarea></p> + <p>List of Safe Domain. Example for search engine.</p> + <p><textarea name="spamlookup.safe_domain.list" cols="70" rows="10">#{h @conf['spamlookup.safe_domain.list']}</textarea></p> + HTML + + r +end + # Local Variables: # mode: ruby # indent-tabs-mode: t Modified: trunk/core/tdiary/filter/spam.rb =================================================================== --- trunk/core/tdiary/filter/spam.rb 2010-04-25 00:47:21 UTC (rev 3620) +++ trunk/core/tdiary/filter/spam.rb 2010-04-25 01:58:06 UTC (rev 3621) @@ -63,6 +63,12 @@ @resolv_check = true end + if @conf.options.include?('spamlookup.ip.list') + @spamlookup_ip_list = @conf.options['spamlookup.ip.list'] + else + @spamlookup_ip_list = "dnsbl.spam-champuru.livedoor.com" + end + if @conf.options.include?('spamlookup.domain.list') @spamlookup_domain_list = @conf.options['spamlookup.domain.list'] else @@ -72,7 +78,7 @@ if @conf.options.include?('spamlookup.safe_domain.list') @spamlookup_safe_domain_list = @conf.options['spamlookup.safe_domain.list'] else - @spamlookup_safe_domain_list = "search.yahoo.co.jp\nwww.google.com\nwww.google.co.jp\nsearch.msn.co.jp" + @spamlookup_safe_domain_list = "www.google.com\nwww.google.co.jp\nsearch.yahoo.co.jp\nwww.bing.com" end if @conf.options.include?('spamfilter.resolv_check_mode') @@ -164,6 +170,22 @@ end def black_domain?( domain ) + @spamlookup_ip_list.split(/[\n\r]+/).each do |dnsbl| + begin + timeout(5) do + ip = IPSocket::getaddress( str ).split(/\./).reverse.join(".") + address = Resolv.getaddress( "#{ip}.#{dnsbl}" ) + debug("lookup:#{domain}.#{dnsbl} address:#{address}") + return true + end + rescue Resolv::ResolvTimeout, Resolv::ResolvError + rescue TimeoutError + debug("timeout error:#{domain}.#{dnsbl}", DEBUG_FULL) + rescue Exception + debug("unknown error:#{domain}.#{dnsbl}", DEBUG_FULL) + end + end + @spamlookup_domain_list.split(/[\n\r]+/).each do |dnsbl| begin timeout(5) do @@ -178,6 +200,7 @@ debug("unknown error:#{domain}.#{dnsbl}", DEBUG_FULL) end end + debug("#{domain} is safe host.", DEBUG_FULL) return false end Modified: trunk/core/tdiary.rb =================================================================== --- trunk/core/tdiary.rb 2010-04-25 00:47:21 UTC (rev 3620) +++ trunk/core/tdiary.rb 2010-04-25 01:58:06 UTC (rev 3621) @@ -7,7 +7,7 @@ You can redistribute it and/or modify it under GPL2. =end -TDIARY_VERSION = '2.3.3.20100421' +TDIARY_VERSION = '2.3.3.20100425' $:.insert( 1, File::dirname( __FILE__ ).untaint + '/misc/lib' ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |