conf.GetConfig().BootstrapAddress
This commit is contained in:
@@ -3,10 +3,11 @@ package conf
|
|||||||
import "sync"
|
import "sync"
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
PublicKeyPath string
|
PublicKeyPath string
|
||||||
PrivateKeyPath string
|
PrivateKeyPath string
|
||||||
DHTEndpointPort int64
|
DHTEndpointPort int64
|
||||||
PSKPath string
|
PSKPath string
|
||||||
|
BootstrapAddress string
|
||||||
}
|
}
|
||||||
|
|
||||||
var instance *Config
|
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/beego/beego/v2/server/web/filter/cors"
|
||||||
"github.com/libp2p/go-libp2p"
|
"github.com/libp2p/go-libp2p"
|
||||||
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
||||||
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
)
|
)
|
||||||
|
|
||||||
const appname = "oc-catalog"
|
const appname = "oc-catalog"
|
||||||
@@ -37,6 +38,7 @@ func main() {
|
|||||||
conf.GetConfig().DHTEndpointPort = o.GetInt64Default("DHT_ENDPOINT_PORT", 4002)
|
conf.GetConfig().DHTEndpointPort = o.GetInt64Default("DHT_ENDPOINT_PORT", 4002)
|
||||||
conf.GetConfig().PublicKeyPath = o.GetStringDefault("CATALOG_PUBLIC_KEY_PATH", "./pem/public.pem")
|
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().PrivateKeyPath = o.GetStringDefault("CATALOG_PRIVATE_KEY_PATH", "./pem/private.pem")
|
||||||
|
conf.GetConfig().BootstrapAddress = o.GetStringDefault("BOOTSTRAP_ADDRESS", "")
|
||||||
// Beego initialization
|
// Beego initialization
|
||||||
beego.BConfig.AppName = appname
|
beego.BConfig.AppName = appname
|
||||||
beego.BConfig.Listen.HTTPPort = o.GetIntDefault("port", 8080)
|
beego.BConfig.Listen.HTTPPort = o.GetIntDefault("port", 8080)
|
||||||
@@ -76,6 +78,16 @@ func InitDTH() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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,
|
ps, err := pubsub.NewGossipSub(context.Background(), h,
|
||||||
pubsub.WithMessageSigning(true),
|
pubsub.WithMessageSigning(true),
|
||||||
|
|||||||
Reference in New Issue
Block a user