config

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var True = true

Functions

func GenerateDefaultTemplate

func GenerateDefaultTemplate(configPath string) error

func GenerateInteractiveConfig

func GenerateInteractiveConfig(configPath string) error

func GeneratePeerIdentity

func GeneratePeerIdentity() (string, string, error)

func HashPassword

func HashPassword(password string) string

HashPassword now uses bcrypt for new hashes. Old salt:sha256 hashes remain valid (backward compatible).

func LoadPrivateKeyFromB64

func LoadPrivateKeyFromB64(privKeyB64 string) (crypto.PrivKey, error)

func Save

func Save(cfg *Config, configPath string) error

func VerifyPassword

func VerifyPassword(password, storedHash string) bool

Types

type ClientConfig

type ClientConfig struct {
	ServerID string `toml:"server_id"`

	Services []LocalServiceConfig `toml:"services"`
}

type CommonConfig

type CommonConfig struct {
	Protocol        string   `toml:"protocol"`
	Listen          []string `toml:"listen"`
	LogLevel        string   `toml:"log_level"`
	ZstdLevel       int      `toml:"zstd_level"`
	ZstdMinSizeB    int      `toml:"zstd_min_size_b"`
	ZstdChunkSizeKB int      `toml:"zstd_chunk_size_kb"`
}

type Config

type Config struct {
	IsServer bool `toml:"is_server"`

	Identity IdentityConfig `toml:"identity"`

	Server ServerConfig `toml:"server,omitempty"`
	Client ClientConfig `toml:"client,omitempty"`

	Common CommonConfig `toml:"common"`
}

func Load

func Load(configPath string) (*Config, error)

func (*Config) ValidateConfig

func (c *Config) ValidateConfig() error

type IdentityConfig

type IdentityConfig struct {
	PrivateKey string `toml:"private_key"`
	PeerID     string `toml:"peer_id"`
}

type LocalServiceConfig

type LocalServiceConfig struct {
	Name     string   `toml:"name"`     // name of remote service exported
	Local    string   `toml:"local"`    // service local destination
	Password string   `toml:"password"` // corresponding service password
	Protocol []string `toml:"protocol"`
	Enabled  bool     `toml:"enabled"`
}

type ServerConfig

type ServerConfig struct {
	PasswordHash string `toml:"password_hash"`
	Compress     bool   `toml:"compress"` // General compression behavior, enforced by the server
	// Considering low-CPU client devices, may add client-side switch in the future.
	Services []ServiceConfig `toml:"services"`
}

type ServiceConfig

type ServiceConfig struct {
	Name     string   `toml:"name"`
	Target   string   `toml:"target"`
	Password string   `toml:"password"`
	Protocol []string `toml:"protocol"`
	Enabled  bool     `toml:"enabled"`
	Compress *bool    `toml:"compress,omitempty"` // Service-level compression behavior (override), can be nil
}

Jump to

Keyboard shortcuts

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