statichost

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package statichost is a host (ip) matching model.

Index

Constants

View Source
const (
	StaticNil = iota
	StaticDirect
	StaticBlocked
)

The strategies the hosts will be processed with.

Variables

This section is empty.

Functions

func HostIsIP

func HostIsIP(h string) bool

HostIsIP tests if a host only name is IP.

Types

type StaticHosts

type StaticHosts map[string]Strategy

StaticHosts struct.

func MapStaticFiles

func MapStaticFiles(blocked, direct string) StaticHosts

MapStaticFiles loads all settings from files. Priority: StaticDirect > StaticBlocked

func (StaticHosts) GetHostStrategy

func (sh StaticHosts) GetHostStrategy(host string) Strategy

GetHostStrategy gets the strategy of an hostname. Right to left, match sufix after the separator first.

func (StaticHosts) GetIPStrategy

func (sh StaticHosts) GetIPStrategy(ip string) Strategy

GetIPStrategy gets the strategy of an ip. Left to right. IP syntax: a.b.c.d, 127.0.0.*, 192.168.*, or 10.*; * is required as IPv6 would omit `0`s.

func (StaticHosts) GetStrategy

func (sh StaticHosts) GetStrategy(q string) Strategy

GetStrategy gets the strategy for a host or ip.

func (StaticHosts) Load

func (sh StaticHosts) Load(file string, strategy Strategy)

Load settings from a file.

func (StaticHosts) Upsert

func (sh StaticHosts) Upsert(in string, strategy Strategy)

Upsert updates/inserts the StaticHosts by line(s) of items for a same strategy. host: sufix, ip: prefix.

type Strategy

type Strategy byte

Strategy type.

Jump to

Keyboard shortcuts

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