net

package module
v0.51.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

README

net/http/auth

Create BasicAuthHandler and populate with BasicAuthMap

var handler http.Handler

server := dch.NewServerWithLogger(serverConfig, logger)

authMap := dca.BasicAuthMap{}
authMap.AddUserWithPlainPassword("userA", "passwordA")

server.AddHandler("/status", dca.NewBasicAuthHandler(handler, authMap))

```§

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// TODO: change this to ipv4.myip.dioad.net(A) ipv6.myip.dioad.net (AAAA) and myip.dioad.net(A and AAAA)
	// IPv4ICanHazIP is the URL to fetch the public IPv4 address.
	IPv4ICanHazIP = "http://ipv4.icanhazip.com"
	// IPv6ICanHazIP is the URL to fetch the public IPv6 address.
	IPv6ICanHazIP = "http://ipv6.icanhazip.com"
)

Functions

func AddrPortDetailsFromString

func AddrPortDetailsFromString(addrPort string) (netip.AddrPort, string, error)

func ConvertAddrToIP

func ConvertAddrToIP(addr netip.Addr) net.IP

func ExpandStringTemplate

func ExpandStringTemplate(templateString string, data any) (string, error)

func FindInterfaceForAddr

func FindInterfaceForAddr(a netip.Addr) (string, error)

func FindInterfaceForIP

func FindInterfaceForIP(ip net.IP) (string, error)

func FindTCPConn added in v0.46.0

func FindTCPConn(c RawConn) *net.TCPConn

func GetMyIPs added in v0.45.1

func GetMyIPs(ctx context.Context) ([]netip.Addr, error)

GetMyIPs fetches the public IP addresses of the host.

func GetMyIPsFromFuncs added in v0.45.3

func GetMyIPsFromFuncs(ctx context.Context, funcs ...GetIPFunc) ([]netip.Addr, error)

GetMyIPsFromFuncs fetches the public IP addresses using the provided functions.

func GetMyIPv4 added in v0.45.1

func GetMyIPv4(ctx context.Context) (netip.Addr, error)

GetMyIPv4 fetches the public IPv4 address of the host.

func GetMyIPv6 added in v0.45.1

func GetMyIPv6(ctx context.Context) (netip.Addr, error)

GetMyIPv6 fetches the public IPv6 address of the host.

func TCPAddrFromURL

func TCPAddrFromURL(url *url.URL) (string, error)

TCPAddrFromURL returns a TCP address in the form of "host:port" from a given URL.

func TCPPortFromURL

func TCPPortFromURL(url *url.URL) (string, error)

TCPPortFromURL returns the TCP port from a given URL. returns string because that's what url.URL.Port() does

Types

type DoneConn added in v0.44.0

type DoneConn interface {
	net.Conn
	RawConn
	Done() <-chan struct{}
	Closed() bool
}

func NewConnWithCloser

func NewConnWithCloser(c net.Conn, closer func(net.Conn)) DoneConn

func NewDoneConn added in v0.44.0

func NewDoneConn(c net.Conn) DoneConn

type GetIPFunc added in v0.45.3

type GetIPFunc func(ctx context.Context) (netip.Addr, error)

GetIPFunc is a function type that fetches an IP address.

type RawConn added in v0.44.0

type RawConn interface {
	NetConn() net.Conn
}

Jump to

Keyboard shortcuts

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