Config dump
This commit is contained in:
@@ -47,27 +47,43 @@ func MainApp(configPath string) {
|
||||
|
||||
apiClient := http.NewHTTPClient(
|
||||
config.GetToken(),
|
||||
config.GetRetriesUntilFailed()*10,
|
||||
config.GetApiTimeoutSecs(),
|
||||
false,
|
||||
config.GetRetriesUntilFailed()*10, // default retries = 2, so this is 20
|
||||
config.GetApiTimeoutSecs(), // default api timeout = 60
|
||||
false, // ipv6 support is not needed for api client
|
||||
config,
|
||||
log.Named("api_client"),
|
||||
)
|
||||
|
||||
unrestrictClient := http.NewHTTPClient(
|
||||
config.GetToken(),
|
||||
config.GetRetriesUntilFailed(),
|
||||
config.GetDownloadTimeoutSecs(),
|
||||
false,
|
||||
config.GetRetriesUntilFailed(), // default retries = 2
|
||||
config.GetDownloadTimeoutSecs(), // default download timeout = 10
|
||||
false, // this is also api client, so no ipv6 support
|
||||
config,
|
||||
log.Named("unrestrict_client"),
|
||||
)
|
||||
|
||||
downloadClient := http.NewHTTPClient(config.GetToken(), config.GetRetriesUntilFailed(), config.GetDownloadTimeoutSecs(), true, config, log.Named("download_client"))
|
||||
downloadClient := http.NewHTTPClient(
|
||||
"",
|
||||
config.GetRetriesUntilFailed(),
|
||||
config.GetDownloadTimeoutSecs(),
|
||||
true,
|
||||
config,
|
||||
log.Named("download_client"),
|
||||
)
|
||||
|
||||
api := realdebrid.NewRealDebrid(apiClient, unrestrictClient, downloadClient, config, log.Named("realdebrid"))
|
||||
api := realdebrid.NewRealDebrid(
|
||||
apiClient,
|
||||
unrestrictClient,
|
||||
downloadClient,
|
||||
config,
|
||||
log.Named("realdebrid"),
|
||||
)
|
||||
|
||||
premium.MonitorPremiumStatus(api, zurglog)
|
||||
premium.MonitorPremiumStatus(
|
||||
api,
|
||||
zurglog,
|
||||
)
|
||||
|
||||
workerPool, err := ants.NewPool(config.GetNumOfWorkers())
|
||||
if err != nil {
|
||||
@@ -77,12 +93,25 @@ func MainApp(configPath string) {
|
||||
defer workerPool.Release()
|
||||
|
||||
utils.EnsureDirExists("data") // Ensure the data directory exists
|
||||
torrentMgr := torrent.NewTorrentManager(config, api, workerPool, log.Named("manager"))
|
||||
torrentMgr := torrent.NewTorrentManager(
|
||||
config,
|
||||
api,
|
||||
workerPool,
|
||||
log.Named("manager"),
|
||||
)
|
||||
|
||||
downloader := universal.NewDownloader(downloadClient)
|
||||
|
||||
router := chi.NewRouter()
|
||||
handlers.AttachHandlers(router, downloader, torrentMgr, config, api, workerPool, log.Named("router"))
|
||||
handlers.AttachHandlers(
|
||||
router,
|
||||
downloader,
|
||||
torrentMgr,
|
||||
config,
|
||||
api,
|
||||
workerPool,
|
||||
log.Named("router"),
|
||||
)
|
||||
|
||||
// go func() {
|
||||
// if err := netHttp.ListenAndServe(":6060", nil); err != nil && err != netHttp.ErrServerClosed {
|
||||
|
||||
@@ -4,7 +4,6 @@ type ConfigInterface interface {
|
||||
GetConfig() ZurgConfig
|
||||
GetVersion() string
|
||||
GetToken() string
|
||||
GetTokens() []string
|
||||
GetNumOfWorkers() int
|
||||
GetRefreshEverySecs() int
|
||||
GetRepairEveryMins() int
|
||||
@@ -35,9 +34,8 @@ type ConfigInterface interface {
|
||||
}
|
||||
|
||||
type ZurgConfig struct {
|
||||
Version string `yaml:"zurg" json:"-"`
|
||||
Token string `yaml:"token" json:"-"`
|
||||
Tokens []string `yaml:"tokens" json:"-"`
|
||||
Version string `yaml:"zurg" json:"-"`
|
||||
Token string `yaml:"token" json:"-"`
|
||||
|
||||
ApiTimeoutSecs int `yaml:"api_timeout_secs" json:"api_timeout_secs"`
|
||||
CanRepair bool `yaml:"enable_repair" json:"enable_repair"`
|
||||
@@ -74,10 +72,6 @@ func (z *ZurgConfig) GetToken() string {
|
||||
return z.Token
|
||||
}
|
||||
|
||||
func (z *ZurgConfig) GetTokens() []string {
|
||||
return z.Tokens
|
||||
}
|
||||
|
||||
func (z *ZurgConfig) GetHost() string {
|
||||
if z.Host == "" {
|
||||
return "[::]"
|
||||
|
||||
@@ -23,6 +23,16 @@ func loadV1Config(content []byte, log *logutil.Logger) (*ZurgConfigV1, error) {
|
||||
if err := yaml.Unmarshal(content, &configV1); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// don't log token and password
|
||||
bufToken := configV1.Token
|
||||
configV1.Token = strings.Repeat("*", len(bufToken)-4) + bufToken[len(bufToken)-4:]
|
||||
bufPassword := configV1.Password
|
||||
configV1.Password = strings.Repeat("*", len(bufPassword))
|
||||
log.Debugf("Config dump: %+v", configV1)
|
||||
configV1.Token = bufToken
|
||||
configV1.Password = bufPassword
|
||||
|
||||
configV1.log = log
|
||||
return &configV1, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user