filterschedule

package module
v0.0.0-...-831b16c Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2025 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

filterschedule

Name

filterschedule - checks and filters requests that match some predefined criterias.

Description

filterschedule checks and filters a request that matches some predefined rules based on:

  • the requested name
  • optionally, the IP address of the client
  • optionally, the date/time when filtering should be applied

Syntax

filterschedule ./path/to/filterschedule.yaml

Example

. {
    filterschedule /etc/coredns/filterschedule.yaml
    forward . 8.8.8.8 9.9.9.9
}

The configuration file is written using YAML.

- filter:
    sites: ["darkweb"]
  for:
    all: true
  when:
    always: true

- filter:
    sites: ["discord", "instagram", "twitch", "twich"]
  for:
    all: false
    hosts:
      - 192.168.1.100
      - 192.168.1.101
  when:
    always: false
    schedule:
      - days: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]
        hours:
          - from: 00:00
            to: 20:00
          - from: 21:00
            to: 23:59
      - days: ["Saturday", "Sunday"]
        hours:
          - from: 00:00
            to: 07:00
          - from: 21:00
            to: 23:59

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DayOfTheWeek

type DayOfTheWeek time.Weekday

func (*DayOfTheWeek) UnmarshalJSON

func (i *DayOfTheWeek) UnmarshalJSON(b []byte) error

type FilterSchedule

type FilterSchedule struct {
	Next plugin.Handler
	// contains filtered or unexported fields
}

func (FilterSchedule) Name

func (e FilterSchedule) Name() string

Name implements the Handler interface.

func (FilterSchedule) ServeDNS

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

ServeDNS implements the plugin.Handler interface. This method gets called when filterschedule is used in a Server.

type Schedule

type Schedule struct {
	Always   bool
	Schedule []ScheduleEntry
}

type ScheduleEntry

type ScheduleEntry struct {
	Days  []DayOfTheWeek
	Hours []TimeInteval
}

type Sites

type Sites struct {
	Everything bool
	Sites      []string
}

type SitesFilter

type SitesFilter struct {
	Description string
	Filter      Sites
	For         Targets
	When        Schedule
}

func LoadFromFile

func LoadFromFile(filename string) ([]SitesFilter, error)

func (*SitesFilter) IsMatching

func (sf *SitesFilter) IsMatching(name string, clientIP string, t time.Time) bool

type Targets

type Targets struct {
	All   bool
	Hosts []string
}

type TimeInteval

type TimeInteval struct {
	From string
	To   string
}

Jump to

Keyboard shortcuts

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