conf.GetConfig().BootstrapAddress
This commit is contained in:
@@ -7,6 +7,7 @@ type Config struct {
|
||||
PrivateKeyPath string
|
||||
DHTEndpointPort int64
|
||||
PSKPath string
|
||||
BootstrapAddress string
|
||||
}
|
||||
|
||||
var instance *Config
|
||||
|
||||
12
main.go
12
main.go
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/beego/beego/v2/server/web/filter/cors"
|
||||
"github.com/libp2p/go-libp2p"
|
||||
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
)
|
||||
|
||||
const appname = "oc-catalog"
|
||||
@@ -37,6 +38,7 @@ func main() {
|
||||
conf.GetConfig().DHTEndpointPort = o.GetInt64Default("DHT_ENDPOINT_PORT", 4002)
|
||||
conf.GetConfig().PublicKeyPath = o.GetStringDefault("CATALOG_PUBLIC_KEY_PATH", "./pem/public.pem")
|
||||
conf.GetConfig().PrivateKeyPath = o.GetStringDefault("CATALOG_PRIVATE_KEY_PATH", "./pem/private.pem")
|
||||
conf.GetConfig().BootstrapAddress = o.GetStringDefault("BOOTSTRAP_ADDRESS", "")
|
||||
// Beego initialization
|
||||
beego.BConfig.AppName = appname
|
||||
beego.BConfig.Listen.HTTPPort = o.GetIntDefault("port", 8080)
|
||||
@@ -76,6 +78,16 @@ func InitDTH() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pi, err := peer.AddrInfoFromString(conf.GetConfig().BootstrapAddress)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logger := oclib.GetLogger()
|
||||
if err := h.Connect(context.Background(), *pi); err != nil {
|
||||
logger.Err(fmt.Errorf("Failed to connect to MAIN bootstrap peer %s: %s", pi.ID, err))
|
||||
} else {
|
||||
logger.Info().Msg(fmt.Sprintf("Connected to MAIN bootstrap peer %s", pi.ID))
|
||||
}
|
||||
|
||||
ps, err := pubsub.NewGossipSub(context.Background(), h,
|
||||
pubsub.WithMessageSigning(true),
|
||||
|
||||
Reference in New Issue
Block a user