config

package
v0.0.0-...-c57407d Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2021 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package config implements the configuration for a BitTorrent tracker

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	Lokinet: LokinetConfig{
		ResolverAddr: "127.0.0.1:1153",
	},
	I2P: I2PConfig{
		SAM: SamConfig{
			Addr:    "127.0.0.1:7656",
			Session: "chihaya-i2p",
			Opts:    make(map[string]string),
			Keyfile: "chihaya-i2p-privkey.dat",
		},
		Enabled: false,
	},
	TrackerConfig: TrackerConfig{
		CreateOnAnnounce:      true,
		PrivateEnabled:        false,
		FreeleechEnabled:      false,
		PurgeInactiveTorrents: true,
		Announce:              Duration{30 * time.Minute},
		MinAnnounce:           Duration{15 * time.Minute},
		ReapInterval:          Duration{60 * time.Second},
		ReapRatio:             1.25,
		NumWantFallback:       50,
		TorrentMapShards:      1,

		NetConfig: NetConfig{
			AllowIPSpoofing:  true,
			DualStackedPeers: true,
			RespectAF:        false,
			NumListeners:     8,
		},

		WhitelistConfig: WhitelistConfig{
			ClientWhitelistEnabled: false,
		},
	},

	APIConfig: APIConfig{
		ListenAddr:     "localhost:6880",
		RequestTimeout: Duration{10 * time.Second},
		ReadTimeout:    Duration{10 * time.Second},
		WriteTimeout:   Duration{10 * time.Second},
	},

	HTTPConfig: HTTPConfig{
		ListenAddr:     "localhost:6881",
		RequestTimeout: Duration{10 * time.Second},
		ReadTimeout:    Duration{10 * time.Second},
		WriteTimeout:   Duration{10 * time.Second},
	},

	UDPConfig: UDPConfig{
		ListenAddr: "localhost:6882",
	},

	DriverConfig: DriverConfig{
		Name: "noop",
	},

	StatsConfig: StatsConfig{
		BufferSize: 0,
		IncludeMem: true,
		VerboseMem: false,

		MemUpdateInterval: Duration{5 * time.Second},
	},
}

DefaultConfig is a configuration that can be used as a fallback value.

View Source
var ErrMissingRequiredParam = errors.New("A parameter that was required by a driver is not present")

ErrMissingRequiredParam is used by drivers to indicate that an entry required to be within the DriverConfig.Params map is not present.

Functions

This section is empty.

Types

type APIConfig

type APIConfig struct {
	ListenAddr     string   `json:"apiListenAddr"`
	RequestTimeout Duration `json:"apiRequestTimeout"`
	ReadTimeout    Duration `json:"apiReadTimeout"`
	WriteTimeout   Duration `json:"apiWriteTimeout"`
	ListenLimit    int      `json:"apiListenLimit"`
}

APIConfig is the configuration for an HTTP JSON API server.

type Config

type Config struct {
	TrackerConfig
	APIConfig
	HTTPConfig
	UDPConfig
	DriverConfig
	StatsConfig
	I2P     I2PConfig
	Lokinet LokinetConfig `json:"lokinet"`
}

Config is the global configuration for an instance of Chihaya.

func Decode

func Decode(r io.Reader) (*Config, error)

Decode casts an io.Reader into a JSONDecoder and decodes it into a *Config.

func Open

func Open(path string) (*Config, error)

Open is a shortcut to open a file, read it, and generate a Config. It supports relative and absolute paths. Given "", it returns DefaultConfig.

type DriverConfig

type DriverConfig struct {
	Name   string            `json:"driver"`
	Params map[string]string `json:"params,omitempty"`
}

DriverConfig is the configuration used to connect to a tracker.Driver or a backend.Driver.

type Duration

type Duration struct{ time.Duration }

Duration wraps a time.Duration and adds JSON marshalling.

func (*Duration) MarshalJSON

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

MarshalJSON transforms a duration into JSON.

func (*Duration) UnmarshalJSON

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

UnmarshalJSON transform JSON into a Duration.

type HTTPConfig

type HTTPConfig struct {
	ListenAddr     string   `json:"httpListenAddr"`
	RequestTimeout Duration `json:"httpRequestTimeout"`
	ReadTimeout    Duration `json:"httpReadTimeout"`
	WriteTimeout   Duration `json:"httpWriteTimeout"`
	ListenLimit    int      `json:"httpListenLimit"`
}

HTTPConfig is the configuration for the HTTP protocol.

type I2PConfig

type I2PConfig struct {
	SAM       SamConfig
	Listeners int
	Enabled   bool
}

I2PConfig is the configuration for i2p tracker mode options

type LokinetConfig

type LokinetConfig struct {
	ResolverAddr string `json:"dns"`
}

type NetConfig

type NetConfig struct {
	AllowIPSpoofing  bool   `json:"allowIPSpoofing"`
	DualStackedPeers bool   `json:"dualStackedPeers"`
	RealIPHeader     string `json:"realIPHeader"`
	RespectAF        bool   `json:"respectAF"`
	NumListeners     int    `json:"listeners"`
	SubnetConfig
}

NetConfig is the configuration used to tune networking behaviour.

type SamConfig

type SamConfig struct {
	Addr    string
	Opts    samOpts
	Session string
	Keyfile string
}

SamConfig is the config type for the sam connector api for i2p which allows applications to 'speak' with i2p

type StatsConfig

type StatsConfig struct {
	BufferSize        int      `json:"statsBufferSize"`
	IncludeMem        bool     `json:"includeMemStats"`
	VerboseMem        bool     `json:"verboseMemStats"`
	MemUpdateInterval Duration `json:"memStatsInterval"`
}

StatsConfig is the configuration used to record runtime statistics.

type SubnetConfig

type SubnetConfig struct {
	PreferredSubnet     bool `json:"preferredSubnet,omitempty"`
	PreferredIPv4Subnet int  `json:"preferredIPv4Subnet,omitempty"`
	PreferredIPv6Subnet int  `json:"preferredIPv6Subnet,omitempty"`
}

SubnetConfig is the configuration used to specify if local peers should be given a preference when responding to an announce.

type TrackerConfig

type TrackerConfig struct {
	CreateOnAnnounce      bool     `json:"createOnAnnounce"`
	PrivateEnabled        bool     `json:"privateEnabled"`
	FreeleechEnabled      bool     `json:"freeleechEnabled"`
	PurgeInactiveTorrents bool     `json:"purgeInactiveTorrents"`
	Announce              Duration `json:"announce"`
	MinAnnounce           Duration `json:"minAnnounce"`
	ReapInterval          Duration `json:"reapInterval"`
	ReapRatio             float64  `json:"reapRatio"`
	NumWantFallback       int      `json:"defaultNumWant"`
	TorrentMapShards      int      `json:"torrentMapShards"`

	NetConfig
	WhitelistConfig
}

TrackerConfig is the configuration for tracker functionality.

type UDPConfig

type UDPConfig struct {
	ListenAddr     string `json:"udpListenAddr"`
	ReadBufferSize int    `json:"udpReadBufferSize"`
}

UDPConfig is the configuration for the UDP protocol.

type WhitelistConfig

type WhitelistConfig struct {
	ClientWhitelistEnabled bool     `json:"clientWhitelistEnabled"`
	ClientWhitelist        []string `json:"clientWhitelist,omitempty"`
}

WhitelistConfig is the configuration used enable and store a whitelist of acceptable torrent client peer ID prefixes.

Jump to

Keyboard shortcuts

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