Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the GeoIpFilter configurable via the web interface
Reload the filter engine if the configuration changes.
- Loading branch information
Showing
7 changed files
with
346 additions
and
125 deletions.
There are no files selected for viewing
12 changes: 0 additions & 12 deletions
12
src/main/java/org/graylog/plugins/map/MapWidgetModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,27 +1,15 @@ | |||
package org.graylog.plugins.map; | package org.graylog.plugins.map; | ||
|
|
||
import com.google.common.collect.Sets; | |||
import org.graylog.plugins.map.config.MapWidgetConfiguration; | |||
import org.graylog.plugins.map.geoip.filter.GeoIpResolverFilter; | import org.graylog.plugins.map.geoip.filter.GeoIpResolverFilter; | ||
import org.graylog.plugins.map.rest.MapDataResource; | import org.graylog.plugins.map.rest.MapDataResource; | ||
import org.graylog.plugins.map.widget.strategy.MapWidgetStrategy; | import org.graylog.plugins.map.widget.strategy.MapWidgetStrategy; | ||
import org.graylog2.plugin.PluginConfigBean; | |||
import org.graylog2.plugin.PluginModule; | import org.graylog2.plugin.PluginModule; | ||
|
|
||
import java.util.Set; | |||
|
|||
public class MapWidgetModule extends PluginModule { | public class MapWidgetModule extends PluginModule { | ||
|
|||
@Override | |||
public Set<? extends PluginConfigBean> getConfigBeans() { | |||
return Sets.newHashSet(new MapWidgetConfiguration()); | |||
} | |||
|
|||
@Override | @Override | ||
protected void configure() { | protected void configure() { | ||
addMessageFilter(GeoIpResolverFilter.class); | addMessageFilter(GeoIpResolverFilter.class); | ||
addWidgetStrategy(MapWidgetStrategy.class, MapWidgetStrategy.Factory.class); | addWidgetStrategy(MapWidgetStrategy.class, MapWidgetStrategy.Factory.class); | ||
addRestResource(MapDataResource.class); | addRestResource(MapDataResource.class); | ||
addConfigBeans(); | |||
} | } | ||
} | } |
64 changes: 64 additions & 0 deletions
64
src/main/java/org/graylog/plugins/map/config/GeoIpResolverConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,64 @@ | |||
package org.graylog.plugins.map.config; | |||
|
|||
import com.fasterxml.jackson.annotation.JsonAutoDetect; | |||
import com.fasterxml.jackson.annotation.JsonCreator; | |||
import com.fasterxml.jackson.annotation.JsonProperty; | |||
import com.google.auto.value.AutoValue; | |||
|
|||
@JsonAutoDetect | |||
@AutoValue | |||
public abstract class GeoIpResolverConfig { | |||
public enum DatabaseType { | |||
GEOLITE2_CITY, GEOLITE2_COUNTRY | |||
} | |||
|
|||
@JsonProperty("enabled") | |||
public abstract boolean enabled(); | |||
|
|||
@JsonProperty("db_type") | |||
public abstract DatabaseType dbType(); | |||
|
|||
@JsonProperty("db_path") | |||
public abstract String dbPath(); | |||
|
|||
@JsonProperty("run_before_extractors") | |||
public abstract boolean runBeforeExtractors(); | |||
|
|||
@JsonCreator | |||
public static GeoIpResolverConfig create(@JsonProperty("enabled") boolean enabled, | |||
@JsonProperty("db_type") DatabaseType dbType, | |||
@JsonProperty("db_path") String dbPath, | |||
@JsonProperty("run_before_extractors") boolean runBeforeExtractors) { | |||
return builder() | |||
.enabled(enabled) | |||
.dbType(dbType) | |||
.dbPath(dbPath) | |||
.runBeforeExtractors(runBeforeExtractors) | |||
.build(); | |||
} | |||
|
|||
public static GeoIpResolverConfig defaultConfig() { | |||
return builder() | |||
.enabled(false) | |||
.dbType(DatabaseType.GEOLITE2_CITY) | |||
.dbPath("/tmp/GeoLite2-City.mmdb") | |||
.runBeforeExtractors(false) | |||
.build(); | |||
} | |||
|
|||
public static Builder builder() { | |||
return new AutoValue_GeoIpResolverConfig.Builder(); | |||
} | |||
|
|||
public abstract Builder toBuilder(); | |||
|
|||
@AutoValue.Builder | |||
public static abstract class Builder { | |||
public abstract Builder enabled(boolean enabled); | |||
public abstract Builder dbType(DatabaseType dbType); | |||
public abstract Builder dbPath(String dbPath); | |||
public abstract Builder runBeforeExtractors(boolean runBeforeExtractors); | |||
|
|||
public abstract GeoIpResolverConfig build(); | |||
} | |||
} |
28 changes: 0 additions & 28 deletions
28
src/main/java/org/graylog/plugins/map/config/MapWidgetConfiguration.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.