lib

package
v0.0.0-...-3e1aefe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2024 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TlsName = "nf6"

	TlsCaTemplate = &x509.Certificate{
		SerialNumber: big.NewInt(69420),

		Subject:     pkix.Name{CommonName: TlsName},
		ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth},
		DNSNames:    []string{TlsName},
		NotBefore:   notBefore,
		NotAfter:    notAfter,

		KeyUsage:              x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
		IsCA:                  true,
		BasicConstraintsValid: true,
	}
	TlsCertTemplate = &x509.Certificate{
		SerialNumber: big.NewInt(42069),

		Subject:     pkix.Name{CommonName: TlsName},
		ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth},
		DNSNames:    []string{TlsName},
		NotBefore:   notBefore,
		NotAfter:    notAfter,

		KeyUsage: x509.KeyUsageDigitalSignature,
	}
)
View Source
var IsDevShell = os.Getenv("IS_DEV_SHELL") != ""
View Source
var OutputType = ""
View Source
var ShowIds = false
View Source
var TableStyle = table.StyleDefault
View Source
var ValidNixSystems = []string{"x86_64-linux", "aarch64-linux"}

Functions

func AddOption

func AddOption(cmd *cobra.Command, o *Option)

func AddStateSubDir

func AddStateSubDir(subDir *StateSubDir)

func Context

func Context() (context.Context, context.CancelFunc)

func Crash

func Crash(a ...any)

func DbCheckAccountOwns

func DbCheckAccountOwns(ctx context.Context, db *pgxpool.Pool, table string, id uint64, accountId uint64) error

func DbCheckNotExists

func DbCheckNotExists[T any](ctx context.Context, db *pgxpool.Pool, table string, column string, value T) error

func DbCheckNotExistsInAccount

func DbCheckNotExistsInAccount[T any](ctx context.Context, db *pgxpool.Pool, table string, column string, value T, accountId uint64) error

func DbSelectColumn

func DbSelectColumn[T any](ctx context.Context, db *pgxpool.Pool, table string, column string, id uint64) (*T, error)

func DbUpdateColumn

func DbUpdateColumn[T any](ctx context.Context, db *pgxpool.Pool, table string, column string, value T, id uint64) error

func DbUpdateUniqueColumn

func DbUpdateUniqueColumn[T comparable](ctx context.Context, db *pgxpool.Pool, table string, column string, value T, id uint64) error

func DbUpdateUniqueColumnInAccount

func DbUpdateUniqueColumnInAccount[T comparable](ctx context.Context, db *pgxpool.Pool, table string, column string, value T, id uint64, accountId uint64) error

func EnsureIpv6PrefixContainsAddr

func EnsureIpv6PrefixContainsAddr(prefix *net.IPNet, addr net.IP) error
func Header(s string)

func InitConfig

func InitConfig(save bool)

func InitStateDir

func InitStateDir()

func LoadOptions

func LoadOptions()

func Output

func Output(a any)

func OutputAll

func OutputAll(a any)

func OutputStringList

func OutputStringList(a []string)

func PromptOrValidate

func PromptOrValidate(value *string, prompt *promptui.Prompt) error

func RandomIpv6Addr

func RandomIpv6Addr(from *net.IPNet) (net.IP, error)

func RandomIpv6Prefix

func RandomIpv6Prefix(from *net.IPNet, length int) (*net.IPNet, error)

func SaveConfig

func SaveConfig()

func SetConfigPath

func SetConfigPath(path string)

func SetHomeConfigPath

func SetHomeConfigPath(dir string)

func SetHomeStateDir

func SetHomeStateDir(dir string)

func SetOutputType

func SetOutputType(t string)

func SetStateDir

func SetStateDir(dir string)

func SetSystemConfigPath

func SetSystemConfigPath(dir string)

func SetSystemStateDir

func SetSystemStateDir(dir string)

func SetTimeout

func SetTimeout(t time.Duration)

func TlsDecodePrivKey

func TlsDecodePrivKey(privKeyPem []byte) (ed25519.PrivateKey, error)

func TlsDecodePubKey

func TlsDecodePubKey(pubKeyPem []byte) (ed25519.PublicKey, error)

func TlsEncodePrivKey

func TlsEncodePrivKey(privKey ed25519.PrivateKey) ([]byte, error)

func TlsEncodePubKey

func TlsEncodePubKey(pubKey ed25519.PublicKey) ([]byte, error)

func TlsGenCert

func TlsGenCert(template *x509.Certificate, pubKey ed25519.PublicKey, caPrivKey ed25519.PrivateKey) ([]byte, error)

func TlsGenCertUsingPrivKeyFile

func TlsGenCertUsingPrivKeyFile(template *x509.Certificate, pubKey ed25519.PublicKey, caPrivKeyPath string) ([]byte, error)

func TlsGenKey

func TlsGenKey() (ed25519.PublicKey, ed25519.PrivateKey, error)

func TlsGetGrpcPubKey

func TlsGetGrpcPubKey(ctx context.Context) (string, error)

func TlsReadFile

func TlsReadFile(path string) ([]byte, error)

func TlsWriteFile

func TlsWriteFile(data []byte, path string) error

func ValidateEmail

func ValidateEmail(email string) error

func ValidateHostName

func ValidateHostName(name string) error

func ValidateIpv6Address

func ValidateIpv6Address(addr string) error

func ValidateIpv6Prefix

func ValidateIpv6Prefix(addr string, prefixLen int) error

func ValidateNixSystem

func ValidateNixSystem(system string) error

func ValidateRepoName

func ValidateRepoName(name string) error

func ValidateWireguardKey

func ValidateWireguardKey(key string) error

func Warn

func Warn(a ...any)

Types

type Option

type Option struct {
	P         any
	Name      string
	Shorthand string
	Value     any
	Usage     string
}

type StateSubDir

type StateSubDir struct {
	P    *string
	Name string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL