config

package
v0.4.7-0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: GPL-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package config provides configuration management for go-pugleaf. Adapted from NZBreX for newsgroup server use.

Index

Constants

View Source
const (
	// NNTP protocol constants
	DOT  = "."
	CR   = "\r"
	LF   = "\n"
	CRLF = CR + LF

	// Default connection settings
	DefaultConnectTimeout  = 30 * time.Second
	DefaultConnectErrSleep = 5 * time.Second
	DefaultRequeueDelay    = 10 * time.Second
	DefaultMaxArticleSize  = 32 * 1024 // 'N' KB max article size

	// NNTPServer defaults
	NNTPServerMaxConns = 500 // Maximum concurrent NNTP connections
)

Variables

View Source
var AppVersion = "-unset-" // will be set at build time
View Source
var DefaultProviders = []Provider{
	{
		Grp:        "Primary",
		Name:       "localhost",
		Host:       "localhost",
		Username:   "",
		Password:   "",
		Port:       119,
		SSL:        false,
		MaxConns:   100,
		Enabled:    false,
		Priority:   97,
		MaxArtSize: 32768,
	},
	{
		Grp:        "Archive",
		Name:       "pugleaf Archive",
		Host:       "81-171-22-215.pugleaf.net",
		Username:   "pugleaf",
		Password:   "rslight",
		Port:       563,
		SSL:        true,
		MaxConns:   50,
		Enabled:    false,
		Priority:   98,
		MaxArtSize: 32768,
	},
	{
		Grp:        "Secondary",
		Name:       "pugleaf - Washington DC",
		Host:       "news-wdc.pugleaf.net",
		Username:   "",
		Password:   "",
		Port:       119,
		SSL:        false,
		MaxConns:   5,
		Enabled:    false,
		Priority:   99,
		MaxArtSize: 32768,
	},
	{
		Grp:        "Secondary",
		Name:       "pugleaf - San Francisco",
		Host:       "news-sfo.pugleaf.net",
		Username:   "",
		Password:   "",
		Port:       119,
		SSL:        false,
		MaxConns:   5,
		Enabled:    false,
		Priority:   99,
		MaxArtSize: 32768,
	},
	{
		Grp:        "Secondary",
		Name:       "pugleaf - Los Angeles",
		Host:       "news-lax.pugleaf.net",
		Username:   "",
		Password:   "",
		Port:       119,
		SSL:        false,
		MaxConns:   5,
		Enabled:    false,
		Priority:   99,
		MaxArtSize: 32768,
	},
	{
		Grp:        "Secondary",
		Name:       "pugleaf - Canada",
		Host:       "news-can.pugleaf.net",
		Username:   "",
		Password:   "",
		Port:       119,
		SSL:        false,
		MaxConns:   5,
		Enabled:    false,
		Priority:   99,
		MaxArtSize: 32768,
	},
	{
		Grp:        "Secondary",
		Name:       "pugleaf - Tokyo",
		Host:       "news-tyo.pugleaf.net",
		Username:   "",
		Password:   "",
		Port:       119,
		SSL:        false,
		MaxConns:   5,
		Enabled:    false,
		Priority:   99,
		MaxArtSize: 32768,
	},
	{
		Grp:        "Secondary",
		Name:       "pugleaf - Singapore",
		Host:       "news-sin.pugleaf.net",
		Username:   "",
		Password:   "",
		Port:       119,
		SSL:        false,
		MaxConns:   5,
		Enabled:    false,
		Priority:   99,
		MaxArtSize: 32768,
	},
	{
		Grp:        "Secondary",
		Name:       "pugleaf - Frankfurt",
		Host:       "news-fra.pugleaf.net",
		Username:   "",
		Password:   "",
		Port:       119,
		SSL:        false,
		MaxConns:   5,
		Enabled:    false,
		Priority:   99,
		MaxArtSize: 32768,
	},
	{
		Grp:        "Secondary",
		Name:       "pugleaf - Amsterdam",
		Host:       "news-ams.pugleaf.net",
		Username:   "",
		Password:   "",
		Port:       119,
		SSL:        false,
		MaxConns:   5,
		Enabled:    false,
		Priority:   99,
		MaxArtSize: 32768,
	},
	{
		Grp:        "Secondary",
		Name:       "pugleaf - London",
		Host:       "news-lon.pugleaf.net",
		Username:   "",
		Password:   "",
		Port:       119,
		SSL:        false,
		MaxConns:   5,
		Enabled:    false,
		Priority:   99,
		MaxArtSize: 32768,
	},
	{
		Grp:        "Backup",
		Name:       "BlueWorldHosting Archive",
		Host:       "news.blueworldhosting.com",
		Username:   "",
		Password:   "",
		Port:       563,
		SSL:        true,
		MaxConns:   3,
		Enabled:    false,
		Priority:   199,
		MaxArtSize: 32768,
	},
}

Functions

This section is empty.

Types

type DatabaseConfig

type DatabaseConfig struct {
	MainDB    string `json:"main_db"`    // Path to main database
	GroupsDir string `json:"groups_dir"` // Directory for per-group databases
	BackupDir string `json:"backup_dir"` // Directory for backups
}

DatabaseConfig holds database configuration

type MainConfig

type MainConfig struct {
	MaxArtSize int `json:"max_article_size"`

	// NNTP Provider configurations
	Providers []Provider `json:"providers"`

	// Server settings
	Server ServerConfig `json:"server"`

	// Database settings
	Database DatabaseConfig `json:"database"`

	// Web interface settings
	Web WebConfig `json:"web"`

	AppVersion string `json:"app_version"` // Application version, set at build time
	// contains filtered or unexported fields
}

Config holds the main configuration for go-pugleaf

func NewDefaultConfig

func NewDefaultConfig() *MainConfig

NewDefaultConfig returns a configuration with sensible defaults

type Provider

type Provider struct {
	Grp        string `json:"grp"`
	Name       string `json:"name"`
	Host       string `json:"host"`
	Port       int    `json:"port"`
	SSL        bool   `json:"ssl"`
	Username   string `json:"username"`
	Password   string `json:"password"`
	MaxConns   int    `json:"max_connections"`
	Enabled    bool   `json:"enabled"`
	Priority   int    `json:"priority"`         // Lower numbers = higher priority
	MaxArtSize int    `json:"max_article_size"` // Maximum article size in bytes
}

Provider represents an NNTP server configuration

type ServerConfig

type ServerConfig struct {
	WEB      *WebConfig
	Hostname string `json:"hostname"` // Server hostname for NNTP Path headers and identification
	// NNTP server-specific configuration
	NNTP struct {
		Enabled    bool   `json:"enabled"`
		Port       int    `json:"port"`
		TLSPort    int    `json:"tls_port"`
		MaxConns   int    `json:"max_connections"`
		TLSCert    string `json:"tls_cert"`
		TLSKey     string `json:"tls_key"`
		MaxArtSize int    `json:"max_article_size"` // Maximum article size in bytes
	} `json:"nntp"`
}

ServerConfig holds Web and NNTP server configuration

type WebConfig

type WebConfig struct {
	ListenPort int    `json:"listen_port"`
	SSL        bool   `json:"ssl"`
	CertFile   string `json:"cert_file,omitempty"`
	KeyFile    string `json:"key_file,omitempty"`
	StaticDir  string `json:"static_dir"`
	Debug      bool   `json:"debug"` // Enable debug logging for sessions/auth
}

WebConfig holds web interface configuration

Jump to

Keyboard shortcuts

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