mirror of
https://github.com/coredns/coredns.git
synced 2025-12-01 08:04:14 -05:00
Adds the ability to query ASN .mmdb databases, in addition to the existing City db functionality. Signed-off-by: Eric Case <eric.case@gmail.com>
22 lines
506 B
Go
22 lines
506 B
Go
package geoip
|
|
|
|
import (
|
|
"context"
|
|
"strconv"
|
|
|
|
"github.com/coredns/coredns/plugin/metadata"
|
|
|
|
"github.com/oschwald/geoip2-golang"
|
|
)
|
|
|
|
func (g GeoIP) setASNMetadata(ctx context.Context, data *geoip2.ASN) {
|
|
asnNumber := strconv.FormatUint(uint64(data.AutonomousSystemNumber), 10)
|
|
metadata.SetValueFunc(ctx, pluginName+"/asn/number", func() string {
|
|
return asnNumber
|
|
})
|
|
asnOrg := data.AutonomousSystemOrganization
|
|
metadata.SetValueFunc(ctx, pluginName+"/asn/org", func() string {
|
|
return asnOrg
|
|
})
|
|
}
|