Documentation
¶
Overview ¶
Package publicnet keeps the hosted build's connections to mail servers on the public internet. A person names their own IMAP server; in MAILRULES_MODE=cloud that name must not lead the daemon into the operator's own network: its loopback, a private network, a cloud metadata service on a link-local address. Check refuses such a server before anything is dialed, and Dialer refuses at dial time, on the address actually connected to, so a name that resolves to a public address when it is checked and to a private one when it is dialed (DNS rebinding) is refused too. Both answer with an error that wraps mail.ErrNotPublic.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check refuses host, an IP address or a name, when it is or resolves to an address that is not public (an error that wraps mail.ErrNotPublic). A name that does not resolve is an error that does not wrap it. Nothing is dialed. r nil is the system's resolver.
func Control ¶
Control is a net.Dialer Control function that refuses to connect to an address that is not public. It runs on the address the socket is about to connect to, after any name was resolved, so no answer of a resolver gets past it. An address it cannot read is refused too.
func Public ¶
Public reports whether ip is an address on the public internet: not loopback, private (RFC 1918, IPv6 unique local), link-local, unspecified, multicast or broadcast, not carrier-grade NAT, documentation or another special-purpose range, in IPv4, in IPv6 and in the IPv6 forms that carry an IPv4 address (IPv4-mapped, NAT64, 6to4), which are judged by the IPv4 address they carry.
Types ¶
type Dialer ¶
type Dialer struct {
Resolver Resolver // nil: the system's resolver
// contains filtered or unexported fields
}
Dialer connects only to public addresses. It resolves the host itself, refuses it when any of its addresses is not public, as Check does, and then connects to those addresses one by one through a net.Dialer whose Control refuses, on the socket about to connect, an address that is not public. A name is resolved once per dial, and what is connected to is what was checked.