xlisthole

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Overview

Package xlisthole implements a CoreDNS plugin that integrates with luIDS xlist.Check api and adds sinkhole functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionInfo

type ActionInfo struct {
	Type ActionType
	Data string
}

ActionInfo stores dns action information.

func ToActionInfo

func ToActionInfo(s string) (ActionInfo, error)

ToActionInfo returns an action from string.

type ActionType

type ActionType int

ActionType defines actions for the rules.

const (
	SendNXDomain ActionType = iota
	SendFixedIP4
	SendRefused
	ReturnValue
	CheckIP
	CheckCNAME
	CheckAll
)

ActionType values.

func (ActionType) String

func (a ActionType) String() string

type Config

type Config struct {
	Service string
	Policy  RuleSet
	Exclude IPSet
	Views   []View
}

Config stores configuration for the plugin.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with default values.

func (*Config) Load

func (cfg *Config) Load(c *caddy.Controller) error

Load configuration from controller.

func (Config) Validate

func (cfg Config) Validate() error

Validate configuration.

type EventInfo

type EventInfo struct {
	Raise bool
	Level event.Level
}

EventInfo stores event information in rules.

func ToEventInfo

func ToEventInfo(s string) (EventInfo, error)

ToEventInfo returns event information from string.

type IPSet

type IPSet struct {
	IPs   []net.IP
	CIDRs []*net.IPNet
}

IPSet contains ips and cidrs.

func (*IPSet) Contains

func (f *IPSet) Contains(ip net.IP) bool

Contains returns true if ip exists in the set.

func (*IPSet) Empty

func (f *IPSet) Empty() bool

Empty returns true if ipset is empty

type Plugin

type Plugin struct {
	Next plugin.Handler
	Fall fall.F
	// contains filtered or unexported fields
}

Plugin is the main struct of the plugin.

func New

func New(cfg Config) (*Plugin, error)

New returns a new Plugin.

func (Plugin) Health

func (p Plugin) Health() bool

Health implements the health.Healther interface.

func (Plugin) Name

func (p Plugin) Name() string

Name implements the plugin.Handle interface.

func (*Plugin) RegisterMetrics

func (p *Plugin) RegisterMetrics(c *caddy.Controller)

RegisterMetrics register metrics in controller.

func (*Plugin) ServeDNS

func (p *Plugin) ServeDNS(ctx context.Context, writer dns.ResponseWriter, query *dns.Msg) (int, error)

ServeDNS implements the plugin.Handle interface. In this method, the blackhole does the checking process of domain names.

func (*Plugin) Shutdown

func (p *Plugin) Shutdown() error

Shutdown plugin.

func (*Plugin) Start

func (p *Plugin) Start() error

Start plugin.

type Rule

type Rule struct {
	Action ActionInfo
	Event  EventInfo
	Log    bool
}

Rule stores rule information.

func ToRule

func ToRule(s string) (Rule, error)

ToRule returns rule information from string.

func (*Rule) Merge

func (r *Rule) Merge(s string) error

Merge extracted reason.

func (Rule) Validate

func (r Rule) Validate() error

Validate validates a rule.

type RuleSet

type RuleSet struct {
	Domain  Rules
	IP      Rules
	CNAME   Rules
	OnError ActionInfo
}

RuleSet stores the policy items.

func (RuleSet) Validate

func (r RuleSet) Validate() error

Validate validates ruleset.

type Rules

type Rules struct {
	Listed   Rule
	Unlisted Rule
	Merge    bool
}

Rules struct groups rules for each item in policy.

type View

type View struct {
	Service string
	Include IPSet
}

View stores view configuration

Jump to

Keyboard shortcuts

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