conf.GetConfig().BootstrapAddress

This commit is contained in:
mr
2026-01-27 16:23:28 +01:00
parent f7f9d722bd
commit cdbf83ee8b
3 changed files with 16 additions and 0 deletions

View File

@@ -9,6 +9,8 @@ type Config struct {
PublicKeyPath string PublicKeyPath string
PrivateKeyPath string PrivateKeyPath string
DHTEndpointPort int64 DHTEndpointPort int64
BootstrapAddress string
} }
var instance *Config var instance *Config

View File

@@ -20,6 +20,7 @@ import (
dht "github.com/libp2p/go-libp2p-kad-dht" dht "github.com/libp2p/go-libp2p-kad-dht"
"github.com/libp2p/go-libp2p/core/crypto" "github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/host" "github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/peer"
) )
type DHTRecord struct { type DHTRecord struct {
@@ -78,6 +79,17 @@ func Init(ctx context.Context) (*DHTService, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
pi, err := peer.AddrInfoFromString(conf.GetConfig().BootstrapAddress)
if err != nil {
return nil, err
}
logger := oclib.GetLogger()
if err := h.Connect(ctx, *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))
}
singletonService = service singletonService = service
if VerifyPubWithPriv() { if VerifyPubWithPriv() {
if _, err := singletonService.ClaimName(context.Background(), if _, err := singletonService.ClaimName(context.Background(),

View File

@@ -35,6 +35,8 @@ func main() {
conf.GetConfig().PublicKeyPath = o.GetStringDefault("PEER_PUBLIC_KEY_PATH", "./pem/public.pem") conf.GetConfig().PublicKeyPath = o.GetStringDefault("PEER_PUBLIC_KEY_PATH", "./pem/public.pem")
conf.GetConfig().PrivateKeyPath = o.GetStringDefault("PEER_PRIVATE_KEY_PATH", "./pem/private.pem") conf.GetConfig().PrivateKeyPath = o.GetStringDefault("PEER_PRIVATE_KEY_PATH", "./pem/private.pem")
conf.GetConfig().DHTEndpointPort = o.GetInt64Default("DHT_ENDPOINT_PORT", 4001) conf.GetConfig().DHTEndpointPort = o.GetInt64Default("DHT_ENDPOINT_PORT", 4001)
conf.GetConfig().BootstrapAddress = o.GetStringDefault("BOOTSTRAP_ADDRESS", "")
// Beego init // Beego init
beego.BConfig.AppName = appname beego.BConfig.AppName = appname
beego.BConfig.Listen.HTTPPort = o.GetIntDefault("port", 8080) beego.BConfig.Listen.HTTPPort = o.GetIntDefault("port", 8080)