netutil

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package netutil provides helper functions for network.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdvertisableIPs

func AdvertisableIPs() ([]net.IP, error)

AdvertisableIPs returns a slice of global unicast IPs.

func ControlRawNetworkConnection

func ControlRawNetworkConnection(network, address string, c syscall.RawConn) error

func GetListenerAddrs

func GetListenerAddrs(addr net.Addr) ([]string, error)

GetListenerAddrs returns ip address of given net.Listener. If the net.Listener is not TCP listener, GetListenerAddrs returns errNotSupportedNetwork. Returned addresses are sorted that advertisable address comes first.

func IPs

func IPs() ([]net.IP, error)

IPs returns a slice of net.IP that is usable. Advertisable IP comes first in the returned slice.

func Listen

func Listen(network, address string) (net.Listener, error)

Types

type StoppableListener

type StoppableListener struct {
	*net.TCPListener
	// contains filtered or unexported fields
}

func NewStoppableListener

func NewStoppableListener(ctx context.Context, addr string) (*StoppableListener, error)

func (StoppableListener) Accept

func (ln StoppableListener) Accept() (c net.Conn, err error)

Jump to

Keyboard shortcuts

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