mirror of
https://github.com/ipfs/kubo.git
synced 2025-05-21 00:47:22 +08:00
bootstrap add --default option
This commit is contained in:
@ -63,8 +63,13 @@ in the bootstrap list).
|
|||||||
},
|
},
|
||||||
|
|
||||||
Arguments: []cmds.Argument{
|
Arguments: []cmds.Argument{
|
||||||
cmds.StringArg("peer", true, true, peerOptionDesc),
|
cmds.StringArg("peer", false, true, peerOptionDesc),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Options: []cmds.Option{
|
||||||
|
cmds.BoolOption("default", "add default bootstrap nodes"),
|
||||||
|
},
|
||||||
|
|
||||||
Run: func(req cmds.Request) (interface{}, error) {
|
Run: func(req cmds.Request) (interface{}, error) {
|
||||||
inputPeers, err := config.ParseBootstrapPeers(req.Arguments())
|
inputPeers, err := config.ParseBootstrapPeers(req.Arguments())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -81,11 +86,30 @@ in the bootstrap list).
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deflt, _, err := req.Option("default").Bool()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if deflt {
|
||||||
|
// parse separately for meaningful, correct error.
|
||||||
|
defltPeers, err := DefaultBootstrapPeers()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
inputPeers = append(inputPeers, defltPeers...)
|
||||||
|
}
|
||||||
|
|
||||||
added, err := bootstrapAdd(filename, cfg, inputPeers)
|
added, err := bootstrapAdd(filename, cfg, inputPeers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(inputPeers) == 0 {
|
||||||
|
return nil, cmds.ClientError("no bootstrap peers to add")
|
||||||
|
}
|
||||||
|
|
||||||
return &BootstrapOutput{added}, nil
|
return &BootstrapOutput{added}, nil
|
||||||
},
|
},
|
||||||
Type: &BootstrapOutput{},
|
Type: &BootstrapOutput{},
|
||||||
|
Reference in New Issue
Block a user