client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Conf       Config
	Database   cidranger.Ranger
	HTTPClient *http.Client
}

func NewClient

func NewClient(conf Config) (client *Client, err error)

NewClient creates new client with the given config and immediately updates its database. It will also run automatic updates, if interval is specified.

func (*Client) FindIP

func (c *Client) FindIP(query net.IP) (bool, string)

FindIP checks if a given IP is on the list. If so, returns `true` and the reason (IP block).

func (*Client) StartServer

func (c *Client) StartServer() error

StartServer starts HTTP server for IP queries. Available endpoints: /ip. Usage is in README.

func (*Client) Update

func (c *Client) Update() (err error)

Update will flush and repopulate database with freshly downloaded list.

type Config

type Config struct {
	DatabaseDownloadURL    string
	DatabaseUpdateInterval string
	WebserverPort          string
	WebserverToken         string
	Debug                  bool
}

Config is a structure of environmental variables

type IpEndpointResponse

type IpEndpointResponse = struct {
	IP    string `json:"ip"`
	Proxy bool   `json:"proxy"`
	Rule  string `json:"rule"`
}

IpEndpointResponse is a structure of /ip endpoint response

Jump to

Keyboard shortcuts

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