config

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

*

configuration loader/saver

Index

Constants

View Source
const DefaultEnableGnutella = false

DefaultEnableGnutella says if should we enable gnutella by default

View Source
const DefaultOpentrackerFilename = "trackers.ini"
View Source
const DefaultRPCAddr = "127.0.0.1:1776"
View Source
const DefaultRPCAuth = "0"
View Source
const DefaultRPCHost = "127.0.0.1"
View Source
const DefaultTorrentQueueSize = 0
View Source
const DisableI2PByDefault = false
View Source
const DisableLokinetByDefault = true
View Source
const EnvI2PAddress = "XD_I2P_ADDRESS"

EnvI2PAddress is the name of the environmental variable to set the i2p address for XD

View Source
const EnvLogLevel = "XD_LOG_LEVEL"
View Source
const EnvLogPProf = "XD_PPROF"
View Source
const EnvOpenTracker = "XD_OPENTRACKER_URL"
View Source
const EnvRPCAddr = "XD_RPC_ADDRESS"
View Source
const EnvRPCHost = "XD_RPC_HOST"
View Source
const EnvRootDir = "XD_HOME"

EnvRootDir is the name of the environmental variable to set the root storage directory at runtime

Variables

View Source
var DefaultOpenTrackers = map[string]string{
	"dg-opentracker":       "http://w7tpbzncbcocrqtwwm3nezhnnsw4ozadvi2hmvzdhrqzfxfum7wa.b32.i2p/a",
	"chudo-opentracker":    "http://swhb5i7wcjcohmus3gbt3w6du6pmvl3isdvxvepuhdxxkfbzao6q.b32.i2p/a",
	"r4sas-opentracker":    "http://punzipidirfqspstvzpj6gb4tkuykqp6quurj6e23bgxcxhdoe7q.b32.i2p/a",
	"thebland-opentracker": "http://s5ikrdyjwbcgxmqetxb3nyheizftms7euacuub2hic7defkh3xhq.b32.i2p/a",
	"skank-opentracker":    "http://by7luzwhx733fhc5ug2o75dcaunblq2ztlshzd7qvptaoa73nqua.b32.i2p/a",
}

TODO: idk if these are the right names but the URL are correct

Functions

This section is empty.

Types

type BittorrentConfig

type BittorrentConfig struct {
	DHT              bool
	PEX              bool
	OpenTrackers     TrackerConfig
	PieceWindowSize  int
	Swarms           int
	TorrentQueueSize int
}

func (*BittorrentConfig) CreateSwarm

func (c *BittorrentConfig) CreateSwarm(st storage.Storage, gnutella *gnutella.Swarm) *swarm.Swarm

func (*BittorrentConfig) Load

func (*BittorrentConfig) LoadEnv

func (cfg *BittorrentConfig) LoadEnv()

func (*BittorrentConfig) Save

type Config

type Config struct {
	LokiNet    LokiNetConfig
	I2P        I2PConfig
	Storage    StorageConfig
	RPC        RPCConfig
	Log        LogConfig
	Bittorrent BittorrentConfig
	Gnutella   G2Config
}

func (*Config) Load

func (cfg *Config) Load(fname string) (err error)

Load loads a config from file by filename

func (*Config) Save

func (cfg *Config) Save(fname string) (err error)

Save saves a loaded config to file by filename

type Configurable

type Configurable interface {
	Load(s *configparser.Section) error
	Save(c *configparser.Section) error
	LoadEnv()
}

Configurable interface for entity serializable to/from config parser section

type G2Config

type G2Config struct {
	// contains filtered or unexported fields
}

func (*G2Config) CreateSwarm

func (c *G2Config) CreateSwarm() *gnutella.Swarm

func (*G2Config) Load

func (c *G2Config) Load(s *configparser.Section) error

func (*G2Config) LoadEnv

func (c *G2Config) LoadEnv()

func (*G2Config) Save

func (c *G2Config) Save(s *configparser.Section) error

type I2PConfig

type I2PConfig struct {
	Addr    string
	Keyfile string
	Name    string

	I2CPOptions map[string]string
	Disabled    bool
	// contains filtered or unexported fields
}

func (*I2PConfig) CreateSession

func (cfg *I2PConfig) CreateSession() i2p.Session

create an i2p session from this config

func (*I2PConfig) Load

func (cfg *I2PConfig) Load(section *configparser.Section) error

func (*I2PConfig) LoadEnv

func (cfg *I2PConfig) LoadEnv()

func (*I2PConfig) Save

func (cfg *I2PConfig) Save(s *configparser.Section) error

type LogConfig

type LogConfig struct {
	Level string
	Pprof bool
}

func (*LogConfig) Load

func (cfg *LogConfig) Load(s *configparser.Section) error

func (*LogConfig) LoadEnv

func (cfg *LogConfig) LoadEnv()

func (*LogConfig) Save

func (cfg *LogConfig) Save(s *configparser.Section) error

type LokiNetConfig

type LokiNetConfig struct {
	DNSAddr  string
	Port     string
	Disabled bool
}

func (*LokiNetConfig) CreateSession

func (cfg *LokiNetConfig) CreateSession() (*inet.Session, error)

create a network session from this config

func (*LokiNetConfig) Load

func (cfg *LokiNetConfig) Load(section *configparser.Section) error

func (*LokiNetConfig) LoadEnv

func (cfg *LokiNetConfig) LoadEnv()

func (*LokiNetConfig) Save

func (cfg *LokiNetConfig) Save(s *configparser.Section) error

type RPCConfig

type RPCConfig struct {
	Enabled      bool
	Bind         string
	ExpectedHost string
	Auth         bool
	Username     string
	Password     string
}

func (*RPCConfig) Load

func (cfg *RPCConfig) Load(s *configparser.Section) error

func (*RPCConfig) LoadEnv

func (cfg *RPCConfig) LoadEnv()

func (*RPCConfig) Save

func (cfg *RPCConfig) Save(s *configparser.Section) error

type SFTPConfig

type SFTPConfig struct {
	Enabled      bool
	Username     string
	Hostname     string
	Keyfile      string
	RemotePubkey string
	Port         int
}

func (*SFTPConfig) Load

func (cfg *SFTPConfig) Load(s *configparser.Section) error

func (*SFTPConfig) LoadEnv

func (cfg *SFTPConfig) LoadEnv()

func (*SFTPConfig) Save

func (cfg *SFTPConfig) Save(s *configparser.Section) error

func (*SFTPConfig) ToFS

func (cfg *SFTPConfig) ToFS() fs.Driver

type StorageConfig

type StorageConfig struct {
	// downloads directory
	Downloads string
	// completed directory
	Completed string
	// metadata directory
	Meta string
	// root directory
	Root string
	// number of io threads
	Workers int
	// number of buffered iops when using pooled io
	IOPBufferSize int
	// sftp config
	SFTP SFTPConfig
}

func (*StorageConfig) CreateStorage

func (cfg *StorageConfig) CreateStorage() storage.Storage

func (*StorageConfig) Load

func (cfg *StorageConfig) Load(s *configparser.Section) error

func (*StorageConfig) LoadEnv

func (cfg *StorageConfig) LoadEnv()

func (*StorageConfig) Save

func (cfg *StorageConfig) Save(s *configparser.Section) error

type TrackerConfig

type TrackerConfig struct {
	Trackers map[string]string
	FileName string
}

func (*TrackerConfig) Load

func (c *TrackerConfig) Load() (err error)

func (*TrackerConfig) Save

func (c *TrackerConfig) Save() (err error)

Jump to

Keyboard shortcuts

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