2020-05-29 04:02:37 +02:00
|
|
|
package configs
|
|
|
|
|
|
|
|
import (
|
2020-06-04 21:29:02 +02:00
|
|
|
"time"
|
|
|
|
|
2020-05-29 04:02:37 +02:00
|
|
|
"github.com/lbryio/lbry.go/v2/extras/errors"
|
|
|
|
"github.com/tkanos/gonfig"
|
|
|
|
)
|
|
|
|
|
|
|
|
type DbConfig struct {
|
|
|
|
Host string `json:"host"`
|
|
|
|
User string `json:"user"`
|
|
|
|
Database string `json:"database"`
|
|
|
|
Password string `json:"password"`
|
|
|
|
}
|
|
|
|
type Configs struct {
|
2022-05-18 16:38:39 +02:00
|
|
|
RedirectBaseURL string `json:"redirect_base_url"`
|
|
|
|
RedirectAdvancedURL string `json:"redirect_advanced_url"`
|
|
|
|
Chainquery DbConfig `json:"chainquery"`
|
|
|
|
Speech DbConfig `json:"speech"`
|
|
|
|
Voidwalker DbConfig `json:"voidwalker"`
|
|
|
|
ChannelID string `json:"channel_id"`
|
|
|
|
PublishAddress string `json:"publish_address"`
|
|
|
|
ReflectorServer string `json:"reflector_server"`
|
|
|
|
LbrynetTimeout time.Duration `json:"lbrynet_timeout"`
|
|
|
|
PreviousChannelIds []string `json:"previous_channel_ids"`
|
2020-05-29 04:02:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var Configuration *Configs
|
|
|
|
|
|
|
|
func Init(configPath string) error {
|
|
|
|
if Configuration != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
c := Configs{}
|
|
|
|
err := gonfig.GetConf(configPath, &c)
|
|
|
|
if err != nil {
|
|
|
|
return errors.Err(err)
|
|
|
|
}
|
|
|
|
Configuration = &c
|
|
|
|
return nil
|
|
|
|
}
|