ipfsd-ctl
0.25.0

Intro

Installable via npm install --save ipfsd-ctl, it can also be used directly in the browser.

Download

The source is available for download from GitHub. Alternatively, you can install using npm:

$ npm install --save ipfsd-ctl

You can then require() ipfsd-ctl as normal:

const ipfsdCtl = require('ipfsd-ctl')

In the Browser

Ipfsd-ctl should work in any ES2015 environment out of the box.

Usage:

<script type="text/javascript" src="index.js"></script>

The portable versions of ipfsd-ctl, including index.js and index.min.js, are included in the /dist folder. Ipfsd-ctl can also be found on unkpkg.com under

Node

Controll a go-ipfs node.

Parameters

  1. path: any:  
  2. opts: any:  
  3. disposable: any:  

instance

Node.prototype.apiAddr

apiAddr

Get the address of connected IPFS API.

Returns

Multiaddr

Node.prototype.gatewayAddr

gatewayAddr

Get the address of connected IPFS HTTP Gateway.

Returns

Multiaddr

Node.prototype.init

init(initOpts: Object, callback: function (Error, Node)): undefined

Initialize a repo.

Parameters

  1. initOpts: Object (={}):  
  2. initOpts.keysize: number (=2048):  
    The bit size of the identiy key.
  3. initOpts.directory: string (=IPFS_PATH):  
    The location of the repo.
  4. callback: function (Error, Node):  

Returns

Node.prototype.shutdown

shutdown(callback: function (Error)): undefined

Delete the repo that was being used. If the node was marked as disposable this will be called automatically when the process is exited.

Parameters

  1. callback: function (Error):  

Returns

Node.prototype.startDaemon

startDaemon(flags: Array<string>, callback: function (Error, IpfsApi)): undefined

Start the daemon.

Parameters

  1. flags: Array<string> (=[]):  
    Flags to be passed to the ipfs daemon command.
  2. callback: function (Error, IpfsApi):  

Returns

Node.prototype.stopDaemon

stopDaemon(callback: function (Error)): undefined

Stop the daemon.

Parameters

  1. callback: function (Error):  

Returns

Node.prototype.killProcess

killProcess(callback: function ()): undefined

Kill the ipfs daemon process.

First SIGTERM is sent, after 7.5 seconds SIGKILL is sent if the process hasn't exited yet.

Parameters

  1. callback: function ():  
    Called when the process was killed.

Returns

Node.prototype.daemonPid

daemonPid(): number

Get the pid of the ipfs daemon process.

Returns

Node.prototype.getConfig

getConfig(key: string?, callback: function (Error, (Object | string))): undefined

Call ipfs config

If no key is passed, the whole config is returned as an object.

Parameters

  1. key: string?:  
    A specific config to retrieve.
  2. callback: function (Error, (Object | string)):  

Returns

Node.prototype.setConfig

setConfig(key: string, value: string, callback: function (Error)): undefined

Set a config value.

Parameters

  1. key: string:  
  2. value: string:  
  3. callback: function (Error):  

Returns

Node.prototype.replaceConf

replaceConf(file: string, callback: function (Error)): undefined

Replace the configuration with a given file

Parameters

  1. file: string:  
    path to the new config file
  2. callback: function (Error):  

Returns

Node.prototype.version

version(callback: function (Error, string)): undefined

Get the version of ipfs

Parameters

  1. callback: function (Error, string):  

Returns

IpfsDaemonController

Control go-ipfs nodes directly from JavaScript.

static

IpfsDaemonController.version

version(callback: function (Error, string)): undefined

Get the version of the currently used go-ipfs binary.

Parameters

  1. callback: function (Error, string):  

Returns

IpfsDaemonController.local

local(path: string?, opts: Object, callback: function (Error, Node)): undefined

Create a new local node.

Parameters

  1. path: string?:  
    Location of the repo. Defaults to $IPFS_PATH , or $HOME/.ipfs , or $USER_PROFILE/.ipfs .
  2. opts: Object (={}):  
  3. callback: function (Error, Node):  

Returns

IpfsDaemonController.disposable

disposable(opts: Object, callback: function (Error, Node)): undefined

Create a new disposable node. This means the repo is created in a temporary location and cleaned up on process exit.

Parameters

  1. opts: Object (={}):  
  2. callback: function (Error, Node):  

Returns

IpfsDaemonController.disposableApi

disposableApi(opts: Object, callback: function (Error, Node)): undefined

Create a new disposable node and already started the daemon.

Parameters

  1. opts: Object (={}):  
  2. callback: function (Error, Node):  

Returns