pihole

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CNAMERecord added in v0.0.2

type CNAMERecord struct {
	Domain string
	Target string
}

type CNAMERecordList added in v0.0.2

type CNAMERecordList []CNAMERecord

type CNAMERecordsListResponse added in v0.0.2

type CNAMERecordsListResponse struct {
	Data [][]string
}

func (CNAMERecordsListResponse) ToDNSRecordList added in v0.0.2

func (rr CNAMERecordsListResponse) ToDNSRecordList() CNAMERecordList

ToDNSRecordList converts a CNAMERecordsListResponse into a CNAMERecordsList object.

type Client

type Client struct {
	URL       string
	UserAgent string
	// contains filtered or unexported fields
}

func New

func New(config *Config) (*Client, error)

New returns a new pihole client

func (Client) CreateDNSRecord

func (c Client) CreateDNSRecord(ctx context.Context, record *DNSRecord) (*DNSRecord, error)

CreateDNSRecord creates a pihole DNS record entry

func (Client) DeleteDNSRecord

func (c Client) DeleteDNSRecord(ctx context.Context, domain string) error

DeleteDNSRecord deletes a pihole local DNS record by domain name

func (Client) GetAdBlockerStatus

func (c Client) GetAdBlockerStatus(ctx context.Context) (*EnableAdBlock, error)

GetAdBlockerStatus returns whether pihole ad blocking is enabled or not

func (Client) GetDNSRecord

func (c Client) GetDNSRecord(ctx context.Context, domain string) (*DNSRecord, error)

GetDNSRecord searches the pihole local DNS records for the passed domain and returns a result if found

func (*Client) Init

func (c *Client) Init(ctx context.Context) error

Init sets fields on the client which are a product of pihole network requests or other side effects

func (Client) ListCNAMERecords added in v0.0.2

func (c Client) ListCNAMERecords(ctx context.Context) (CNAMERecordList, error)

ListCNAMERecords returns a list of the configured CNAME Pi-hole records

func (Client) ListDNSRecords

func (c Client) ListDNSRecords(ctx context.Context) (DNSRecordList, error)

ListDNSRecords Returns the list of custom DNS records configured in pihole

func (*Client) Request

func (c *Client) Request(ctx context.Context, method string, path string, data *url.Values) (*http.Request, error)

Request executes a basic unauthenticated http request

func (Client) RequestWithAuth

func (c Client) RequestWithAuth(ctx context.Context, method string, path string, data *url.Values) (*http.Request, error)

RequestWithAuth adds an auth token to the passed request

func (Client) RequestWithSession

func (c Client) RequestWithSession(ctx context.Context, method string, path string, data *url.Values) (*http.Request, error)

RequestWithSession executes a request with appropriate session authentication (login() must have been called)

func (Client) SetAdBlockEnabled

func (c Client) SetAdBlockEnabled(ctx context.Context, enable bool) (*EnableAdBlock, error)

SetAdBlockEnabled sets whether pihole ad blocking is enabled or not

func (Client) UpdateDNSRecord

func (c Client) UpdateDNSRecord(ctx context.Context, record *DNSRecord) (*DNSRecord, error)

UpdateDNSRecord deletes a pihole local DNS record by domain name

func (*Client) Validate

func (c *Client) Validate() error

Validate returns an error if any of the required fields on the client are empty

type Config

type Config struct {
	Password  string
	URL       string
	UserAgent string
}

type CreateDNSRecordResponse

type CreateDNSRecordResponse struct {
	Success bool
	Message string
}

type DNSRecord

type DNSRecord struct {
	Domain string
	IP     string
}

type DNSRecordList

type DNSRecordList []DNSRecord

type DNSRecordsListResponse

type DNSRecordsListResponse struct {
	Data [][]string
}

func (DNSRecordsListResponse) ToDNSRecordList

func (rr DNSRecordsListResponse) ToDNSRecordList() DNSRecordList

ToDNSRecordList converts a DNSRecordsListResponse into a DNSRecordList object.

type EnableAdBlock

type EnableAdBlock struct {
	Enabled bool
}

type EnableAdBlockResponse

type EnableAdBlockResponse struct {
	Status string
}

func (EnableAdBlockResponse) ToEnableAdBlock

func (eb EnableAdBlockResponse) ToEnableAdBlock() *EnableAdBlock

ToEnableAdBlock turns am EnableAdBlockResponse into an EnableAdBlock object

Jump to

Keyboard shortcuts

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