mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-01 10:49:24 +08:00
feat(daemon) learns --routing=supernode
This commit is contained in:
@ -18,12 +18,13 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
initOptionKwd = "init"
|
||||
gcrKwd = "gcr"
|
||||
mountKwd = "mount"
|
||||
writableKwd = "writable"
|
||||
ipfsMountKwd = "mount-ipfs"
|
||||
ipnsMountKwd = "mount-ipns"
|
||||
initOptionKwd = "init"
|
||||
routingOptionKwd = "routing"
|
||||
routingOptionSupernodeKwd = "supernode"
|
||||
mountKwd = "mount"
|
||||
writableKwd = "writable"
|
||||
ipfsMountKwd = "mount-ipfs"
|
||||
ipnsMountKwd = "mount-ipns"
|
||||
// apiAddrKwd = "address-api"
|
||||
// swarmAddrKwd = "address-swarm"
|
||||
)
|
||||
@ -42,7 +43,7 @@ the daemon.
|
||||
|
||||
Options: []cmds.Option{
|
||||
cmds.BoolOption(initOptionKwd, "Initialize IPFS with default settings if not already initialized"),
|
||||
cmds.BoolOption(gcrKwd, "Enables Grandcentral Routing"),
|
||||
cmds.StringOption(routingOptionKwd, "Overrides the routing option (dht, supernode)"),
|
||||
cmds.BoolOption(mountKwd, "Mounts IPFS to the filesystem"),
|
||||
cmds.BoolOption(writableKwd, "Enable writing objects (with POST, PUT and DELETE)"),
|
||||
cmds.StringOption(ipfsMountKwd, "Path to the mountpoint for IPFS (if using --mount)"),
|
||||
@ -107,12 +108,12 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
|
||||
nb := core.NewNodeBuilder().Online()
|
||||
nb.SetRepo(repo)
|
||||
|
||||
useGCR, _, err := req.Option(gcrKwd).Bool()
|
||||
routingOption, _, err := req.Option(routingOptionKwd).String()
|
||||
if err != nil {
|
||||
res.SetError(err, cmds.ErrNormal)
|
||||
return
|
||||
}
|
||||
if useGCR {
|
||||
if routingOption == routingOptionSupernodeKwd {
|
||||
servers, err := repo.Config().GCR.ServerIPFSAddrs()
|
||||
if err != nil {
|
||||
res.SetError(err, cmds.ErrNormal)
|
||||
|
Reference in New Issue
Block a user