mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
go-ipfs-config: bootstrap: use ipfsaddr for boostrap peers ⚠️
⚠️ this commit makes your current configs unusable, as the
default bootstrap peers. You may need to edit your config.
Go from:
```js
Bootstrap: [
{
"Address": "/ip4/104.131.131.82/tcp/4001",
"PeerID": "QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"
}
]
```
To:
```js
Bootstrap: [
"/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"
]
```
This commit is contained in:
parent
cf854f9a20
commit
9adf5bc2bf
@ -1,12 +1,9 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
|
||||
mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
|
||||
|
||||
errors "github.com/jbenet/go-ipfs/util/debugerror"
|
||||
|
||||
iaddr "github.com/jbenet/go-ipfs/util/ipfsaddr"
|
||||
)
|
||||
|
||||
// DefaultBootstrapAddresses are the hardcoded bootstrap addresses
|
||||
@ -16,21 +13,25 @@ import (
|
||||
// Note: this is here -- and not inside cmd/ipfs/init.go -- because of an
|
||||
// import dependency issue. TODO: move this into a config/default/ package.
|
||||
var DefaultBootstrapAddresses = []string{
|
||||
"/ip4/104.131.131.82/tcp/4001/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io
|
||||
"/ip4/104.236.176.52/tcp/4001/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z", // neptune (to be neptune.i.ipfs.io)
|
||||
"/ip4/104.236.179.241/tcp/4001/QmSoLpPVmHKQ4XTPdz8tjDFgdeRFkpV8JgYq8JVJ69RrZm", // pluto (to be pluto.i.ipfs.io)
|
||||
"/ip4/162.243.248.213/tcp/4001/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm", // uranus (to be uranus.i.ipfs.io)
|
||||
"/ip4/128.199.219.111/tcp/4001/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn (to be saturn.i.ipfs.io)
|
||||
"/ip4/104.236.76.40/tcp/4001/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus (to be venus.i.ipfs.io)
|
||||
"/ip4/178.62.158.247/tcp/4001/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth (to be earth.i.ipfs.io)
|
||||
"/ip4/178.62.61.185/tcp/4001/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3", // mercury (to be mercury.i.ipfs.io)
|
||||
"/ip4/104.236.151.122/tcp/4001/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx", // jupiter (to be jupiter.i.ipfs.io)
|
||||
"/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io
|
||||
"/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z", // neptune (to be neptune.i.ipfs.io)
|
||||
"/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLpPVmHKQ4XTPdz8tjDFgdeRFkpV8JgYq8JVJ69RrZm", // pluto (to be pluto.i.ipfs.io)
|
||||
"/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm", // uranus (to be uranus.i.ipfs.io)
|
||||
"/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn (to be saturn.i.ipfs.io)
|
||||
"/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus (to be venus.i.ipfs.io)
|
||||
"/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth (to be earth.i.ipfs.io)
|
||||
"/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3", // mercury (to be mercury.i.ipfs.io)
|
||||
"/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx", // jupiter (to be jupiter.i.ipfs.io)
|
||||
}
|
||||
|
||||
// BootstrapPeer is a peer used to bootstrap the network.
|
||||
type BootstrapPeer struct {
|
||||
Address string
|
||||
PeerID string // until multiaddr supports ipfs, use another field.
|
||||
type BootstrapPeer iaddr.IPFSAddr
|
||||
|
||||
// ErrInvalidPeerAddr signals an address is not a valid peer address.
|
||||
var ErrInvalidPeerAddr = errors.New("invalid peer address")
|
||||
|
||||
func (c *Config) BootstrapPeers() ([]BootstrapPeer, error) {
|
||||
return ParseBootstrapPeers(c.Bootstrap)
|
||||
}
|
||||
|
||||
// DefaultBootstrapPeers returns the (parsed) set of default bootstrap peers.
|
||||
@ -45,39 +46,16 @@ This is a problem with the ipfs codebase. Please report it to the dev team.`, er
|
||||
return ps, nil
|
||||
}
|
||||
|
||||
func (bp *BootstrapPeer) String() string {
|
||||
return bp.Address + "/" + bp.PeerID
|
||||
func (c *Config) SetBootstrapPeers(bps []BootstrapPeer) {
|
||||
c.Bootstrap = BootstrapPeerStrings(bps)
|
||||
}
|
||||
|
||||
func ParseBootstrapPeer(addr string) (BootstrapPeer, error) {
|
||||
// to be replaced with just multiaddr parsing, once ptp is a multiaddr protocol
|
||||
idx := strings.LastIndex(addr, "/")
|
||||
if idx == -1 {
|
||||
return BootstrapPeer{}, errors.New("invalid address")
|
||||
}
|
||||
addrS := addr[:idx]
|
||||
peeridS := addr[idx+1:]
|
||||
|
||||
// make sure addrS parses as a multiaddr.
|
||||
if len(addrS) > 0 {
|
||||
maddr, err := ma.NewMultiaddr(addrS)
|
||||
if err != nil {
|
||||
return BootstrapPeer{}, err
|
||||
}
|
||||
|
||||
addrS = maddr.String()
|
||||
}
|
||||
|
||||
// make sure idS parses as a peer.ID
|
||||
_, err := mh.FromB58String(peeridS)
|
||||
ia, err := iaddr.ParseString(addr)
|
||||
if err != nil {
|
||||
return BootstrapPeer{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return BootstrapPeer{
|
||||
Address: addrS,
|
||||
PeerID: peeridS,
|
||||
}, nil
|
||||
return BootstrapPeer(ia), err
|
||||
}
|
||||
|
||||
func ParseBootstrapPeers(addrs []string) ([]BootstrapPeer, error) {
|
||||
@ -91,3 +69,11 @@ func ParseBootstrapPeers(addrs []string) ([]BootstrapPeer, error) {
|
||||
}
|
||||
return peers, nil
|
||||
}
|
||||
|
||||
func BootstrapPeerStrings(bps []BootstrapPeer) []string {
|
||||
bpss := make([]string, len(bps))
|
||||
for i, p := range bps {
|
||||
bpss[i] = p.String()
|
||||
}
|
||||
return bpss
|
||||
}
|
||||
|
||||
@ -16,14 +16,14 @@ var log = u.Logger("config")
|
||||
|
||||
// Config is used to load IPFS config files.
|
||||
type Config struct {
|
||||
Identity Identity // local node's peer identity
|
||||
Datastore Datastore // local node's storage
|
||||
Addresses Addresses // local node's addresses
|
||||
Mounts Mounts // local node's mount points
|
||||
Version Version // local node's version management
|
||||
Bootstrap []BootstrapPeer // local nodes's bootstrap peers
|
||||
Tour Tour // local node's tour position
|
||||
Gateway Gateway // local node's gateway server options
|
||||
Identity Identity // local node's peer identity
|
||||
Datastore Datastore // local node's storage
|
||||
Addresses Addresses // local node's addresses
|
||||
Mounts Mounts // local node's mount points
|
||||
Version Version // local node's version management
|
||||
Bootstrap []string // local nodes's bootstrap peer addresses
|
||||
Tour Tour // local node's tour position
|
||||
Gateway Gateway // local node's gateway server options
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
@ -38,7 +38,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
|
||||
API: "/ip4/127.0.0.1/tcp/5001",
|
||||
},
|
||||
|
||||
Bootstrap: bootstrapPeers,
|
||||
Bootstrap: BootstrapPeerStrings(bootstrapPeers),
|
||||
Datastore: *ds,
|
||||
Identity: identity,
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user