config

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// CurrentConfigVersion represents the current configuration version
	CurrentConfigVersion = 1
)

Variables

This section is empty.

Functions

func IsConfigVersionOutdated added in v0.0.8

func IsConfigVersionOutdated(configVersion int) bool

IsConfigVersionOutdated checks if the given config version is outdated

func SaveConfig added in v0.0.6

func SaveConfig(configData *ConfigData, path string) error

SaveConfig saves a ConfigData to a file

Types

type CompressionType added in v0.0.5

type CompressionType string
const (
	// No compression
	CompressionTypeNone CompressionType = "none"
	// Zstandard compression
	CompressionTypeZstd CompressionType = "zstd"
	// Brotli compression
	CompressionTypeBrotli CompressionType = "brotli"
	// ZIP compression
	CompressionTypeZip CompressionType = "zip"
)

type Config

type Config interface {
	GetNNTPPool() (nntppool.UsenetConnectionPool, error)
	GetPostingConfig() PostingConfig
	GetPostCheckConfig() PostCheck
	GetPar2Config(ctx context.Context) (*Par2Config, error)
	GetWatcherConfig() WatcherConfig
	GetNzbCompressionConfig() NzbCompressionConfig
	GetDatabaseConfig() DatabaseConfig
	GetQueueConfig() QueueConfig
	GetPostUploadScriptConfig() PostUploadScriptConfig
	GetMaintainOriginalExtension() bool
}

type ConfigData added in v0.0.6

type ConfigData struct {
	Version        int                  `yaml:"version" json:"version"`
	Servers        []ServerConfig       `yaml:"servers" json:"servers"`
	ConnectionPool ConnectionPoolConfig `yaml:"connection_pool" json:"connection_pool"`
	Posting        PostingConfig        `yaml:"posting" json:"posting"`
	// Check uploaded article configuration. used to check if an article was successfully uploaded and propagated.
	PostCheck                 PostCheck              `yaml:"post_check" json:"post_check"`
	Par2                      Par2Config             `yaml:"par2" json:"par2"`
	Watcher                   WatcherConfig          `yaml:"watcher" json:"watcher"`
	NzbCompression            NzbCompressionConfig   `yaml:"nzb_compression" json:"nzb_compression"`
	Database                  DatabaseConfig         `yaml:"database" json:"database"`
	Queue                     QueueConfig            `yaml:"queue" json:"queue"`
	OutputDir                 string                 `yaml:"output_dir" json:"output_dir"`
	MaintainOriginalExtension *bool                  `yaml:"maintain_original_extension" json:"maintain_original_extension"`
	PostUploadScript          PostUploadScriptConfig `yaml:"post_upload_script" json:"post_upload_script"`
}

config is the internal implementation of the Config interface

func GetDefaultConfig added in v0.0.6

func GetDefaultConfig() ConfigData

GetDefaultConfig returns a default configuration

func Load

func Load(path string) (*ConfigData, error)

Load loads configuration from a file

func (*ConfigData) GetDatabaseConfig added in v0.0.22

func (c *ConfigData) GetDatabaseConfig() DatabaseConfig

func (*ConfigData) GetMaintainOriginalExtension added in v0.0.6

func (c *ConfigData) GetMaintainOriginalExtension() bool

func (*ConfigData) GetNNTPPool added in v0.0.6

func (c *ConfigData) GetNNTPPool() (nntppool.UsenetConnectionPool, error)

GetNNTPPool returns the NNTP connection pool

func (*ConfigData) GetNNTPPoolConfig added in v0.0.22

func (c *ConfigData) GetNNTPPoolConfig() (nntppool.Config, error)

GetNNTPPoolConfig returns the nntppool configuration without creating the actual pool

func (*ConfigData) GetNzbCompressionConfig added in v0.0.6

func (c *ConfigData) GetNzbCompressionConfig() NzbCompressionConfig

func (*ConfigData) GetOutputDir added in v0.0.6

func (c *ConfigData) GetOutputDir() string

func (*ConfigData) GetPar2Config added in v0.0.6

func (c *ConfigData) GetPar2Config(ctx context.Context) (*Par2Config, error)

func (*ConfigData) GetPostCheckConfig added in v0.0.6

func (c *ConfigData) GetPostCheckConfig() PostCheck

func (*ConfigData) GetPostUploadScriptConfig added in v0.0.6

func (c *ConfigData) GetPostUploadScriptConfig() PostUploadScriptConfig

func (*ConfigData) GetPostingConfig added in v0.0.6

func (c *ConfigData) GetPostingConfig() PostingConfig

func (*ConfigData) GetQueueConfig added in v0.0.6

func (c *ConfigData) GetQueueConfig() QueueConfig

func (*ConfigData) GetWatcherConfig added in v0.0.6

func (c *ConfigData) GetWatcherConfig() WatcherConfig

type ConnectionPoolConfig added in v0.0.2

type ConnectionPoolConfig struct {
	MinConnections      int      `yaml:"min_connections" json:"min_connections"`
	HealthCheckInterval Duration `yaml:"health_check_interval" json:"health_check_interval"`
}

type CustomHeader

type CustomHeader struct {
	Name  string `yaml:"name" json:"name"`
	Value string `yaml:"value" json:"value"`
}

type DatabaseConfig added in v0.0.22

type DatabaseConfig struct {
	// Database type to use. Supported: "sqlite", "postgres", "mysql"
	DatabaseType string `yaml:"database_type" json:"database_type"`
	// Database connection string or file path
	DatabasePath string `yaml:"database_path" json:"database_path"`
}

DatabaseConfig represents the database configuration

type Duration added in v0.0.8

type Duration string

Duration wraps time.Duration to provide custom JSON and YAML marshalling

func (Duration) MarshalJSON added in v0.0.8

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (Duration) MarshalYAML added in v0.0.8

func (d Duration) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler interface

func (Duration) ToDuration added in v0.0.8

func (d Duration) ToDuration() time.Duration

ToDuration converts Duration to time.Duration

func (*Duration) UnmarshalJSON added in v0.0.8

func (d *Duration) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

func (*Duration) UnmarshalYAML added in v0.0.8

func (d *Duration) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler interface

type GroupPolicy

type GroupPolicy string
const (
	//    ALL       : everything is posted on ALL the Groups
	GroupPolicyAll GroupPolicy = "all"
	//    EACH_FILE : each File will be posted on a random Group from the list (only with Article's obfuscation)
	GroupPolicyEachFile GroupPolicy = "each_file"
)

type MessageIDFormat

type MessageIDFormat string
const (
	// NXG: the Message-ID will be formatted as https://github.com/javi11/nxg
	MessageIDFormatNXG MessageIDFormat = "nxg"
	// Random: the Message-ID will be a random string of 32 characters
	MessageIDFormatRandom MessageIDFormat = "random"
)

type NzbCompressionConfig added in v0.0.5

type NzbCompressionConfig struct {
	// Whether to enable compression. Default is false.
	Enabled bool `yaml:"enabled" json:"enabled"`
	// Compression type to use. Default is "none".
	Type CompressionType `yaml:"type" json:"type"`
	// Compression level to use. Default depends on the compression type.
	Level int `yaml:"level" json:"level"`
}

NzbCompressionConfig represents the NZB compression configuration

type ObfuscationPolicy

type ObfuscationPolicy string
const (
	// Will do the following obfuscation:
	// - Subject: will be obfuscated
	// - Filename: will be obfuscated
	// - Yenc header filename: will be randomized for every article
	// - Date: will be randomized for every article within last 6 hours
	// - NXG-header: will not be added
	// - Poster: will be random for each article
	ObfuscationPolicyFull ObfuscationPolicy = "full"
	// Will do the following obfuscation:
	// - Subject: will be obfuscated
	// - Filename: will be obfuscated
	// - Yenc header filename: will be same one for all articles
	// - Date: will be the real posted date
	// - Poster: will be the same one for all articles
	ObfuscationPolicyPartial ObfuscationPolicy = "partial"
	// Nothing will be obfuscated
	ObfuscationPolicyNone ObfuscationPolicy = "none"
)

type Par2Config

type Par2Config struct {
	Enabled          *bool    `yaml:"enabled" json:"enabled"`
	Par2Path         string   `yaml:"par2_path" json:"par2_path"`
	Redundancy       string   `yaml:"redundancy" json:"redundancy"`
	VolumeSize       int      `yaml:"volume_size" json:"volume_size"`
	MaxInputSlices   int      `yaml:"max_input_slices" json:"max_input_slices"`
	ExtraPar2Options []string `yaml:"extra_par2_options" json:"extra_par2_options"`
	TempDir          string   `yaml:"temp_dir" json:"temp_dir"`
	// contains filtered or unexported fields
}

type Par2DownloadStatus added in v0.0.8

type Par2DownloadStatus struct {
	Status  string `json:"status"`  // "downloading", "completed", "error"
	Message string `json:"message"` // Human readable message
}

Par2DownloadStatus represents the status of par2 executable download

type PostCheck

type PostCheck struct {
	// If enabled articles will be checked after being posted. Default value is `true`.
	Enabled *bool `yaml:"enabled" json:"enabled"`
	// Delay between retries. Default value is `10s`.
	RetryDelay Duration `yaml:"delay" json:"delay"`
	// The maximum number of re-posts if article check fails. Default value is `1`.
	MaxRePost uint `yaml:"max_reposts" json:"max_reposts"`
}

type PostHeaders

type PostHeaders struct {
	// Whether to add the X-NXG header to the uploaded articles (You will still see this header in the generated NZB). Default value is `true`.
	// If obfuscation policy is `FULL` this header will not be added.
	// If message_id_format is not `nxg` this header will not be added.
	AddNXGHeader bool `yaml:"add_nxg_header" json:"add_nxg_header"`
	// The default from header for the uploaded articles. By default a random poster will be used for each article. This will override GenerateFromByArticle
	DefaultFrom string `yaml:"default_from" json:"default_from"`
	// Add custom headers to the uploaded articles. Subject, From, Newsgroups, Message-ID and Date can not be override.
	CustomHeaders []CustomHeader `yaml:"custom_headers" json:"custom_headers"`
}

type PostUploadScriptConfig added in v0.0.6

type PostUploadScriptConfig struct {
	// Whether to enable the post upload script execution. Default value is `false`.
	Enabled bool `yaml:"enabled" json:"enabled"`
	// Command to execute after NZB generation. Use {nzb_path} placeholder for the NZB file path
	Command string `yaml:"command" json:"command"`
	// Timeout for script execution. Default value is `30s`.
	Timeout Duration `yaml:"timeout" json:"timeout"`
}

PostUploadScriptConfig represents the post upload script configuration

type PostingConfig

type PostingConfig struct {
	WaitForPar2        *bool           `yaml:"wait_for_par2" json:"wait_for_par2"`
	MaxRetries         int             `yaml:"max_retries" json:"max_retries"`
	RetryDelay         Duration        `yaml:"retry_delay" json:"retry_delay"`
	ArticleSizeInBytes uint64          `yaml:"article_size_in_bytes" json:"article_size_in_bytes"`
	Groups             []string        `yaml:"groups" json:"groups"`
	ThrottleRate       int64           `yaml:"throttle_rate" json:"throttle_rate"` // bytes per second
	MessageIDFormat    MessageIDFormat `yaml:"message_id_format" json:"message_id_format"`
	PostHeaders        PostHeaders     `yaml:"post_headers" json:"post_headers"`
	// If true the uploaded subject and filename will be obfuscated. Default value is `true`.
	ObfuscationPolicy     ObfuscationPolicy `yaml:"obfuscation_policy" json:"obfuscation_policy"`
	Par2ObfuscationPolicy ObfuscationPolicy `yaml:"par2_obfuscation_policy" json:"par2_obfuscation_policy"`
	//  If you give several Groups you've 3 policy when posting
	GroupPolicy GroupPolicy `yaml:"group_policy" json:"group_policy"`
}

PostingConfig represents posting configuration

type ProgressStatus added in v0.0.8

type ProgressStatus struct {
	CurrentFile         string  `json:"currentFile"`
	TotalFiles          int     `json:"totalFiles"`
	CompletedFiles      int     `json:"completedFiles"`
	Stage               string  `json:"stage"`
	Details             string  `json:"details"`
	IsRunning           bool    `json:"isRunning"`
	LastUpdate          int64   `json:"lastUpdate"`
	Percentage          float64 `json:"percentage"`
	CurrentFileProgress float64 `json:"currentFileProgress"`
	JobID               string  `json:"jobID"`
	TotalBytes          int64   `json:"totalBytes"`
	TransferredBytes    int64   `json:"transferredBytes"`
	CurrentFileBytes    int64   `json:"currentFileBytes"`
	Speed               float64 `json:"speed"`
	SecondsLeft         float64 `json:"secondsLeft"`
	ElapsedTime         float64 `json:"elapsedTime"`
}

ProgressStatus represents the progress of file processing operations

type QueueConfig added in v0.0.6

type QueueConfig struct {
	// Maximum concurrent uploads from queue
	MaxConcurrentUploads int `yaml:"max_concurrent_uploads" json:"max_concurrent_uploads"`
}

QueueConfig represents the upload queue configuration

type ScheduleConfig added in v0.0.2

type ScheduleConfig struct {
	StartTime string `yaml:"start_time" json:"start_time"`
	EndTime   string `yaml:"end_time" json:"end_time"`
}

type ServerConfig

type ServerConfig struct {
	Host                           string `yaml:"host" json:"host"`
	Port                           int    `yaml:"port" json:"port"`
	Username                       string `yaml:"username" json:"username"`
	Password                       string `yaml:"password" json:"password"`
	SSL                            bool   `yaml:"ssl" json:"ssl"`
	MaxConnections                 int    `yaml:"max_connections" json:"max_connections"`
	MaxConnectionIdleTimeInSeconds int    `yaml:"max_connection_idle_time_in_seconds" json:"max_connection_idle_time_in_seconds"`
	MaxConnectionTTLInSeconds      int    `yaml:"max_connection_ttl_in_seconds" json:"max_connection_ttl_in_seconds"`
	InsecureSSL                    bool   `yaml:"insecure_ssl" json:"insecure_ssl"`
	Enabled                        *bool  `yaml:"enabled" json:"enabled"`
}

ServerConfig represents a Usenet server configuration

type WatcherConfig added in v0.0.2

type WatcherConfig struct {
	Enabled            bool           `yaml:"enabled" json:"enabled"`
	WatchDirectory     string         `yaml:"watch_directory" json:"watch_directory"`
	SizeThreshold      int64          `yaml:"size_threshold" json:"size_threshold"`
	Schedule           ScheduleConfig `yaml:"schedule" json:"schedule"`
	IgnorePatterns     []string       `yaml:"ignore_patterns" json:"ignore_patterns"`
	MinFileSize        int64          `yaml:"min_file_size" json:"min_file_size"`
	CheckInterval      Duration       `yaml:"check_interval" json:"check_interval"`
	DeleteOriginalFile bool           `yaml:"delete_original_file" json:"delete_original_file"`
}

Jump to

Keyboard shortcuts

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