@@ -12,11 +12,6 @@ import (
1212 "strconv"
1313)
1414
15- const (
16- IP2PROXY_PRO = iota
17- IP2PROXY_LITE
18- )
19-
2015type ip2proxyItem struct {
2116 IPFrom net.IP
2217 IPTo net.IP
@@ -29,39 +24,36 @@ type ip2proxyItem struct {
2924}
3025
3126type ip2proxy struct {
32- Type int
3327 items []* ip2proxyItem
3428 archive []* zip.File
3529 OutputDir string
3630 ErrorsChan chan Error
3731 Token string
3832 Filename string
39- name string
33+ Name string
4034 csvFilename string
4135 zipFilename string
4236 PrintType bool
4337}
4438
4539func (o * ip2proxy ) checkErr (err error , message string ) bool {
4640 if err != nil {
47- o .ErrorsChan <- Error {err , o .name , message }
41+ o .ErrorsChan <- Error {err , o .Name , message }
4842 return true
4943 }
50- printMessage (o .name , message , "OK" )
44+ printMessage (o .Name , message , "OK" )
5145 return false
5246}
5347
5448func (o * ip2proxy ) Get () {
55- if o .Type == IP2PROXY_PRO {
56- o .name = "ip2proxyPro"
49+ if o .Name == "ip2proxyPro" {
5750 o .csvFilename = "IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.CSV"
5851 o .zipFilename = "PX4-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP"
59- } else if o .Type == IP2PROXY_LITE {
60- o .name = "ip2proxyLite"
52+ } else if o .Name == "ip2proxyLite" {
6153 o .csvFilename = "IP2PROXY-LITE-PX4.CSV"
6254 o .zipFilename = "PX4LITE"
6355 } else {
64- o .ErrorsChan <- Error {errors .New ("Unknown ip2proxy type requested" ), o .name , "bad init" }
56+ o .ErrorsChan <- Error {errors .New ("Unknown ip2proxy type requested" ), o .Name , "bad init" }
6557 return
6658 }
6759 fileData , err := o .getZip ()
@@ -125,10 +117,10 @@ func (o *ip2proxy) unpack(response []byte) error {
125117
126118func (o * ip2proxy ) Parse (filename string ) error {
127119 var list []* ip2proxyItem
128- for record := range readCSVDatabase (o .archive , filename , o .name , ',' , false ) {
120+ for record := range readCSVDatabase (o .archive , filename , o .Name , ',' , false ) {
129121 item , err := o .lineToItem (record )
130122 if err != nil {
131- printMessage (o .name , fmt .Sprintf ("Can't parse line from %s with %v" , filename , err ), "WARN" )
123+ printMessage (o .Name , fmt .Sprintf ("Can't parse line from %s with %v" , filename , err ), "WARN" )
132124 continue
133125 }
134126 list = append (list , item )
@@ -168,7 +160,7 @@ func (o *ip2proxy) Write() error {
168160}
169161
170162func (o * ip2proxy ) writeNetworks () error {
171- file , err := os .Create (path .Join (o .OutputDir , o .name + "_net.txt" ))
163+ file , err := os .Create (path .Join (o .OutputDir , o .Name + "_net.txt" ))
172164 if err != nil {
173165 return err
174166 }
0 commit comments