Documentation ¶
Index ¶
- Constants
- Variables
- func AbsolutePathFromConfigPath(path string) string
- func CheckForFQDNRules(name string) error
- func DecodeAndUnmarshalNaCl(msg []byte, output interface{}, pubKey *key.MachinePublic, ...) error
- func EnsureDir(dir string) error
- func GenerateIPv4DNSRootDomain(ipPrefix netip.Prefix) []dnsname.FQDN
- func GenerateIPv6DNSRootDomain(ipPrefix netip.Prefix) []dnsname.FQDN
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomStringDNSSafe(size int) (string, error)
- func GenerateRandomStringURLSafe(n int) (string, error)
- func GetFileMode(key string) fs.FileMode
- func GetIPPrefixEndpoints(na netip.Prefix) (netip.Addr, netip.Addr)
- func GrpcSocketDialer(ctx context.Context, addr string) (net.Conn, error)
- func LogErr(err error, msg string)
- func NormalizeToFQDNRules(name string, stripEmailDomain bool) (string, error)
- func NormalizeToFQDNRulesConfigFromViper(name string) (string, error)
- func ParseIPSet(arg string, bits *int) (*netipx.IPSet, error)
- func StringOrPrefixListContains[T string | netip.Prefix](ts []T, t T) bool
- func StringToIPPrefix(prefixes []string) ([]netip.Prefix, error)
- func TSLogfWrapper() logger.Logf
- func TailMapResponseToString(resp tailcfg.MapResponse) string
- func TailNodesToString(nodes []*tailcfg.Node) string
- func TailscaleVersionNewerOrEqual(minimum, toCheck string) bool
- type DBLogWrapper
- func (l *DBLogWrapper) Error(ctx context.Context, msg string, data ...interface{})
- func (l *DBLogWrapper) Info(ctx context.Context, msg string, data ...interface{})
- func (l *DBLogWrapper) LogMode(gormLogger.LogLevel) gormLogger.Interface
- func (l *DBLogWrapper) ParamsFilter(ctx context.Context, sql string, params ...interface{}) (string, []interface{})
- func (l *DBLogWrapper) Trace(ctx context.Context, begin time.Time, ...)
- func (l *DBLogWrapper) Warn(ctx context.Context, msg string, data ...interface{})
- type DBLogWrapperOption
Constants ¶
const ( RegisterMethodAuthKey = "authkey" RegisterMethodOIDC = "oidc" RegisterMethodCLI = "cli" )
const ( ByteSize = 8 // value related to RFC 1123 and 952. LabelHostnameLength = 63 )
const ( Base8 = 8 Base10 = 10 BitSize16 = 16 BitSize32 = 32 BitSize64 = 64 PermissionFallback = 0o700 )
Variables ¶
var ( NodePublicKeyRegex = regexp.MustCompile("nodekey:[a-fA-F0-9]+") ErrCannotDecryptResponse = errors.New("cannot decrypt response") ZstdCompression = "zstd" )
var Comparers []cmp.Option = []cmp.Option{ IPComparer, PrefixComparer, AddrPortComparer, MkeyComparer, NkeyComparer, DkeyComparer, ViewSliceIPProtoComparer, }
var DkeyComparer = cmp.Comparer(func(x, y key.DiscoPublic) bool {
return x.String() == y.String()
})
var ErrInvalidUserName = errors.New("invalid user name")
var MkeyComparer = cmp.Comparer(func(x, y key.MachinePublic) bool {
return x.String() == y.String()
})
var NkeyComparer = cmp.Comparer(func(x, y key.NodePublic) bool {
return x.String() == y.String()
})
var ViewSliceIPProtoComparer = cmp.Comparer(func(a, b views.Slice[ipproto.Proto]) bool { return views.SliceEqual(a, b) })
Functions ¶
func CheckForFQDNRules ¶
func DecodeAndUnmarshalNaCl ¶
func DecodeAndUnmarshalNaCl( msg []byte, output interface{}, pubKey *key.MachinePublic, privKey *key.MachinePrivate, ) error
func GenerateIPv4DNSRootDomain ¶
From the netmask we can find out the wildcard bits (the bits that are not set in the netmask). This allows us to then calculate the subnets included in the subsequent class block and generate the entries.
func GenerateIPv6DNSRootDomain ¶
From the netmask we can find out the wildcard bits (the bits that are not set in the netmask). This allows us to then calculate the subnets included in the subsequent class block and generate the entries.
func GenerateRandomBytes ¶
GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateRandomStringDNSSafe ¶
GenerateRandomStringDNSSafe returns a DNS-safe securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateRandomStringURLSafe ¶
GenerateRandomStringURLSafe returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GetFileMode ¶
func NormalizeToFQDNRules ¶
NormalizeToFQDNRules will replace forbidden chars in user it can also return an error if the user doesn't respect RFC 952 and 1123.
func ParseIPSet ¶
parseIPSet parses arg as one:
- an IP address (IPv4 or IPv6)
- the string "*" to match everything (both IPv4 & IPv6)
- a CIDR (e.g. "192.168.0.0/16")
- a range of two IPs, inclusive, separated by hyphen ("2eff::1-2eff::0800")
bits, if non-nil, is the legacy SrcBits CIDR length to make a IP address (without a slash) treated as a CIDR of *bits length. nolint
func TSLogfWrapper ¶
func TailMapResponseToString ¶
func TailMapResponseToString(resp tailcfg.MapResponse) string
func TailNodesToString ¶
Types ¶
type DBLogWrapper ¶
type DBLogWrapper struct { Logger *zerolog.Logger Level zerolog.Level Event *zerolog.Event SlowThreshold time.Duration SkipErrRecordNotFound bool ParameterizedQueries bool }
func NewDBLogWrapper ¶
func (*DBLogWrapper) Error ¶
func (l *DBLogWrapper) Error(ctx context.Context, msg string, data ...interface{})
func (*DBLogWrapper) Info ¶
func (l *DBLogWrapper) Info(ctx context.Context, msg string, data ...interface{})
func (*DBLogWrapper) LogMode ¶
func (l *DBLogWrapper) LogMode(gormLogger.LogLevel) gormLogger.Interface
func (*DBLogWrapper) ParamsFilter ¶
func (l *DBLogWrapper) ParamsFilter(ctx context.Context, sql string, params ...interface{}) (string, []interface{})
type DBLogWrapperOption ¶
type DBLogWrapperOption func(*DBLogWrapper)