ip

package
v0.0.0-...-e5c115e Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	net.IP
}

Info contains the client's public IP address or nil of not connected.

func (Info) Connected

func (i Info) Connected() bool

Connected returns true when the client is connected to the internet, that is the IP address is not nil.

type Module

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

Module is a module for displaying the client's current public IP address in the bar.

func New

func New(provider Provider) *Module

New creates a new *Module with the given provider for looking up the ip address. By default, the module will refresh the IP address every 10 minutes. The refresh interval can be configured using `Every`. Clicking on the bar output will also update the module output if not overridden.

func (*Module) Every

func (m *Module) Every(interval time.Duration) *Module

Every configures the refresh interval for the module. Passing a zero interval will disable refreshing.

func (*Module) Output

func (m *Module) Output(format func(Info) bar.Output) *Module

Output updates the output format func.

func (*Module) Refresh

func (m *Module) Refresh()

Refresh forces a refresh of the module output.

func (*Module) Stream

func (m *Module) Stream(s bar.Sink)

Stream implements bar.Module.

type Provider

type Provider interface {
	// GetIP retrieves the current public client IP. Must return nil for both
	// return values if there is no internet connection.
	GetIP() (net.IP, error)
}

Provider provides the current public ip of the client.

type ProviderFunc

type ProviderFunc func() (net.IP, error)

ProviderFunc is a func that satisfies the Provider interface.

func (ProviderFunc) GetIP

func (f ProviderFunc) GetIP() (net.IP, error)

GetIP implements Provider.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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