summaryrefslogtreecommitdiff
path: root/plugin/maxmind/asn_csv.go
diff options
context:
space:
mode:
authorLoyalsoldier <[email protected]>2024-08-13 11:30:39 +0800
committerLoyalsoldier <[email protected]>2024-08-13 11:31:05 +0800
commitd3d84fd33727fb323eec832adf6f5897997fd84e (patch)
treefb050cc6eda2a90862ad504e71927d8949e19fb9 /plugin/maxmind/asn_csv.go
parent50ed45ced0f436f1a2817390df46f85a953af675 (diff)
Feat: support remote URL in maxmindGeoLite2ASNCSV & maxmindGeoLite2CountryCSV
Diffstat (limited to 'plugin/maxmind/asn_csv.go')
-rw-r--r--plugin/maxmind/asn_csv.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/plugin/maxmind/asn_csv.go b/plugin/maxmind/asn_csv.go
index 73cd052b..e738a44b 100644
--- a/plugin/maxmind/asn_csv.go
+++ b/plugin/maxmind/asn_csv.go
@@ -163,13 +163,21 @@ func (g *geoLite2ASNCSV) process(file string, entries map[string]*lib.Entry) err
entries = make(map[string]*lib.Entry)
}
- fReader, err := os.Open(file)
+ var f io.ReadCloser
+ var err error
+ switch {
+ case strings.HasPrefix(strings.ToLower(file), "http://"), strings.HasPrefix(strings.ToLower(file), "https://"):
+ f, err = lib.GetRemoteURLReader(file)
+ default:
+ f, err = os.Open(file)
+ }
+
if err != nil {
return err
}
- defer fReader.Close()
+ defer f.Close()
- reader := csv.NewReader(fReader)
+ reader := csv.NewReader(f)
reader.Read() // skip header
for {