Documentation
¶
Index ¶
- Constants
- func IsConfigVersionTooNew(configVersion int) bool
- func SaveConfig(configData *ConfigData, path string) error
- func ServerConfigToProvider(s ServerConfig) nntppool.Provider
- type CompressionType
- type Config
- type ConfigData
- func (c *ConfigData) GetCheckOnlyServers() []ServerConfig
- func (c *ConfigData) GetCheckPool() (*nntppool.Client, error)
- func (c *ConfigData) GetDatabaseConfig() DatabaseConfig
- func (c *ConfigData) GetMaintainOriginalExtension() bool
- func (c *ConfigData) GetNNTPPool() (*nntppool.Client, error)
- func (c *ConfigData) GetNzbCompressionConfig() NzbCompressionConfig
- func (c *ConfigData) GetOutputDir() string
- func (c *ConfigData) GetPar2Config(_ context.Context) (*Par2Config, error)
- func (c *ConfigData) GetPostCheckConfig() PostCheck
- func (c *ConfigData) GetPostUploadScriptConfig() PostUploadScriptConfig
- func (c *ConfigData) GetPostingConfig() PostingConfig
- func (c *ConfigData) GetPostingPool() (*nntppool.Client, error)
- func (c *ConfigData) GetPostingServers() []ServerConfig
- func (c *ConfigData) GetQueueConfig() QueueConfig
- func (c *ConfigData) GetUploadPool() (*nntppool.Client, error)
- func (c *ConfigData) GetUploadServers() []ServerConfig
- func (c *ConfigData) GetVerifyPool() (*nntppool.Client, error)
- func (c *ConfigData) GetVerifyServers() []ServerConfig
- func (c *ConfigData) GetWatcherConfig() WatcherConfig
- func (c *ConfigData) GetWatcherConfigs() []WatcherConfig
- func (c *ConfigData) Validate() error
- type ConnectionPoolConfig
- type CustomHeader
- type DatabaseConfig
- type Duration
- type GroupPolicy
- type MessageIDFormat
- type NewsgroupConfig
- type NzbCompressionConfig
- type ObfuscationPolicy
- type Par2Config
- type PostCheck
- type PostHeaders
- type PostUploadScriptConfig
- type PostingConfig
- type ProgressStatus
- type QueueConfig
- type ScheduleConfig
- type ServerConfig
- type ServerRole
- type WatcherConfig
Constants ¶
const (
// CurrentConfigVersion represents the current configuration version
CurrentConfigVersion = 2
)
Variables ¶
This section is empty.
Functions ¶
func IsConfigVersionTooNew ¶ added in v0.0.29
IsConfigVersionTooNew checks if the config version is newer than the current version
func SaveConfig ¶ added in v0.0.6
func SaveConfig(configData *ConfigData, path string) error
SaveConfig saves a ConfigData to a file
func ServerConfigToProvider ¶ added in v0.0.29
func ServerConfigToProvider(s ServerConfig) nntppool.Provider
ServerConfigToProvider converts a ServerConfig to nntppool.Provider
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.Client, error)
GetPostingConfig() PostingConfig
GetPostCheckConfig() PostCheck
GetPar2Config(ctx context.Context) (*Par2Config, error)
GetWatcherConfig() WatcherConfig
GetWatcherConfigs() []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 is deprecated: use Watchers instead. Retained for backward-compatible YAML parsing.
Watcher WatcherConfig `yaml:"watcher,omitempty" json:"watcher,omitempty"`
Watchers []WatcherConfig `yaml:"watchers" json:"watchers"`
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 (*ConfigData) GetCheckOnlyServers ¶ added in v0.0.29
func (c *ConfigData) GetCheckOnlyServers() []ServerConfig
GetCheckOnlyServers is a backward-compatible alias for GetVerifyServers.
func (*ConfigData) GetCheckPool ¶ added in v0.0.29
func (c *ConfigData) GetCheckPool() (*nntppool.Client, error)
GetCheckPool is a backward-compatible alias for GetVerifyPool.
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.Client, error)
GetNNTPPool returns the NNTP client (all enabled servers)
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(_ 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) GetPostingPool ¶ added in v0.0.29
func (c *ConfigData) GetPostingPool() (*nntppool.Client, error)
GetPostingPool is a backward-compatible alias for GetUploadPool.
func (*ConfigData) GetPostingServers ¶ added in v0.0.29
func (c *ConfigData) GetPostingServers() []ServerConfig
GetPostingServers is a backward-compatible alias for GetUploadServers.
func (*ConfigData) GetQueueConfig ¶ added in v0.0.6
func (c *ConfigData) GetQueueConfig() QueueConfig
func (*ConfigData) GetUploadPool ¶ added in v0.0.29
func (c *ConfigData) GetUploadPool() (*nntppool.Client, error)
GetUploadPool returns the NNTP client for posting articles (upload-role servers only).
func (*ConfigData) GetUploadServers ¶ added in v0.0.29
func (c *ConfigData) GetUploadServers() []ServerConfig
GetUploadServers returns enabled servers with the upload role (used for posting articles).
func (*ConfigData) GetVerifyPool ¶ added in v0.0.29
func (c *ConfigData) GetVerifyPool() (*nntppool.Client, error)
GetVerifyPool returns the NNTP client for article verification. Uses verify-role servers if available, otherwise falls back to upload servers.
func (*ConfigData) GetVerifyServers ¶ added in v0.0.29
func (c *ConfigData) GetVerifyServers() []ServerConfig
GetVerifyServers returns enabled servers with the verify role (used only for STAT checks).
func (*ConfigData) GetWatcherConfig ¶ added in v0.0.6
func (c *ConfigData) GetWatcherConfig() WatcherConfig
GetWatcherConfig returns the first watcher config (legacy compatibility).
func (*ConfigData) GetWatcherConfigs ¶ added in v0.0.29
func (c *ConfigData) GetWatcherConfigs() []WatcherConfig
GetWatcherConfigs returns all watcher configurations.
func (*ConfigData) Validate ¶ added in v0.0.29
func (c *ConfigData) Validate() error
Validate validates the configuration
type ConnectionPoolConfig ¶ added in v0.0.2
type CustomHeader ¶
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
MarshalJSON implements json.Marshaler interface
func (Duration) MarshalYAML ¶ added in v0.0.8
MarshalYAML implements yaml.Marshaler interface
func (Duration) ToDuration ¶ added in v0.0.8
ToDuration converts Duration to time.Duration
func (*Duration) UnmarshalJSON ¶ added in v0.0.8
UnmarshalJSON implements json.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 NewsgroupConfig ¶ added in v0.0.29
type NewsgroupConfig struct {
Name string `yaml:"name" json:"name"`
Enabled *bool `yaml:"enabled" json:"enabled"`
}
NewsgroupConfig represents a single newsgroup configuration
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"`
Redundancy string `yaml:"redundancy" json:"redundancy"`
TempDir string `yaml:"temp_dir" json:"temp_dir"`
MaintainPar2Files *bool `yaml:"maintain_par2_files" json:"maintain_par2_files"`
SkipIfPar2Exists *bool `yaml:"skip_if_par2_exists" json:"skip_if_par2_exists"`
ParparBinaryPath string `yaml:"parpar_binary_path" json:"parpar_binary_path"`
ParparExtraArgs []string `yaml:"parpar_extra_args" json:"parpar_extra_args"`
NumGoroutines int `yaml:"num_goroutines" json:"num_goroutines"`
MemoryLimit int64 `yaml:"memory_limit" json:"memory_limit"`
SliceSize int64 `yaml:"slice_size" json:"slice_size"`
}
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"`
// Initial delay before first deferred recheck. Default value is `5m`.
// Auto-enabled when PostCheck.Enabled is true.
DeferredCheckDelay Duration `yaml:"deferred_check_delay" json:"deferred_check_delay"`
// Maximum number of deferred check retry attempts. Default value is `5`.
DeferredMaxRetries int `yaml:"deferred_max_retries" json:"deferred_max_retries"`
// Maximum backoff cap for deferred checks. Default value is `1h`.
DeferredMaxBackoff Duration `yaml:"deferred_max_backoff" json:"deferred_max_backoff"`
// Worker poll interval for deferred checks. Default value is `2m`.
DeferredCheckInterval Duration `yaml:"deferred_check_interval" json:"deferred_check_interval"`
// Number of articles processed per deferred check cycle. Default value is 500.
DeferredBatchSize int `yaml:"deferred_batch_size" json:"deferred_batch_size"`
}
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"`
// Maximum number of retry attempts for failed script executions.
// Set to 0 for unlimited retries (will use MaxRetryDuration as the limit).
// Default value is `3`.
MaxRetries int `yaml:"max_retries" json:"max_retries"`
// Base delay for retry attempts with exponential backoff. Default value is `30s`.
RetryDelay Duration `yaml:"retry_delay" json:"retry_delay"`
// Maximum backoff duration. Caps the exponential backoff to prevent very long waits.
// Default value is `1h`.
MaxBackoff Duration `yaml:"max_backoff" json:"max_backoff"`
// Maximum duration to keep retrying after the first failure.
// After this duration, the script is marked as permanently failed.
// Default value is `24h`.
MaxRetryDuration Duration `yaml:"max_retry_duration" json:"max_retry_duration"`
// How often to check for pending retries. Default value is `1m`.
RetryCheckInterval Duration `yaml:"retry_check_interval" json:"retry_check_interval"`
}
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 []NewsgroupConfig `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 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"`
// Role defines how this server is used: "upload" for posting, "verify" for STAT checks only.
// All upload-role servers must share the same provider host.
Role ServerRole `yaml:"role" json:"role"`
// CheckOnly is deprecated: use Role instead. Retained for backward-compatible YAML parsing (v1 configs).
CheckOnly *bool `yaml:"check_only,omitempty" json:"check_only,omitempty"`
// Inflight sets the number of concurrent requests per connection. 0 defaults to 1 in nntppool v4.
Inflight int `yaml:"inflight" json:"inflight"`
// SOCKS5 Proxy URL (optional, format: socks5://username:password@hostname:port)
ProxyURL string `yaml:"proxy_url,omitempty" json:"proxy_url,omitempty"`
}
ServerConfig represents a Usenet server configuration
type ServerRole ¶ added in v0.0.29
type ServerRole string
ServerRole defines how a server is used in the pool.
const ( // ServerRoleUpload indicates the server is used for posting articles. ServerRoleUpload ServerRole = "upload" // ServerRoleVerify indicates the server is used only for article verification (STAT checks). ServerRoleVerify ServerRole = "verify" )
type WatcherConfig ¶ added in v0.0.2
type WatcherConfig struct {
Name string `yaml:"name" json:"name"`
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"`
// If true, creates one NZB per folder instead of one NZB per file in watch mode. Default value is `false`.
SingleNzbPerFolder bool `yaml:"single_nzb_per_folder" json:"single_nzb_per_folder"`
// FollowSymlinks controls whether symbolic links are followed during directory scanning.
// If false (default), symlinks are skipped to avoid double-counting files and including
// files outside the watch directory. Set to true to process symlinks as regular files.
FollowSymlinks bool `yaml:"follow_symlinks" json:"follow_symlinks"`
// MinFileAge is the minimum time since last modification before a file is eligible for upload.
// This prevents uploading files that are still being written to (e.g. slow copies, torrents).
// Default: 60s
MinFileAge Duration `yaml:"min_file_age" json:"min_file_age"`
// MinFileAgeToDelete is the minimum time to wait after a successful upload before
// deleting the original file. Useful when a downstream tool (e.g. AltMount) needs
// time to import the generated NZB before the source file disappears.
// Requires DeleteOriginalFile=true. Default: 0 (delete immediately).
MinFileAgeToDelete Duration `yaml:"min_file_age_to_delete" json:"min_file_age_to_delete"`
}