Fix path used to load the embedded geoip database (LOGSTASH-734)

This commit is contained in:
Jordan Sissel 2013-01-03 14:49:34 -08:00
parent 46712eb832
commit 47a8ace6a9

View file

@ -31,7 +31,7 @@ class LogStash::Filters::GeoIP < LogStash::Filters::Base
if @database.nil?
if __FILE__ =~ /^file:\/.+!.+/
# Running from a jar, assume GeoLiteCity.dat is at the root.
@database = [__FILE__.split("!").first, "GeoLiteCity.dat"].join("!")
@database = [__FILE__.split("!").first, "/GeoLiteCity.dat"].join("!")
else
if File.exists?("GeoLiteCity.dat")
@database = "GeoLiteCity.dat"
@ -40,7 +40,9 @@ class LogStash::Filters::GeoIP < LogStash::Filters::Base
end
end
end
@logger.info("Using geoip database", :path => @database)
@geoip = ::GeoIP.new(@database)
@geoip_type = case @geoip.database_type
when GeoIP::GEOIP_CITY_EDITION_REV0, GeoIP::GEOIP_CITY_EDITION_REV1
:city