From 0a200936112c85930f6d37e12b839c5866fa0f14 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Wed, 6 Nov 2019 09:41:48 +0000 Subject: [PATCH] Add some documentation on external sources --- README.md | 31 ++++++++++++++++++++++++++++--- ext/ext.go | 2 +- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 22aa9d4..477b770 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,32 @@ submission and querying. The query API is a simple IP lookup, returning a score. This conceivably could be turned into a DNS-based API as well. -## Third-party sources +## External sources -It would be nice to allow the scoring script to consult other IP-based -third-party sources, such as DNSBLs, or GeoIP lookups, etc. +The scoring script can consult other IP-based third-party sources, such +as DNSBLs, or GeoIP lookups, etc. + +These are configured via YAML snippets in a directory, each file +corresponding to a separate external source. + +Each source configuration should specify the following parameters: + +* *name*, the name of the source +* *type*, one of the supported source types (either *dnsbl* or *geoip* + at the moment) +* *params*, a dictionary of further type-specific configuration + parameters. + +The parameters for *dnsbl* source type are: + +* *domain*, the DNSBL domain to query +* *match*, a regexp pattern for the DNS query result. The default is + ".*", i.e. any result will be regarded as a positive match. + +The parameters for *geoip* source type are: + +* *paths*, a list of paths to MaxMind GeoIP databases. The default + list contains a single path, /var/lib/GeoIP/GeoLite2-Country.mmdb + +External sources can be used in the scoring script by calling the +*ext()* function, with the source name and IP address as parameters. diff --git a/ext/ext.go b/ext/ext.go index 6a2eb8f..69b29a4 100644 --- a/ext/ext.go +++ b/ext/ext.go @@ -29,7 +29,7 @@ func New(sourceType string, params map[string]interface{}) (ExternalSource, erro } match, ok := params["match"].(string) if !ok { - return nil, errors.New("missing parameter 'match'") + match = ".*" } return dnsbl.New(domain, match) -- GitLab