mirror of
https://github.com/coredns/coredns.git
synced 2025-12-09 20:05:11 -05:00
22 lines
509 B
Go
22 lines
509 B
Go
package geoip
|
|
|
|
import (
|
|
"context"
|
|
"strconv"
|
|
|
|
"github.com/coredns/coredns/plugin/metadata"
|
|
|
|
"github.com/oschwald/geoip2-golang/v2"
|
|
)
|
|
|
|
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
|
|
})
|
|
}
|