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