client

package
v0.0.0-...-b1aaf46 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SecureDialer = &net.Dialer{
	Control: func(network, address string, c syscall.RawConn) error {
		host, _, err := net.SplitHostPort(address)
		if err != nil {
			return err
		}
		ip, err := netip.ParseAddr(host)
		if err != nil || !isPublicIP(ip) {
			return fmt.Errorf("blocked address %s", host)
		}
		return nil
	},
	Timeout:   5 * time.Second,
	KeepAlive: 30 * time.Second,
}

SecureDialer is a net.Dialer that performs some additional checks of an address before performing connection logic. It will ensure that the address is actually a public address. This also covers redirects, since every connection the client makes goes through the hook. Note that if you use a proxy, the dial goes to the proxy, so the check won't apply to the final destination.

Functions

func IsPublicURL

func IsPublicURL(ctx context.Context, u *url.URL) (bool, error)

IsPublicURL performs checks on the given url.URL to ensure that it is a public address.

func New

func New() *resty.Client

New creates a new resty.Client with some default headers, redirects enabled (up to 3) and logging to the default slog.Logger.

Types

This section is empty.

Jump to

Keyboard shortcuts

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