mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-23 19:37:46 +08:00
core: Don't require address for node initialization
This commit is contained in:
parent
7b32c11347
commit
b63e10f3b5
14
core/core.go
14
core/core.go
@ -122,9 +122,15 @@ func initIdentity(cfg *config.Config) (*peer.Peer, error) {
|
||||
return nil, errors.New("No peer ID in config! (was ipfs init run?)")
|
||||
}
|
||||
|
||||
maddr, err := ma.NewMultiaddr(cfg.Identity.Address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
// address is optional
|
||||
var addresses []*ma.Multiaddr
|
||||
if len(cfg.Identity.Address) > 0 {
|
||||
maddr, err := ma.NewMultiaddr(cfg.Identity.Address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
addresses = []*ma.Multiaddr{ maddr }
|
||||
}
|
||||
|
||||
skb, err := base64.StdEncoding.DecodeString(cfg.Identity.PrivKey)
|
||||
@ -139,7 +145,7 @@ func initIdentity(cfg *config.Config) (*peer.Peer, error) {
|
||||
|
||||
return &peer.Peer{
|
||||
ID: peer.ID(b58.Decode(cfg.Identity.PeerID)),
|
||||
Addresses: []*ma.Multiaddr{maddr},
|
||||
Addresses: addresses,
|
||||
PrivKey: sk,
|
||||
PubKey: sk.GetPublic(),
|
||||
}, nil
|
||||
|
||||
Loading…
Reference in New Issue
Block a user