ipfs 状态查看,修改配置文件,修改API

1,ipfs 状态

  • ipfs stats repo 仓库状态
  • ipfs stats bw网络状态
$ ipfs stats repo
NumObjects: 145
RepoSize:   689856
StorageMax: 10000000000
RepoPath:   /Users/y50/.ipfs
Version:    fs-repo@7
$ ipfs stats bw
Bandwidth
TotalIn: 23 MB
TotalOut: 14 MB
RateIn: 3.4 kB/s
RateOut: 3.0 kB/s
  • ipfs bootstrap信任引导节点
$ ipfs bootstrap list
  • ipfs swarm peers连接节点
$ ipfs swarm peers
  • ipfs dht findpeer查看其它节点的信息
$ ipfs dht findpeer QmQamgdAXCCf6xxHUMRZCgv8qJJdrtXWCzfxTL1JdNe3xh
/ip4/192.168.1.7/tcp/4001
/ip4/192.168.122.1/tcp/4001
/ip6/::1/tcp/4001
/ip6/240e:fa:c676:2b00:21c:42ff:fe25:db22/tcp/4001
/ip4/113.104.227.178/tcp/9407
/ip4/127.0.0.1/tcp/4001

2,修改配置文件

  • ipfs config show显示配置信息
  • "StorageMax": "10GB"存储空间
$ ipfs config show
  • 修改配置,EDITOR设置编辑器
$ which vim
/usr/bin/vim
$ export EDITOR=/usr/bin/vim
$ ipfs config edit
  • 或者添加到环境变量里
# vim .bashrc
export EDITOR=/usr/bin/vim

# source .bashrc
# echo $EDITOR
/usr/bin/vim

3,修改API

  • API 查看
$ ipfs config Addresses.API
/ip4/127.0.0.1/tcp/5001
$ ipfs config Addresses
{
  "API": "/ip4/127.0.0.1/tcp/5001",
  "Announce": [],
  "Gateway": "/ip4/127.0.0.1/tcp/8080",
  "NoAnnounce": [],
  "Swarm": [
    "/ip4/0.0.0.0/tcp/4001",
    "/ip6/::/tcp/4001"
  ]
}
  • Addresses.API 修改
$ ipfs config Addresses.API
/ip4/127.0.0.1/tcp/5001
[y50@192 ~]$ ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
  • Gateway修改
$ ipfs config Addresses.Gateway
/ip4/127.0.0.1/tcp/8080
[y50@192 ~]$ ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
[y50@192 ~]$ ipfs config Addresses.Gateway
/ip4/0.0.0.0/tcp/8080

4,配置CORS

  • API.HTTPHeaders查看
$ ipfs config --json API.HTTPHeaders
{}
  • API.HTTPHeaders修改配置
$ ipfs config show
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST", "OPTIONS"]'
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials '["true"]'
$ ipfs config show
$ ipfs config --json API.HTTPHeaders
{
  "Access-Control-Allow-Credentials": [
    "true"
  ],
  "Access-Control-Allow-Methods": [
    "PUT",
    "GET",
    "POST",
    "OPTIONS"
  ],
  "Access-Control-Allow-Origin": [
    "*"
  ]
}

参考:

  1. 星际文件系统 CORS
  2. 修改配置 ipfs
  3. ipfs - 命令行简介

你可能感兴趣的:(IPFS)