Browse files

Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki

  • Loading branch information...
2 parents 17451c7 + 1d0fef9 commit cb60cb24e76fce656049eaa85ce54159f4a95a39 @distler distler committed Feb 15, 2013
View
6 app/controllers/application_controller.rb
@@ -23,6 +23,12 @@ def self.wiki
protected
+ def remote_ip
+ ip = request.remote_ip
+ logger.info(ip)
+ ip.dup.gsub!(Regexp.union(Resolv::IPv4::Regex, Resolv::IPv6::Regex), '\0') || 'bogus address'
+ end
+
def xhtml_enabled?
in_a_web? and [:markdownMML, :markdownPNG, :markdown].include?(@web.markup)
end
View
6 app/controllers/wiki_controller.rb
@@ -529,12 +529,6 @@ def parse_category
end
end
- def remote_ip
- ip = request.remote_ip
- logger.info(ip)
- ip.dup.gsub!(Regexp.union(Resolv::IPv4::Regex, Resolv::IPv6::Regex), '\0') || 'bogus address'
- end
-
def render_atom(hide_description = false, limit = 15)
@pages_by_revision = @web.select.by_revision.first(limit)
@hide_description = hide_description
View
4 test/functional/wiki_controller_test.rb
@@ -1352,7 +1352,7 @@ def test_tex
assert_equal @tex_header1 + @tex_header2 + %q!\section*{HomePage}
-HisWay would be MyWay $\sin(x) \includegraphics[width=3em]{foo}$ in kinda ThatWay in HisWay though MyWay $\backslash$OverThere --{} see SmartEngine in that SmartEngineGUI
+HisWay would be MyWay $\sin(x) \includegraphics[width=3em]{foo}$ in kinda ThatWay in HisWay though MyWay $\backslash$OverThere -- see SmartEngine in that SmartEngineGUI
@@ -1407,7 +1407,7 @@ def test_tex_list
\section*{HomePage}
-HisWay would be MyWay $\sin(x) \includegraphics[width=3em]{foo}$ in kinda ThatWay in HisWay though MyWay $\backslash$OverThere --{} see SmartEngine in that SmartEngineGUI
+HisWay would be MyWay $\sin(x) \includegraphics[width=3em]{foo}$ in kinda ThatWay in HisWay though MyWay $\backslash$OverThere -- see SmartEngine in that SmartEngineGUI
View
20 vendor/plugins/dnsbl_check/lib/dnsbl_check.rb
@@ -30,22 +30,23 @@ module DNSBL_Check
private
# Filter to check if the client is listed. This will be run before all requests.
def dnsbl_check
+ ip = self.remote_ip
return true if respond_to?(:logged_in?) && logged_in?
- return true if $dnsbl_passed.include? request.remote_addr
+ return true if $dnsbl_passed.include? ip
passed = true
ban_help = ''
threads = []
- request.remote_addr =~ /(\d+).(\d+).(\d+).(\d+)/
+ ip =~ /(\d+).(\d+).(\d+).(\d+)/
# Check the remote address against each dnsbl in a separate thread
DNSBLS.each_key do |dnsbl|
threads << Thread.new("#$4.#$3.#$2.#$1.#{dnsbl}") do |host|
logger.warn("Checking DNSBL #{host}")
addr = Resolv.getaddress("#{host}") rescue ''
if addr[0,7]=="127.0.0"
- logger.info("#{request.remote_addr} found using DNSBL #{host}")
- ban_help << "\n<p>See <a href='#{DNSBLS[dnsbl]}#{request.remote_addr}'>here</a> for more information.</p>"
+ logger.info("#{ip} found using DNSBL #{host}")
+ ban_help << "\n<p>See <a href='#{DNSBLS[dnsbl]}#{ip}'>here</a> for more information.</p>"
passed = false
end
end
@@ -54,12 +55,13 @@ def dnsbl_check
# Add client ip to global passed cache if no dnsbls objected. else deny service.
if passed
-# $dnsbl_passed = $dnsbl_passed[0,99].unshift request.remote_addr
- $dnsbl_passed.push request.remote_addr
- logger.warn("#{request.remote_addr} added to DNSBL passed cache")
+# $dnsbl_passed = $dnsbl_passed[0,99].unshift ip
+ $dnsbl_passed.push ip
+ logger.warn("#{ip} added to DNSBL passed cache")
else
- render( :text => "<p>Access denied. Your IP address, #{request.remote_addr}, was found on one or more DNSBL" +
- " blocking list(s).</p>#{ban_help}", :status => 403, :layout => 'error', :locals => {:raw => true})
+ render( :text =>
+ "<p>Access denied. Your IP address, #{ip}, was found on one or more DNSBL blocking list(s).</p>#{ban_help}".html_safe,
+ :status => 403, :layout => 'error', :locals => {:raw => true})
return false
end
end

0 comments on commit cb60cb2

Please sign in to comment.