utils

package
v0.0.0-...-3f2847d Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterPeersByQuery

func FilterPeersByQuery(q string, peers []wgtypes.Peer) []wgtypes.Peer

func GetExternalIP

func GetExternalIP() (string, error)

func GetInterfaceIPs

func GetInterfaceIPs(name string) (addresses []string, err error)

func GetPeerQuickConfig

func GetPeerQuickConfig(device wgtypes.Device, peer wgtypes.Peer, options PeerQuickConfigOptions) (io.Reader, error)

func SortPeersByField

func SortPeersByField(field string, peers []wgtypes.Peer) error

Types

type Paginator

type Paginator struct {
	Request     *http.Request
	PerPageNums int
	MaxPages    int
	// contains filtered or unexported fields
}

Paginator within the state of a http request.

func NewPaginator

func NewPaginator(req *http.Request, per int, nums interface{}) *Paginator

NewPaginator Instantiates a paginator struct for the current http request.

func (*Paginator) HasNext

func (p *Paginator) HasNext() bool

HasNext Returns true if the current page has a successor.

func (*Paginator) HasPages

func (p *Paginator) HasPages() bool

HasPages Returns true if there is more than one page.

func (*Paginator) HasPrev

func (p *Paginator) HasPrev() bool

HasPrev Returns true if the current page has a predecessor.

func (*Paginator) IsActive

func (p *Paginator) IsActive(page int) bool

IsActive Returns true if the given page index points to the current page.

func (*Paginator) Nums

func (p *Paginator) Nums() int64

Nums Returns the total number of items (e.g. from doing SQL count).

func (*Paginator) Offset

func (p *Paginator) Offset() int

Offset Returns the current offset.

func (*Paginator) Page

func (p *Paginator) Page() int

Page Returns the current page.

func (p *Paginator) PageLink(page int) string

PageLink Returns URL for a given page index.

func (*Paginator) PageLinkFirst

func (p *Paginator) PageLinkFirst() (link string)

PageLinkFirst Returns URL to the first page.

func (*Paginator) PageLinkLast

func (p *Paginator) PageLinkLast() (link string)

PageLinkLast Returns URL to the last page.

func (*Paginator) PageLinkNext

func (p *Paginator) PageLinkNext() (link string)

PageLinkNext Returns URL to the next page.

func (*Paginator) PageLinkPrev

func (p *Paginator) PageLinkPrev() (link string)

PageLinkPrev Returns URL to the previous page.

func (*Paginator) PageNums

func (p *Paginator) PageNums() int

PageNums Returns the total number of pages.

func (*Paginator) Pages

func (p *Paginator) Pages() []int

Pages Returns a list of all pages.

Usage (in a view template):

{{range $index, $page := .paginator.Pages}}
  <li{{if $.paginator.IsActive .}} class="active"{{end}}>
    <a href="{{$.paginator.PageLink $page}}">{{$page}}</a>
  </li>
{{end}}

func (*Paginator) SetNums

func (p *Paginator) SetNums(nums interface{})

SetNums Sets the total number of items.

func (*Paginator) Write

func (p *Paginator) Write(response *echo.Response)

type PeerQuickConfigOptions

type PeerQuickConfigOptions struct {
	PrivateKey *string
	DNSServers *[]string
	AllowedIPs *[]string
	Host       *string
}

Jump to

Keyboard shortcuts

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