coredns_gdns

package module
v1.7.0-st Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

README

CoreDNS enterprise plugin for DoPaaS

That can obtain zone resolution records from redis-cluster, it can be integrated with DoPaaS https://github.com/wl4g/dopaas, provides DoPaaS unified management web GUI.

English version goes here

Developer Guide

Configuration example

For more configuration items, please refer to the coredns official website. For example, we give a general example:

.:53 {
    loadbalance round_robin
    # Load zones records from local /etc/hosts.
    hosts {
        fallthrough
    }
    # Load zones records from redis-cluster(default settings).
    coredns_gdns {
        address localhost:6379,localhost:6380,localhost:6381,localhost:7379,localhost:7380,localhost:7381
        password "123456"
        connect_timeout 5000
        read_timeout 10000
        write_timeout 5000
        max_retries 10
        pool_size 10
        ttl 360
        prefix _coredns:
        local_cache_expire_ms 5000
    }
    # Up recursive DNS query server list.
    # e.g. Google dns servers: 8.8.8.8, china telecom dns servers: 114.114.114.114,202.96.134.133,202.96.212.68
    #forward . 8.8.8.8 114.114.114.114 {
    #  tls_servername dns.google
    #  force_tcp
    #  max_fails 3
    #  expire 10s
    #  health_check 5s
    #  policy sequential
    #  except www.baidu.com
    #}
    forward . 202.96.134.133 202.96.212.68 # In china
    reload 6s
    log . "{local}:{port} - {>id} '{type} {class} {name} {proto} {size} {>do} {>bufsize}' {rcode} {>rflags} {rsize} {duration}"
    errors
}
  • address redis cluster node address host:port or ip:port, default: localhost:6379,localhost:6380,localhost:6381,localhost:7379,localhost:7380,localhost:7381
  • password redis cluster password, default: empty
  • connect_timeout connection timeout time, default: 5000ms
  • read_timeout data read timeout, default: 10000ms
  • write_timeout data write timeout, default: 5000ms
  • max_retries Maximum number of retries, default: 10
  • pool_size redis connection pool size, default: 10
  • ttl zones resolve cache ttl, default: 360sec
  • prefix zones resolution record data is stored in redis-cluster key prefix, default: _coredns:
  • local_cache_expire_ms zones resolving and record the validity period of the local cache, default: 5000ms (Note: In order to improve performance, the loading sequence of zones map data is in order: localCache -> redisCache -> db)

Reverse resolution

Currently does not support direction resolution

Proxy resolution

Currently does not support direction resolution

Zones resolving records are stored in redis-cluster data format

Each zone is stored as a hash map in redis-cluster, with zone as the key. Note: According to the https://tools.ietf.org/html/rfc6763 protocol, it ends with a "." suffix. Such as:

redis-cli>KEYS *
1) "example.com."
2) "example.net."
redis-cli>
dns RRs

Stored in redis cluster in json string format, @ is used for RR value of the region itself. Such as:

A
{
    "a":{
        "ip": "1.2.3.4",
        "ttl": 360
    }
}
AAAA
{
    "aaaa":{
        "ip": "::1",
        "ttl": 360
    }
}
CNAME
{
    "cname":{
        "host": "x.example.com.",
        "ttl": 360
    }
}
TXT
{
    "TXT":{
        "text": "this is a text",
        "ttl": 360
    }
}
NS
{
    "ns":{
        "host": "ns1.example.com.",
        "ttl": 360
    }
}
MX
{
    "mx":{
        "host": "mx1.example.com",
        "priority": 10,
        "ttl": 360
    }
}
SRV
{
    "srv":{
        "host": "sip.example.com.",
        "port": 555,
        "priority": 10,
        "weight": 100,
        "ttl": 360
    }
}
SOA
{
    "soa":{
        "ttl": 100,
        "mbox": "hostmaster.example.com.",
        "ns": "ns1.example.com.",
        "refresh": 44,
        "retry": 55,
        "expire": 66
    }
}
CAA
{
    "caa":{
        "flag": 0,
        "tag": "issue",
        "value": "letsencrypt.org"
    }
}

Parsing example

$ORIGIN example.net.
 example.net. 300 IN SOA <SOA RDATA>
 example.net. 300 NS ns1.example.net.
 example.net. 300 NS ns2.example.net.
 *.example.net. 300 TXT "this is a wildcard"
 *.example.net. 300 MX 10 host1.example.net.
 sub.*.example.net. 300 TXT "this is not a wildcard"
 host1.example.net. 300 A 5.5.5.5
 _ssh.tcp.host1.example.net. 300 SRV <SRV RDATA>
 _ssh.tcp.host2.example.net. 300 SRV <SRV RDATA>
 subdel.example.net. 300 NS ns1.subdel.example.net.
 subdel.example.net. 300 NS ns2.subdel.example.net.
 host2.example.net CAA 0 issue "letsencrypt.org"

The above zone data should be stored in redis-cluster as follows:

redis-cli> hgetall example.net.
 1) "_ssh._tcp.host1"
 2) "{\"srv\":[{\"ttl\":300, \"target\":\"tcp.example.com.\",\"port\":123,\"priority\" :10,\"weight\":100}]}"
 3) "*"
 4) "{\"txt\":[{\"ttl\":300, \"text\":\"this is a wildcard\"}],\"mx\":[{\"ttl\" :300, \"host\":\"host1.example.net.\",\"preference\": 10}]}"
 5) "host1"
 6) "{\"a\":[{\"ttl\":300, \"ip\":\"5.5.5.5\"}]}"
 7) "sub.*"
 8) "{\"txt\":[{\"ttl\":300, \"text\":\"this is not a wildcard\"}]}"
 9) "_ssh._tcp.host2"
10) "{\"srv\":[{\"ttl\":300, \"target\":\"tcp.example.com.\",\"port\":123,\"priority\" :10,\"weight\":100}]}"
11) "subdel"
12) "{\"ns\":[{\"ttl\":300, \"host\":\"ns1.subdel.example.net.\"},{\"ttl\":300, \ "host\":\"ns2.subdel.example.net.\"}]}"
13) "@"
14) "{\"soa\":{\"ttl\":300, \"minttl\":100, \"mbox\":\"hostmaster.example.net.\",\"ns\": \"ns1.example.net.\",\"refresh\":44,\"retry\":55,\"expire\":66},\"ns\":[{\"ttl\": 300, \"host\":\"ns1.example.net.\"},{\"ttl\":300, \"host\":\"ns2.example.net.\"}]}"
15) "host2"
16)"{\"caa\":[{\"flag\":0, \"tag\":\"issue\", \"value\":\"letsencrypt.org\"}]}"
redis-cli>

Other Tools

Documentation

Overview

This ip2location package provides a fast lookup of country, region, city, latitude, longitude, ZIP code, time zone, ISP, domain name, connection type, IDD code, area code, weather station code, station name, MCC, MNC, mobile brand, elevation, usage type, address type and IAB category from IP address by using IP2Location database.

*

  • Copyright 2017 ~ 2025 the original author or authors. *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2017 ~ 2025 the original author or authors. *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

Index

Constants

View Source
const (
	PluginName = "coredns_gdns"
)

Variables

View Source
var SpecialDomains = [...]string{"com.cn.", "net.cn.", ".ac.cn.", ".org.cn.", ".gov.cn.", ".mil.cn.", ".edu.cn."}

Some special top-level domain names are defined here, because they have two levels of top-level names, which need special treatment when dealing with DNS query.

Functions

func Api_version

func Api_version() string

Api_version returns the version of the component.

func Close deprecated

func Close()

Close will close the file handle to the BIN file.

Deprecated: No longer being updated.

func Debugf

func Debugf(format string, v ...interface{})

Debugf print debug format log

func Error

func Error(v ...interface{})

Error print error log

func Errorf

func Errorf(format string, v ...interface{})

Errorf print error format log

func ExpressionMatch

func ExpressionMatch(a string, b string) bool

*

  • 判断一个字符串是否和另一个包含通配符的字符串相等
  • a 普通字符串
  • b 带通配符字符串

func Infof

func Infof(format string, v ...interface{})

Infof print info format log

func InterfaceToArray

func InterfaceToArray(i interface{}) []string

func Open deprecated

func Open(dbpath string)

Open takes the path to the IP2Location BIN database file. It will read all the metadata required to be able to extract the embedded geolocation data.

Deprecated: No longer being updated.

func Printrecord

func Printrecord(x IP2Locationrecord)

Printrecord is used to output the geolocation data for debugging purposes.

func Qname2Zone

func Qname2Zone(qname string) string

*

  • qname截取出zone

func Warningf

func Warningf(format string, v ...interface{})

Warningf print warn format log

Types

type AAAA_Record

type AAAA_Record struct {
	Ttl uint32 `json:"ttl,omitempty"`
	Ip  net.IP `json:"ip"`
}

type A_Record

type A_Record struct {
	Ttl uint32 `json:"ttl,omitempty"`
	Ip  net.IP `json:"ip"`
}

type CAA_Record

type CAA_Record struct {
	Flag  uint8  `json:"flag"`
	Tag   string `json:"tag"`
	Value string `json:"value"`
}

type CNAME_Record

type CNAME_Record struct {
	Ttl  uint32 `json:"ttl,omitempty"`
	Host string `json:"host"`
}

type DB

type DB struct {
	// contains filtered or unexported fields
}

func OpenDB

func OpenDB(dbpath string) (*DB, error)

Open takes the path to the IP2Location BIN database file. It will read all the metadata required to be able to extract the embedded geolocation data, and return the underlining DB object.

func OpenDBWithReader

func OpenDBWithReader(reader DBReader) (*DB, error)

OpenDBWithReader takes a DBReader to the IP2Location BIN database file. It will read all the metadata required to be able to extract the embedded geolocation data, and return the underlining DB object.

func (*DB) Close

func (d *DB) Close()

func (*DB) Get_addresstype

func (d *DB) Get_addresstype(ipaddress string) (IP2Locationrecord, error)

Get_addresstype will return the address type based on the queried IP address.

func (*DB) Get_all

func (d *DB) Get_all(ipaddress string) (IP2Locationrecord, error)

Get_all will return all geolocation fields based on the queried IP address.

func (*DB) Get_areacode

func (d *DB) Get_areacode(ipaddress string) (IP2Locationrecord, error)

Get_areacode will return the area code based on the queried IP address.

func (*DB) Get_category

func (d *DB) Get_category(ipaddress string) (IP2Locationrecord, error)

Get_category will return the category based on the queried IP address.

func (*DB) Get_city

func (d *DB) Get_city(ipaddress string) (IP2Locationrecord, error)

Get_city will return the city name based on the queried IP address.

func (*DB) Get_country_long

func (d *DB) Get_country_long(ipaddress string) (IP2Locationrecord, error)

Get_country_long will return the country name based on the queried IP address.

func (*DB) Get_country_short

func (d *DB) Get_country_short(ipaddress string) (IP2Locationrecord, error)

Get_country_short will return the ISO-3166 country code based on the queried IP address.

func (*DB) Get_domain

func (d *DB) Get_domain(ipaddress string) (IP2Locationrecord, error)

Get_domain will return the domain name based on the queried IP address.

func (*DB) Get_elevation

func (d *DB) Get_elevation(ipaddress string) (IP2Locationrecord, error)

Get_elevation will return the elevation in meters based on the queried IP address.

func (*DB) Get_iddcode

func (d *DB) Get_iddcode(ipaddress string) (IP2Locationrecord, error)

Get_iddcode will return the International Direct Dialing code based on the queried IP address.

func (*DB) Get_isp

func (d *DB) Get_isp(ipaddress string) (IP2Locationrecord, error)

Get_isp will return the Internet Service Provider name based on the queried IP address.

func (*DB) Get_latitude

func (d *DB) Get_latitude(ipaddress string) (IP2Locationrecord, error)

Get_latitude will return the latitude based on the queried IP address.

func (*DB) Get_longitude

func (d *DB) Get_longitude(ipaddress string) (IP2Locationrecord, error)

Get_longitude will return the longitude based on the queried IP address.

func (*DB) Get_mcc

func (d *DB) Get_mcc(ipaddress string) (IP2Locationrecord, error)

Get_mcc will return the mobile country code based on the queried IP address.

func (*DB) Get_mnc

func (d *DB) Get_mnc(ipaddress string) (IP2Locationrecord, error)

Get_mnc will return the mobile network code based on the queried IP address.

func (*DB) Get_mobilebrand

func (d *DB) Get_mobilebrand(ipaddress string) (IP2Locationrecord, error)

Get_mobilebrand will return the mobile carrier brand based on the queried IP address.

func (*DB) Get_netspeed

func (d *DB) Get_netspeed(ipaddress string) (IP2Locationrecord, error)

Get_netspeed will return the Internet connection speed based on the queried IP address.

func (*DB) Get_region

func (d *DB) Get_region(ipaddress string) (IP2Locationrecord, error)

Get_region will return the region name based on the queried IP address.

func (*DB) Get_timezone

func (d *DB) Get_timezone(ipaddress string) (IP2Locationrecord, error)

Get_timezone will return the time zone based on the queried IP address.

func (*DB) Get_usagetype

func (d *DB) Get_usagetype(ipaddress string) (IP2Locationrecord, error)

Get_usagetype will return the usage type based on the queried IP address.

func (*DB) Get_weatherstationcode

func (d *DB) Get_weatherstationcode(ipaddress string) (IP2Locationrecord, error)

Get_weatherstationcode will return the weather station code based on the queried IP address.

func (*DB) Get_weatherstationname

func (d *DB) Get_weatherstationname(ipaddress string) (IP2Locationrecord, error)

Get_weatherstationname will return the weather station name based on the queried IP address.

func (*DB) Get_zipcode

func (d *DB) Get_zipcode(ipaddress string) (IP2Locationrecord, error)

Get_zipcode will return the postal code based on the queried IP address.

type DBReader

type DBReader interface {
	io.ReadCloser
	io.ReaderAt
}

type IP2LocationCreditResult

type IP2LocationCreditResult struct {
	Response int `json:"response"`
}

The IP2LocationCreditResult struct stores the credit balance for the IP2Location Web Service.

type IP2LocationResult

type IP2LocationResult struct {
	Response           string  `json:"response"`
	CountryCode        string  `json:"country_code"`
	CountryName        string  `json:"country_name"`
	RegionName         string  `json:"region_name"`
	CityName           string  `json:"city_name"`
	Latitude           float64 `json:"latitude"`
	Longitude          float64 `json:"longitude"`
	ZipCode            string  `json:"zip_code"`
	TimeZone           string  `json:"time_zone"`
	Isp                string  `json:"isp"`
	Domain             string  `json:"domain"`
	NetSpeed           string  `json:"net_speed"`
	IddCode            string  `json:"idd_code"`
	AreaCode           string  `json:"area_code"`
	WeatherStationCode string  `json:"weather_station_code"`
	WeatherStationName string  `json:"weather_station_name"`
	Mcc                string  `json:"mcc"`
	Mnc                string  `json:"mnc"`
	MobileBrand        string  `json:"mobile_brand"`
	Elevation          int     `json:"elevation"`
	UsageType          string  `json:"usage_type"`
	AddressType        string  `json:"address_type"`
	Category           string  `json:"category"`
	CategoryName       string  `json:"category_name"`
	Geotargeting       struct {
		Metro string `json:"metro"`
	} `json:"geotargeting"`
	Continent struct {
		Name       string   `json:"name"`
		Code       string   `json:"code"`
		Hemisphere []string `json:"hemisphere"`
	} `json:"continent"`
	Country struct {
		Name        string `json:"name"`
		Alpha3Code  string `json:"alpha3_code"`
		NumericCode string `json:"numeric_code"`
		Demonym     string `json:"demonym"`
		Flag        string `json:"flag"`
		Capital     string `json:"capital"`
		TotalArea   string `json:"total_area"`
		Population  string `json:"population"`
		Currency    struct {
			Code   string `json:"code"`
			Name   string `json:"name"`
			Symbol string `json:"symbol"`
		} `json:"currency"`
		Language struct {
			Code string `json:"code"`
			Name string `json:"name"`
		} `json:"language"`
		IddCode string `json:"idd_code"`
		Tld     string `json:"tld"`
		IsEu    bool   `json:"is_eu"`
	} `json:"country"`
	CountryGroupings []struct {
		Acronym string `json:"acronym"`
		Name    string `json:"name"`
	} `json:"country_groupings"`
	Region struct {
		Name string `json:"name"`
		Code string `json:"code"`
	} `json:"region"`
	City struct {
		Name string `json:"name"`
	} `json:"city"`
	TimeZoneInfo struct {
		Olson       string `json:"olson"`
		CurrentTime string `json:"current_time"`
		GmtOffset   int    `json:"gmt_offset"`
		IsDst       string `json:"is_dst"`
		Sunrise     string `json:"sunrise"`
		Sunset      string `json:"sunset"`
	} `json:"time_zone_info"`
	CreditsConsumed int `json:"credits_consumed"`
}

The IP2LocationResult struct stores all of the available geolocation info found in the IP2Location Web Service.

type IP2Locationrecord

type IP2Locationrecord struct {
	Country_short      string
	Country_long       string
	Region             string
	City               string
	Isp                string
	Latitude           float32
	Longitude          float32
	Domain             string
	Zipcode            string
	Timezone           string
	Netspeed           string
	Iddcode            string
	Areacode           string
	Weatherstationcode string
	Weatherstationname string
	Mcc                string
	Mnc                string
	Mobilebrand        string
	Elevation          float32
	Usagetype          string
	Addresstype        string
	Category           string
}

The IP2Locationrecord struct stores all of the available geolocation info found in the IP2Location database.

func Get_all deprecated

func Get_all(ipaddress string) IP2Locationrecord

Get_all will return all geolocation fields based on the queried IP address.

Deprecated: No longer being updated.

func Get_areacode deprecated

func Get_areacode(ipaddress string) IP2Locationrecord

Get_areacode will return the area code based on the queried IP address.

Deprecated: No longer being updated.

func Get_city deprecated

func Get_city(ipaddress string) IP2Locationrecord

Get_city will return the city name based on the queried IP address.

Deprecated: No longer being updated.

func Get_country_long deprecated

func Get_country_long(ipaddress string) IP2Locationrecord

Get_country_long will return the country name based on the queried IP address.

Deprecated: No longer being updated.

func Get_country_short deprecated

func Get_country_short(ipaddress string) IP2Locationrecord

Get_country_short will return the ISO-3166 country code based on the queried IP address.

Deprecated: No longer being updated.

func Get_domain deprecated

func Get_domain(ipaddress string) IP2Locationrecord

Get_domain will return the domain name based on the queried IP address.

Deprecated: No longer being updated.

func Get_elevation deprecated

func Get_elevation(ipaddress string) IP2Locationrecord

Get_elevation will return the elevation in meters based on the queried IP address.

Deprecated: No longer being updated.

func Get_iddcode deprecated

func Get_iddcode(ipaddress string) IP2Locationrecord

Get_iddcode will return the International Direct Dialing code based on the queried IP address.

Deprecated: No longer being updated.

func Get_isp deprecated

func Get_isp(ipaddress string) IP2Locationrecord

Get_isp will return the Internet Service Provider name based on the queried IP address.

Deprecated: No longer being updated.

func Get_latitude deprecated

func Get_latitude(ipaddress string) IP2Locationrecord

Get_latitude will return the latitude based on the queried IP address.

Deprecated: No longer being updated.

func Get_longitude deprecated

func Get_longitude(ipaddress string) IP2Locationrecord

Get_longitude will return the longitude based on the queried IP address.

Deprecated: No longer being updated.

func Get_mcc deprecated

func Get_mcc(ipaddress string) IP2Locationrecord

Get_mcc will return the mobile country code based on the queried IP address.

Deprecated: No longer being updated.

func Get_mnc deprecated

func Get_mnc(ipaddress string) IP2Locationrecord

Get_mnc will return the mobile network code based on the queried IP address.

Deprecated: No longer being updated.

func Get_mobilebrand deprecated

func Get_mobilebrand(ipaddress string) IP2Locationrecord

Get_mobilebrand will return the mobile carrier brand based on the queried IP address.

Deprecated: No longer being updated.

func Get_netspeed deprecated

func Get_netspeed(ipaddress string) IP2Locationrecord

Get_netspeed will return the Internet connection speed based on the queried IP address.

Deprecated: No longer being updated.

func Get_region deprecated

func Get_region(ipaddress string) IP2Locationrecord

Get_region will return the region name based on the queried IP address.

Deprecated: No longer being updated.

func Get_timezone deprecated

func Get_timezone(ipaddress string) IP2Locationrecord

Get_timezone will return the time zone based on the queried IP address.

Deprecated: No longer being updated.

func Get_usagetype deprecated

func Get_usagetype(ipaddress string) IP2Locationrecord

Get_usagetype will return the usage type based on the queried IP address.

Deprecated: No longer being updated.

func Get_weatherstationcode deprecated

func Get_weatherstationcode(ipaddress string) IP2Locationrecord

Get_weatherstationcode will return the weather station code based on the queried IP address.

Deprecated: No longer being updated.

func Get_weatherstationname deprecated

func Get_weatherstationname(ipaddress string) IP2Locationrecord

Get_weatherstationname will return the weather station name based on the queried IP address.

Deprecated: No longer being updated.

func Get_zipcode deprecated

func Get_zipcode(ipaddress string) IP2Locationrecord

Get_zipcode will return the postal code based on the queried IP address.

Deprecated: No longer being updated.

type IpLocation

type IpLocation struct {
	// contains filtered or unexported fields
}

func NewIpLocation

func NewIpLocation() *IpLocation

type MX_Record

type MX_Record struct {
	Ttl        uint32 `json:"ttl,omitempty"`
	Host       string `json:"host"`
	Preference uint16 `json:"preference"`
}

type NS_Record

type NS_Record struct {
	Ttl  uint32 `json:"ttl,omitempty"`
	Host string `json:"host"`
}

type Record

type Record struct {
	A     []A_Record     `json:"a,omitempty"`
	AAAA  []AAAA_Record  `json:"aaaa,omitempty"`
	TXT   []TXT_Record   `json:"txt,omitempty"`
	CNAME []CNAME_Record `json:"cname,omitempty"`
	NS    []NS_Record    `json:"ns,omitempty"`
	MX    []MX_Record    `json:"mx,omitempty"`
	SRV   []SRV_Record   `json:"srv,omitempty"`
	CAA   []CAA_Record   `json:"caa,omitempty"`
	SOA   SOA_Record     `json:"soa,omitempty"`
}

type RedisService

type RedisService struct {
	Next          plugin.Handler
	ClusterClient *redisCon.ClusterClient
	// contains filtered or unexported fields
}

func (*RedisService) A

func (redisService *RedisService) A(name string, z *Zone, record *Record) (answers, extras []dns.RR)

func (*RedisService) AAAA

func (redisService *RedisService) AAAA(name string, z *Zone, record *Record) (answers, extras []dns.RR)

func (*RedisService) AXFR

func (redisService *RedisService) AXFR(z *Zone) (records []dns.RR)

func (*RedisService) CAA

func (redisService *RedisService) CAA(name string, z *Zone, record *Record) (answers, extras []dns.RR)

func (*RedisService) CNAME

func (redisService *RedisService) CNAME(name string, z *Zone, record *Record) (answers, extras []dns.RR)

func (*RedisService) Connect

func (redisService *RedisService) Connect()

func (*RedisService) GetBlacklist

func (redisService *RedisService) GetBlacklist() []string

func (*RedisService) GetWhitelist

func (redisService *RedisService) GetWhitelist() []string

func (*RedisService) MX

func (redisService *RedisService) MX(name string, z *Zone, record *Record) (answers, extras []dns.RR)

func (*RedisService) NS

func (redisService *RedisService) NS(name string, z *Zone, record *Record) (answers, extras []dns.RR)

func (*RedisService) Name

func (redisService *RedisService) Name() string

Name implements the Handler interface.

func (*RedisService) SOA

func (redisService *RedisService) SOA(name string, z *Zone, record *Record) (answers, extras []dns.RR)

func (*RedisService) SRV

func (redisService *RedisService) SRV(name string, z *Zone, record *Record) (answers, extras []dns.RR)

func (*RedisService) ServeDNS

func (redisService *RedisService) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

ServeDNS implements the plugin.Handler interface.

func (*RedisService) TXT

func (redisService *RedisService) TXT(name string, z *Zone, record *Record) (answers, extras []dns.RR)

type SOA_Record

type SOA_Record struct {
	Ttl     uint32 `json:"ttl,omitempty"`
	Ns      string `json:"ns"`
	MBox    string `json:"MBox"`
	Refresh uint32 `json:"refresh"`
	Retry   uint32 `json:"retry"`
	Expire  uint32 `json:"expire"`
	MinTtl  uint32 `json:"minttl"`
}

type SRV_Record

type SRV_Record struct {
	Ttl      uint32 `json:"ttl,omitempty"`
	Priority uint16 `json:"priority"`
	Weight   uint16 `json:"weight"`
	Port     uint16 `json:"port"`
	Target   string `json:"target"`
}

type TXT_Record

type TXT_Record struct {
	Ttl  uint32 `json:"ttl,omitempty"`
	Text string `json:"text"`
}

type WS

type WS struct {
	// contains filtered or unexported fields
}

The WS struct is the main object used to query the IP2Location Web Service.

func OpenWS

func OpenWS(apikey string, apipackage string, usessl bool) (*WS, error)

OpenWS initializes with the web service API key, API package and whether to use SSL

func (*WS) GetCredit

func (w *WS) GetCredit() (IP2LocationCreditResult, error)

GetCredit will return the web service credit balance.

func (*WS) LookUp

func (w *WS) LookUp(ipAddress string, addOn string, lang string) (IP2LocationResult, error)

LookUp will return all geolocation fields based on the queried IP address, addon, lang

type Zone

type Zone struct {
	Name      string
	Locations map[string]*Record
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL