network

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HostNetwork

type HostNetwork struct{}

func Host

func Host() *HostNetwork

Host returns a network implementation that uses the host's network stack.

func (*HostNetwork) DialContext

func (n *HostNetwork) DialContext(ctx context.Context, network, addr string) (net.Conn, error)

func (*HostNetwork) LookupContextHost

func (n *HostNetwork) LookupContextHost(ctx context.Context, host string) ([]string, error)

type LoopbackNetwork

type LoopbackNetwork struct{}

func Loopback

func Loopback() *LoopbackNetwork

Loopback returns a network that only connects to localhost.

func (*LoopbackNetwork) DialContext

func (n *LoopbackNetwork) DialContext(ctx context.Context, network, addr string) (net.Conn, error)

func (*LoopbackNetwork) LookupContextHost

func (n *LoopbackNetwork) LookupContextHost(ctx context.Context, host string) ([]string, error)

type Network

type Network interface {
	// DialContext connects to the address on the named network using the provided context.
	DialContext(ctx context.Context, network, addr string) (net.Conn, error)
	// LookupContextHost looks up the given host using the local resolver.
	// It returns a slice of that host's addresses.
	LookupContextHost(ctx context.Context, host string) ([]string, error)
}

Network is a simple network abstraction.

Jump to

Keyboard shortcuts

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