utils

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2022 License: AGPL-3.0-or-later Imports: 15 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// IP4arpa is the reverse tree suffix for v4 IP addresses.
	IP4arpa = ".in-addr.arpa."
	// IP6arpa is the reverse tree suffix for v6 IP addresses.
	IP6arpa = ".ip6.arpa."
)

Variables

This section is empty.

Functions

func CheckErr

func CheckErr(err error)

CheckErr : If fatal error, log it and panic

func DbgErr

func DbgErr(err error)

DbgErr : If basic error, log it as classic error but don't panic and keep kalm

func ExtractAddressFromReverse

func ExtractAddressFromReverse(reverseName string) string

ExtractAddressFromReverse turns a standard PTR reverse record name into an IP address. This works for ipv4 or ipv6.

54.119.58.176.in-addr.arpa. becomes 176.58.119.54. If the conversion fails the empty string is returned.

func GetAllRecords added in v0.0.6

func GetAllRecords(d types.Domain) []types.Record

GetAllRecords : Retrive all records for a domain

func GetRecord

func GetRecord(entry types.Record) []types.Record

GetRecord : Check the SQL and REDIS database for a Record. A Record struct is used as input and output

func InitLogger

func InitLogger(conf *Conf)

InitLogger : Init the logrus logger with rotateFileHook. Conf struct passed to get informations about the logger (debug or not)

func IsReverse

func IsReverse(name string) int

IsReverse returns 0 is name is not in a reverse zone. Anything > 0 indicates name is in a reverse zone. The returned integer will be 1 for in-addr.arpa. (IPv4) and 2 for ip6.arpa. (IPv6).

func RedisDatabase

func RedisDatabase(conf *Conf) *redis.Client

RedisDatabase : Initialize the Redis Database Requires a conf struct Return a *redis.Client

func SQLDatabase

func SQLDatabase(conf *Conf) *gorm.DB

SQLDatabase Initialize the SQL Database Requires a conf struct

func XfrAllowed added in v0.0.6

func XfrAllowed(remoteIP string, conf *Conf) bool

XfrAllowed : check if the IP is allowed to perform XFR requests

Types

type App

type App struct {
	Port           int
	IP             string `ini:"IP"`
	Logdir         string
	Logfile        bool
	AllowedOrigins []string //API conf only
}

App : Struct for App (dns server) configuration in the config.ini file

type Conf

type Conf struct {
	AppMode string `ini:"app_mode"`
	App
	Database
	Redis //DNS conf only
	DNS   DNS
}

Conf : Struct for the whole config.ini file when it will be parsed by go-ini

type DNS added in v0.0.6

type DNS struct {
	XfrIPs      []string //DNS conf only
	Nameservers []string //API conf only
}

DNS : Struct for XFR and NS

type Database

type Database struct {
	Host     string `ini:"Host"`
	Port     string
	Username string
	Password string
	Db       string `ini:"DB"`
	Type     string
}

Database : Struct for SQL Database configuration in the config.ini file

type Redis

type Redis struct {
	IP       string `ini:"IP"`
	Port     int
	Password string
	Db       int `ini:"DB"`
	TTL      int `ini:"TTL"`
}

Redis : Struct for Redis Database configuration in the config.ini file

Jump to

Keyboard shortcuts

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