database

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NS    Types = "ns"
	DNS   Types = "dns"
	Host  Types = "host"
	Regex Types = "regexp"
	Query Types = "query"
	IP    Types = "ip"

	ActiveTrue  Active = 1
	ActiveFalse Active = 0
	ActiveALL   Active = -1
)

Functions

This section is empty.

Types

type Active

type Active int64

type BlacklistDomainModel

type BlacklistDomainModel struct {
	Tag    string
	Domain string
	Active Active
}

type BlacklistDomainsModel

type BlacklistDomainsModel []BlacklistDomainModel

func (BlacklistDomainsModel) ToMap

func (v BlacklistDomainsModel) ToMap(a Active) map[string]string

type BlacklistURIModel

type BlacklistURIModel struct {
	Tag    string
	URI    string
	Active Active
}

type BlacklistURIsModel

type BlacklistURIsModel []BlacklistURIModel

func (BlacklistURIsModel) ToMap

func (v BlacklistURIsModel) ToMap(a Active) map[string]string

type Database

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

func New

func New(log logger.Logger, conf *sqlite.Config) (*Database, error)

func (*Database) DelRules

func (v *Database) DelRules(ctx context.Context, t Types, domain string) error

func (*Database) Down

func (v *Database) Down(_ ctx.Context) error

func (*Database) GetAllRules

func (v *Database) GetAllRules(ctx context.Context, ts int64) (RulesModel, error)

func (*Database) GetBlacklistDomain

func (v *Database) GetBlacklistDomain(ctx context.Context, ts int64) (BlacklistDomainsModel, error)

func (*Database) GetBlacklistURI

func (v *Database) GetBlacklistURI(ctx context.Context, ts int64) (BlacklistURIsModel, error)

func (*Database) GetRules

func (v *Database) GetRules(ctx context.Context, t Types, ts int64, active Active) (RulesModel, error)

func (*Database) GetRulesMap

func (v *Database) GetRulesMap(ctx context.Context, types Types, ts int64, call func(map[string]string) error) error

func (*Database) SetBlacklistDomain

func (v *Database) SetBlacklistDomain(ctx context.Context, tag string, domain []string) error

func (*Database) SetBlacklistDomainActive

func (v *Database) SetBlacklistDomainActive(ctx context.Context, domain string, active Active) error

func (*Database) SetBlacklistURI

func (v *Database) SetBlacklistURI(ctx context.Context, uri string) (string, error)

func (*Database) SetRules

func (v *Database) SetRules(ctx context.Context, t Types, domain, ips string, active Active) error

func (*Database) Up

func (v *Database) Up(ctx ctx.Context) error

type RuleModel

type RuleModel struct {
	Types  string
	Domain string
	IPs    string
	Active Active
}

type RulesModel

type RulesModel []RuleModel

func (RulesModel) ToMap

func (v RulesModel) ToMap() map[string]string

type Types

type Types string

func ValidateType

func ValidateType(v string) (Types, error)

Jump to

Keyboard shortcuts

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