Help us shape the future of Go! Take the 2026 Go Developer Survey

policy

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ConnectTimeout = 30 * time.Second
View Source
const Errno = "EACCES"

Variables

View Source
var ErrDenied = errors.New("denied by policy")

Functions

This section is empty.

Types

type Dialer

type Dialer struct {
	Policy *Policy
	Base   net.Dialer
}

func NewDialer

func NewDialer(p *Policy) *Dialer

func (*Dialer) Control

func (d *Dialer) Control(_, address string, _ syscall.RawConn) error

func (*Dialer) Dial

func (d *Dialer) Dial(network, address string) (net.Conn, error)

func (*Dialer) DialContext

func (d *Dialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)

type Error

type Error struct {
	Addr    netip.AddrPort
	Checked netip.Addr
	Rule    string
	Reason  string
}

func (*Error) Errno

func (e *Error) Errno() string

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target error) bool

type Policy

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

func Local

func Local(loopbackPorts ...uint16) *Policy

func New

func New() *Policy

func Remote

func Remote() *Policy

func (*Policy) Allow

func (p *Policy) Allow() []string

func (*Policy) AllowsAny

func (p *Policy) AllowsAny(addr netip.Addr) bool

func (*Policy) Check

func (p *Policy) Check(addr netip.Addr, port uint16) error

func (*Policy) Deny

func (p *Policy) Deny() []string

func (*Policy) Filter

func (p *Policy) Filter(addrs []netip.Addr) []netip.Addr

func (*Policy) Summary

func (p *Policy) Summary() string

func (*Policy) With

func (p *Policy) With(allow, deny []Rule) *Policy

type Resolver

type Resolver struct {
	Policy *Policy
	Base   *net.Resolver
}

func NewResolver

func NewResolver(p *Policy) *Resolver

func (*Resolver) LookupNetIP

func (r *Resolver) LookupNetIP(ctx context.Context, network, host string) ([]netip.Addr, error)

type Rule

type Rule struct {
	Prefix netip.Prefix
	Port   uint16
}

func ParseRule

func ParseRule(s string) (Rule, error)

func (Rule) String

func (r Rule) String() string

type Rules

type Rules []Rule

func ParseRules

func ParseRules(values []string) (Rules, error)

func (*Rules) Set

func (r *Rules) Set(value string) error

func (Rules) String

func (r Rules) String() string

Jump to

Keyboard shortcuts

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