validate

package
v0.90.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractTCPPort

func ExtractTCPPort(multiaddrStr string) string

ExtractTCPPort extracts the TCP port from a multiaddr string.

func ValidateDataDir

func ValidateDataDir(path string) error

ValidateDataDir validates that a data directory exists or can be created.

func ValidateDatabase

func ValidateDatabase(dc DatabaseConfig) []error

ValidateDatabase performs validation of the database configuration.

func ValidateDirWritable

func ValidateDirWritable(path string) error

ValidateDirWritable validates that a directory exists and is writable.

func ValidateDiscovery

func ValidateDiscovery(disc DiscoveryConfig) []error

ValidateDiscovery performs validation of the discovery configuration.

func ValidateFileReadable

func ValidateFileReadable(path string) error

ValidateFileReadable validates that a file exists and is readable.

func ValidateHostOrHostPort

func ValidateHostOrHostPort(addr string) error

ValidateHostOrHostPort validates either a hostname or host:port format.

func ValidateHostPort

func ValidateHostPort(hostPort string) error

ValidateHostPort validates a host:port address format.

func ValidateLogging

func ValidateLogging(log LoggingConfig) []error

ValidateLogging performs validation of the logging configuration.

func ValidateNode

func ValidateNode(nc NodeConfig) []error

ValidateNode performs validation of the node configuration.

func ValidatePort

func ValidatePort(port int) error

ValidatePort validates that a port number is in the valid range.

func ValidateSecurity

func ValidateSecurity(sec SecurityConfig) []error

ValidateSecurity performs validation of the security configuration.

func ValidateSwarmKey

func ValidateSwarmKey(key string) error

ValidateSwarmKey validates that a swarm key is 64 hex characters.

Types

type DatabaseConfig

type DatabaseConfig struct {
	DataDir             string
	ReplicationFactor   int
	ShardCount          int
	MaxDatabaseSize     int64
	RQLitePort          int
	RQLiteRaftPort      int
	RQLiteJoinAddress   string
	ClusterSyncInterval time.Duration
	PeerInactivityLimit time.Duration
	MinClusterSize      int
}

DatabaseConfig represents the database configuration for validation purposes.

type DiscoveryConfig

type DiscoveryConfig struct {
	BootstrapPeers    []string
	DiscoveryInterval time.Duration
	BootstrapPort     int
	HttpAdvAddress    string
	RaftAdvAddress    string
}

DiscoveryConfig represents the discovery configuration for validation purposes.

type LoggingConfig

type LoggingConfig struct {
	Level      string
	Format     string
	OutputFile string
}

LoggingConfig represents the logging configuration for validation purposes.

type NodeConfig

type NodeConfig struct {
	ID              string
	ListenAddresses []string
	DataDir         string
	MaxConnections  int
}

NodeConfig represents the node configuration for validation purposes.

type SecurityConfig

type SecurityConfig struct {
	EnableTLS       bool
	PrivateKeyFile  string
	CertificateFile string
}

SecurityConfig represents the security configuration for validation purposes.

type ValidationError

type ValidationError struct {
	Path    string // e.g., "discovery.bootstrap_peers[0]" or "discovery.peers[0]"
	Message string // e.g., "invalid multiaddr"
	Hint    string // e.g., "expected /ip{4,6}/.../tcp/<port>/p2p/<peerID>"
}

ValidationError represents a single validation error with context.

func (ValidationError) Error

func (e ValidationError) Error() string

Jump to

Keyboard shortcuts

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