Documentation
¶
Overview ¶
Package hostname decides whether a name may be handed to ssh or put into a URL as a host, and whether an account may be handed to ssh as a user.
A node name reaches places that give some characters a meaning: ssh reads a leading "-" as an option, and a URL reads ":", "@", "/", "?" and "#" as the port, the userinfo, the path, the query and the fragment. Checking each place for the characters it happens to care about would miss the next one, so a name is accepted only when it is spelled in the host name alphabet of RFC 1123, in which none of them has a meaning, and an account only when it is spelled in the portable user name alphabet of POSIX.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check reports whether name is a host name: dot separated labels of ASCII letters, digits and hyphens, none of them empty, none longer than 63 characters, and none beginning or ending with a hyphen. A single final dot is allowed, since it only says the name is fully qualified.
An IPv4 address in dotted form passes, because it is spelled in the same alphabet. An IPv6 address does not; use CheckHost where one is expected.
func CheckHost ¶
CheckHost reports whether host names a machine on its own: a host name as Check accepts it, or an IPv4 or IPv6 address. Anything that would add a port, an account, a zone or a path to the host is refused.
func CheckUser ¶ added in v0.4.0
CheckUser reports whether user is an account name in the portable user name alphabet of POSIX: ASCII letters, digits, ".", "_" and "-", not beginning with "-", which ssh would read as an option. The same rule is the pattern of every user field in the schema, so that a name ssh cannot be given is refused where it is written, not when a command connects.
Types ¶
This section is empty.