Documentation
¶
Overview ¶
Package pagereader is our own page reader for the web_fetch built-in tool: it fetches the page itself and turns it into markdown, with no service in between and nothing to pay. It refuses private and local addresses, checked before every request and every redirect, and again on the address it actually connects to. A page built with JavaScript, a PDF, or a site that blocks plain fetches reads badly here; the jina reader is for those.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBlocked = errors.New("page-reader: not allowed")
ErrBlocked is what errors.Is finds for an address the reader must not reach.
Functions ¶
func IsPrivateAddress ¶
IsPrivateAddress is true for an address the reader must never reach: loopback, private, link-local (cloud metadata), carrier NAT, multicast and reserved ranges, and an IPv6 address that maps onto one of them. Anything that is not an address at all is refused rather than guessed at.
Types ¶
type Options ¶
type Options struct {
// MaxRedirects is the most redirects followed. Default 5.
MaxRedirects int
// Timeout is per page. Default 30s.
Timeout time.Duration
UserAgent string
// AllowPrivate reaches private and local addresses (127.0.0.1, 10.x,
// 169.254.169.254, localhost…). Off by default: a prompt must never make
// the agent read your cloud metadata or admin pages. For tests and local
// development.
AllowPrivate bool
// Lookup is for tests: the addresses a host name resolves to.
Lookup func(ctx context.Context, host string) ([]string, error)
// Transport is for tests.
Transport http.RoundTripper
}
Options shape a Reader. The zero value is the safe default.