diff options
| author | Loyalsoldier <[email protected]> | 2024-11-03 08:41:18 +0800 |
|---|---|---|
| committer | Loyalsoldier <[email protected]> | 2024-11-03 08:41:18 +0800 |
| commit | 87e9814e8587dee8b593b8b02f84cd359b365e5b (patch) | |
| tree | 65ba469668a4e8c089f1609068578edb7a6050d9 | |
| parent | 5ddcf42db3b2633f73aa9fe7755174e4b0980814 (diff) | |
Chore: refine reading MMDB file
| -rw-r--r-- | go.mod | 1 | ||||
| -rw-r--r-- | go.sum | 2 | ||||
| -rw-r--r-- | plugin/maxmind/mmdb_in.go | 13 |
3 files changed, 4 insertions, 12 deletions
@@ -7,6 +7,7 @@ toolchain go1.23.2 require ( github.com/klauspost/compress v1.17.11 github.com/maxmind/mmdbwriter v1.0.0 + github.com/oschwald/geoip2-golang v1.11.0 github.com/oschwald/maxminddb-golang v1.13.1 github.com/sagernet/sing-box v1.10.1 github.com/spf13/cobra v1.8.1 @@ -22,6 +22,8 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWb github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/onsi/ginkgo/v2 v2.9.7 h1:06xGQy5www2oN160RtEZoTvnP2sPhEfePYmCDc2szss= github.com/onsi/ginkgo/v2 v2.9.7/go.mod h1:cxrmXWykAwTwhQsJOPfdIDiJ+l2RYq7U8hFU+M/1uw0= +github.com/oschwald/geoip2-golang v1.11.0 h1:hNENhCn1Uyzhf9PTmquXENiWS6AlxAEnBII6r8krA3w= +github.com/oschwald/geoip2-golang v1.11.0/go.mod h1:P9zG+54KPEFOliZ29i7SeYZ/GM6tfEL+rgSn03hYuUo= github.com/oschwald/maxminddb-golang v1.13.1 h1:G3wwjdN9JmIK2o/ermkHM+98oX5fS+k5MbwsmL4MRQE= github.com/oschwald/maxminddb-golang v1.13.1/go.mod h1:K4pgV9N/GcK694KSTmVSDTODk4IsCNThNdTmnaBZ/F8= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/plugin/maxmind/mmdb_in.go b/plugin/maxmind/mmdb_in.go index 80fa2523..0a539dd1 100644 --- a/plugin/maxmind/mmdb_in.go +++ b/plugin/maxmind/mmdb_in.go @@ -143,18 +143,7 @@ func (m *MaxmindMMDBIn) generateEntries(content []byte, entries map[string]*lib. networks := db.Networks(maxminddb.SkipAliasedNetworks) for networks.Next() { - record := struct { - Country struct { - IsoCode string `maxminddb:"iso_code"` - } `maxminddb:"country"` - RegisteredCountry struct { - IsoCode string `maxminddb:"iso_code"` - } `maxminddb:"registered_country"` - RepresentedCountry struct { - IsoCode string `maxminddb:"iso_code"` - } `maxminddb:"represented_country"` - }{} - + var record geoip2.Country subnet, err := networks.Network(&record) if err != nil { continue |
