Documentation
¶
Index ¶
- Constants
- Variables
- func AddrIsLocal(addr net.Addr) bool
- func AddrIsUnix(addr net.Addr) bool
- func AddrToIP(addr net.Addr) net.IP
- func ArgsToStrings(maxLength int, arguments []string, delim string) []string
- func BitsetCopy(set []uint64, other []uint64)
- func BitsetEmpty(set []uint64) (empty bool)
- func BitsetGet(set []uint64, position uint) bool
- func BitsetInitialize(set []uint64)
- func BitsetSet(set []uint64, position uint, on bool) (changed bool)
- func BitsetSubtract(set []uint64, other []uint64)
- func BitsetUnion(set []uint64, other []uint64)
- func CopyFile(src string, dst string) (err error)
- func FieldsFuncN(s string, f func(rune) bool, n int) []string
- func FieldsN(s string, n int) []string
- func GenerateSecretToken() string
- func GetClientOnlyTags(tags map[string]ircmsg.TagValue) *map[string]ircmsg.TagValue
- func IPInNets(ip net.IP, nets []net.IPNet) bool
- func IsHostname(name string) bool
- func LookupHostname(addr string) string
- func NetToNormalizedString(network net.IPNet) string
- func NormalizeIPToNet(addr net.IP) (network net.IPNet)
- func NormalizeNet(network net.IPNet) (result net.IPNet)
- func NormalizedNetFromString(str string) (result net.IPNet, err error)
- func ParseNetList(netList []string) (nets []net.IPNet, err error)
- func SecretTokensMatch(storedToken string, suppliedToken string) bool
- func WordWrap(text string, lineWidth int) []string
- type SplitMessage
Constants ¶
const (
SecretTokenLength = 26
)
Variables ¶
var (
IPv4LoopbackAddress = net.ParseIP("127.0.0.1").To16()
)
Functions ¶
func AddrIsLocal ¶ added in v0.11.0
AddrIsLocal returns whether the address is from a trusted local connection (loopback or unix).
func AddrIsUnix ¶ added in v0.11.0
AddrIsUnix returns whether the address is a unix domain socket.
func AddrToIP ¶ added in v0.11.0
AddrToIP returns the IP address for a net.Addr; unix domain sockets are treated as IPv4 loopback
func ArgsToStrings ¶
ArgsToStrings takes the arguments and splits them into a series of strings, each argument separated by delim and each string bounded by maxLength.
func BitsetCopy ¶ added in v1.0.0
BitsetCopy copies the contents of `other` over `set`. Similar caveats about race conditions as with `BitsetUnion` apply.
func BitsetEmpty ¶ added in v0.12.0
BitsetEmpty returns whether the bitset is empty. This has false positives under concurrent modification (i.e., it can return true even though w.r.t. the sequence of atomic modifications, there was no point at which the bitset was completely empty), but that's not how we're using this method.
func BitsetInitialize ¶ added in v0.12.0
func BitsetInitialize(set []uint64)
BitsetInitialize initializes a bitset.
func BitsetSet ¶ added in v0.12.0
BitsetSet sets a given bit of the bitset to 0 or 1, returning whether it changed.
func BitsetSubtract ¶ added in v1.0.0
BitsetSubtract modifies `set` to subtract the contents of `other`. Similar caveats about race conditions as with `BitsetUnion` apply.
func BitsetUnion ¶ added in v0.12.0
BitsetUnion modifies `set` to be the union of `set` and `other`. This has race conditions in that we don't necessarily get a single consistent view of `other` across word boundaries.
func FieldsFuncN ¶ added in v1.0.0
FieldsFuncN is like strings.FieldsFunc, but returns at most n fields, and the nth field includes any runes at the end of the string normally excluded by f.
func FieldsN ¶ added in v1.0.0
FieldsN is like strings.Fields, but returns at most n fields, and the nth field includes any whitespace at the end of the string.
func GenerateSecretToken ¶ added in v1.0.0
func GenerateSecretToken() string
generate a secret token that cannot be brute-forced via online attacks
func GetClientOnlyTags ¶ added in v0.11.0
GetClientOnlyTags takes a tag map and returns a map containing just the client-only tags from it.
func IsHostname ¶
IsHostname returns whether we consider `name` a valid hostname.
func LookupHostname ¶
LookupHostname returns the hostname for `addr` if it has one. Otherwise, just returns `addr`.
func NetToNormalizedString ¶ added in v1.0.0
Given a network, produce a human-readable string (i.e., CIDR if it's actually a network, IPv6 address if it's a v6 /128, dotted quad if it's a v4 /32).
func NormalizeIPToNet ¶ added in v1.0.0
NormalizeIPToNet represents an address (v4 or v6) as the v6 /128 CIDR containing only it.
func NormalizeNet ¶ added in v1.0.0
NormalizeNet normalizes an IPNet to a v6 CIDR, using the 4-in-6 prefix. (this is like IP.To16(), but for IPNet instead of IP)
func NormalizedNetFromString ¶ added in v1.0.0
Parse a human-readable description (an address or CIDR, either v4 or v6) into a normalized v6 net.IPNet.
func ParseNetList ¶ added in v1.0.0
Parse a list of IPs and nets as they would appear in one of our config files, e.g., proxy-allowed-from or a throttling exemption list.
func SecretTokensMatch ¶ added in v1.0.0
securely check if a supplied token matches a stored token
Types ¶
type SplitMessage ¶ added in v1.0.0
type SplitMessage struct { Original string Wrapped []string // if this is nil, Original didn't need wrapping and can be sent to anyone }
SplitMessage represents a message that's been split for sending.
func MakeSplitMessage ¶ added in v1.0.0
func MakeSplitMessage(original string, origIs512 bool) (result SplitMessage)