bootstrap

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package bootstrap 提供 goed2k 客户端的共享初始化逻辑: 配置映射、状态加载、监听启动,以及服务器 / DHT 后台引导。

CLI(cmd/goed2k)与 github.com/goed2k/daemon(https://github.com/goed2k/daemon) 均可复用此包。

Index

Constants

View Source
const (
	DefaultServerList = "" /* 128-byte string literal not displayed */
	DefaultServerMet  = "ed2k://|serverlist|http://upd.emule-security.org/server.met|/"
	DefaultNodesDat   = "http://www.alldivx.de/nodes/nodes.dat,https://upd.emule-security.org/nodes.dat"
)

Variables

This section is empty.

Functions

func BuildSettings

func BuildSettings(cfg Config) (ed2k.Settings, error)

BuildSettings maps Config to library Settings.

func DefaultStatePath

func DefaultStatePath() string

DefaultStatePath returns the per-user state file location.

func InitClient

func InitClient(cfg Config, logger *slog.Logger) (*ed2k.Client, error)

InitClient creates a client, optionally loads persisted state, and starts listening.

func RunBackground

func RunBackground(client *ed2k.Client, cfg Config, notify Notifier)

RunBackground starts server/DHT bootstrap goroutines.

func SplitCommaList

func SplitCommaList(value string) []string

SplitCommaList splits a comma-separated list and trims empty entries.

Types

type Config

type Config struct {
	Links                    []string
	OutDir                   string
	ServerAddr               string
	ServerMetPath            string
	ListenPort               int
	UDPPort                  int
	UDPPortV6                int
	EnableKAD                bool
	EnableKADV6              bool
	EnableUPnP               bool
	EnableCryptLayer         bool
	EnableCryptLayerRequired bool
	EnableSecIdent           bool
	SecIdentRequired         bool
	CreditsOnlyVerified      bool
	IdentityKeyPath          string
	CategoriesConfig         string
	KADNodesDat              string
	KADNodes                 string
	KADV6NodesDat            string
	KADV6Nodes               string
	PeerTimeout              int
	MaxDownloadRateKB        int
	MaxUploadRateKB          int
	Timeout                  time.Duration
	StatePath                string
	DisableState             bool
}

Config holds runtime options for the goed2k CLI.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns library defaults aligned with the CLI.

func (*Config) ApplyEnv

func (cfg *Config) ApplyEnv(prefix string)

ApplyEnv overlays known environment variables onto cfg (later keys win over earlier).

type Notifier

type Notifier func(format string, args ...any)

Notifier receives non-fatal bootstrap warnings.

Jump to

Keyboard shortcuts

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