config

package
v0.0.0-...-5607d3c Latest Latest
Warning

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

Go to latest
Published: May 13, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SendEmail     = true
	EmailFrom     = "donotrespond@nyaa.pantsu.cat"
	EmailTestTo   = ""
	EmailHost     = "localhost"
	EmailUsername = ""
	EmailPassword = ""
	EmailPort     = 465
	EmailTimeout  = 10 * time.Second
)
View Source
const (
	// Environment should be one of: DEVELOPMENT, TEST, PRODUCTION
	Environment            = "DEVELOPMENT"
	WebAddress             = "nyaa.pantsu.cat"
	AuthTokenExpirationDay = 1000
)
View Source
const (
	AccessLogFilePath      = "log/access"
	AccessLogFileExtension = ".txt"
	AccessLogMaxSize       = 5 // megabytes
	AccessLogMaxBackups    = 7
	AccessLogMaxAge        = 30 //days
	ErrorLogFilePath       = "log/error"
	ErrorLogFileExtension  = ".json"
	ErrorLogMaxSize        = 10 // megabytes
	ErrorLogMaxBackups     = 7
	ErrorLogMaxAge         = 30 //days
)
View Source
const (
	TorrentOrder = "torrent_id"
	TorrentSort  = "DESC"
)
View Source
const (
	// TorrentFileStorage = "/var/www/wherever/you/want"
	// TorrentStorageLink = "https://your.site/somewhere/%s.torrent"
	TorrentFileStorage = ""
	TorrentStorageLink = ""

	// TODO: deprecate this and move all files to the same server
	TorrentCacheLink = "http://anicache.com/torrent/%s.torrent"
	UploadsDisabled  = false
)
View Source
const DefaultCacheSize = 1 << 10
View Source
const (
	// LastOldTorrentID is the highest torrent ID
	// that was copied from the original Nyaa
	LastOldTorrentID = 923000
)
View Source
const (
	TorrentsPerPage = 50
)

Variables

View Source
var DefaultCacheConfig = CacheConfig{
	Dialect: "nop",
}
View Source
var DefaultScraperConfig = ScraperConfig{
	Addr: ":9999",

	NumWorkers: 4,

	IntervalSeconds: 60 * 60,
	Trackers: []ScrapeConfig{
		ScrapeConfig{
			URL:  "udp://tracker.coppersurfer.tk:6969/",
			Name: "coppersurfer.tk",
		},
	},
}

DefaultScraperConfig is the default config for bittorrent scraping

View Source
var DefaultSearchConfig = SearchConfig{}
View Source
var Defaults = Config{"localhost", 9999, "sqlite3", "./nyaa.db?cache_size=50", "default", DefaultScraperConfig, DefaultCacheConfig, DefaultSearchConfig, nil}
View Source
var EmailTokenHashKey = []byte("CHANGE_THIS_BEFORE_DEPLOYING_YOU_GIT")
View Source
var Trackers = []string{
	"udp://tracker.doko.moe:6969",
	"udp://tracker.coppersurfer.tk:6969",
	"udp://zer0day.to:1337/announce",
	"udp://tracker.leechers-paradise.org:6969",
	"udp://explodie.org:6969",
	"udp://tracker.opentrackr.org:1337",
	"udp://tracker.internetwarriors.net:1337/announce",
	"http://mgtracker.org:6969/announce",
	"http://tracker.baka-sub.cf/announce"}

Functions

This section is empty.

Types

type CacheConfig

type CacheConfig struct {
	Dialect string
	URL     string
	Size    float64
}

CacheConfig is config struct for caching strategy

type Config

type Config struct {
	Host   string `json:"host"`
	Port   int    `json:"port"`
	DBType string `json:"db_type"`
	// DBParams will be directly passed to Gorm, and its internal
	// structure depends on the dialect for each db type
	DBParams  string `json:"db_params"`
	DBLogMode string `json:"db_logmode"`
	// tracker scraper config (required)
	Scrape ScraperConfig `json:"scraper"`
	// cache config
	Cache CacheConfig `json:"cache"`
	// search config
	Search SearchConfig `json:"search"`
	// optional i2p configuration
	I2P *I2PConfig `json:"i2p"`
}

func New

func New() *Config

func (*Config) BindFlags

func (config *Config) BindFlags() func() error

BindFlags returns a function which is to be used after flag.Parse to check and copy the flags' values to the Config instance.

func (*Config) HandleConfFileFlag

func (config *Config) HandleConfFileFlag(path string) error

func (*Config) Pretty

func (config *Config) Pretty(output io.Writer) error

func (*Config) Read

func (config *Config) Read(input io.Reader) error

func (*Config) SetDBLogMode

func (config *Config) SetDBLogMode(db_logmode string) error

func (*Config) SetDBType

func (config *Config) SetDBType(db_type string) error

func (*Config) Write

func (config *Config) Write(output io.Writer) error

type I2PConfig

type I2PConfig struct {
	Name    string `json:"name"`
	Addr    string `json:"samaddr"`
	Keyfile string `json:"keyfile"`
}

type ScrapeConfig

type ScrapeConfig struct {
	URL             string `json:"scrape_url"`
	Name            string `json:"name"`
	IntervalSeconds int64  `json:"interval"`
}

type ScraperConfig

type ScraperConfig struct {
	Addr            string         `json:"bind"`
	NumWorkers      int            `json:"workers"`
	IntervalSeconds int64          `json:"default_interval"`
	Trackers        []ScrapeConfig `json:"trackers"`
}

type SearchConfig

type SearchConfig struct {
}

Jump to

Keyboard shortcuts

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