forked from Loyalsoldier/geoip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (33 loc) · 886 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// GeoIP generator
//
// Before running this file, the GeoIP database must be downloaded and present.
// To download GeoIP database: https://dev.maxmind.com/geoip/geoip2/geolite2/
// Inside you will find block files for IPv4 and IPv6 and country code mapping.
package main
import (
"flag"
"log"
"github.com/Loyalsoldier/geoip/lib"
)
var (
list = flag.Bool("l", false, "List all available input and output formats")
configFile = flag.String("c", "config.json", "URI of the JSON format config file, support both local file path and remote HTTP(S) URL")
)
func main() {
flag.Parse()
if *list {
lib.ListInputConverter()
lib.ListOutputConverter()
return
}
instance, err := lib.NewInstance()
if err != nil {
log.Fatal(err)
}
if err := instance.Init(*configFile); err != nil {
log.Fatal(err)
}
if err := instance.Run(); err != nil {
log.Fatal(err)
}
}