home

package
v0.107.0-b.5 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2021 License: GPL-3.0 Imports: 66 Imported by: 0

Documentation

Overview

Package home contains AdGuard Home's HTTP API methods.

Index

Constants

View Source
const (
	ClientSourceWHOIS clientSource = iota
	ClientSourceRDNS
	ClientSourceARP
	ClientSourceDHCP
	ClientSourceHostsFile
)

Client sources. The order determines the priority.

View Source
const MaxConnReadSize = 64 * 1024

MaxConnReadSize is an upper limit in bytes for reading from net.Conn.

View Source
const MaxFileSize = 1024 * 1024

MaxFileSize is a maximum file length in bytes.

Variables

View Source
var Context homeContext

Context - a global context object

View Source
var GLMode bool

GLMode - enable GL-Inet compatibility mode

Functions

func InitTLSCiphers added in v0.106.0

func InitTLSCiphers() (ciphers []uint16)

InitTLSCiphers performs the same work as initDefaultCipherSuites() from crypto/tls/common.go but don't uses lots of other default ciphers.

func LoadSystemRootCAs added in v0.106.0

func LoadSystemRootCAs() (roots *x509.CertPool)

LoadSystemRootCAs tries to load root certificates from the operating system. It returns nil in case nothing is found so that that Go.crypto will use it's default algorithm to find system root CA list.

See https://github.com/AdguardTeam/AdGuardHome/internal/issues/1311.

func Main

func Main(clientBuildFS fs.FS)

Main is the entry point

func RegisterAuthHandlers

func RegisterAuthHandlers()

RegisterAuthHandlers - register handlers

func StartMods

func StartMods() error

StartMods initializes and starts the DNS server after installation.

func WebCheckPortAvailable

func WebCheckPortAvailable(port int) bool

WebCheckPortAvailable - check if port is available BUT: if we are already using this port, no need

Types

type Auth

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

Auth - global object

func InitAuth

func InitAuth(dbFilename string, users []User, sessionTTL uint32, blocker *authRateLimiter) *Auth

InitAuth - create a global object

func (*Auth) AuthRequired

func (a *Auth) AuthRequired() bool

AuthRequired - if authentication is required

func (*Auth) Close

func (a *Auth) Close()

Close - close module

func (*Auth) GetUsers

func (a *Auth) GetUsers() []User

GetUsers - get users

func (*Auth) RemoveSession

func (a *Auth) RemoveSession(sess string)

RemoveSession - remove session

func (*Auth) UserAdd

func (a *Auth) UserAdd(u *User, password string)

UserAdd - add new user

func (*Auth) UserFind

func (a *Auth) UserFind(login, password string) User

UserFind - find a user

type Client

type Client struct {
	Name string

	IDs             []string
	Tags            []string
	BlockedServices []string
	Upstreams       []string

	UseOwnSettings        bool
	FilteringEnabled      bool
	SafeSearchEnabled     bool
	SafeBrowsingEnabled   bool
	ParentalEnabled       bool
	UseOwnBlockedServices bool
	// contains filtered or unexported fields
}

Client contains information about persistent clients.

type Duration

type Duration struct {
	// time.Duration is embedded here to avoid implementing all the methods.
	time.Duration
}

Duration is a wrapper for time.Duration providing functionality for encoding.

func (Duration) MarshalText

func (d Duration) MarshalText() (text []byte, err error)

MarshalText implements the encoding.TextMarshaler interface for Duration.

func (Duration) String

func (d Duration) String() (str string)

String implements the fmt.Stringer interface for Duration. It wraps time.Duration.String method and additionally cuts off non-leading zero values of minutes and seconds. Some values which are differ between the implementations:

Duration:   "1m", time.Duration:   "1m0s"
Duration:   "1h", time.Duration: "1h0m0s"
Duration: "1h1m", time.Duration: "1h1m0s"

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(b []byte) (err error)

UnmarshalText implements the encoding.TextUnmarshaler interface for *Duration.

TODO(e.burkov): Make it able to parse larger units like days.

type Filtering

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

Filtering - module object

func (*Filtering) Close

func (f *Filtering) Close()

Close - close the module

func (*Filtering) Init

func (f *Filtering) Init()

Init - initialize the module

func (*Filtering) RegisterFilteringHandlers

func (f *Filtering) RegisterFilteringHandlers()

RegisterFilteringHandlers - register handlers

func (*Filtering) Start

func (f *Filtering) Start()

Start - start the module

type HTTPSServer

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

HTTPSServer - HTTPS Server

type RDNS

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

RDNS resolves clients' addresses to enrich their metadata.

func NewRDNS added in v0.106.0

func NewRDNS(
	exchanger dnsforward.RDNSExchanger,
	clients *clientsContainer,
	usePrivate bool,
) (rDNS *RDNS)

NewRDNS creates and returns initialized RDNS.

func (*RDNS) Begin

func (r *RDNS) Begin(ip net.IP)

Begin adds the ip to the resolving queue if it is not cached or already resolved.

type RuntimeClient added in v0.106.0

type RuntimeClient struct {
	WHOISInfo *RuntimeClientWHOISInfo
	Host      string
	Source    clientSource
}

RuntimeClient information

type RuntimeClientWHOISInfo added in v0.107.0

type RuntimeClientWHOISInfo struct {
	City    string `json:"city,omitempty"`
	Country string `json:"country,omitempty"`
	Orgname string `json:"orgname,omitempty"`
}

RuntimeClientWHOISInfo is the filtered WHOIS data for a runtime client.

type TLSMod

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

TLSMod - TLS module object

func (*TLSMod) Close

func (t *TLSMod) Close()

Close - close module

func (*TLSMod) Reload

func (t *TLSMod) Reload()

Reload updates the configuration of TLSMod and restarts it.

func (*TLSMod) Start

func (t *TLSMod) Start()

Start updates the configuration of TLSMod and starts it.

func (*TLSMod) WriteDiskConfig

func (t *TLSMod) WriteDiskConfig(conf *tlsConfigSettings)

WriteDiskConfig - write config

type User

type User struct {
	Name         string `yaml:"name"`
	PasswordHash string `yaml:"password"` // bcrypt hash
}

User object

type WHOIS added in v0.107.0

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

WHOIS - module context

func (*WHOIS) Begin added in v0.107.0

func (w *WHOIS) Begin(ip net.IP)

Begin - begin requesting WHOIS info

type Web

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

Web - module object

func CreateWeb

func CreateWeb(conf *webConfig) *Web

CreateWeb - create module

func (*Web) Close

func (web *Web) Close(ctx context.Context)

Close gracefully shuts down the HTTP servers.

func (*Web) Start

func (web *Web) Start()

Start - start serving HTTP requests

func (*Web) TLSConfigChanged

func (web *Web) TLSConfigChanged(ctx context.Context, tlsConf tlsConfigSettings)

TLSConfigChanged updates the TLS configuration and restarts the HTTPS server if necessary.

Jump to

Keyboard shortcuts

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