├── assets
├── init-doc
│ ├── ping
│ ├── docs
│ │ └── index
│ ├── contact
│ ├── help
│ ├── readme
│ └── security-notes
├── README.md
└── assets_test.go
├── core
├── .gitignore
├── coreunix
│ ├── test
│ │ └── data
│ │ │ ├── colors
│ │ │ └── orange
│ │ │ ├── corps
│ │ │ └── apple
│ │ │ └── fruits
│ │ │ ├── apple
│ │ │ └── orange
│ └── metadata.go
├── coreapi
│ └── interface
│ │ ├── errors.go
│ │ ├── util.go
│ │ ├── block.go
│ │ ├── dht.go
│ │ ├── unixfs.go
│ │ ├── dag.go
│ │ ├── key.go
│ │ ├── options
│ │ ├── global.go
│ │ ├── pubsub.go
│ │ └── dht.go
│ │ ├── pubsub.go
│ │ ├── name.go
│ │ ├── pin.go
│ │ ├── coreapi.go
│ │ └── swarm.go
├── commands
│ ├── diag.go
│ ├── root_test.go
│ ├── cmdenv
│ │ └── file.go
│ ├── mount_windows.go
│ ├── e
│ │ └── error.go
│ ├── mount_nofuse.go
│ ├── dht_test.go
│ ├── shutdown.go
│ ├── unixfs
│ │ └── unixfs.go
│ └── helptext_test.go
├── corehttp
│ ├── redirect.go
│ ├── webui.go
│ ├── ipns_hostname.go
│ ├── mutex_profile.go
│ ├── logs.go
│ ├── gateway_indexPage.go
│ └── metrics_test.go
├── coredag
│ ├── cbor.go
│ ├── raw.go
│ └── dagpb.go
├── pathresolver_test.go
└── bootstrap_test.go
├── cmd
├── seccat
│ ├── .gitignore
│ └── util.go
├── ipfs
│ ├── .gitignore
│ ├── util
│ │ ├── ulimit_windows.go
│ │ ├── signal_wasm.go
│ │ ├── ulimit_unix.go
│ │ └── ulimit_freebsd.go
│ ├── dist
│ │ ├── README.md
│ │ ├── install.sh
│ │ └── LICENSE
│ └── runmain_test.go
└── ipfswatch
│ ├── README.md
│ └── ipfswatch_test.go
├── test
├── 3nodetest
│ ├── build
│ │ ├── .gitkeep
│ │ └── .gitignore
│ ├── bin
│ │ ├── .gitignore
│ │ ├── clean.sh
│ │ ├── save_logs.sh
│ │ └── save_profiling_data.sh
│ ├── data
│ │ ├── .gitignore
│ │ └── Dockerfile
│ ├── bootstrap
│ │ ├── README.md
│ │ ├── Dockerfile
│ │ └── config
│ ├── server
│ │ ├── README.md
│ │ ├── Dockerfile
│ │ ├── run.sh
│ │ └── config
│ ├── README.md
│ ├── client
│ │ ├── Dockerfile
│ │ ├── run.sh
│ │ └── config
│ ├── fig.yml
│ ├── Makefile
│ └── run-test-on-img.sh
├── .gitignore
├── dependencies
│ ├── go-sleep
│ │ ├── .gitignore
│ │ ├── README.md
│ │ ├── go-sleep.go
│ │ └── LICENSE
│ ├── go-timeout
│ │ ├── .gitignore
│ │ ├── LICENSE
│ │ └── main.go
│ ├── Makefile
│ ├── iptb
│ │ └── iptb.go
│ └── ma-pipe-unidir
│ │ └── LICENSE
├── sharness
│ ├── t0110-gateway-data
│ │ ├── foo.block
│ │ └── foofoo.block
│ ├── t0060-data
│ │ └── mss-ls
│ ├── t0275-cid-security-data
│ │ ├── AFKSEBCGPUJZE.data
│ │ └── CIQG6PGTD2VV34S33BE4MNCQITBRFYUPYQLDXYARR3DQW37MOT7K5XI.data
│ ├── t0051-object-data
│ │ ├── testPut.pb
│ │ ├── testPut.json
│ │ ├── testPut.xml
│ │ ├── expected_getOut
│ │ ├── brokenPut.xml
│ │ ├── brokenPut.json
│ │ └── UTF-8-test.txt
│ ├── .gitignore
│ ├── t0053-dag-data
│ │ └── non-canon.cbor
│ ├── t0280-plugin-git-data
│ │ └── git.tar.gz
│ ├── Makefile
│ ├── lib
│ │ ├── gen-junit-report.sh
│ │ ├── test-lib-hashes.sh
│ │ ├── test-aggregate-results.sh
│ │ └── iptb-lib.sh
│ ├── t0018-indent.sh
│ ├── t0025-datastores.sh
│ ├── t0410-api-add.sh
│ ├── t0070-user-config.sh
│ ├── t0024-files
│ │ ├── spec-newshardfun
│ │ └── spec-nosync
│ ├── t0088-repo-stat-symlink.sh
│ ├── t0024-datastore-config.sh
│ ├── x0601-pin-fail-test.sh
│ ├── t0023-shutdown.sh
│ ├── t0150-clisuggest.sh
│ ├── t0231-channel-streaming.sh
│ ├── t0400-api-security.sh
│ ├── t0151-sysdiag.sh
│ ├── t0251-files-flushing.sh
│ ├── t0101-iptb-name.sh
│ ├── t0210-tar.sh
│ ├── t0065-active-requests.sh
│ ├── t0041-ping.sh
│ ├── t0500-issues-and-regressions-offline.sh
│ ├── t0063-external.sh
│ ├── t0236-cli-api-dns-resolve.sh
│ ├── t0022-init-default.sh
│ ├── t0190-quic-ping.sh
│ ├── t0086-repo-verify.sh
│ ├── t0280-plugin-git.sh
│ ├── t0063-daemon-init.sh
│ ├── t0084-repo-read-rehash.sh
│ ├── t0235-cli-request.sh
│ ├── t0066-migration.sh
│ ├── t0031-mount-publish.sh
│ └── t0061-daemon-opts.sh
├── unit
│ ├── .gitignore
│ └── Rules.mk
├── Rules.mk
├── bin
│ ├── .gitignore
│ ├── continueyn
│ ├── verify-go-fmt.sh
│ ├── checkflags
│ └── Rules.mk
├── api-startup
│ └── main.go
├── integration
│ └── Makefile
└── README.md
├── plugin
├── plugins
│ ├── .gitignore
│ ├── gen_main.sh
│ └── Rules.mk
├── Rules.mk
├── loader
│ ├── Rules.mk
│ ├── preload_list
│ ├── preload.sh
│ ├── preload.go
│ └── load_linux.go
├── plugin.go
├── tracer.go
├── datastore.go
└── ipld.go
├── coverage
└── .gitignore
├── .gx
└── lastpubver
├── mk
├── git.mk
├── footer.mk
├── header.mk
├── tarball.mk
├── gx.mk
└── util.mk
├── .gitattributes
├── docs
├── cli-http-api-core-diagram.png
├── generate-authors.sh
├── transports.md
├── openbsd.md
├── command-completion.md
├── README.md
└── developer-certificate-of-origin
├── CODEOWNERS
├── filestore
└── pb
│ ├── Rules.mk
│ └── dataobj.proto
├── misc
└── launchd
│ ├── README.md
│ ├── io.ipfs.ipfs-daemon.plist
│ └── install.sh
├── pin
└── internal
│ └── pb
│ ├── Rules.mk
│ ├── doc.go
│ └── header.proto
├── Makefile
├── thirdparty
├── README.md
├── math2
│ └── math2.go
├── unit
│ ├── unit_test.go
│ └── unit.go
├── assert
│ └── assert.go
└── dir
│ └── dir.go
├── .dockerignore
├── fuse
├── readonly
│ ├── doc.go
│ └── mount_unix.go
├── node
│ ├── mount_windows.go
│ └── mount_nofuse.go
└── ipns
│ ├── link_unix.go
│ ├── mount_unix.go
│ └── common.go
├── .gitignore
├── bin
├── test-go-fmt
├── mkreleaselog
├── check_go_path
├── maketarball.sh
├── Rules.mk
├── graphmd
├── ipns-republish
├── gencmdref
├── check_go_version
├── check_gx_program
└── container_daemon
├── codecov.yml
├── version.go
├── .travis.yml
├── CONTRIBUTING.md
├── repo
├── fsrepo
│ ├── doc.go
│ ├── misc.go
│ └── migrations
│ │ ├── mfsr_test.go
│ │ └── mfsr.go
├── onlyone.go
├── common
│ └── common.go
├── mock.go
└── repo.go
├── doc.go
├── .codeclimate.yml
├── LICENSE
├── namesys
├── cache.go
├── proquint.go
└── opts
│ └── opts.go
├── ci
└── Dockerfile.buildenv
├── appveyor.yml
├── p2p
└── p2p.go
└── keystore
└── memkeystore.go
/assets/init-doc/ping:
--------------------------------------------------------------------------------
1 | ipfs
--------------------------------------------------------------------------------
/core/.gitignore:
--------------------------------------------------------------------------------
1 | .testdb
2 |
--------------------------------------------------------------------------------
/cmd/seccat/.gitignore:
--------------------------------------------------------------------------------
1 | seccat
2 |
--------------------------------------------------------------------------------
/test/3nodetest/build/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/init-doc/docs/index:
--------------------------------------------------------------------------------
1 | Index
2 |
--------------------------------------------------------------------------------
/test/.gitignore:
--------------------------------------------------------------------------------
1 | IPFS-BUILD-OPTIONS
2 |
--------------------------------------------------------------------------------
/test/3nodetest/bin/.gitignore:
--------------------------------------------------------------------------------
1 | random
2 |
--------------------------------------------------------------------------------
/test/3nodetest/data/.gitignore:
--------------------------------------------------------------------------------
1 | file*
2 |
--------------------------------------------------------------------------------
/core/coreunix/test/data/colors/orange:
--------------------------------------------------------------------------------
1 | orange
2 |
--------------------------------------------------------------------------------
/core/coreunix/test/data/corps/apple:
--------------------------------------------------------------------------------
1 | apple
2 |
--------------------------------------------------------------------------------
/core/coreunix/test/data/fruits/apple:
--------------------------------------------------------------------------------
1 | apple
2 |
--------------------------------------------------------------------------------
/core/coreunix/test/data/fruits/orange:
--------------------------------------------------------------------------------
1 | orange
2 |
--------------------------------------------------------------------------------
/plugin/plugins/.gitignore:
--------------------------------------------------------------------------------
1 | *.so
2 | */main
3 |
--------------------------------------------------------------------------------
/test/dependencies/go-sleep/.gitignore:
--------------------------------------------------------------------------------
1 | go-sleep
2 |
--------------------------------------------------------------------------------
/test/dependencies/go-timeout/.gitignore:
--------------------------------------------------------------------------------
1 | go-timeout
2 |
--------------------------------------------------------------------------------
/test/sharness/t0110-gateway-data/foo.block:
--------------------------------------------------------------------------------
1 |
2 | foo
--------------------------------------------------------------------------------
/test/unit/.gitignore:
--------------------------------------------------------------------------------
1 | gotest.json
2 | gotest.junit.xml
3 |
--------------------------------------------------------------------------------
/cmd/ipfs/.gitignore:
--------------------------------------------------------------------------------
1 | ipfs
2 | ipfs-test-cover
3 | ipfs.exe
4 |
--------------------------------------------------------------------------------
/test/sharness/t0060-data/mss-ls:
--------------------------------------------------------------------------------
1 | /multistream/1.0.0
2 | ls
3 |
--------------------------------------------------------------------------------
/coverage/.gitignore:
--------------------------------------------------------------------------------
1 | unitcover
2 | sharnesscover
3 | ipfs
4 |
5 |
--------------------------------------------------------------------------------
/test/sharness/t0275-cid-security-data/AFKSEBCGPUJZE.data:
--------------------------------------------------------------------------------
1 | testing
2 |
--------------------------------------------------------------------------------
/.gx/lastpubver:
--------------------------------------------------------------------------------
1 | 0.4.18: QmUJYo4etAQqFfSS2rarFAE97eNGB8ej64YkRT2SmsYD4r
2 |
--------------------------------------------------------------------------------
/mk/git.mk:
--------------------------------------------------------------------------------
1 | git-hash:=$(shell git rev-parse --short HEAD 2>/dev/null)
2 |
--------------------------------------------------------------------------------
/test/3nodetest/build/.gitignore:
--------------------------------------------------------------------------------
1 | .built_img
2 | *.log
3 | profiling_data*
4 |
--------------------------------------------------------------------------------
/test/sharness/t0051-object-data/testPut.pb:
--------------------------------------------------------------------------------
1 |
2 | test json for sharness test
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | assets/init-doc/* binary
2 | core/coreunix/test_data/** binary
3 |
--------------------------------------------------------------------------------
/test/3nodetest/bin/clean.sh:
--------------------------------------------------------------------------------
1 | docker rm -f $( docker ps -q -a -f status=exited ) || true
2 |
--------------------------------------------------------------------------------
/test/sharness/.gitignore:
--------------------------------------------------------------------------------
1 | lib/sharness/
2 | test-results/
3 | trash directory.*.sh/
4 | plugins
5 |
--------------------------------------------------------------------------------
/test/sharness/t0051-object-data/testPut.json:
--------------------------------------------------------------------------------
1 | {
2 | "Data": "test json for sharness test"
3 | }
4 |
--------------------------------------------------------------------------------
/test/sharness/t0051-object-data/testPut.xml:
--------------------------------------------------------------------------------
1 | Test xml for sharness test
2 |
--------------------------------------------------------------------------------
/test/sharness/t0051-object-data/expected_getOut:
--------------------------------------------------------------------------------
1 | {"Links":[],"Data":"\u0008\u0002\u0012\nHello Mars\u0018\n"}
2 |
--------------------------------------------------------------------------------
/test/sharness/t0051-object-data/brokenPut.xml:
--------------------------------------------------------------------------------
1 | This is not a valid dag object fail
2 |
--------------------------------------------------------------------------------
/test/3nodetest/bootstrap/README.md:
--------------------------------------------------------------------------------
1 | this is a bootstrap peer with an empty bootstrap list
2 |
3 | it listens on 4011 and 4012
4 |
--------------------------------------------------------------------------------
/test/sharness/t0051-object-data/brokenPut.json:
--------------------------------------------------------------------------------
1 | {
2 | "this": "should",
3 | "return": "an",
4 | "error":"not valid dag object"
5 | }
--------------------------------------------------------------------------------
/docs/cli-http-api-core-diagram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinchengtsinghua/IPFS-Golang-China/HEAD/docs/cli-http-api-core-diagram.png
--------------------------------------------------------------------------------
/mk/footer.mk:
--------------------------------------------------------------------------------
1 | # standard NR-make boilerplate, to be included at the end of a file
2 | d := $(dirstack_$(sp))
3 | sp := $(basename $(sp))
4 |
--------------------------------------------------------------------------------
/test/3nodetest/data/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu
2 |
3 | ADD filetiny /data/filetiny
4 | ADD filerand /data/filerand
5 |
6 | VOLUME ["/data"]
7 |
--------------------------------------------------------------------------------
/test/sharness/t0053-dag-data/non-canon.cbor:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinchengtsinghua/IPFS-Golang-China/HEAD/test/sharness/t0053-dag-data/non-canon.cbor
--------------------------------------------------------------------------------
/test/sharness/t0051-object-data/UTF-8-test.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinchengtsinghua/IPFS-Golang-China/HEAD/test/sharness/t0051-object-data/UTF-8-test.txt
--------------------------------------------------------------------------------
/test/sharness/t0110-gateway-data/foofoo.block:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinchengtsinghua/IPFS-Golang-China/HEAD/test/sharness/t0110-gateway-data/foofoo.block
--------------------------------------------------------------------------------
/test/sharness/t0280-plugin-git-data/git.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinchengtsinghua/IPFS-Golang-China/HEAD/test/sharness/t0280-plugin-git-data/git.tar.gz
--------------------------------------------------------------------------------
/mk/header.mk:
--------------------------------------------------------------------------------
1 | # keep track of dirs
2 | # standard NR-make boilerplate, to be included at the beginning of a file
3 | p := $(sp).x
4 | dirstack_$(sp) := $(d)
5 | d := $(dir)
6 |
--------------------------------------------------------------------------------
/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # Please see https://help.github.com/articles/about-codeowners/ for more information
2 |
3 | # Global owner
4 | * @Kubuxu
5 |
6 | # Subsystem specific owners
7 |
8 |
9 |
--------------------------------------------------------------------------------
/plugin/Rules.mk:
--------------------------------------------------------------------------------
1 | include mk/header.mk
2 |
3 | dir := $(d)/loader
4 | include $(dir)/Rules.mk
5 |
6 | dir := $(d)/plugins
7 | include $(dir)/Rules.mk
8 |
9 | include mk/footer.mk
10 |
--------------------------------------------------------------------------------
/cmd/ipfswatch/README.md:
--------------------------------------------------------------------------------
1 | IPFSWatch monitors a directory and adds changes to IPFS
2 |
3 | ```
4 | λ. ipfswatch --help
5 | -path=".": the path to watch
6 | -repo="": IPFS_PATH to use
7 | ```
8 |
--------------------------------------------------------------------------------
/filestore/pb/Rules.mk:
--------------------------------------------------------------------------------
1 | include mk/header.mk
2 |
3 | PB_$(d) = $(wildcard $(d)/*.proto)
4 | TGTS_$(d) = $(PB_$(d):.proto=.pb.go)
5 |
6 | #DEPS_GO += $(TGTS_$(d))
7 |
8 | include mk/footer.mk
9 |
--------------------------------------------------------------------------------
/misc/launchd/README.md:
--------------------------------------------------------------------------------
1 | # ipfs launchd agent
2 |
3 | A bare-bones launchd agent file for ipfs. To have launchd automatically run the ipfs daemon for you, run `./misc/launchd/install.sh`
4 |
5 |
--------------------------------------------------------------------------------
/pin/internal/pb/Rules.mk:
--------------------------------------------------------------------------------
1 | include mk/header.mk
2 |
3 | PB_$(d) = $(wildcard $(d)/*.proto)
4 | TGTS_$(d) = $(PB_$(d):.proto=.pb.go)
5 |
6 | #DEPS_GO += $(TGTS_$(d))
7 |
8 | include mk/footer.mk
9 |
--------------------------------------------------------------------------------
/assets/init-doc/contact:
--------------------------------------------------------------------------------
1 | Come hang out in our IRC chat room if you have any questions.
2 |
3 | Contact the ipfs dev team:
4 | - Bugs: https://github.com/ipfs/go-ipfs/issues
5 | - Help: irc.freenode.org/#ipfs
6 | - Email: dev@ipfs.io
7 |
--------------------------------------------------------------------------------
/test/3nodetest/server/README.md:
--------------------------------------------------------------------------------
1 | **requirements**
2 |
3 | * docker container with bootstrap node linked as "bootstrap" with ID QmNXuBh8HFsWq68Fid8dMbGNQTh7eG6hV9rr1fQyfmfomE
4 | * file in data volume, internally mapped to /data/file
5 |
--------------------------------------------------------------------------------
/filestore/pb/dataobj.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package datastore.pb;
4 |
5 | message DataObj {
6 | optional string FilePath = 1;
7 | optional uint64 Offset = 2;
8 | optional uint64 Size = 3;
9 | }
10 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | # General tools
2 |
3 | SHELL=PATH='$(PATH)' /bin/sh
4 |
5 | PROTOC = protoc --gogofaster_out=. --proto_path=.:$(GOPATH)/src:$(dir $@) $<
6 |
7 | # enable second expansion
8 | .SECONDEXPANSION:
9 |
10 | include Rules.mk
11 |
--------------------------------------------------------------------------------
/test/Rules.mk:
--------------------------------------------------------------------------------
1 | include mk/header.mk
2 |
3 | dir := $(d)/bin
4 | include $(dir)/Rules.mk
5 |
6 | dir := $(d)/sharness
7 | include $(dir)/Rules.mk
8 |
9 | dir := $(d)/unit
10 | include $(dir)/Rules.mk
11 |
12 | include mk/footer.mk
13 |
--------------------------------------------------------------------------------
/test/3nodetest/README.md:
--------------------------------------------------------------------------------
1 | this is an ipfs integration test
2 |
3 | **requirements**
4 |
5 | * Docker
6 | * fig
7 | * Go
8 |
9 | * ipfs image named "zaqwsx_ipfs-test-img"
10 |
11 | ```
12 | make setup
13 | fig build
14 | fig up
15 | ```
16 |
--------------------------------------------------------------------------------
/test/sharness/Makefile:
--------------------------------------------------------------------------------
1 | # default target is to run all tests
2 | all: aggregate
3 |
4 | SH := $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
5 |
6 | .DEFAULT $(SH): ALWAYS
7 | $(MAKE) -C ../.. test/sharness/$@
8 |
9 | ALWAYS:
10 | .PHONY: ALWAYS
11 |
--------------------------------------------------------------------------------
/mk/tarball.mk:
--------------------------------------------------------------------------------
1 |
2 |
3 | ifeq (,$(wildcard .tarball))
4 | tarball-is:=0
5 | else
6 | tarball-is:=1
7 | # override git hash
8 | git-hash:=$(shell cat .tarball)
9 | endif
10 |
11 |
12 | go-ipfs-source.tar.gz: distclean
13 | bin/maketarball.sh $@
14 |
--------------------------------------------------------------------------------
/plugin/loader/Rules.mk:
--------------------------------------------------------------------------------
1 | include mk/header.mk
2 |
3 | $(d)/preload.go: d:=$(d)
4 | $(d)/preload.go: $(d)/preload_list $(d)/preload.sh
5 | $(d)/preload.sh > $@
6 | go fmt $@ >/dev/null
7 |
8 | DEPS_GO += $(d)/preload.go
9 |
10 | include mk/footer.mk
11 |
--------------------------------------------------------------------------------
/test/sharness/t0275-cid-security-data/CIQG6PGTD2VV34S33BE4MNCQITBRFYUPYQLDXYARR3DQW37MOT7K5XI.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinchengtsinghua/IPFS-Golang-China/HEAD/test/sharness/t0275-cid-security-data/CIQG6PGTD2VV34S33BE4MNCQITBRFYUPYQLDXYARR3DQW37MOT7K5XI.data
--------------------------------------------------------------------------------
/test/bin/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore everything in this directory by default
2 | /**
3 |
4 | # Do not ignore this file itself
5 | !.gitignore
6 |
7 | # Do not ignore the following special scripts
8 | !checkflags
9 | !continueyn
10 | !verify-go-fmt.sh
11 | !Rules.mk
12 |
--------------------------------------------------------------------------------
/test/sharness/lib/gen-junit-report.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | cat > test-results/sharness.xml <<-EOF
4 |
5 |
6 | $(find test-results -name '*.xml.part' | sort | xargs cat)
7 |
8 | EOF
9 |
--------------------------------------------------------------------------------
/test/3nodetest/bootstrap/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM zaqwsx_ipfs-test-img
2 |
3 | RUN ipfs init -b=1024
4 | ADD . /tmp/id
5 | RUN mv -f /tmp/id/config /root/.ipfs/config
6 | RUN ipfs id
7 |
8 | ENV IPFS_PROF true
9 | ENV IPFS_LOGGING_FMT nocolor
10 |
11 | EXPOSE 4011 4012/udp
12 |
--------------------------------------------------------------------------------
/thirdparty/README.md:
--------------------------------------------------------------------------------
1 | thirdparty consists of Golang packages that contain no go-ipfs dependencies and
2 | may be vendored ipfs/go-ipfs at a later date.
3 |
4 | packages in under this directory _must not_ import packages under
5 | `ipfs/go-ipfs` that are not also under `thirdparty`.
6 |
--------------------------------------------------------------------------------
/.dockerignore:
--------------------------------------------------------------------------------
1 | Dockerfile
2 | Dockerfile.fast
3 | .git/
4 | !.git/HEAD
5 | !.git/refs/
6 | !.git/packed-refs
7 | test/sharness/lib/sharness/
8 |
9 | # The Docker client might not be running on Linux
10 | # so delete any compiled binaries
11 | bin/gx
12 | bin/gx*
13 | bin/tmp
14 |
--------------------------------------------------------------------------------
/test/unit/Rules.mk:
--------------------------------------------------------------------------------
1 | include mk/header.mk
2 |
3 | CLEAN += $(d)/gotest.json $(d)/gotest.junit.xml
4 |
5 | $(d)/gotest.junit.xml: clean test/bin/json-to-junit coverage/unit_tests.coverprofile
6 | cat $(@D)/gotest.json | json-to-junit > $(@D)/gotest.junit.xml
7 |
8 | include mk/footer.mk
9 |
--------------------------------------------------------------------------------
/mk/gx.mk:
--------------------------------------------------------------------------------
1 | gx-path = gx/ipfs/$(shell gx deps find $(1))/$(1)
2 |
3 | gx-deps:
4 | gx install --global
5 | .PHONY: gx-deps
6 |
7 | ifneq ($(IPFS_GX_USE_GLOBAL),1)
8 | gx-deps: bin/gx bin/gx-go
9 | endif
10 | .PHONY: gx-deps
11 |
12 | ifeq ($(tarball-is),0)
13 | DEPS_GO += gx-deps
14 | endif
15 |
--------------------------------------------------------------------------------
/test/bin/continueyn:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Author: Juan Batiz-Benet
3 | # MIT LICENSED
4 |
5 | # if not a terminal, exit 0 (yes!)
6 | test -t 1 || exit 0
7 |
8 | read -p "continue? [y/N] " REPLY
9 | echo
10 | case "$REPLY" in
11 | [Yy]*) exit 0 ;;
12 | *) exit 1 ;;
13 | esac
14 |
--------------------------------------------------------------------------------
/test/sharness/lib/test-lib-hashes.sh:
--------------------------------------------------------------------------------
1 | # this file defines several useful hashes used across the test codebase.
2 | # thus they can be defined + changed in one place
3 |
4 | HASH_WELCOME_DOCS="QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv"
5 | HASH_EMPTY_DIR="QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn"
6 |
--------------------------------------------------------------------------------
/pin/internal/pb/doc.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package pb
10 |
11 | //go:生成protoc--go go_out=原标题
12 |
--------------------------------------------------------------------------------
/assets/README.md:
--------------------------------------------------------------------------------
1 | # Assets loaded in with IPFS
2 |
3 | ## Generating docs
4 |
5 | Do not edit the .go files directly.
6 |
7 | Instead, edit the source files and use `go generate` from within the
8 | assets directory:
9 |
10 | ```
11 | go get -u github.com/jteeuwen/go-bindata/...
12 | go generate
13 | ```
14 |
--------------------------------------------------------------------------------
/fuse/readonly/doc.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | //package fuse/readonly实现一个fuse文件系统来访问文件
10 | //存储在IPF中。
11 | package readonly
12 |
--------------------------------------------------------------------------------
/test/3nodetest/client/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM zaqwsx_ipfs-test-img
2 |
3 | RUN ipfs init -b=1024
4 | ADD . /tmp/id
5 | RUN mv -f /tmp/id/config /root/.ipfs/config
6 | RUN ipfs id
7 |
8 | EXPOSE 4031 4032/udp
9 |
10 | ENV IPFS_PROF true
11 | ENV IPFS_LOGGING_FMT nocolor
12 |
13 | ENTRYPOINT ["/bin/bash"]
14 | CMD ["/tmp/id/run.sh"]
15 |
--------------------------------------------------------------------------------
/test/dependencies/Makefile:
--------------------------------------------------------------------------------
1 |
2 | all: restore
3 |
4 | restore:
5 | @echo "*** $@ ***"
6 | which godep
7 | mkdir -p tmp_gopath
8 | OLD_GOPATH="$$GOPATH"
9 | export GOPATH=$$(pwd)/tmp_gopath
10 | cd ../..
11 | godep restore
12 | cd -
13 | rm -rf tmp_gopath
14 | export GOPATH="$$OLD_GOPATH"
15 |
16 | .PHONY: all restore
17 |
--------------------------------------------------------------------------------
/test/sharness/t0018-indent.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | test_description="Test sharness test indent"
4 |
5 | . lib/test-lib.sh
6 |
7 | for file in $(find .. -name 't*.sh' -type f); do
8 | test_expect_success "indent in $file is not using tabs" '
9 | test_must_fail grep -P "^ *\t" $file
10 | '
11 | done
12 |
13 | test_done
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # ipfs can generate profiling dump files
2 | *.cpuprof
3 | *.memprof
4 |
5 | *.swp
6 | .ipfsconfig
7 | *.out
8 | *.coverprofile
9 | *.test
10 | *.orig
11 | *~
12 |
13 | coverage.txt
14 | gx-workspace-update.json
15 |
16 | .ipfs
17 | bin/gx
18 | bin/gx*
19 | bin/tmp
20 |
21 |
22 | vendor
23 | .tarball
24 | go-ipfs-source.tar.gz
25 |
--------------------------------------------------------------------------------
/assets/init-doc/help:
--------------------------------------------------------------------------------
1 | Some helpful resources for finding your way around ipfs:
2 |
3 | - quick-start: a quick show of various ipfs features.
4 | - ipfs commands: a list of all commands
5 | - ipfs --help: every command describes itself
6 | - https://github.com/ipfs/go-ipfs -- the src repository
7 | - #ipfs on irc.freenode.org -- the community irc channel
8 |
--------------------------------------------------------------------------------
/cmd/ipfs/util/ulimit_windows.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | //+构建窗口
10 |
11 | package util
12 |
13 | func init() {
14 | supportsFDManagement = false
15 | }
16 |
--------------------------------------------------------------------------------
/test/3nodetest/server/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM zaqwsx_ipfs-test-img
2 |
3 | RUN ipfs init -b=1024
4 | ADD . /tmp/test
5 | RUN mv -f /tmp/test/config /root/.ipfs/config
6 | RUN ipfs id
7 | RUN chmod +x /tmp/test/run.sh
8 |
9 | EXPOSE 4021 4022/udp
10 |
11 | ENV IPFS_PROF true
12 | ENV IPFS_LOGGING_FMT nocolor
13 |
14 | ENTRYPOINT ["/bin/bash"]
15 | CMD ["/tmp/test/run.sh"]
16 |
--------------------------------------------------------------------------------
/docs/generate-authors.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | # see also ".mailmap" for how email addresses and names are deduplicated
5 |
6 |
7 | cat >AUTHORS <<-'EOF'
8 | # This file lists all individuals having contributed content to the repository.
9 | # For how it is generated, see `docs/generate-authors.sh`.
10 |
11 | EOF
12 | git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf >>AUTHORS
13 |
--------------------------------------------------------------------------------
/thirdparty/math2/math2.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package math2
10 |
11 | //Intmin返回x或y的较小值。
12 | func IntMin(x, y int) int {
13 | if x < y {
14 | return x
15 | }
16 | return y
17 | }
18 |
--------------------------------------------------------------------------------
/test/sharness/t0025-datastores.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | test_description="Test non-standard datastores"
4 |
5 | . lib/test-lib.sh
6 |
7 | test_expect_success "'ipfs init --profile=badgerds' succeeds" '
8 | BITS="1024" &&
9 | ipfs init --bits="$BITS" --profile=badgerds
10 | '
11 |
12 | test_expect_success "'ipfs pin ls' works" '
13 | ipfs pin ls | wc -l | grep 9
14 | '
15 |
16 | test_done
17 |
--------------------------------------------------------------------------------
/bin/test-go-fmt:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -euo pipefail
3 | T="$(mktemp)"
4 | find . -name '*.go' | xargs gofmt -l > "$T"
5 |
6 | if [ -n "$(cat $T)" ]; then
7 | echo "Following Go code is not formatted."
8 | echo "-----------------------------------"
9 | cat "$T"
10 | echo "-----------------------------------"
11 | echo "Run 'go fmt ./...' in your source directory"
12 | rm -f "$T"
13 | exit 1
14 | fi
15 | rm -f "$T"
16 |
--------------------------------------------------------------------------------
/codecov.yml:
--------------------------------------------------------------------------------
1 | codecov:
2 | ci:
3 | - "ci/circle-ci"
4 | - "!travis-ci.org"
5 | - "!ci.ipfs.team:8111"
6 | - "!ci.ipfs.team"
7 | notify:
8 | require_ci_to_pass: no
9 | after_n_builds: 2
10 |
11 | coverage:
12 | range: "50...100"
13 |
14 | status:
15 | project:
16 | default:
17 | threshold: 0.2%
18 |
19 | patch:
20 | default:
21 | threshold: 2%
22 |
23 | comment: off
24 |
--------------------------------------------------------------------------------
/pin/internal/pb/header.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package ipfs.pin;
4 |
5 | option go_package = "pb";
6 |
7 | message Set {
8 | // 1 for now, library will refuse to handle entries with an unrecognized version.
9 | optional uint32 version = 1;
10 | // how many of the links are subtrees
11 | optional uint32 fanout = 2;
12 | // hash seed for subtree selection, a random number
13 | optional fixed32 seed = 3;
14 | }
15 |
--------------------------------------------------------------------------------
/test/bin/verify-go-fmt.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #TODO add go lint and go vet
4 |
5 | verify_gofmt() {
6 | GOFMT="gofmt -s"
7 | cd "$(git rev-parse --show-toplevel)"
8 | bad_files=$($GOFMT -l .)
9 | cd -
10 | if [[ -n $bad_files ]]; then
11 | echo "You have to run '$GOFMT' on these files:"
12 | echo "$bad_files"
13 | false
14 | else
15 | true
16 | fi
17 | }
18 |
19 | verify_gofmt
20 |
--------------------------------------------------------------------------------
/plugin/loader/preload_list:
--------------------------------------------------------------------------------
1 | # this file contains plugins to be preloaded
2 | # empty lines or starting with '#' are ignored
3 | #
4 | # name go-path number of the sub-plugin
5 |
6 | ipldgit github.com/ipfs/go-ipfs/plugin/plugins/git 0
7 |
8 | badgerds github.com/ipfs/go-ipfs/plugin/plugins/badgerds 0
9 | flatfs github.com/ipfs/go-ipfs/plugin/plugins/flatfs 0
10 | levelds github.com/ipfs/go-ipfs/plugin/plugins/levelds 0
11 |
--------------------------------------------------------------------------------
/test/3nodetest/bin/save_logs.sh:
--------------------------------------------------------------------------------
1 | # STRIP strips color from terminal output
2 | STRIP="perl -pe 's/\e\[?.*?[\@-~]//g'"
3 |
4 | # TODO use a for loop like a grownup
5 | docker logs 3nodetest_bootstrap_1 2>&1 | eval $STRIP > ./build/bootstrap.log
6 | docker logs 3nodetest_client_1 2>&1 | eval $STRIP > ./build/client.log
7 | docker logs 3nodetest_data_1 2>&1 | eval $STRIP > ./build/data.log
8 | docker logs 3nodetest_server_1 2>&1 | eval $STRIP > ./build/server.log
9 |
--------------------------------------------------------------------------------
/fuse/node/mount_windows.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package node
10 |
11 | import (
12 | "github.com/ipfs/go-ipfs/core"
13 | )
14 |
15 | func Mount(node *core.IpfsNode, fsdir, nsdir string) error {
16 | //托多
17 | //目前没有操作,但我们不想返回错误
18 | return nil
19 | }
20 |
--------------------------------------------------------------------------------
/plugin/plugin.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package plugin
10 |
11 | //插件是各种go ipfs插件的基本接口
12 | //它将包含在不同插件的接口中
13 | type Plugin interface {
14 | //名称应返回插件的唯一名称
15 | Name() string
16 | //版本返回插件的当前版本
17 | Version() string
18 | //加载插件时调用一次init
19 | Init() error
20 | }
21 |
--------------------------------------------------------------------------------
/bin/mkreleaselog:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | LAST_TAG=$(git tag -l | sort -V | grep -v -- '-rc' | grep 'v'| tail -n1)
4 |
5 | git log --oneline --merges --reverse $LAST_TAG...master |
6 | while read MERGE
7 | do
8 | commit=$(echo $MERGE | awk '{ print $1 }')
9 | prnum=$(echo $MERGE | awk '{ print $5 }' | tr -d '#')
10 | desc=$(git show $commit | sed '8q;d' | sed 's/^ //g')
11 | printf " - %s ([ipfs/go-ipfs#%s](https://github.com/ipfs/go-ipfs/pull/%s))\n" "$desc" "$prnum" "$prnum"
12 | done
13 |
--------------------------------------------------------------------------------
/version.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package ipfs
10 |
11 | //current commit是当前的git commit,它在makefile中设置为ldflag
12 | var CurrentCommit string
13 |
14 | //当前版本号是当前应用程序的版本文本
15 | const CurrentVersionNumber = "0.4.19-dev"
16 |
17 | const ApiVersion = "/go-ipfs/" + CurrentVersionNumber + "/"
18 |
--------------------------------------------------------------------------------
/fuse/node/mount_nofuse.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | //+建设!视窗
10 |
11 | package node
12 |
13 | import (
14 | "errors"
15 |
16 | core "github.com/ipfs/go-ipfs/core"
17 | )
18 |
19 | func Mount(node *core.IpfsNode, fsdir, nsdir string) error {
20 | return errors.New("not compiled in")
21 | }
22 |
--------------------------------------------------------------------------------
/plugin/tracer.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package plugin
10 |
11 | import (
12 | "gx/ipfs/QmWLWmRVSiagqP15jczsGME1qpob6HDbtbHAY2he9W5iUo/opentracing-go"
13 | )
14 |
15 | //PlugIncer是一个接口,可以实现添加跟踪程序
16 | type PluginTracer interface {
17 | Plugin
18 | InitTracer() (opentracing.Tracer, error)
19 | }
20 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | # dist: trusty # KVM Setup
2 |
3 | notifications:
4 | email: false
5 |
6 | os:
7 | - linux
8 | - osx
9 |
10 | language: go
11 |
12 | go:
13 | - 1.11.x
14 |
15 | env:
16 | - TEST_NO_FUSE=1 TEST_VERBOSE=1 TEST_SUITE=test_go_expensive
17 | - TEST_NO_FUSE=1 TEST_VERBOSE=1 TEST_SUITE=test_sharness_expensive
18 |
19 | install:
20 | - make install
21 |
22 | script:
23 | - make $TEST_SUITE
24 |
25 | # For docker containers
26 |
27 | sudo: required
28 |
29 | services:
30 | - docker
31 |
--------------------------------------------------------------------------------
/docs/transports.md:
--------------------------------------------------------------------------------
1 | ## /ws and /wss -- websockets
2 |
3 | If you want browsers to connect to e.g. `/dns4/example.com/tcp/443/wss/ipfs/QmFoo`
4 |
5 | - [ ] An SSL cert matching the `/dns4` or `/dns6` name
6 | - [ ] go-ipfs listening on `/ip4/127.0.0.1/tcp/8081/ws`
7 | - 8081 is just an example
8 | - note that it's `/ws` here, not `/wss` -- go-ipfs can't currently do SSL, see the next point
9 | - [ ] nginx
10 | - configured with the SSL cert
11 | - listening on port 443
12 | - forwarding to 127.0.0.1:8081
13 |
--------------------------------------------------------------------------------
/test/sharness/lib/test-aggregate-results.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Script to aggregate results using Sharness
4 | #
5 | # Copyright (c) 2014 Christian Couder
6 | # MIT Licensed; see the LICENSE file in this repository.
7 | #
8 |
9 | SHARNESS_AGGREGATE="lib/sharness/aggregate-results.sh"
10 |
11 | test -f "$SHARNESS_AGGREGATE" || {
12 | echo >&2 "Cannot find: $SHARNESS_AGGREGATE"
13 | echo >&2 "Please check Sharness installation."
14 | exit 1
15 | }
16 |
17 | ls test-results/t*-*.sh.*.counts | "$SHARNESS_AGGREGATE"
18 |
--------------------------------------------------------------------------------
/plugin/datastore.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package plugin
10 |
11 | import (
12 | "github.com/ipfs/go-ipfs/repo/fsrepo"
13 | )
14 |
15 | //PluginDatastore是一个接口,可以实现它来添加
16 | //对于不同的数据存储
17 | type PluginDatastore interface {
18 | Plugin
19 |
20 | DatastoreTypeName() string
21 | DatastoreConfigParser() fsrepo.ConfigFromMap
22 | }
23 |
--------------------------------------------------------------------------------
/plugin/plugins/gen_main.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | dir=${1:?first paramater with dir to work in is required}
4 | pkg=${2:?second parameter with full name of the package is required}
5 | main_pkg="$dir/main"
6 |
7 | shortpkg="uniquepkgname"
8 |
9 | mkdir -p "$main_pkg"
10 |
11 | cat > "$main_pkg/main.go" <expected &&
17 | ipfs config Foo.Bar >actual &&
18 | test_cmp expected actual
19 | '
20 |
21 | test_done
22 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | IPFS as a project, including go-ipfs and all of its modules, follows the [standard IPFS Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md).
2 |
3 | We also adhere to the [GO IPFS Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_GO.md) which provide additional information of how to collaborate and contribute in the Go implementation of IPFS.
4 |
5 | We appreciate your time and attention for going over these. Please open an issue on ipfs/community if you have any questions.
6 |
7 | Thank you.
8 |
--------------------------------------------------------------------------------
/test/bin/checkflags:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Author: Christian Couder
3 | # MIT LICENSED
4 |
5 | if test "$#" -lt 3
6 | then
7 | echo >&2 "usage $0 FILE VALUES MSG..."
8 | exit 1
9 | fi
10 |
11 | FLAG_FILE="$1"
12 | FLAG_VALS="$2"
13 | shift
14 | shift
15 | FLAG_MSGS="$@"
16 |
17 | test -f $FLAG_FILE || touch $FLAG_FILE
18 |
19 | # Use x in front of tested values as flags could be
20 | # interpreted by "test" to be for itself.
21 | if test x"$FLAG_VALS" != x"$(cat "$FLAG_FILE")"
22 | then
23 | echo "$FLAG_MSGS"
24 | echo "$FLAG_VALS" >"$FLAG_FILE"
25 | fi
26 |
--------------------------------------------------------------------------------
/cmd/ipfs/dist/README.md:
--------------------------------------------------------------------------------
1 | # ipfs commandline tool
2 |
3 | This is the [ipfs](http://ipfs.io) commandline tool. It contains a full ipfs node.
4 |
5 | ## Install
6 |
7 | To install it, move the binary somewhere in your `$PATH`:
8 |
9 | ```sh
10 | sudo mv ipfs /usr/local/bin/ipfs
11 | ```
12 |
13 | Or run `sudo ./install.sh` which does this for you.
14 |
15 | ## Usage
16 |
17 | First, you must initialize your local ipfs node:
18 |
19 | ```sh
20 | ipfs init
21 | ```
22 |
23 | This will give you directions to get started with ipfs.
24 | You can always get help with:
25 |
26 | ```sh
27 | ipfs --help
28 | ```
29 |
--------------------------------------------------------------------------------
/core/coreapi/interface/util.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package iface
10 |
11 | import (
12 | "context"
13 | "io"
14 | )
15 |
16 | type Reader interface {
17 | ReadSeekCloser
18 | Size() uint64
19 | CtxReadFull(context.Context, []byte) (int, error)
20 | }
21 |
22 | //readseekCloser实现读取、复制、查找和关闭的接口。
23 | type ReadSeekCloser interface {
24 | io.Reader
25 | io.Seeker
26 | io.Closer
27 | io.WriterTo
28 | }
29 |
--------------------------------------------------------------------------------
/cmd/ipfs/util/signal_wasm.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package util
10 |
11 | import (
12 | "context"
13 | "io"
14 | )
15 |
16 | type ctxCloser context.CancelFunc
17 |
18 | func (c ctxCloser) Close() error {
19 | c()
20 | return nil
21 | }
22 |
23 | func SetupInterruptHandler(ctx context.Context) (io.Closer, context.Context) {
24 | ctx, cancel := context.WithCancel(ctx)
25 | return ctxCloser(cancel), ctx
26 | }
27 |
--------------------------------------------------------------------------------
/plugin/ipld.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package plugin
10 |
11 | import (
12 | "github.com/ipfs/go-ipfs/core/coredag"
13 |
14 | ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format"
15 | )
16 |
17 | //pluginipld是一个接口,可以实现它来添加
18 | //对于不同的IPLD格式
19 | type PluginIPLD interface {
20 | Plugin
21 |
22 | RegisterBlockDecoders(dec ipld.BlockDecoder) error
23 | RegisterInputEncParsers(iec coredag.InputEncParsers) error
24 | }
25 |
--------------------------------------------------------------------------------
/repo/fsrepo/doc.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | //包装FSRPO
10 | //
11 | //要解释程序包路线图…
12 | //
13 | //IPFS/
14 | //——客户/
15 | //——client.lock<------保护client/+信号自己的PID
16 | //珍——ipfs-client.cpuprof
17 | //│——ipfs-client.memprof
18 | //——配置
19 | //——守护进程/
20 | //珍——daemon.lock<------保护daemon/+信号自己的地址
21 | //珍——ipfs-daemon.cpuprof
22 | //│———ipfs-daemon.memprof
23 | //——数据存储/
24 | //——repo.lock<------保护数据存储/和配置
25 | //破译——版本
26 | package fsrepo
27 |
28 | //TODO防止多个守护进程运行
29 |
--------------------------------------------------------------------------------
/test/sharness/t0024-files/spec-newshardfun:
--------------------------------------------------------------------------------
1 | {
2 | "mounts": [
3 | {
4 | "child": {
5 | "path": "blocks",
6 | "shardFunc": "/repo/flatfs/shard/v1/next-to-last/3",
7 | "sync": true,
8 | "type": "flatfs"
9 | },
10 | "mountpoint": "/blocks",
11 | "prefix": "flatfs.datastore",
12 | "type": "measure"
13 | },
14 | {
15 | "child": {
16 | "compression": "none",
17 | "path": "datastore",
18 | "type": "levelds"
19 | },
20 | "mountpoint": "/",
21 | "prefix": "leveldb.datastore",
22 | "type": "measure"
23 | }
24 | ],
25 | "type": "mount"
26 | }
27 |
--------------------------------------------------------------------------------
/test/sharness/t0024-files/spec-nosync:
--------------------------------------------------------------------------------
1 | {
2 | "mounts": [
3 | {
4 | "child": {
5 | "path": "blocks",
6 | "shardFunc": "/repo/flatfs/shard/v1/next-to-last/2",
7 | "sync": false,
8 | "type": "flatfs"
9 | },
10 | "mountpoint": "/blocks",
11 | "prefix": "flatfs.datastore",
12 | "type": "measure"
13 | },
14 | {
15 | "child": {
16 | "compression": "none",
17 | "path": "datastore",
18 | "type": "levelds"
19 | },
20 | "mountpoint": "/",
21 | "prefix": "leveldb.datastore",
22 | "type": "measure"
23 | }
24 | ],
25 | "type": "mount"
26 | }
27 |
--------------------------------------------------------------------------------
/bin/check_go_path:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 |
5 | PKG="$1"
6 |
7 | DIR="$(pwd -P)"
8 | GOPATH="$(go env GOPATH)"
9 |
10 | # The path separator is ; on windows.
11 | if [ "$(go env GOOS)" = "windows" ]; then
12 | PATHSEP=';'
13 | else
14 | PATHSEP=':'
15 | fi
16 |
17 | while read -r -d "$PATHSEP" p; do
18 | if ! cd "$p/src/$PKG" 2>/dev/null; then
19 | continue
20 | fi
21 |
22 | if [ "$DIR" = "$(pwd -P)" ]; then
23 | exit 0
24 | fi
25 | cd "$DIR"
26 | done <<< "$GOPATH$PATHSEP"
27 |
28 | echo "go-ipfs must be built from within your \$GOPATH directory."
29 | echo "expected within '$GOPATH' but got '$DIR'"
30 | exit 1
31 |
--------------------------------------------------------------------------------
/cmd/ipfswatch/ipfswatch_test.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package main
10 |
11 | import (
12 | "testing"
13 |
14 | "github.com/ipfs/go-ipfs/thirdparty/assert"
15 | )
16 |
17 | func TestIsHidden(t *testing.T) {
18 | assert.True(IsHidden("bar/.git"), t, "dirs beginning with . should be recognized as hidden")
19 | assert.False(IsHidden("."), t, ". for current dir should not be considered hidden")
20 | assert.False(IsHidden("bar/baz"), t, "normal dirs should not be hidden")
21 | }
22 |
--------------------------------------------------------------------------------
/doc.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | /*
10 | IPFS是一个全局的、版本控制的对等文件系统
11 |
12 | IPFS包中有用于各种低级的子包
13 | 公用设施,依次组装成:
14 |
15 | 核心/…
16 | 为消费者提供所需的所有旋钮的低级API,
17 | 我们努力保持稳定。
18 | 壳牌/…
19 | 高级API,让用户轻松访问公共
20 | 操作(例如,从读卡器创建文件节点而不进行包装
21 | 使用元数据)。我们努力保持稳定。
22 |
23 | 然后在核心之上。和壳牌/…Go API,我们有:
24 |
25 | CMD/…
26 | 命令行可执行文件
27 | 测试/…
28 | 集成测试等。
29 |
30 | 为了避免周期性进口,进口不应拉高进口水平。
31 | 将API放入较低级别的包中。例如,您可以导入
32 | 命令中的核心和外壳。或测试/…,但无法导入任何
33 | 来自核心的外壳。
34 | **/
35 |
36 | package ipfs
37 |
--------------------------------------------------------------------------------
/core/commands/diag.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package commands
10 |
11 | import (
12 | cmds "gx/ipfs/QmWGm4AbZEbnmdgVTza52MSNpEmBdFVqzmAysRbjrRyGbH/go-ipfs-cmds"
13 | cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit"
14 | )
15 |
16 | var DiagCmd = &cmds.Command{
17 | Helptext: cmdkit.HelpText{
18 | Tagline: "Generate diagnostic reports.",
19 | },
20 |
21 | Subcommands: map[string]*cmds.Command{
22 | "sys": sysDiagCmd,
23 | "cmds": ActiveReqsCmd,
24 | },
25 | }
26 |
--------------------------------------------------------------------------------
/misc/launchd/io.ipfs.ipfs-daemon.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | KeepAlive
6 |
7 | Label
8 | io.ipfs.ipfs-daemon
9 | ProgramArguments
10 |
11 | {{IPFS_BIN}}
12 | daemon
13 |
14 | EnvironmentVariables
15 |
16 | IPFS_PATH
17 | {{IPFS_PATH}}
18 |
19 | RunAtLoad
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/bin/maketarball.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # vim: set expandtab sw=2 ts=2:
3 |
4 | # bash safe mode
5 | set -euo pipefail
6 | IFS=$'\n\t'
7 |
8 | # readlink doesn't work on macos
9 | OUTPUT="${1:-go-ipfs-source.tar.gz}"
10 | if ! [[ "$OUTPUT" = /* ]]; then
11 | OUTPUT="$PWD/$OUTPUT"
12 | fi
13 |
14 | TMPDIR="$(mktemp -d)"
15 | NEWIPFS="$TMPDIR/src/github.com/ipfs/go-ipfs"
16 | mkdir -p "$NEWIPFS"
17 | cp -r . "$NEWIPFS"
18 | ( cd "$NEWIPFS" &&
19 | echo $PWD &&
20 | GOPATH="$TMPDIR" gx install --local &&
21 | (git rev-parse --short HEAD || true) > .tarball &&
22 | chmod -R u=rwX,go=rX "$NEWIPFS" # normalize permissions
23 | tar -czf "$OUTPUT" --exclude="./.git" .
24 | )
25 |
26 | rm -rf "$TMPDIR"
27 |
--------------------------------------------------------------------------------
/core/commands/root_test.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package commands
10 |
11 | import (
12 | "testing"
13 | )
14 |
15 | func TestCommandTree(t *testing.T) {
16 | printErrors := func(errs map[string][]error) {
17 | if errs == nil {
18 | return
19 | }
20 | t.Error("In Root command tree:")
21 | for cmd, err := range errs {
22 | t.Errorf(" In X command %s:", cmd)
23 | for _, e := range err {
24 | t.Errorf(" %s", e)
25 | }
26 | }
27 | }
28 | printErrors(Root.DebugValidate())
29 | printErrors(RootRO.DebugValidate())
30 | }
31 |
--------------------------------------------------------------------------------
/thirdparty/unit/unit_test.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package unit
10 |
11 | import "testing"
12 |
13 | //大多数meta奖授予…
14 |
15 | func TestByteSizeUnit(t *testing.T) {
16 | if 1*KB != 1*1024 {
17 | t.Fatal(1 * KB)
18 | }
19 | if 1*MB != 1*1024*1024 {
20 | t.Fail()
21 | }
22 | if 1*GB != 1*1024*1024*1024 {
23 | t.Fail()
24 | }
25 | if 1*TB != 1*1024*1024*1024*1024 {
26 | t.Fail()
27 | }
28 | if 1*PB != 1*1024*1024*1024*1024*1024 {
29 | t.Fail()
30 | }
31 | if 1*EB != 1*1024*1024*1024*1024*1024*1024 {
32 | t.Fail()
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/thirdparty/assert/assert.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package assert
10 |
11 | import "testing"
12 |
13 | func Nil(err error, t *testing.T, msgs ...string) {
14 | if err != nil {
15 | t.Fatal(msgs, "error:", err)
16 | }
17 | }
18 |
19 | func True(v bool, t *testing.T, msgs ...string) {
20 | if !v {
21 | t.Fatal(msgs)
22 | }
23 | }
24 |
25 | func False(v bool, t *testing.T, msgs ...string) {
26 | True(!v, t, msgs...)
27 | }
28 |
29 | func Err(err error, t *testing.T, msgs ...string) {
30 | if err == nil {
31 | t.Fatal(msgs, "error:", err)
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/thirdparty/dir/dir.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package dir
10 |
11 | //TODO移动到一般位置
12 |
13 | import (
14 | "errors"
15 | "os"
16 | "path/filepath"
17 | )
18 |
19 | //可写确保目录存在且可写
20 | func Writable(path string) error {
21 | //如果缺少,则构造路径
22 | if err := os.MkdirAll(path, os.ModePerm); err != nil {
23 | return err
24 | }
25 | //检查目录是否可写
26 | if f, err := os.Create(filepath.Join(path, "._check_writable")); err == nil {
27 | f.Close()
28 | os.Remove(f.Name())
29 | } else {
30 | return errors.New("'" + path + "' is not writable")
31 | }
32 | return nil
33 | }
34 |
--------------------------------------------------------------------------------
/plugin/loader/preload.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4 |
5 | to_preload() {
6 | awk 'NF' "$DIR/preload_list" | sed '/^#/d'
7 | }
8 |
9 | cat < go-sleep
20 | Usage: go-sleep
21 | Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
22 | See https://godoc.org/time#ParseDuration for more.
23 | > time go-sleep 100ms
24 |
25 | real 0m0.104s
26 | user 0m0.000s
27 | sys 0m0.007s
28 | ```
29 |
30 | ### License
31 |
32 | MIT
33 |
--------------------------------------------------------------------------------
/core/commands/cmdenv/file.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package cmdenv
10 |
11 | import (
12 | "fmt"
13 |
14 | files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files"
15 | )
16 |
17 | //
18 | func GetFileArg(it files.DirIterator) (files.File, error) {
19 | if !it.Next() {
20 | err := it.Err()
21 | if err == nil {
22 | err = fmt.Errorf("expected a file argument")
23 | }
24 | return nil, err
25 | }
26 | file := files.FileFromEntry(it)
27 | if file == nil {
28 | return nil, fmt.Errorf("file argument was nil")
29 | }
30 | return file, nil
31 | }
32 |
--------------------------------------------------------------------------------
/bin/Rules.mk:
--------------------------------------------------------------------------------
1 | include mk/header.mk
2 |
3 | dist_root_$(d)="/ipfs/QmPrXH9jRVwvd7r5MC5e6nV4uauQGzLk1i2647Ye9Vbbwe"
4 |
5 | $(d)/gx: $(d)/gx-v0.14.0
6 | $(d)/gx-go: $(d)/gx-go-v1.9.0
7 |
8 | TGTS_$(d) := $(d)/gx $(d)/gx-go
9 | DISTCLEAN += $(wildcard $(d)/gx-v*) $(wildcard $(d)/gx-go-v*) $(d)/tmp
10 |
11 | PATH := $(realpath $(d)):$(PATH)
12 |
13 | $(TGTS_$(d)):
14 | rm -f $@$(?exe)
15 | ifeq ($(WINDOWS),1)
16 | cp $^$(?exe) $@$(?exe)
17 | else
18 | ln -s $(notdir $^) $@
19 | endif
20 |
21 | bin/gx-v%:
22 | @echo "installing gx $(@:bin/gx-%=%)"
23 | bin/dist_get $(dist_root_bin) gx $@ $(@:bin/gx-%=%)
24 |
25 | bin/gx-go-v%:
26 | @echo "installing gx-go $(@:bin/gx-go-%=%)"
27 | @bin/dist_get $(dist_root_bin) gx-go $@ $(@:bin/gx-go-%=%)
28 |
29 | CLEAN += $(TGTS_$(d))
30 | include mk/footer.mk
31 |
--------------------------------------------------------------------------------
/test/3nodetest/fig.yml:
--------------------------------------------------------------------------------
1 | data:
2 | build: ./data
3 | volumes:
4 | - /data
5 | command: sleep 1000000
6 |
7 | bootstrap:
8 | build: ./bootstrap
9 | command: daemon --debug --init
10 | expose:
11 | - "4011"
12 | - "4012/udp"
13 | environment:
14 | IPFS_LOGGING: debug
15 |
16 | server:
17 | build: ./server
18 | links:
19 | - bootstrap
20 | volumes_from:
21 | - data
22 | expose:
23 | - "4021"
24 | - "4022/udp"
25 | environment:
26 | IPFS_LOGGING: debug
27 |
28 | client:
29 | build: ./client
30 | links:
31 | - bootstrap
32 | volumes_from:
33 | - data
34 | expose:
35 | - "4031"
36 | - "4032/udp"
37 | environment:
38 | IPFS_LOGGING: debug
39 |
--------------------------------------------------------------------------------
/test/sharness/t0088-repo-stat-symlink.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copyright (c) 2017 John Reed
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="Test 'ipfs repo stat' where IPFS_PATH is a symbolic link"
8 |
9 | . lib/test-lib.sh
10 |
11 | test_expect_success "create symbolic link for IPFS_PATH" '
12 | mkdir sym_link_target &&
13 | ln -s sym_link_target .ipfs
14 | '
15 |
16 | test_init_ipfs
17 |
18 | # ensure that the RepoSize is reasonable when checked via a symlink.
19 | test_expect_success "'ipfs repo stat' RepoSize is correct with sym link" '
20 | reposize_symlink=$(ipfs repo stat | grep RepoSize | awk '\''{ print $2 }'\'') &&
21 | symlink_size=$(file_size .ipfs) &&
22 | test "${reposize_symlink}" -gt "${symlink_size}"
23 | '
24 |
25 | test_done
26 |
--------------------------------------------------------------------------------
/test/sharness/t0024-datastore-config.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | test_description="Test datastore config"
4 |
5 | . lib/test-lib.sh
6 |
7 | test_init_ipfs
8 |
9 | test_launch_ipfs_daemon
10 | test_kill_ipfs_daemon
11 |
12 | SPEC_NOSYNC=$(cat ../t0024-files/spec-nosync)
13 |
14 | SPEC_NEWSHARDFUN=$(cat ../t0024-files/spec-newshardfun)
15 |
16 | test_expect_success "change runtime value in spec config" '
17 | ipfs config --json Datastore.Spec "$SPEC_NOSYNC"
18 | '
19 |
20 | test_launch_ipfs_daemon
21 | test_kill_ipfs_daemon
22 |
23 | test_expect_success "change on-disk value in spec config" '
24 | ipfs config --json Datastore.Spec "$SPEC_NEWSHARDFUN"
25 | '
26 |
27 | test_expect_success "can not launch daemon after on-disk value change" '
28 | test_must_fail ipfs daemon
29 | '
30 |
31 | test_done
32 |
--------------------------------------------------------------------------------
/fuse/readonly/mount_unix.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | //+构建Linux darwin freebsd netbsd openbsd
10 | //+建设!诺福斯
11 |
12 | package readonly
13 |
14 | import (
15 | core "github.com/ipfs/go-ipfs/core"
16 | mount "github.com/ipfs/go-ipfs/fuse/mount"
17 | )
18 |
19 | //mount在给定位置安装IPF,并返回mount.mount实例。
20 | func Mount(ipfs *core.IpfsNode, mountpoint string) (mount.Mount, error) {
21 | cfg, err := ipfs.Repo.Config()
22 | if err != nil {
23 | return nil, err
24 | }
25 | allow_other := cfg.Mounts.FuseAllowOther
26 | fsys := NewFileSystem(ipfs)
27 | return mount.NewMount(ipfs.Process(), fsys, mountpoint, allow_other)
28 | }
29 |
--------------------------------------------------------------------------------
/bin/graphmd:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | if [ "$#" -ne 1 ]; then
4 | echo "usage: $0 ..."
5 | echo "output merkledag links in graphviz dot"
6 | echo ""
7 | echo "use it with dot:"
8 | echo " $0 QmZPAMWUfLD95GsdorXt9hH7aVrarb2SuLDMVVe6gABYmx | dot -Tsvg"
9 | echo " $0 QmZPAMWUfLD95GsdorXt9hH7aVrarb2SuLDMVVe6gABYmx | dot -Tpng"
10 | echo " $0 QmZPAMWUfLD95GsdorXt9hH7aVrarb2SuLDMVVe6gABYmx | dot -Tpdf"
11 | echo ""
12 | exit 1
13 | fi
14 |
15 | src=' [fontsize=8 shape=box];'
16 | dst=' [fontsize=8 shape=box];'
17 | edge=' -> [label=""];'
18 | fmt="$src
19 | $dst
20 | $edge"
21 |
22 | echo "digraph {"
23 | echo " graph [rankdir=LR];"
24 | ipfs refs -r --format="$fmt" "$@" | awk '{ print "\t" $0 }'
25 | # ipfs refs -r --format="$fmt" "$@" | awk '{ print "\t" $0 }' | unflatten -l3
26 | echo "}"
27 |
--------------------------------------------------------------------------------
/bin/ipns-republish:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [ "$#" -ne 1 ]; then
4 | echo "usage: $0 "
5 | echo "republishes an ipns name every 20 minutes"
6 | echo "(this is an icky stop-gap until ipfs nodes do it for you)"
7 | echo ""
8 | echo "example:"
9 | echo " > $0 QmSYCpuKPbPQ2iFr2swJj2hvz7wQUXfPBXPiuVsQdL5FEs"
10 | echo ""
11 | exit 1
12 | fi
13 |
14 | # must be run online.
15 | ipfs swarm peers >/dev/null
16 | if [ $? -ne 0 ]; then
17 | echo "error: ipfs daemon must be online and connected to peers "
18 | exit 1
19 | fi
20 |
21 | # check the object is there
22 | ipfs object stat "$1" >/dev/null
23 | if [ $? -ne 0 ]; then
24 | echo "error: ipfs cannot find $1"
25 | exit 1
26 | fi
27 |
28 | echo "republishing $1 every 20 minutes"
29 | while :
30 | do
31 | ipfs name publish $1
32 | sleep 1200
33 | done
34 |
--------------------------------------------------------------------------------
/docs/openbsd.md:
--------------------------------------------------------------------------------
1 | # Building on OpenBSD
2 |
3 | ## Prepare your system
4 |
5 | Make sure you have `git`, `go` and `gmake` installed on your system.
6 |
7 | ```
8 | $ doas pkg_add -v git go gmake
9 | ```
10 |
11 | ## Prepare go environment
12 |
13 | Make sure your gopath is set:
14 |
15 | ```
16 | $ export GOPATH=~/go
17 | $ echo "$GOPATH"
18 | $ export PATH="$PATH:$GOPATH/bin"
19 | ```
20 |
21 | ## Build
22 |
23 | The `install_unsupported` target works nicely for openbsd. This will install
24 | `gx`, `gx-go` and run `go install -tags nofuse ./cmd/ipfs`.
25 |
26 | ```
27 | $ go get -v -u -d github.com/ipfs/go-ipfs
28 |
29 | $ cd $GOPATH/src/github.com/ipfs/go-ipfs
30 | $ gmake install_unsupported
31 | ```
32 |
33 | if everything went well, your ipfs binary should be ready at `$GOPATH/bin/ipfs`.
34 |
35 | ```
36 | $ ipfs version
37 | ```
38 |
--------------------------------------------------------------------------------
/core/corehttp/redirect.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package corehttp
10 |
11 | import (
12 | "net"
13 | "net/http"
14 |
15 | core "github.com/ipfs/go-ipfs/core"
16 | )
17 |
18 | func RedirectOption(path string, redirect string) ServeOption {
19 | handler := &redirectHandler{redirect}
20 | return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
21 | mux.Handle("/"+path+"/", handler)
22 | return mux, nil
23 | }
24 | }
25 |
26 | type redirectHandler struct {
27 | path string
28 | }
29 |
30 | func (i *redirectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
31 | http.Redirect(w, r, i.path, 302)
32 | }
33 |
--------------------------------------------------------------------------------
/test/3nodetest/bin/save_profiling_data.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | for container in 3nodetest_bootstrap_1 3nodetest_client_1 3nodetest_server_1; do
4 | # ipfs binary is required by `go tool pprof`
5 | docker cp $container:/go/bin/ipfs build/profiling_data_$container
6 | done
7 |
8 | # since the nodes are executed with the --debug flag, profiling data is written
9 | # to the the working dir. by default, the working dir is /go.
10 |
11 | for container in 3nodetest_bootstrap_1 3nodetest_client_1 3nodetest_server_1; do
12 | docker cp $container:/go/ipfs.cpuprof build/profiling_data_$container
13 | done
14 |
15 | # TODO get memprof from client (client daemon isn't terminated, so memprof isn't retrieved)
16 | for container in 3nodetest_bootstrap_1 3nodetest_server_1; do
17 | docker cp $container:/go/ipfs.memprof build/profiling_data_$container
18 | done
19 |
--------------------------------------------------------------------------------
/core/commands/mount_windows.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package commands
10 |
11 | import (
12 | "errors"
13 |
14 | cmds "gx/ipfs/QmWGm4AbZEbnmdgVTza52MSNpEmBdFVqzmAysRbjrRyGbH/go-ipfs-cmds"
15 | cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit"
16 | )
17 |
18 | var MountCmd = &cmds.Command{
19 | Helptext: cmdkit.HelpText{
20 | Tagline: "Not yet implemented on Windows.",
21 | ShortDescription: "Not yet implemented on Windows. :(",
22 | },
23 |
24 | Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
25 | return errors.New("Mount isn't compatible with Windows yet")
26 | },
27 | }
28 |
--------------------------------------------------------------------------------
/plugin/loader/preload.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package loader
10 |
11 | import (
12 | "github.com/ipfs/go-ipfs/plugin"
13 | pluginbadgerds "github.com/ipfs/go-ipfs/plugin/plugins/badgerds"
14 | pluginflatfs "github.com/ipfs/go-ipfs/plugin/plugins/flatfs"
15 | pluginipldgit "github.com/ipfs/go-ipfs/plugin/plugins/git"
16 | pluginlevelds "github.com/ipfs/go-ipfs/plugin/plugins/levelds"
17 | )
18 |
19 | //不编辑此文件
20 | //此文件正在作为插件生成过程的一部分生成
21 | //要更改它,请修改plugin/loader/preload.sh
22 |
23 | var preloadPlugins = []plugin.Plugin{
24 | pluginipldgit.Plugins[0],
25 | pluginbadgerds.Plugins[0],
26 | pluginflatfs.Plugins[0],
27 | pluginlevelds.Plugins[0],
28 | }
29 |
--------------------------------------------------------------------------------
/plugin/plugins/Rules.mk:
--------------------------------------------------------------------------------
1 | include mk/header.mk
2 |
3 | $(d)_plugins:=$(d)/git $(d)/badgerds $(d)/flatfs $(d)/levelds
4 | $(d)_plugins_so:=$(addsuffix .so,$($(d)_plugins))
5 | $(d)_plugins_main:=$(addsuffix /main/main.go,$($(d)_plugins))
6 |
7 |
8 | $($(d)_plugins_main): d:=$(d)
9 | $($(d)_plugins_main):
10 | $(d)/gen_main.sh "$(dir $@).." "$(call go-pkg-name,$(dir $@)/..)"
11 | $(GOCC) fmt $@ >/dev/null
12 |
13 | $($(d)_plugins_so): %.so : %/main/main.go
14 | $($(d)_plugins_so): $$(DEPS_GO) ALWAYS
15 | $(GOCC) build -buildmode=plugin -i -pkgdir "$(GOPATH)/pkg/linux_amd64_dynlink" $(go-flags-with-tags) -o "$@" "$(call go-pkg-name,$(basename $@))/main"
16 | chmod +x "$@"
17 |
18 | CLEAN += $($(d)_plugins_so)
19 | CLEAN += $(foreach main_dir,$($(d)_plugins_main),$(dir $(main_dir)))
20 |
21 | build_plugins: $($(d)_plugins_so)
22 |
23 |
24 | include mk/footer.mk
25 |
--------------------------------------------------------------------------------
/repo/fsrepo/misc.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package fsrepo
10 |
11 | import (
12 | "os"
13 |
14 | config "gx/ipfs/QmcRKBUqc2p3L1ZraoJjbXfs9E6xzvEuyK9iypb5RGwfsr/go-ipfs-config"
15 | homedir "gx/ipfs/QmdcULN1WCzgoQmcCaUAmEhwcxHYsDrbZ2LvRJKCL8dMrK/go-homedir"
16 | )
17 |
18 | //BestKnownPath返回最著名的fsrepo路径。如果env覆盖是
19 | //现在,此函数返回该值。否则,它将返回默认值
20 | //回购路径。
21 | func BestKnownPath() (string, error) {
22 | ipfsPath := config.DefaultPathRoot
23 | if os.Getenv(config.EnvDir) != "" {
24 | ipfsPath = os.Getenv(config.EnvDir)
25 | }
26 | ipfsPath, err := homedir.Expand(ipfsPath)
27 | if err != nil {
28 | return "", err
29 | }
30 | return ipfsPath, nil
31 | }
32 |
--------------------------------------------------------------------------------
/.codeclimate.yml:
--------------------------------------------------------------------------------
1 | ratings:
2 | paths:
3 | - "**/*.go"
4 |
5 | exclude_paths:
6 | - test/
7 | - Godeps/
8 | - thirdparty/
9 | - "**/*.pb.go"
10 |
11 | engines:
12 | fixme:
13 | enabled: true
14 | config:
15 | strings:
16 | - FIXME
17 | - HACK
18 | - XXX
19 | - BUG
20 | golint:
21 | enabled: true
22 | govet:
23 | enabled: true
24 | gofmt:
25 | enabled: true
26 |
27 | version: "2"
28 | checks:
29 | argument-count:
30 | enabled: false
31 | complex-logic:
32 | enabled: false
33 | file-lines:
34 | enabled: false
35 | method-complexity:
36 | enabled: false
37 | method-count:
38 | enabled: false
39 | method-lines:
40 | enabled: false
41 | nested-control-flow:
42 | enabled: false
43 | return-statements:
44 | enabled: false
45 | similar-code:
46 | enabled: false
47 |
--------------------------------------------------------------------------------
/cmd/ipfs/runmain_test.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | //+生成testrunmain
10 |
11 | package main
12 |
13 | import (
14 | "flag"
15 | "fmt"
16 | "io/ioutil"
17 | "os"
18 | "testing"
19 | )
20 |
21 | //这种滥用非常严重,以至于我在写这段代码时感到很肮脏。
22 | //但这是在不编写自定义编译器的情况下完成此任务的唯一方法
23 | //通过go测试成为go build的克隆
24 | func TestRunMain(t *testing.T) {
25 | args := flag.Args()
26 | os.Args = append([]string{os.Args[0]}, args...)
27 | ret := mainRet()
28 |
29 | p := os.Getenv("IPFS_COVER_RET_FILE")
30 | if len(p) != 0 {
31 | ioutil.WriteFile(p, []byte(fmt.Sprintf("%d\n", ret)), 0777)
32 | }
33 |
34 | //关闭输出,这样Go测试就不会打印任何内容
35 | null, _ := os.Open(os.DevNull)
36 | os.Stderr = null
37 | os.Stdout = null
38 | }
39 |
--------------------------------------------------------------------------------
/test/sharness/x0601-pin-fail-test.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copyright (c) 2016 Jeromy Johnson
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="Test very large number of pins"
8 |
9 | . lib/test-lib.sh
10 |
11 | test_init_ipfs
12 |
13 | test_launch_ipfs_daemon
14 |
15 | test_expect_success "pre-test setup" '
16 | printf "" > pins &&
17 | ipfs pin ls --type=recursive -q > rec_pins_before
18 | '
19 |
20 |
21 | for i in `seq 9000`
22 | do
23 | test_expect_success "ipfs add (and pin) a file" '
24 | echo $i | ipfs add -q >> pins
25 | '
26 | done
27 |
28 | test_expect_success "get pinset afterwards" '
29 | ipfs pin ls --type=recursive -q | sort > rec_pins_after &&
30 | cat pins rec_pins_before | sort | uniq > exp_pins_after &&
31 | test_cmp rec_pins_after exp_pins_after
32 | '
33 |
34 | test_kill_ipfs_daemon
35 |
36 | test_done
37 |
38 |
--------------------------------------------------------------------------------
/test/sharness/t0023-shutdown.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copyright (c) 2017 Jeromy Johnson
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="Test shutdown command"
8 |
9 | . lib/test-lib.sh
10 |
11 | test_init_ipfs
12 |
13 | test_launch_ipfs_daemon
14 |
15 | test_expect_success "shutdown succeeds" '
16 | ipfs shutdown
17 | '
18 |
19 | test_expect_success "daemon no longer running" '
20 | for i in $(test_seq 1 100)
21 | do
22 | go-sleep 100ms
23 | ! kill -0 $IPFS_PID 2>/dev/null && return
24 | done
25 | '
26 |
27 | test_launch_ipfs_daemon --offline
28 |
29 | test_expect_success "shutdown succeeds" '
30 | ipfs shutdown
31 | '
32 |
33 | test_expect_success "daemon no longer running" '
34 | for i in $(test_seq 1 100)
35 | do
36 | go-sleep 100ms
37 | ! kill -0 $IPFS_PID 2>/dev/null && return
38 | done
39 | '
40 | test_done
41 |
--------------------------------------------------------------------------------
/mk/util.mk:
--------------------------------------------------------------------------------
1 | # util functions
2 | OS ?= $(shell sh -c 'uname -s 2>/dev/null || echo not')
3 | ifeq ($(OS),Windows_NT)
4 | WINDOWS :=1
5 | ?exe :=.exe # windows compat
6 | PATH_SEP :=;
7 | else
8 | ?exe :=
9 | PATH_SEP :=:
10 | endif
11 |
12 | SUPPORTED_PLATFORMS += windows-386
13 | SUPPORTED_PLATFORMS += windows-amd64
14 |
15 | SUPPORTED_PLATFORMS += linux-arm
16 | SUPPORTED_PLATFORMS += linux-arm64
17 | SUPPORTED_PLATFORMS += linux-386
18 | SUPPORTED_PLATFORMS += linux-amd64
19 |
20 | SUPPORTED_PLATFORMS += darwin-386
21 | SUPPORTED_PLATFORMS += darwin-amd64
22 |
23 | SUPPORTED_PLATFORMS += freebsd-amd64
24 |
25 | space:=
26 | space+=
27 | comma:=,
28 | join-with=$(subst $(space),$1,$(strip $2))
29 |
30 | # debug target, prints varaible. Example: `make print-GOFLAGS`
31 | print-%:
32 | @echo $*=$($*)
33 |
34 | # phony target that will mean that recipe is always exectued
35 | ALWAYS:
36 | .PHONY: ALWAYS
37 |
--------------------------------------------------------------------------------
/test/dependencies/go-sleep/go-sleep.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package main
10 |
11 | import (
12 | "fmt"
13 | "os"
14 | "time"
15 | )
16 |
17 | func main() {
18 | if len(os.Args) != 2 {
19 | usageError()
20 | }
21 | d, err := time.ParseDuration(os.Args[1])
22 | if err != nil {
23 | fmt.Fprintf(os.Stderr, "Could not parse duration: %s\n", err)
24 | usageError()
25 | }
26 |
27 | time.Sleep(d)
28 | }
29 |
30 | func usageError() {
31 | fmt.Fprintf(os.Stderr, "Usage: %s \n", os.Args[0])
32 | fmt.Fprintln(os.Stderr, `Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".`)
33 | fmt.Fprintln(os.Stderr, "See https://godoc.org/time parseDuration for more.”)
34 | os.Exit(-1)
35 | }
36 |
--------------------------------------------------------------------------------
/cmd/ipfs/util/ulimit_unix.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | //+构建darwin linux netbsd openbsd
10 |
11 | package util
12 |
13 | import (
14 | unix "gx/ipfs/QmVGjyM9i2msKvLXwh9VosCTgP4mL91kC7hDmqnwTTx6Hu/sys/unix"
15 | )
16 |
17 | func init() {
18 | supportsFDManagement = true
19 | getLimit = unixGetLimit
20 | setLimit = unixSetLimit
21 | }
22 |
23 | func unixGetLimit() (uint64, uint64, error) {
24 | rlimit := unix.Rlimit{}
25 | err := unix.Getrlimit(unix.RLIMIT_NOFILE, &rlimit)
26 | return rlimit.Cur, rlimit.Max, err
27 | }
28 |
29 | func unixSetLimit(soft uint64, max uint64) error {
30 | rlimit := unix.Rlimit{
31 | Cur: soft,
32 | Max: max,
33 | }
34 | return unix.Setrlimit(unix.RLIMIT_NOFILE, &rlimit)
35 | }
36 |
--------------------------------------------------------------------------------
/fuse/ipns/link_unix.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | //+建设!诺福斯
10 |
11 | package ipns
12 |
13 | import (
14 | "context"
15 | "os"
16 |
17 | "gx/ipfs/QmSJBsmLP1XMjv8hxYg2rUMdPDB7YUpyBo9idjrJ6Cmq6F/fuse"
18 | "gx/ipfs/QmSJBsmLP1XMjv8hxYg2rUMdPDB7YUpyBo9idjrJ6Cmq6F/fuse/fs"
19 | )
20 |
21 | type Link struct {
22 | Target string
23 | }
24 |
25 | func (l *Link) Attr(ctx context.Context, a *fuse.Attr) error {
26 | log.Debug("Link attr.")
27 | a.Mode = os.ModeSymlink | 0555
28 | return nil
29 | }
30 |
31 | func (l *Link) Readlink(ctx context.Context, req *fuse.ReadlinkRequest) (string, error) {
32 | log.Debugf("ReadLink: %s", l.Target)
33 | return l.Target, nil
34 | }
35 |
36 | var _ fs.NodeReadlinker = (*Link)(nil)
37 |
--------------------------------------------------------------------------------
/fuse/ipns/mount_unix.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | //+构建Linux darwin freebsd netbsd openbsd
10 | //+建设!诺福斯
11 |
12 | package ipns
13 |
14 | import (
15 | core "github.com/ipfs/go-ipfs/core"
16 | mount "github.com/ipfs/go-ipfs/fuse/mount"
17 | )
18 |
19 | //mount在给定位置安装IPN,并返回mount.mount实例。
20 | func Mount(ipfs *core.IpfsNode, ipnsmp, ipfsmp string) (mount.Mount, error) {
21 | cfg, err := ipfs.Repo.Config()
22 | if err != nil {
23 | return nil, err
24 | }
25 |
26 | allow_other := cfg.Mounts.FuseAllowOther
27 |
28 | fsys, err := NewFileSystem(ipfs, ipfs.PrivateKey, ipfsmp, ipnsmp)
29 | if err != nil {
30 | return nil, err
31 | }
32 |
33 | return mount.NewMount(ipfs.Process(), fsys, ipnsmp, allow_other)
34 | }
35 |
--------------------------------------------------------------------------------
/test/api-startup/main.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package main
10 |
11 | import (
12 | "fmt"
13 | "log"
14 | "net/http"
15 | "sync"
16 | "time"
17 | )
18 |
19 | func main() {
20 | when := make(chan time.Time, 2)
21 | var wg sync.WaitGroup
22 | wg.Add(2)
23 | for _, port := range []string{"5001", "8080"} {
24 | go func(port string) {
25 | defer wg.Done()
26 | for {
27 | r, err := http.Get(fmt.Sprintf("http://127.0.0.1:%s”,端口)
28 | if err != nil {
29 | continue
30 | }
31 | t := time.Now()
32 | when <- t
33 | log.Println(port, t, r.StatusCode)
34 | break
35 | }
36 | }(port)
37 | }
38 | wg.Wait()
39 | first := <-when
40 | second := <-when
41 | log.Println(second.Sub(first))
42 | }
43 |
--------------------------------------------------------------------------------
/assets/init-doc/readme:
--------------------------------------------------------------------------------
1 | Hello and Welcome to IPFS!
2 |
3 | ██╗██████╗ ███████╗███████╗
4 | ██║██╔══██╗██╔════╝██╔════╝
5 | ██║██████╔╝█████╗ ███████╗
6 | ██║██╔═══╝ ██╔══╝ ╚════██║
7 | ██║██║ ██║ ███████║
8 | ╚═╝╚═╝ ╚═╝ ╚══════╝
9 |
10 | If you're seeing this, you have successfully installed
11 | IPFS and are now interfacing with the ipfs merkledag!
12 |
13 | -------------------------------------------------------
14 | | Warning: |
15 | | This is alpha software. Use at your own discretion! |
16 | | Much is missing or lacking polish. There are bugs. |
17 | | Not yet secure. Read the security notes for more. |
18 | -------------------------------------------------------
19 |
20 | Check out some of the other files in this directory:
21 |
22 | ./about
23 | ./help
24 | ./quick-start <-- usage examples
25 | ./readme <-- this file
26 | ./security-notes
27 |
--------------------------------------------------------------------------------
/test/sharness/t0150-clisuggest.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | test_description="Test ipfs cli cmd suggest"
4 |
5 | . lib/test-lib.sh
6 |
7 | test_suggest() {
8 |
9 |
10 | test_expect_success "test command fails" '
11 | test_must_fail ipfs kog 2>actual
12 | '
13 |
14 | test_expect_success "test one command is suggested" '
15 | grep "Did you mean this?" actual &&
16 | grep "log" actual ||
17 | test_fsh cat actual
18 | '
19 |
20 | test_expect_success "test command fails" '
21 | test_must_fail ipfs lis 2>actual
22 | '
23 |
24 | test_expect_success "test multiple commands are suggested" '
25 | grep "Did you mean any of these?" actual &&
26 | grep "ls" actual &&
27 | grep "id" actual ||
28 | test_fsh cat actual
29 | '
30 |
31 | }
32 |
33 | test_init_ipfs
34 |
35 | test_suggest
36 |
37 | test_launch_ipfs_daemon
38 |
39 | test_suggest
40 |
41 | test_kill_ipfs_daemon
42 |
43 | test_done
44 |
--------------------------------------------------------------------------------
/core/commands/e/error.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package e
10 |
11 | import (
12 | "fmt"
13 | "runtime/debug"
14 | )
15 |
16 | //typeerr返回一个错误,其字符串解释了预期的错误和收到的错误。
17 | func TypeErr(expected, actual interface{}) error {
18 | return fmt.Errorf("expected type %T, got %T", expected, actual)
19 | }
20 |
21 | //编译时类型检查handlerError是否为错误
22 | var _ error = New(nil)
23 |
24 | //handlerError向错误添加堆栈跟踪
25 | type HandlerError struct {
26 | Err error
27 | Stack []byte
28 | }
29 |
30 | //错误使handlerError实现错误
31 | func (err HandlerError) Error() string {
32 | return fmt.Sprintf("%s in:\n%s", err.Err.Error(), err.Stack)
33 | }
34 |
35 | //new返回新的handlerError
36 | func New(err error) HandlerError {
37 | return HandlerError{Err: err, Stack: debug.Stack()}
38 | }
39 |
--------------------------------------------------------------------------------
/bin/gencmdref:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | import os
4 | import sys
5 | import datetime
6 | import subprocess
7 |
8 | from subprocess import check_output
9 |
10 | def run(cmd):
11 | return check_output(cmd)
12 |
13 | def main():
14 | lines = [l.strip() for l in sys.stdin]
15 |
16 | print '# ipfs command reference'
17 | print ''
18 | print 'generated on', datetime.datetime.now()
19 | print ''
20 | for line in lines:
21 | print '- [%s](#%s)' % (line, line.replace(' ', '-'))
22 | print ''
23 |
24 | for line in lines:
25 | print '## %s' % line
26 | print ''
27 | print '```'
28 | print run((line + ' --help').split(' ')).strip()
29 | print '```'
30 | print ''
31 |
32 | if __name__ == '__main__':
33 | if '-h' in sys.argv or '--help' in sys.argv:
34 | print 'usage: ipfs commands | %s >cmdref.md' % sys.argv[0]
35 | print 'outputs all commands with --help to a markdown file'
36 | exit(0)
37 |
38 | main()
39 |
--------------------------------------------------------------------------------
/core/commands/mount_nofuse.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | //+建设!视窗
10 |
11 | package commands
12 |
13 | import (
14 | cmds "gx/ipfs/QmWGm4AbZEbnmdgVTza52MSNpEmBdFVqzmAysRbjrRyGbH/go-ipfs-cmds"
15 | cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit"
16 | )
17 |
18 | var MountCmd = &cmds.Command{
19 | Helptext: cmdkit.HelpText{
20 | Tagline: "Mounts ipfs to the filesystem (disabled).",
21 | ShortDescription: `
22 | This version of ipfs is compiled without fuse support, which is required
23 | for mounting. If you'd like to be able to mount, please use a version of
24 | ipfs compiled with fuse.
25 |
26 | For the latest instructions, please check the project's repository:
27 | http://github.com/ipfs/go-ipfs(Github.com/ipfs/go-ipfs)
28 | `,
29 | },
30 | }
31 |
--------------------------------------------------------------------------------
/test/sharness/t0231-channel-streaming.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copyright (c) 2015 Jeromy Johnson
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="Test output of streaming json commands"
8 |
9 | . lib/test-lib.sh
10 |
11 | test_init_ipfs
12 |
13 | get_api_port() {
14 | cat "$IPFS_PATH/api" | awk -F/ '{ print $5 }'
15 | }
16 |
17 | test_ls_cmd() {
18 | test_expect_success "make a file with multiple refs" '
19 | HASH=$(random 1000000 | ipfs add -q)
20 | '
21 |
22 | test_expect_success "can get refs through curl" '
23 | PORT=$(get_api_port) &&
24 | curl http://localhost:$PORT/api/v0/refs/$HASH > output
25 | '
26 |
27 | # make sure newlines are printed between each object
28 | test_expect_success "output looks good" '
29 | test_expect_code 1 grep "}{" output > /dev/null
30 | '
31 | }
32 |
33 | # should work online (only)
34 | test_launch_ipfs_daemon
35 | test_ls_cmd
36 | test_kill_ipfs_daemon
37 |
38 | test_done
39 |
--------------------------------------------------------------------------------
/test/3nodetest/Makefile:
--------------------------------------------------------------------------------
1 | IMAGE_NAME = ipfs-test-latest
2 | IPFS_ROOT = ../..
3 |
4 | test: clean setup
5 | ./run-test-on-img.sh $(IMAGE_NAME)
6 |
7 | setup: docker_ipfs_image data/filetiny data/filerand
8 |
9 | save_logs:
10 | sh bin/save_logs.sh
11 |
12 | save_profiling_data:
13 | sh bin/save_profiling_data.sh
14 |
15 | data/filetiny: Makefile
16 | cp Makefile ./data/filetiny # simple
17 |
18 | data/filerand: ../bin/random
19 | ../bin/random 50000000 > ./data/filerand
20 |
21 | ../bin/random:
22 | make -C ./../../ test/bin/random
23 |
24 | # just build it every time... this part isn't
25 | # even the lengthy part, and it decreases pain.
26 | docker_ipfs_image:
27 | docker build -t $(IMAGE_NAME) -f Dockerfile.fast .
28 | docker images | grep $(IMAGE_NAME)
29 |
30 | clean:
31 | sh bin/clean.sh
32 | fig stop
33 | fig rm -v --force
34 | rm -f bin/random
35 | rm -f data/filetiny
36 | rm -f data/filerand
37 | rm -rf build/*
38 | docker rmi $(docker images | grep "^" | awk "{print \$3}") -f || true
39 |
--------------------------------------------------------------------------------
/cmd/ipfs/dist/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Installation script for ipfs. It tries to move $bin in one of the
4 | # directories stored in $binpaths.
5 |
6 | INSTALL_DIR=$(dirname $0)
7 |
8 | bin="$INSTALL_DIR/ipfs"
9 | binpaths="/usr/local/bin /usr/bin"
10 |
11 | # This variable contains a nonzero length string in case the script fails
12 | # because of missing write permissions.
13 | is_write_perm_missing=""
14 |
15 | for binpath in $binpaths; do
16 | if mv "$bin" "$binpath/$bin" 2> /dev/null; then
17 | echo "Moved $bin to $binpath"
18 | exit 0
19 | else
20 | if [ -d "$binpath" -a ! -w "$binpath" ]; then
21 | is_write_perm_missing=1
22 | fi
23 | fi
24 | done
25 |
26 | echo "We cannot install $bin in one of the directories $binpaths"
27 |
28 | if [ -n "$is_write_perm_missing" ]; then
29 | echo "It seems that we do not have the necessary write permissions."
30 | echo "Perhaps try running this script as a privileged user:"
31 | echo
32 | echo " sudo $0"
33 | echo
34 | fi
35 |
36 | exit 1
37 |
--------------------------------------------------------------------------------
/thirdparty/unit/unit.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package unit
10 |
11 | import "fmt"
12 |
13 | type Information int64
14 |
15 | const (
16 | _ Information = iota //通过分配给空标识符忽略第一个值
17 | KB = 1 << (10 * iota)
18 | MB
19 | GB
20 | TB
21 | PB
22 | EB
23 | )
24 |
25 | func (i Information) String() string {
26 |
27 | tmp := int64(i)
28 |
29 | //违约
30 | var d = tmp
31 | symbol := "B"
32 |
33 | switch {
34 | case i > EB:
35 | d = tmp / EB
36 | symbol = "EB"
37 | case i > PB:
38 | d = tmp / PB
39 | symbol = "PB"
40 | case i > TB:
41 | d = tmp / TB
42 | symbol = "TB"
43 | case i > GB:
44 | d = tmp / GB
45 | symbol = "GB"
46 | case i > MB:
47 | d = tmp / MB
48 | symbol = "MB"
49 | case i > KB:
50 | d = tmp / KB
51 | symbol = "KB"
52 | }
53 | return fmt.Sprintf("%d %s", d, symbol)
54 | }
55 |
--------------------------------------------------------------------------------
/misc/launchd/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | src_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
4 | plist=io.ipfs.ipfs-daemon.plist
5 | dest_dir="$HOME/Library/LaunchAgents"
6 | IPFS_PATH="${IPFS_PATH:-$HOME/.ipfs}"
7 | escaped_ipfs_path=$(echo $IPFS_PATH|sed 's/\//\\\//g')
8 |
9 | IPFS_BIN=$(which ipfs || echo ipfs)
10 | escaped_ipfs_bin=$(echo $IPFS_BIN|sed 's/\//\\\//g')
11 |
12 | mkdir -p "$dest_dir"
13 |
14 | sed -e 's/{{IPFS_PATH}}/'"$escaped_ipfs_path"'/g' \
15 | -e 's/{{IPFS_BIN}}/'"$escaped_ipfs_bin"'/g' \
16 | "$src_dir/$plist" \
17 | > "$dest_dir/$plist"
18 |
19 | launchctl list | grep ipfs-daemon >/dev/null
20 | if [ $? ]; then
21 | echo Unloading existing ipfs-daemon
22 | launchctl unload "$dest_dir/$plist"
23 | fi
24 |
25 | echo Loading ipfs-daemon
26 | if (( `sw_vers -productVersion | cut -d'.' -f2` > 9 )); then
27 | sudo chown root "$dest_dir/$plist"
28 | sudo launchctl bootstrap system "$dest_dir/$plist"
29 | else
30 | launchctl load "$dest_dir/$plist"
31 | fi
32 | launchctl list | grep ipfs-daemon
33 |
--------------------------------------------------------------------------------
/core/commands/dht_test.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package commands
10 |
11 | import (
12 | "testing"
13 |
14 | "github.com/ipfs/go-ipfs/namesys"
15 |
16 | tu "gx/ipfs/QmNvHv84aH2qZafDuSdKJCQ1cvPZ1kmQmyD4YtzjUHuk9v/go-testutil"
17 | ipns "gx/ipfs/QmWPFehHmySCdaGttQ48iwF7M6mBRrGE5GSPWKCuMWqJDR/go-ipns"
18 | )
19 |
20 | func TestKeyTranslation(t *testing.T) {
21 | pid := tu.RandPeerIDFatal(t)
22 | pkname := namesys.PkKeyForID(pid)
23 | ipnsname := ipns.RecordKey(pid)
24 |
25 | pkk, err := escapeDhtKey("/pk/" + pid.Pretty())
26 | if err != nil {
27 | t.Fatal(err)
28 | }
29 |
30 | ipnsk, err := escapeDhtKey("/ipns/" + pid.Pretty())
31 | if err != nil {
32 | t.Fatal(err)
33 | }
34 |
35 | if pkk != pkname {
36 | t.Fatal("keys didnt match!")
37 | }
38 |
39 | if ipnsk != ipnsname {
40 | t.Fatal("keys didnt match!")
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/core/coredag/cbor.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package coredag
10 |
11 | import (
12 | "io"
13 | "io/ioutil"
14 |
15 | ipldcbor "gx/ipfs/QmRoARq3nkUb13HSKZGepCZSWe5GrVPwx7xURJGZ7KWv9V/go-ipld-cbor"
16 | ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format"
17 | )
18 |
19 | func cborJSONParser(r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
20 | nd, err := ipldcbor.FromJSON(r, mhType, mhLen)
21 | if err != nil {
22 | return nil, err
23 | }
24 |
25 | return []ipld.Node{nd}, nil
26 | }
27 |
28 | func cborRawParser(r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
29 | data, err := ioutil.ReadAll(r)
30 | if err != nil {
31 | return nil, err
32 | }
33 |
34 | nd, err := ipldcbor.Decode(data, mhType, mhLen)
35 | if err != nil {
36 | return nil, err
37 | }
38 |
39 | return []ipld.Node{nd}, nil
40 | }
41 |
--------------------------------------------------------------------------------
/core/coreapi/interface/block.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package iface
10 |
11 | import (
12 | "context"
13 | "io"
14 |
15 | options "github.com/ipfs/go-ipfs/core/coreapi/interface/options"
16 | )
17 |
18 | //blockstat包含有关块的信息
19 | type BlockStat interface {
20 | //大小是块的大小
21 | Size() int
22 |
23 | //path返回块的路径
24 | Path() ResolvedPath
25 | }
26 |
27 | //blockapi指定块层的接口
28 | type BlockAPI interface {
29 | //Put导入原始块数据,使用指定的设置对其进行哈希处理。
30 | Put(context.Context, io.Reader, ...options.BlockPutOption) (BlockStat, error)
31 |
32 | //获取解析路径的尝试并返回块中数据的读卡器
33 | Get(context.Context, Path) (io.Reader, error)
34 |
35 | //RM从本地BlockStore中删除由路径指定的块。
36 | //默认情况下,如果在本地找不到块,将返回错误。
37 | //
38 | //注意:如果固定了指定的块,它将不会被删除,也不会出错。
39 | //将被退回
40 | Rm(context.Context, Path, ...options.BlockRmOption) error
41 |
42 | //stat返回信息
43 | Stat(context.Context, Path) (BlockStat, error)
44 | }
45 |
--------------------------------------------------------------------------------
/core/coreapi/interface/dht.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package iface
10 |
11 | import (
12 | "context"
13 |
14 | "github.com/ipfs/go-ipfs/core/coreapi/interface/options"
15 |
16 | pstore "gx/ipfs/QmPiemjiKBC9VA7vZF82m4x1oygtg2c2YVqag8PX7dN1BD/go-libp2p-peerstore"
17 | peer "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer"
18 | )
19 |
20 | //DHTAPI指定DHT的接口
21 | //注意:此API在不久的将来可能会被弃用,请参阅
22 | //https://github.com/ipfs/interface-ipfs-core/issues/249了解更多上下文。
23 | type DhtAPI interface {
24 | //findpeer查询DHT中与
25 | //对等体ID
26 | FindPeer(context.Context, peer.ID) (pstore.PeerInfo, error)
27 |
28 | //findproviders在DHT中查找能够提供特定值的对等方
29 | //给出了一个键。
30 | FindProviders(context.Context, Path, ...options.DhtFindProvidersOption) (<-chan pstore.PeerInfo, error)
31 |
32 | //向网络宣布您正在提供给定值
33 | Provide(context.Context, Path, ...options.DhtProvideOption) error
34 | }
35 |
--------------------------------------------------------------------------------
/test/integration/Makefile:
--------------------------------------------------------------------------------
1 | # This Makefile provides a way to really simple way to run benchmarks in a
2 | # docker environment.
3 |
4 | IPFS_ROOT = ../..
5 | CONTAINER = go-ipfs-bench
6 | PACKAGE = integrationtest
7 | PACKAGE_DIR = test/integration
8 | BUILD_DIR = ./build/bench
9 | CONTAINER_WORKING_DIR = /go
10 | CPU_PROF_NAME = cpu.out
11 | EXTRA_TEST_ARGS =
12 |
13 | all: collect
14 |
15 | collect: clean build_image run_profiler cp_pprof_from_container
16 |
17 | cp_pprof_from_container:
18 | docker cp $(CONTAINER):$(CONTAINER_WORKING_DIR)/$(CPU_PROF_NAME) $(BUILD_DIR)
19 | docker cp $(CONTAINER):$(CONTAINER_WORKING_DIR)/$(PACKAGE).test $(BUILD_DIR)
20 |
21 | build_image:
22 | cd $(IPFS_ROOT) && docker build -t $(IMAGE) .
23 |
24 | run_profiler:
25 | docker run --name $(CONTAINER) -it --entrypoint go $(IMAGE) test ./src/github.com/ipfs/go-ipfs/$(PACKAGE_DIR) --cpuprofile=$(CPU_PROF_NAME) $(EXTRA_TEST_ARGS)
26 |
27 |
28 | clean:
29 | docker rm $(CONTAINER) || true
30 | rm -rf $(BUILD_DIR)
31 |
32 | analyze:
33 | go tool pprof $(BUILD_DIR)/$(PACKAGE).test $(BUILD_DIR)/$(CPU_PROF_NAME)
34 |
--------------------------------------------------------------------------------
/core/commands/shutdown.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package commands
10 |
11 | import (
12 | cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv"
13 |
14 | cmds "gx/ipfs/QmWGm4AbZEbnmdgVTza52MSNpEmBdFVqzmAysRbjrRyGbH/go-ipfs-cmds"
15 | "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit"
16 | )
17 |
18 | var daemonShutdownCmd = &cmds.Command{
19 | Helptext: cmdkit.HelpText{
20 | Tagline: "Shut down the ipfs daemon",
21 | },
22 | Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error {
23 | nd, err := cmdenv.GetNode(env)
24 | if err != nil {
25 | return err
26 | }
27 |
28 | if nd.LocalMode() {
29 | return cmdkit.Errorf(cmdkit.ErrClient, "daemon not running")
30 | }
31 |
32 | if err := nd.Process().Close(); err != nil {
33 | log.Error("error while shutting down ipfs daemon:", err)
34 | }
35 |
36 | return nil
37 | },
38 | }
39 |
--------------------------------------------------------------------------------
/test/sharness/t0400-api-security.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copyright (c) 2016 Lars Gierth
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="Test API security"
8 |
9 | . lib/test-lib.sh
10 |
11 | test_init_ipfs
12 |
13 | # by default, we don't let you load arbitrary ipfs objects through the api,
14 | # because this would open up the api to scripting vulnerabilities.
15 | # only the webui objects are allowed.
16 | # if you know what you're doing, go ahead and pass --unrestricted-api.
17 |
18 | test_launch_ipfs_daemon
19 | test_expect_success "Gateway on API unavailable" '
20 | HASH=$(echo "testing" | ipfs add -q)
21 | test_curl_resp_http_code "http://127.0.0.1:$API_PORT/ipfs/$HASH" "HTTP/1.1 404 Not Found"
22 | '
23 | test_kill_ipfs_daemon
24 |
25 | test_launch_ipfs_daemon --unrestricted-api
26 | test_expect_success "Gateway on --unrestricted-api API available" '
27 | HASH=$(echo "testing" | ipfs add -q)
28 | test_curl_resp_http_code "http://127.0.0.1:$API_PORT/ipfs/$HASH" "HTTP/1.1 200 OK"
29 | '
30 | test_kill_ipfs_daemon
31 |
32 | test_done
33 |
--------------------------------------------------------------------------------
/test/dependencies/iptb/iptb.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package main
10 |
11 | import (
12 | "fmt"
13 | "os"
14 |
15 | cli "gx/ipfs/QmckeQ2zrYLAXoSHYTGn5BDdb22BqbUoHEHm8KZ9YWRxd1/iptb/cli"
16 | testbed "gx/ipfs/QmckeQ2zrYLAXoSHYTGn5BDdb22BqbUoHEHm8KZ9YWRxd1/iptb/testbed"
17 |
18 | plugin "gx/ipfs/QmdK1j8AGfu26tQxTVgnMtMBJfZpsYQor7HSNjjunRZZ6g/iptb-plugins/local"
19 | )
20 |
21 | func init() {
22 | _, err := testbed.RegisterPlugin(testbed.IptbPlugin{
23 | From: "",
24 | NewNode: plugin.NewNode,
25 | GetAttrList: plugin.GetAttrList,
26 | GetAttrDesc: plugin.GetAttrDesc,
27 | PluginName: plugin.PluginName,
28 | BuiltIn: true,
29 | }, false)
30 |
31 | if err != nil {
32 | panic(err)
33 | }
34 | }
35 |
36 | func main() {
37 | cli := cli.NewCli()
38 | if err := cli.Run(os.Args); err != nil {
39 | fmt.Fprintf(cli.ErrWriter, "%s\n", err)
40 | os.Exit(1)
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/docs/command-completion.md:
--------------------------------------------------------------------------------
1 | Command Completion
2 | ==================
3 |
4 | Shell command completion is provided by the script at
5 | [/misc/completion/ipfs-completion.bash](../misc/completion/ipfs-completion.bash).
6 |
7 |
8 | Installation
9 | ------------
10 | The simplest way to see it working is to run
11 | `source misc/completion/ipfs-completion.bash` straight from your shell. This
12 | is only temporary and to fully enable it, you'll have to follow one of the steps
13 | below.
14 |
15 | ### Bash on Linux
16 | For bash, completion can be enabled in a couple of ways. One is to copy the
17 | completion script to the directory `~/.ipfs/` and then in the file
18 | `~/.bash_completion` add
19 | ```bash
20 | source ~/.ipfs/ipfs-completion.bash
21 | ```
22 | It will automatically be loaded the next time bash is loaded.
23 | To enable ipfs command completion globally on your system you may also
24 | copy the completion script to `/etc/bash_completion.d/`.
25 |
26 |
27 | Additional References
28 | ---------------------
29 | * https://www.debian-administration.org/article/316/An_introduction_to_bash_completion_part_1
30 |
--------------------------------------------------------------------------------
/test/sharness/t0151-sysdiag.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copyright (c) 2015 Jeromy Johnson
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="test output of sysdiag command"
8 |
9 | . lib/test-lib.sh
10 |
11 | test_init_ipfs
12 |
13 | test_expect_success "ipfs diag sys succeeds" '
14 | ipfs diag sys > output
15 | '
16 |
17 | test_expect_success "output contains some expected keys" '
18 | grep "virt" output &&
19 | grep "interface_addresses" output &&
20 | grep "arch" output &&
21 | grep "online" output
22 | '
23 |
24 | test_expect_success "uname succeeds" '
25 | UOUT=$(uname)
26 | '
27 |
28 | test_expect_success "output is similar to uname" '
29 | case $UOUT in
30 | Linux)
31 | grep linux output > /dev/null
32 | ;;
33 | Darwin)
34 | grep darwin output > /dev/null
35 | ;;
36 | FreeBSD)
37 | grep freebsd output > /dev/null
38 | ;;
39 | CYGWIN*)
40 | grep windows output > /dev/null
41 | ;;
42 | *)
43 | test_fsh echo system check for $UOUT failed, unsupported system?
44 | ;;
45 | esac
46 | '
47 |
48 | test_done
49 |
--------------------------------------------------------------------------------
/core/commands/unixfs/unixfs.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package unixfs
10 |
11 | import (
12 | cmds "gx/ipfs/QmWGm4AbZEbnmdgVTza52MSNpEmBdFVqzmAysRbjrRyGbH/go-ipfs-cmds"
13 | cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit"
14 | )
15 |
16 | var UnixFSCmd = &cmds.Command{
17 | Helptext: cmdkit.HelpText{
18 | Tagline: "Interact with IPFS objects representing Unix filesystems.",
19 | ShortDescription: `
20 | 'ipfs file' provides a familiar interface to file systems represented
21 | by IPFS objects, which hides ipfs implementation details like layout
22 | objects (e.g. fanout and chunking).
23 | `,
24 | LongDescription: `
25 | 'ipfs file' provides a familiar interface to file systems represented
26 | by IPFS objects, which hides ipfs implementation details like layout
27 | objects (e.g. fanout and chunking).
28 | `,
29 | },
30 |
31 | Subcommands: map[string]*cmds.Command{
32 | "ls": LsCmd,
33 | },
34 | }
35 |
--------------------------------------------------------------------------------
/test/README.md:
--------------------------------------------------------------------------------
1 |
2 | ## Sharness test command coverage
3 |
4 | Module | Online Test | Offline Test |
5 | -----------|-----------------|-----------------|
6 | object | t0051 | t0051
7 | ls | t0045 | t0045
8 | cat | t0040 |
9 | dht | |
10 | bitswap | |
11 | block | | t0050
12 | daemon | t0030 | N/A
13 | init | N/A | t0020
14 | add | t0040 |
15 | config | t0021 | t0021
16 | version | t0060 | t0010
17 | ping | |
18 | diag | |
19 | mount | t0030 |
20 | name | t0110 | t0100
21 | pin | t0080 |
22 | get | t0090 | t0090
23 | refs | t0080 |
24 | repo gc | t0080 |
25 | id | |
26 | bootstrap | t0120 | t0120
27 | swarm | |
28 | update | |
29 | commands | |
30 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014-2016 Juan Batiz-Benet
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/test/sharness/t0251-files-flushing.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copyright (c) 2016 Jeromy Johnson
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="test the unix files api flushing"
8 |
9 | . lib/test-lib.sh
10 |
11 | test_init_ipfs
12 |
13 | verify_path_exists() {
14 | # simply running ls on a file should be a good 'check'
15 | ipfs files ls $1
16 | }
17 |
18 | verify_dir_contents() {
19 | dir=$1
20 | shift
21 | rm -f expected
22 | touch expected
23 | for e in $@
24 | do
25 | echo $e >> expected
26 | done
27 |
28 | test_expect_success "can list dir" '
29 | ipfs files ls $dir > output
30 | '
31 |
32 | test_expect_success "dir entries look good" '
33 | test_sort_cmp output expected
34 | '
35 | }
36 |
37 | test_launch_ipfs_daemon
38 |
39 | test_expect_success "can copy a file in" '
40 | HASH=$(echo "foo" | ipfs add -q) &&
41 | ipfs files cp /ipfs/$HASH /file
42 | '
43 |
44 | test_kill_ipfs_daemon
45 | test_launch_ipfs_daemon
46 |
47 | test_expect_success "file is still there" '
48 | verify_path_exists /file
49 | '
50 |
51 | test_kill_ipfs_daemon
52 |
53 | test_done
54 |
--------------------------------------------------------------------------------
/cmd/ipfs/dist/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Juan Batiz-Benet
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/cmd/ipfs/util/ulimit_freebsd.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | //+构建FreeBSD
10 |
11 | package util
12 |
13 | import (
14 | "errors"
15 | "math"
16 |
17 | unix "gx/ipfs/QmVGjyM9i2msKvLXwh9VosCTgP4mL91kC7hDmqnwTTx6Hu/sys/unix"
18 | )
19 |
20 | func init() {
21 | supportsFDManagement = true
22 | getLimit = freebsdGetLimit
23 | setLimit = freebsdSetLimit
24 | }
25 |
26 | func freebsdGetLimit() (uint64, uint64, error) {
27 | rlimit := unix.Rlimit{}
28 | err := unix.Getrlimit(unix.RLIMIT_NOFILE, &rlimit)
29 | if (rlimit.Cur < 0) || (rlimit.Max < 0) {
30 | return 0, 0, errors.New("invalid rlimits")
31 | }
32 | return uint64(rlimit.Cur), uint64(rlimit.Max), err
33 | }
34 |
35 | func freebsdSetLimit(soft uint64, max uint64) error {
36 | if (soft > math.MaxInt64) || (max > math.MaxInt64) {
37 | return errors.New("invalid rlimits")
38 | }
39 | rlimit := unix.Rlimit{
40 | Cur: int64(soft),
41 | Max: int64(max),
42 | }
43 | return unix.Setrlimit(unix.RLIMIT_NOFILE, &rlimit)
44 | }
45 |
--------------------------------------------------------------------------------
/fuse/ipns/common.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package ipns
10 |
11 | import (
12 | "context"
13 |
14 | "github.com/ipfs/go-ipfs/core"
15 | nsys "github.com/ipfs/go-ipfs/namesys"
16 | path "gx/ipfs/QmNYPETsdAu2uQ1k9q9S1jYEGURaLHV6cbYRSVFVRftpF8/go-path"
17 | ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto"
18 | ft "gx/ipfs/QmQXze9tG878pa4Euya4rrDpyTNX3kQe4dhCaBzBozGgpe/go-unixfs"
19 | )
20 |
21 | //InitializeKeyspace将给定密钥的IPN记录设置为
22 | //指向空目录。
23 | func InitializeKeyspace(n *core.IpfsNode, key ci.PrivKey) error {
24 | ctx, cancel := context.WithCancel(n.Context())
25 | defer cancel()
26 |
27 | emptyDir := ft.EmptyDirNode()
28 |
29 | err := n.Pinning.Pin(ctx, emptyDir, false)
30 | if err != nil {
31 | return err
32 | }
33 |
34 | err = n.Pinning.Flush()
35 | if err != nil {
36 | return err
37 | }
38 |
39 | pub := nsys.NewIpnsPublisher(n.Routing, n.Repo.Datastore())
40 |
41 | return pub.Publish(ctx, key, path.FromCid(emptyDir.Cid()))
42 | }
43 |
--------------------------------------------------------------------------------
/test/3nodetest/run-test-on-img.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | if [ "$#" -ne 1 ]; then
3 | echo "usage: $0 "
4 | echo "runs this test on image matching "
5 | exit 1
6 | fi
7 |
8 | # this tag is used by the dockerfiles in
9 | # {data, server, client, bootstrap}
10 | tag=zaqwsx_ipfs-test-img
11 |
12 | # could use set -v, but i dont want to see the comments...
13 |
14 | img=$(docker images | grep $1 | awk '{print $3}')
15 | echo "using docker image: $img ($1)"
16 |
17 | echo docker tag -f $img $tag
18 | docker tag -f $img $tag
19 |
20 | echo "fig build --no-cache"
21 | fig build --no-cache
22 |
23 | echo "fig up --no-color | tee build/fig.log"
24 | fig up --no-color | tee build/fig.log
25 |
26 | # save the ipfs logs for inspection
27 | echo "make save_logs"
28 | make save_logs || true # don't fail
29 |
30 | # save the ipfs logs for inspection
31 | echo "make save_profiling_data"
32 | make save_profiling_data || true # don't fail
33 |
34 | # fig up won't report the error using an error code, so we grep the
35 | # fig.log file to find out whether the call succeeded
36 | echo 'tail build/fig.log | grep "exited with code 0"'
37 | tail build/fig.log | grep "exited with code 0"
38 |
--------------------------------------------------------------------------------
/test/dependencies/ma-pipe-unidir/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2017 Łukasz Magiera
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/test/sharness/t0101-iptb-name.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copyright (c) 2014 Jeromy Johnson
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="Test ipfs repo operations"
8 |
9 | . lib/test-lib.sh
10 |
11 | num_nodes=4
12 |
13 | test_expect_success "set up an iptb cluster" '
14 | iptb testbed create -type localipfs -count $num_nodes -force -init
15 | '
16 |
17 | startup_cluster $num_nodes
18 |
19 | test_expect_success "add an obect on one node" '
20 | echo "ipns is super fun" > file &&
21 | HASH_FILE=$(ipfsi 1 add -q file)
22 | '
23 |
24 | test_expect_success "publish that object as an ipns entry" '
25 | ipfsi 1 name publish $HASH_FILE
26 | '
27 |
28 | test_expect_success "add an entry on another node pointing to that one" '
29 | NODE1_ID=$(iptb attr get 1 id) &&
30 | ipfsi 2 name publish /ipns/$NODE1_ID
31 | '
32 |
33 | test_expect_success "cat that entry on a third node" '
34 | NODE2_ID=$(iptb attr get 2 id) &&
35 | ipfsi 3 cat /ipns/$NODE2_ID > output
36 | '
37 |
38 | test_expect_success "ensure output was the same" '
39 | test_cmp file output
40 | '
41 |
42 | test_expect_success "shut down iptb" '
43 | iptb stop
44 | '
45 |
46 | test_done
47 |
--------------------------------------------------------------------------------
/test/3nodetest/server/run.sh:
--------------------------------------------------------------------------------
1 | # must be connected to bootstrap node
2 | ipfs bootstrap add /ip4/$BOOTSTRAP_PORT_4011_TCP_ADDR/tcp/$BOOTSTRAP_PORT_4011_TCP_PORT/ipfs/QmNXuBh8HFsWq68Fid8dMbGNQTh7eG6hV9rr1fQyfmfomE
3 | ipfs bootstrap # list bootstrap nodes for debugging
4 |
5 | # wait for daemon to start/bootstrap
6 | # alternatively use ipfs swarm connect
7 | echo "3nodetest> starting server daemon"
8 |
9 | # run daemon in debug mode to collect profiling data
10 | ipfs daemon --debug &
11 | sleep 3
12 | # TODO instead of bootrapping: ipfs swarm connect /ip4/$BOOTSTRAP_PORT_4011_TCP_ADDR/tcp/$BOOTSTRAP_PORT_4011_TCP_PORT/ipfs/QmNXuBh8HFsWq68Fid8dMbGNQTh7eG6hV9rr1fQyfmfomE
13 |
14 | # change dir before running add commands so ipfs client profiling data doesn't
15 | # overwrite the daemon profiling data
16 | cd /tmp
17 |
18 | # must mount this volume from data container
19 | ipfs add -q /data/filetiny > tmptiny
20 | mv tmptiny /data/idtiny
21 | echo "3nodetest> added tiny file. hash is" $(cat /data/idtiny)
22 |
23 | ipfs add -q /data/filerand > tmprand
24 | mv tmprand /data/idrand
25 | echo "3nodetest> added rand file. hash is" $(cat /data/idrand)
26 |
27 | # allow ample time for the client to pull the data
28 | sleep 10000000
29 |
--------------------------------------------------------------------------------
/core/coreapi/interface/unixfs.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package iface
10 |
11 | import (
12 | "context"
13 |
14 | "github.com/ipfs/go-ipfs/core/coreapi/interface/options"
15 |
16 | files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files"
17 | ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format"
18 | )
19 |
20 | type AddEvent struct {
21 | Name string
22 | Path ResolvedPath `json:",omitempty"`
23 | Bytes int64 `json:",omitempty"`
24 | Size string `json:",omitempty"`
25 | }
26 |
27 | //unixfsapi是IPF中不可变文件的基本接口
28 | //注意:这个API是大量WIP,保证经常中断。
29 | type UnixfsAPI interface {
30 | //添加将读卡器中的数据导入到merkledag文件中
31 | //
32 | //TODO:关于如何在许多不同的场景中使用它的一个长期有用的注释
33 | Add(context.Context, files.Node, ...options.UnixfsAddOption) (ResolvedPath, error)
34 |
35 | //get返回路径引用的文件树的只读句柄
36 | //
37 | //请注意,此API的某些实现可能应用指定的上下文
38 | //到对返回文件执行的操作
39 | Get(context.Context, Path) (files.Node, error)
40 |
41 | //ls返回目录中的链接列表
42 | Ls(context.Context, Path) ([]*ipld.Link, error)
43 | }
44 |
--------------------------------------------------------------------------------
/namesys/cache.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package namesys
10 |
11 | import (
12 | "time"
13 |
14 | path "gx/ipfs/QmNYPETsdAu2uQ1k9q9S1jYEGURaLHV6cbYRSVFVRftpF8/go-path"
15 | )
16 |
17 | func (ns *mpns) cacheGet(name string) (path.Path, bool) {
18 | if ns.cache == nil {
19 | return "", false
20 | }
21 |
22 | ientry, ok := ns.cache.Get(name)
23 | if !ok {
24 | return "", false
25 | }
26 |
27 | entry, ok := ientry.(cacheEntry)
28 | if !ok {
29 | //绝对不应该发生,纯粹为了理智
30 | log.Panicf("unexpected type %T in cache for %q.", ientry, name)
31 | }
32 |
33 | if time.Now().Before(entry.eol) {
34 | return entry.val, true
35 | }
36 |
37 | ns.cache.Remove(name)
38 |
39 | return "", false
40 | }
41 |
42 | func (ns *mpns) cacheSet(name string, val path.Path, ttl time.Duration) {
43 | if ns.cache == nil || ttl <= 0 {
44 | return
45 | }
46 | ns.cache.Add(name, cacheEntry{
47 | val: val,
48 | eol: time.Now().Add(ttl),
49 | })
50 | }
51 |
52 | type cacheEntry struct {
53 | val path.Path
54 | eol time.Time
55 | }
56 |
--------------------------------------------------------------------------------
/test/dependencies/go-sleep/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Juan Batiz-Benet
4 | Copyright (c) 2015 Christian Couder
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/test/dependencies/go-timeout/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Jakub "Kubuxu" Sztandera
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/test/sharness/t0210-tar.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copyright (c) 2015 Jeromy Johnson
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="Test tar commands"
8 |
9 | . lib/test-lib.sh
10 |
11 | test_init_ipfs
12 |
13 | test_expect_success "create some random files" '
14 | mkdir foo &&
15 | random 10000 > foo/a &&
16 | random 12345 > foo/b &&
17 | mkdir foo/bar &&
18 | random 5432 > foo/bar/baz &&
19 | ln -s ../a foo/bar/link &&
20 | echo "exit" > foo/script &&
21 | chmod +x foo/script
22 | '
23 |
24 | test_expect_success "tar those random files up" '
25 | tar cf files.tar foo/
26 | '
27 |
28 | test_expect_success "'ipfs tar add' succeeds" '
29 | TAR_HASH=$(ipfs tar add files.tar)
30 | '
31 |
32 | test_expect_success "'ipfs tar cat' succeeds" '
33 | mkdir output &&
34 | ipfs tar cat $TAR_HASH > output/out.tar
35 | '
36 |
37 | test_expect_success "can extract tar" '
38 | tar xf output/out.tar -C output/
39 | '
40 |
41 | test_expect_success "files look right" '
42 | diff foo/a output/foo/a &&
43 | diff foo/b output/foo/b &&
44 | diff foo/bar/baz output/foo/bar/baz &&
45 | [ -L output/foo/bar/link ] &&
46 | [ -x foo/script ]
47 | '
48 |
49 | test_done
50 |
--------------------------------------------------------------------------------
/cmd/seccat/util.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package main
10 |
11 | import (
12 | "fmt"
13 | "net"
14 | "os"
15 |
16 | logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log"
17 | )
18 |
19 | var log = logging.Logger("seccat")
20 |
21 | func exit(format string, vals ...interface{}) {
22 | if format != "" {
23 | fmt.Fprintf(os.Stderr, "seccat: error: "+format+"\n", vals...)
24 | }
25 | Usage()
26 | os.Exit(1)
27 | }
28 |
29 | func out(format string, vals ...interface{}) {
30 | if verbose {
31 | fmt.Fprintf(os.Stderr, "seccat: "+format+"\n", vals...)
32 | }
33 | }
34 |
35 | type logConn struct {
36 | net.Conn
37 | n string
38 | }
39 |
40 | func (r *logConn) Read(buf []byte) (int, error) {
41 | n, err := r.Conn.Read(buf)
42 | if n > 0 {
43 | log.Debugf("%s read: %v", r.n, buf)
44 | }
45 | return n, err
46 | }
47 |
48 | func (r *logConn) Write(buf []byte) (int, error) {
49 | log.Debugf("%s write: %v", r.n, buf)
50 | return r.Conn.Write(buf)
51 | }
52 |
53 | func (r *logConn) Close() error {
54 | return r.Conn.Close()
55 | }
56 |
--------------------------------------------------------------------------------
/core/pathresolver_test.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package core_test
10 |
11 | import (
12 | "testing"
13 |
14 | core "github.com/ipfs/go-ipfs/core"
15 | coremock "github.com/ipfs/go-ipfs/core/mock"
16 | path "gx/ipfs/QmNYPETsdAu2uQ1k9q9S1jYEGURaLHV6cbYRSVFVRftpF8/go-path"
17 | )
18 |
19 | func TestResolveNoComponents(t *testing.T) {
20 | n, err := coremock.NewMockNode()
21 | if n == nil || err != nil {
22 | t.Fatal("Should have constructed a mock node", err)
23 | }
24 |
25 | _, err = core.Resolve(n.Context(), n.Namesys, n.Resolver, path.Path("/ipns/"))
26 | if err != path.ErrNoComponents {
27 | t.Fatal("Should error with no components (/ipns/).", err)
28 | }
29 |
30 | _, err = core.Resolve(n.Context(), n.Namesys, n.Resolver, path.Path("/ipfs/"))
31 | if err != path.ErrNoComponents {
32 | t.Fatal("Should error with no components (/ipfs/).", err)
33 | }
34 |
35 | _, err = core.Resolve(n.Context(), n.Namesys, n.Resolver, path.Path("/../.."))
36 | if err != path.ErrBadPath {
37 | t.Fatal("Should error with invalid path.", err)
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/test/sharness/t0065-active-requests.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copyright (c) 2016 Jeromy Johnson
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="Test active request commands"
8 |
9 | . lib/test-lib.sh
10 |
11 | test_init_ipfs
12 | test_launch_ipfs_daemon
13 |
14 | test_expect_success "command works" '
15 | ipfs diag cmds > cmd_out
16 | '
17 |
18 | test_expect_success "invoc shows up in output" '
19 | grep "diag/cmds" cmd_out > /dev/null
20 | '
21 |
22 | test_expect_success "start longer running command" '
23 | ipfs log tail &
24 | LOGPID=$!
25 | go-sleep 100ms
26 | '
27 |
28 | test_expect_success "long running command shows up" '
29 | ipfs diag cmds > cmd_out2
30 | '
31 |
32 | test_expect_success "output looks good" '
33 | grep "log/tail" cmd_out2 | grep "true" > /dev/null
34 | '
35 |
36 | test_expect_success "kill log cmd" '
37 | kill $LOGPID
38 | go-sleep 0.5s
39 | kill $LOGPID
40 |
41 | wait $LOGPID || true
42 | '
43 |
44 | test_expect_success "long running command inactive" '
45 | ipfs diag cmds > cmd_out3
46 | '
47 |
48 | test_expect_success "command shows up as inactive" '
49 | grep "log/tail" cmd_out3 | grep "false"
50 | '
51 |
52 | test_kill_ipfs_daemon
53 | test_done
54 |
--------------------------------------------------------------------------------
/assets/init-doc/security-notes:
--------------------------------------------------------------------------------
1 | IPFS Alpha Security Notes
2 |
3 | We try hard to ensure our system is safe and robust, but all software
4 | has bugs, especially new software. This distribution is meant to be an
5 | alpha preview, don't use it for anything mission critical.
6 |
7 | Please note the following:
8 |
9 | - This is alpha software and has not been audited. It is our goal
10 | to conduct a proper security audit once we close in on a 1.0 release.
11 |
12 | - ipfs is a networked program, and may have serious undiscovered
13 | vulnerabilities. It is written in Go, and we do not execute any
14 | user provided data. But please point any problems out to us in a
15 | github issue, or email security@ipfs.io privately.
16 |
17 | - security@ipfs.io GPG key:
18 | - 4B9665FB 92636D17 7C7A86D3 50AAE8A9 59B13AF3
19 | - https://pgp.mit.edu/pks/lookup?op=get&search=0x50AAE8A959B13AF3
20 |
21 | - ipfs uses encryption for all communication, but it's NOT PROVEN SECURE
22 | YET! It may be totally broken. For now, the code is included to make
23 | sure we benchmark our operations with encryption in mind. In the future,
24 | there will be an "unsafe" mode for high performance intranet apps.
25 | If this is a blocking feature for you, please contact us.
26 |
--------------------------------------------------------------------------------
/core/coreapi/interface/dag.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package iface
10 |
11 | import (
12 | "context"
13 | "io"
14 |
15 | "github.com/ipfs/go-ipfs/core/coreapi/interface/options"
16 |
17 | ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format"
18 | )
19 |
20 | //DAGOPS对可以一起批处理的操作进行分组
21 | type DagOps interface {
22 | //使用指定的格式和输入编码放置插入数据。
23 | //除非与withcodec或withhash一起使用,否则默认值为“dag cbor”和
24 | //使用“sha256”。
25 | Put(ctx context.Context, src io.Reader, opts ...options.DagPutOption) (ResolvedPath, error)
26 | }
27 |
28 | //dagbatch是dagapi的批处理版本。dagbatch的所有实现
29 | //应该是螺纹安全的
30 | type DagBatch interface {
31 | DagOps
32 |
33 | //提交将节点提交到数据存储并向网络公布它们
34 | Commit(ctx context.Context) error
35 | }
36 |
37 | //dagapi指定到ipld的接口
38 | type DagAPI interface {
39 | DagOps
40 |
41 | //获取解析和获取由路径指定的节点的尝试
42 | Get(ctx context.Context, path Path) (ipld.Node, error)
43 |
44 | //树返回由路径指定的节点内的路径列表。
45 | Tree(ctx context.Context, path Path, opts ...options.DagTreeOption) ([]Path, error)
46 |
47 | //批量创建新的dagbatch
48 | Batch(ctx context.Context) DagBatch
49 | }
50 |
--------------------------------------------------------------------------------
/bin/check_go_version:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Check that the go version is at least equal to a minimum version
4 | # number.
5 | #
6 | # Call it for example like this:
7 | #
8 | # $ check_go_version "1.5.2"
9 | #
10 |
11 | USAGE="$0 GO_MIN_VERSION"
12 |
13 | die() {
14 | printf >&2 "fatal: %s\n" "$@"
15 | exit 1
16 | }
17 |
18 | # Get arguments
19 |
20 | test "$#" -eq "1" || die "This program must be passed exactly 1 arguments" "Usage: $USAGE"
21 |
22 | GO_MIN_VERSION="$1"
23 |
24 | UPGRADE_MSG="Please take a look at https://golang.org/doc/install to install or upgrade go."
25 |
26 | # Get path to the directory containing this file
27 | # If $0 has no slashes, uses "./"
28 | PREFIX=$(expr "$0" : "\(.*\/\)") || PREFIX='./'
29 | # Include the 'check_at_least_version' function
30 | . ${PREFIX}check_version
31 |
32 | # Check that the go binary exist and is in the path
33 |
34 | type go >/dev/null 2>&1 || die_upgrade "go is not installed or not in the PATH!"
35 |
36 | # Check the go binary version
37 |
38 | VERS_STR=$(go version 2>&1) || die "'go version' failed with output: $VERS_STR"
39 |
40 | GO_CUR_VERSION=$(expr "$VERS_STR" : ".*go version go\([^ ]*\) .*") || die "Invalid 'go version' output: $VERS_STR"
41 |
42 | check_at_least_version "$GO_MIN_VERSION" "$GO_CUR_VERSION" "go"
43 |
--------------------------------------------------------------------------------
/core/coreapi/interface/key.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package iface
10 |
11 | import (
12 | "context"
13 |
14 | options "github.com/ipfs/go-ipfs/core/coreapi/interface/options"
15 |
16 | "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer"
17 | )
18 |
19 | //key指定keyapi keystore中键的接口
20 | type Key interface {
21 | //键返回键名称
22 | Name() string
23 |
24 | //路径返回键路径
25 | Path() Path
26 |
27 | //id返回密钥peerid
28 | ID() peer.ID
29 | }
30 |
31 | //keyapi指定到keystore的接口
32 | type KeyAPI interface {
33 | //生成生成新密钥,并将其存储在指定的密钥库中
34 | //名称并返回其公钥的base58编码多哈希
35 | Generate(ctx context.Context, name string, opts ...options.KeyGenerateOption) (Key, error)
36 |
37 | //重命名将oldname键重命名为newname。返回键以及是否另一个键
38 | //密钥被覆盖,或出现错误
39 | Rename(ctx context.Context, oldName string, newName string, opts ...options.KeyRenameOption) (Key, bool, error)
40 |
41 | //列表列出存储在密钥库中的密钥
42 | List(ctx context.Context) ([]Key, error)
43 |
44 | //self返回“main”节点键
45 | Self(ctx context.Context) (Key, error)
46 |
47 | //移除从密钥库中移除密钥。返回已删除密钥的IPN路径
48 | Remove(ctx context.Context, name string) (Key, error)
49 | }
50 |
--------------------------------------------------------------------------------
/core/coredag/raw.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package coredag
10 |
11 | import (
12 | "io"
13 | "io/ioutil"
14 | "math"
15 |
16 | "gx/ipfs/QmTQdH4848iTVCJmKXYyRiK72HufWTLYQQ8iN3JaQ8K1Hq/go-merkledag"
17 |
18 | cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid"
19 | block "gx/ipfs/QmWoXtvgC8inqFkAATB7cp2Dax7XBi9VDvSg9RCCZufmRk/go-block-format"
20 | ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format"
21 | mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash"
22 | )
23 |
24 | func rawRawParser(r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
25 | if mhType == math.MaxUint64 {
26 | mhType = mh.SHA2_256
27 | }
28 |
29 | data, err := ioutil.ReadAll(r)
30 | if err != nil {
31 | return nil, err
32 | }
33 |
34 | h, err := mh.Sum(data, mhType, mhLen)
35 | if err != nil {
36 | return nil, err
37 | }
38 | c := cid.NewCidV1(cid.Raw, h)
39 | blk, err := block.NewBlockWithCid(data, c)
40 | if err != nil {
41 | return nil, err
42 | }
43 | nd := &merkledag.RawNode{Block: blk}
44 | return []ipld.Node{nd}, nil
45 | }
46 |
--------------------------------------------------------------------------------
/test/sharness/t0041-ping.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | test_description="Test ping command"
4 |
5 | . lib/test-lib.sh
6 |
7 | test_init_ipfs
8 |
9 | BAD_PEER="QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJx"
10 |
11 | # start iptb + wait for peering
12 | test_expect_success 'init iptb' '
13 | iptb testbed create -type localipfs -count 2 -init
14 | '
15 |
16 | startup_cluster 2
17 |
18 | test_expect_success 'peer ids' '
19 | PEERID_0=$(iptb attr get 0 id) &&
20 | PEERID_1=$(iptb attr get 1 id)
21 | '
22 |
23 | test_expect_success "test ping other" '
24 | ipfsi 0 ping -n2 -- "$PEERID_1" &&
25 | ipfsi 1 ping -n2 -- "$PEERID_0"
26 | '
27 |
28 | test_expect_success "test ping unreachable peer" '
29 | printf "Looking up peer %s\n" "$BAD_PEER" > bad_ping_exp &&
30 | printf "Peer lookup error: routing: not found\n" >> bad_ping_exp &&
31 | ipfsi 0 ping -n2 -- "$BAD_PEER" > bad_ping_actual &&
32 | test_cmp bad_ping_exp bad_ping_actual
33 | '
34 |
35 | test_expect_success "test ping self" '
36 | ! ipfsi 0 ping -n2 -- "$PEERID_0" &&
37 | ! ipfsi 1 ping -n2 -- "$PEERID_1"
38 | '
39 |
40 | test_expect_success "test ping 0" '
41 | ! ipfsi 0 ping -n0 -- "$PEERID_1" &&
42 | ! ipfsi 1 ping -n0 -- "$PEERID_0"
43 | '
44 |
45 | test_expect_success 'stop iptb' '
46 | iptb stop
47 | '
48 |
49 | test_done
50 |
--------------------------------------------------------------------------------
/namesys/proquint.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package namesys
10 |
11 | import (
12 | "context"
13 | "errors"
14 |
15 | path "gx/ipfs/QmNYPETsdAu2uQ1k9q9S1jYEGURaLHV6cbYRSVFVRftpF8/go-path"
16 | proquint "gx/ipfs/QmYnf27kzqR2cxt6LFZdrAFJuQd6785fTkBvMuEj9EeRxM/proquint"
17 |
18 | opts "github.com/ipfs/go-ipfs/namesys/opts"
19 | )
20 |
21 | type ProquintResolver struct{}
22 |
23 | //解析实现解析程序。
24 | func (r *ProquintResolver) Resolve(ctx context.Context, name string, options ...opts.ResolveOpt) (path.Path, error) {
25 | return resolve(ctx, r, name, opts.ProcessOpts(options))
26 | }
27 |
28 | //resolveonce实现resolver。解码ProQuint字符串。
29 | func (r *ProquintResolver) resolveOnceAsync(ctx context.Context, name string, options opts.ResolveOpts) <-chan onceResult {
30 | out := make(chan onceResult, 1)
31 | defer close(out)
32 |
33 | ok, err := proquint.IsProquint(name)
34 | if err != nil || !ok {
35 | out <- onceResult{err: errors.New("not a valid proquint string")}
36 | return out
37 | }
38 | //返回0 TTL,因为缓存此结果是无意义的。
39 | out <- onceResult{value: path.FromString(string(proquint.Decode(name)))}
40 | return out
41 | }
42 |
--------------------------------------------------------------------------------
/ci/Dockerfile.buildenv:
--------------------------------------------------------------------------------
1 | FROM golang:1.11
2 | MAINTAINER Jakub Sztandera
3 |
4 |
5 | RUN apt-get update && apt-get install -y --no-install-recommends \
6 | netcat-openbsd bash curl \
7 | sudo \
8 | && rm -rf /var/lib/apt/lists/*
9 |
10 | ENV GOBIN $GOPATH/bin
11 | ENV SRC_PATH /go/src/github.com/ipfs/go-ipfs
12 |
13 | RUN curl -s https://codecov.io/bash > /usr/bin/codecov && chmod +x /usr/bin/codecov \
14 | && go get -u github.com/Kubuxu/gocovmerge && go get -u golang.org/x/tools/cmd/cover
15 | ENV IPFS_SKIP_COVER_BINS 1
16 |
17 |
18 | RUN useradd user
19 | RUN chown -R user $GOPATH
20 |
21 | WORKDIR $SRC_PATH
22 |
23 | COPY ./bin $SRC_PATH/bin/
24 | COPY ./mk $SRC_PATH/mk/
25 | RUN chown -R user $GOPATH
26 |
27 | USER user
28 | # install gx and gx-go
29 | RUN make -j 4 -f bin/Rules.mk d=bin bin/gx bin/gx-go && cp bin/gx bin/gx-go $GOBIN
30 | USER root
31 | ENV IPFS_GX_USE_GLOBAL 1
32 |
33 | COPY package.json $SRC_PATH/
34 | ENV PATH $SRC_PATH/bin:$PATH
35 |
36 | USER user
37 | RUN make -f mk/gx.mk gx-deps
38 | USER root
39 |
40 | COPY . $SRC_PATH
41 | RUN chown -R user:user $GOPATH
42 | USER user
43 | # mkdir .git/objects is required for git to detect repo
44 | RUN mkdir .git/objects && make cmd/ipfs/ipfs #populate go cache
45 |
46 | CMD ["/bin/bash", "-c", "trap : TERM INT; sleep infinity & wait"]
47 |
--------------------------------------------------------------------------------
/core/coreapi/interface/options/global.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package options
10 |
11 | type ApiSettings struct {
12 | Offline bool
13 | FetchBlocks bool
14 | }
15 |
16 | type ApiOption func(*ApiSettings) error
17 |
18 | func ApiOptions(opts ...ApiOption) (*ApiSettings, error) {
19 | options := &ApiSettings{
20 | Offline: false,
21 | FetchBlocks: true,
22 | }
23 |
24 | return ApiOptionsTo(options, opts...)
25 | }
26 |
27 | func ApiOptionsTo(options *ApiSettings, opts ...ApiOption) (*ApiSettings, error) {
28 | for _, opt := range opts {
29 | err := opt(options)
30 | if err != nil {
31 | return nil, err
32 | }
33 | }
34 | return options, nil
35 | }
36 |
37 | type apiOpts struct{}
38 |
39 | var Api apiOpts
40 |
41 | func (apiOpts) Offline(offline bool) ApiOption {
42 | return func(settings *ApiSettings) error {
43 | settings.Offline = offline
44 | return nil
45 | }
46 | }
47 |
48 | //如果设置为false,则fetchBlocks会阻止API从
49 | //网络,同时允许其他服务(如IPN)仍然在线
50 | func (apiOpts) FetchBlocks(fetch bool) ApiOption {
51 | return func(settings *ApiSettings) error {
52 | settings.FetchBlocks = fetch
53 | return nil
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/test/sharness/t0500-issues-and-regressions-offline.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | test_description="Tests for various fixed issues and regressions."
4 |
5 | . lib/test-lib.sh
6 |
7 | # Tests go here
8 |
9 | test_expect_success "ipfs init with occupied input works - #2748" '
10 | export IPFS_PATH="ipfs_path"
11 | echo "" | go-timeout 10 ipfs init &&
12 | rm -rf ipfs_path
13 | '
14 | test_init_ipfs
15 |
16 | test_expect_success "ipfs cat --help succeeds when input remains open" '
17 | yes | go-timeout 1 ipfs cat --help
18 | '
19 |
20 | test_expect_success "ipfs pin ls --help succeeds when input remains open" '
21 | yes | go-timeout 1 ipfs pin ls --help
22 | '
23 |
24 | test_expect_success "ipfs add on 1MB from stdin woks" '
25 | random 1048576 42 | ipfs add -q > 1MB.hash
26 | '
27 |
28 | test_expect_success "'ipfs refs -r -e \$(cat 1MB.hash)' succeeds" '
29 | ipfs refs -r -e $(cat 1MB.hash) > refs-e.out
30 | '
31 |
32 | test_expect_success "output of 'ipfs refs -e' links to separate blocks" '
33 | grep "$(cat 1MB.hash) ->" refs-e.out
34 | '
35 |
36 | test_expect_success "output of 'ipfs refs -e' contains all first level links" '
37 | grep "$(cat 1MB.hash) ->" refs-e.out | sed -e '\''s/.* -> //'\'' | sort > refs-s.out &&
38 | ipfs refs "$(cat 1MB.hash)" | sort > refs-one.out &&
39 | test_cmp refs-s.out refs-one.out
40 | '
41 |
42 | test_done
43 |
--------------------------------------------------------------------------------
/core/coreapi/interface/pubsub.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package iface
10 |
11 | import (
12 | "context"
13 | "io"
14 |
15 | options "github.com/ipfs/go-ipfs/core/coreapi/interface/options"
16 |
17 | peer "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer"
18 | )
19 |
20 | //pubsubscription是一个活动的pubsubscription
21 | type PubSubSubscription interface {
22 | io.Closer
23 |
24 | //下一步返回下一条传入消息
25 | Next(context.Context) (PubSubMessage, error)
26 | }
27 |
28 | //pubsub message是单个pubsub消息
29 | type PubSubMessage interface {
30 | //From返回消息到达的对等方的ID
31 | From() peer.ID
32 |
33 | //数据返回消息体
34 | Data() []byte
35 |
36 | //seq返回消息标识符
37 | Seq() []byte
38 |
39 | //主题返回此邮件设置为的主题列表
40 | Topics() []string
41 | }
42 |
43 | //pubsubapi指定到pubsub的接口
44 | type PubSubAPI interface {
45 | //LS按名称列出订阅的主题
46 | Ls(context.Context) ([]string, error)
47 |
48 | //对等方列出我们当前发布的对等方
49 | Peers(context.Context, ...options.PubSubPeersOption) ([]peer.ID, error)
50 |
51 | //将消息发布到给定的pubsub主题
52 | Publish(context.Context, string, []byte) error
53 |
54 | //订阅给定主题的消息
55 | Subscribe(context.Context, string, ...options.PubSubSubscribeOption) (PubSubSubscription, error)
56 | }
57 |
--------------------------------------------------------------------------------
/test/sharness/t0063-external.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copyright (c) 2015 Jeromy Johnson
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="test external command functionality"
8 |
9 | . lib/test-lib.sh
10 |
11 |
12 | # set here so daemon launches with it
13 | PATH=`pwd`/bin:$PATH
14 |
15 | test_init_ipfs
16 |
17 | test_expect_success "create fake ipfs-update bin" '
18 | mkdir bin &&
19 | echo "#!/bin/sh" > bin/ipfs-update &&
20 | echo "pwd" >> bin/ipfs-update &&
21 | echo "test -e \"$IPFS_PATH/repo.lock\" || echo \"repo not locked\" " >> bin/ipfs-update &&
22 | chmod +x bin/ipfs-update &&
23 | mkdir just_for_test
24 | '
25 |
26 | test_expect_success "external command runs from current user directory and doesn't lock repo" '
27 | (cd just_for_test && ipfs update) > actual
28 | '
29 |
30 | test_expect_success "output looks good" '
31 | echo `pwd`/just_for_test > exp &&
32 | echo "repo not locked" >> exp &&
33 | test_cmp exp actual
34 | '
35 |
36 | test_launch_ipfs_daemon
37 |
38 | test_expect_success "external command runs from current user directory when daemon is running" '
39 | (cd just_for_test && ipfs update) > actual
40 | '
41 |
42 | test_expect_success "output looks good" '
43 | echo `pwd`/just_for_test > exp &&
44 | test_cmp exp actual
45 | '
46 |
47 | test_kill_ipfs_daemon
48 |
49 | test_done
50 |
--------------------------------------------------------------------------------
/repo/fsrepo/migrations/mfsr_test.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package mfsr
10 |
11 | import (
12 | "io/ioutil"
13 | "os"
14 | "strconv"
15 | "testing"
16 |
17 | "github.com/ipfs/go-ipfs/thirdparty/assert"
18 | )
19 |
20 | func testVersionFile(v string, t *testing.T) (rp RepoPath) {
21 | name, err := ioutil.TempDir("", v)
22 | if err != nil {
23 | t.Fatal(err)
24 | }
25 | rp = RepoPath(name)
26 | return rp
27 | }
28 |
29 | func TestVersion(t *testing.T) {
30 | rp := RepoPath("")
31 | _, err := rp.Version()
32 | assert.Err(err, t, "Should throw an error when path is bad,")
33 |
34 | rp = RepoPath("/path/to/nowhere")
35 | _, err = rp.Version()
36 | if !os.IsNotExist(err) {
37 | t.Fatalf("Should throw an `IsNotExist` error when file doesn't exist: %v", err)
38 | }
39 |
40 | fsrepoV := 5
41 |
42 | rp = testVersionFile(strconv.Itoa(fsrepoV), t)
43 | _, err = rp.Version()
44 | assert.Err(err, t, "Bad VersionFile")
45 |
46 | assert.Nil(rp.WriteVersion(fsrepoV), t, "Trouble writing version")
47 |
48 | assert.Nil(rp.CheckVersion(fsrepoV), t, "Trouble checking the version")
49 |
50 | assert.Err(rp.CheckVersion(1), t, "Should throw an error for the wrong version.")
51 | }
52 |
--------------------------------------------------------------------------------
/core/coreapi/interface/name.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package iface
10 |
11 | import (
12 | "context"
13 | "errors"
14 |
15 | options "github.com/ipfs/go-ipfs/core/coreapi/interface/options"
16 | )
17 |
18 | var ErrResolveFailed = errors.New("could not resolve name")
19 |
20 | //ipnsentry指定ipnsentries的接口
21 | type IpnsEntry interface {
22 | //name返回ipnsentry名称
23 | Name() string
24 | //值返回ipnsentry值
25 | Value() Path
26 | }
27 |
28 | type IpnsResult struct {
29 | Path
30 | Err error
31 | }
32 |
33 | //nameapi指定IPN的接口。
34 | //
35 | //IPN是一个pki命名空间,其中名称是公钥的散列值,并且
36 | //私钥允许发布新的(签名的)值。在发布和
37 | //解析,使用的默认名称是节点自己的peerID,它是
38 | //它的公钥。
39 | //
40 | //可以使用.key API列出并生成更多名称及其各自的键。
41 | type NameAPI interface {
42 | //发布宣布新的IPN名称
43 | Publish(ctx context.Context, path Path, opts ...options.NamePublishOption) (IpnsEntry, error)
44 |
45 | //解析尝试解析指定名称的最新版本
46 | Resolve(ctx context.Context, name string, opts ...options.NameResolveOption) (Path, error)
47 |
48 | //搜索是解析的一个版本,它在发现路径时输出路径,
49 | //缩短第一次进入的时间
50 | //
51 | //注意:默认情况下,从通道读取的所有路径都被认为是不安全的,
52 | //除了最新的(通道读取缓冲区中的最后一个路径)。
53 | Search(ctx context.Context, name string, opts ...options.NameResolveOption) (<-chan IpnsResult, error)
54 | }
55 |
--------------------------------------------------------------------------------
/test/sharness/t0236-cli-api-dns-resolve.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copyright (c) 2015 Jeromy Johnson
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="test dns resolution of api endpoint by cli"
8 |
9 | . lib/test-lib.sh
10 |
11 | test_init_ipfs
12 |
13 | test_expect_success "start nc" '
14 | rm -f nc_out nc_outp nc_inp && mkfifo nc_inp nc_outp
15 |
16 | nc -k -l 127.0.0.1 5006 nc_outp &
17 | NCPID=$!
18 |
19 | exec 6>nc_inp 7nc_out &&
37 |
38 | echo -e "HTTP/1.1 200 OK\r" >&6 &&
39 | echo -e "Content-Type: text/plain\r" >&6 &&
40 | echo -e "Content-Length: 0\r" >&6 &&
41 | echo -e "\r" >&6 &&
42 | exec 6<&- &&
43 |
44 | # Wait for IPFS
45 | wait $IPFSPID
46 | '
47 |
48 | test_expect_success "stop nc" '
49 | kill "$NCPID" && wait "$NCPID" || true
50 | '
51 |
52 | test_expect_success "request was received by local nc server" '
53 | grep "POST /api/v0/cat" nc_out
54 | '
55 |
56 | test_done
57 |
--------------------------------------------------------------------------------
/test/3nodetest/client/run.sh:
--------------------------------------------------------------------------------
1 | ipfs bootstrap add /ip4/$BOOTSTRAP_PORT_4011_TCP_ADDR/tcp/$BOOTSTRAP_PORT_4011_TCP_PORT/ipfs/QmNXuBh8HFsWq68Fid8dMbGNQTh7eG6hV9rr1fQyfmfomE
2 | ipfs bootstrap # list bootstrap nodes for debugging
3 |
4 | echo "3nodetest> starting client daemon"
5 |
6 | ipfs daemon --debug &
7 | sleep 3
8 |
9 | # switch dirs so ipfs client profiling data doesn't overwrite the ipfs daemon
10 | # profiling data
11 | cd /tmp
12 |
13 | while [ ! -f /data/idtiny ]
14 | do
15 | echo "3nodetest> waiting for server to add the file..."
16 | sleep 1
17 | done
18 | echo "3nodetest> client found file with hash:" $(cat /data/idtiny)
19 |
20 | ipfs cat $(cat /data/idtiny) > filetiny
21 |
22 | cat filetiny
23 |
24 | diff -u filetiny /data/filetiny
25 |
26 | if (($? > 0)); then
27 | printf '%s\n' 'files did not match' >&2
28 | exit 1
29 | fi
30 |
31 | while [ ! -f /data/idrand ]
32 | do
33 | echo "3nodetest> waiting for server to add the file..."
34 | sleep 1
35 | done
36 | echo "3nodetest> client found file with hash:" $(cat /data/idrand)
37 |
38 | cat /data/idrand
39 |
40 | ipfs cat $(cat /data/idrand) > filerand
41 |
42 | if (($? > 0)); then
43 | printf '%s\n' 'ipfs cat failed' >&2
44 | exit 1
45 | fi
46 |
47 | diff -u filerand /data/filerand
48 |
49 | if (($? > 0)); then
50 | printf '%s\n' 'files did not match' >&2
51 | exit 1
52 | fi
53 |
54 | echo "3nodetest> success"
55 |
--------------------------------------------------------------------------------
/core/corehttp/webui.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package corehttp
10 |
11 | //TODO:移动到IPN
12 | const WebUIPath = "/ipfs/QmXc9raDM1M5G5fpBnVyQ71vR4gbnskwnB9iMEzBuLgvoZ"
13 |
14 | //这是所有过去的WebUI路径的列表。
15 | var WebUIPaths = []string{
16 | WebUIPath,
17 | "/ipfs/QmenEBWcAk3tN94fSKpKFtUMwty1qNwSYw3DMDFV6cPBXA",
18 | "/ipfs/QmUnXcWZC5Ve21gUseouJsH5mLAyz5JPp8aHsg8qVUUK8e",
19 | "/ipfs/QmSDgpiHco5yXdyVTfhKxr3aiJ82ynz8V14QcGKicM3rVh",
20 | "/ipfs/QmRuvWJz1Fc8B9cTsAYANHTXqGmKR9DVfY5nvMD1uA2WQ8",
21 | "/ipfs/QmQLXHs7K98JNQdWrBB2cQLJahPhmupbDjRuH1b9ibmwVa",
22 | "/ipfs/QmXX7YRpU7nNBKfw75VG7Y1c3GwpSAGHRev67XVPgZFv9R",
23 | "/ipfs/QmXdu7HWdV6CUaUabd9q2ZeA4iHZLVyDRj3Gi4dsJsWjbr",
24 | "/ipfs/QmaaqrHyAQm7gALkRW8DcfGX3u8q9rWKnxEMmf7m9z515w",
25 | "/ipfs/QmSHDxWsMPuJQKWmVA1rB5a3NX2Eme5fPqNb63qwaqiqSp",
26 | "/ipfs/QmctngrQAt9fjpQUZr7Bx3BsXUcif52eZGTizWhvcShsjz",
27 | "/ipfs/QmS2HL9v5YeKgQkkWMvs1EMnFtUowTEdFfSSeMT4pos1e6",
28 | "/ipfs/QmR9MzChjp1MdFWik7NjEjqKQMzVmBkdK3dz14A6B5Cupm",
29 | "/ipfs/QmRyWyKWmphamkMRnJVjUTzSFSAAZowYP4rnbgnfMXC9Mr",
30 | "/ipfs/QmU3o9bvfenhTKhxUakbYrLDnZU7HezAVxPM6Ehjw9Xjqy",
31 | "/ipfs/QmPhnvn747LqwPYMJmQVorMaGbMSgA7mRRoyyZYz3DoZRQ",
32 | }
33 |
34 | var WebUIOption = RedirectOption("webui", WebUIPath)
35 |
--------------------------------------------------------------------------------
/test/sharness/t0022-init-default.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copyright (c) 2014 Christian Couder
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="Test init command with default config"
8 |
9 | . lib/test-lib.sh
10 |
11 | cfg_key="Addresses.API"
12 | cfg_val="/ip4/0.0.0.0/tcp/5001"
13 |
14 | # test that init succeeds
15 | test_expect_success "ipfs init succeeds" '
16 | export IPFS_PATH="$(pwd)/.ipfs" &&
17 | echo "IPFS_PATH: \"$IPFS_PATH\"" &&
18 | BITS="2048" &&
19 | ipfs init --bits="$BITS" >actual_init ||
20 | test_fsh cat actual_init
21 | '
22 |
23 | test_expect_success ".ipfs/config has been created" '
24 | test -f "$IPFS_PATH"/config ||
25 | test_fsh ls -al .ipfs
26 | '
27 |
28 | test_expect_success "ipfs config succeeds" '
29 | ipfs config $cfg_flags "$cfg_key" "$cfg_val"
30 | '
31 |
32 | test_expect_success "ipfs read config succeeds" '
33 | IPFS_DEFAULT_CONFIG=$(cat "$IPFS_PATH"/config)
34 | '
35 |
36 | test_expect_success "clean up ipfs dir" '
37 | rm -rf "$IPFS_PATH"
38 | '
39 |
40 | test_expect_success "ipfs init default config succeeds" '
41 | echo $IPFS_DEFAULT_CONFIG | ipfs init - >actual_init ||
42 | test_fsh cat actual_init
43 | '
44 |
45 | test_expect_success "ipfs config output looks good" '
46 | echo "$cfg_val" >expected &&
47 | ipfs config "$cfg_key" >actual &&
48 | test_cmp expected actual
49 | '
50 |
51 | test_done
52 |
--------------------------------------------------------------------------------
/core/coreapi/interface/pin.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package iface
10 |
11 | import (
12 | "context"
13 |
14 | options "github.com/ipfs/go-ipfs/core/coreapi/interface/options"
15 | )
16 |
17 | //pin保存有关pinned资源的信息
18 | type Pin interface {
19 | //固定对象的路径
20 | Path() ResolvedPath
21 |
22 | //引脚类型
23 | Type() string
24 | }
25 |
26 | //pinstatus保存有关pin运行状况的信息
27 | type PinStatus interface {
28 | //OK指示是否已验证PIN正确。
29 | Ok() bool
30 |
31 | //bad nodes从pin返回任何坏(通常丢失)节点
32 | BadNodes() []BadPinNode
33 | }
34 |
35 | //bad pin node是一个被pin标记为坏的节点。请验证
36 | type BadPinNode interface {
37 | //路径是节点的路径
38 | Path() ResolvedPath
39 |
40 | //err是将节点标记为坏节点的原因
41 | Err() error
42 | }
43 |
44 | //pinapi指定Pining的接口
45 | type PinAPI interface {
46 | //添加创建新的pin,默认为递归-固定整个引用的pin
47 | //树
48 | Add(context.Context, Path, ...options.PinAddOption) error
49 |
50 | //ls返回此节点上固定对象的列表
51 | Ls(context.Context, ...options.PinLsOption) ([]Pin, error)
52 |
53 | //rm删除由路径指定的对象的pin
54 | Rm(context.Context, Path) error
55 |
56 | //更新将一个管脚更改为另一个管脚,跳过对中匹配路径的检查
57 | //老树
58 | Update(ctx context.Context, from Path, to Path, opts ...options.PinUpdateOption) error
59 |
60 | //验证验证固定对象的完整性
61 | Verify(context.Context) (<-chan PinStatus, error)
62 | }
63 |
--------------------------------------------------------------------------------
/repo/fsrepo/migrations/mfsr.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package mfsr
10 |
11 | import (
12 | "fmt"
13 | "io/ioutil"
14 | "os"
15 | "path"
16 | "strconv"
17 | "strings"
18 | )
19 |
20 | const VersionFile = "version"
21 |
22 | type RepoPath string
23 |
24 | func (rp RepoPath) VersionFile() string {
25 | return path.Join(string(rp), VersionFile)
26 | }
27 |
28 | func (rp RepoPath) Version() (int, error) {
29 | if rp == "" {
30 | return 0, fmt.Errorf("invalid repo path \"%s\"", rp)
31 | }
32 |
33 | fn := rp.VersionFile()
34 | if _, err := os.Stat(fn); err != nil {
35 | return 0, err
36 | }
37 |
38 | c, err := ioutil.ReadFile(fn)
39 | if err != nil {
40 | return 0, err
41 | }
42 |
43 | s := strings.TrimSpace(string(c))
44 | return strconv.Atoi(s)
45 | }
46 |
47 | func (rp RepoPath) CheckVersion(version int) error {
48 | v, err := rp.Version()
49 | if err != nil {
50 | return err
51 | }
52 |
53 | if v != version {
54 | return fmt.Errorf("versions differ (expected: %d, actual:%d)", version, v)
55 | }
56 |
57 | return nil
58 | }
59 |
60 | func (rp RepoPath) WriteVersion(version int) error {
61 | fn := rp.VersionFile()
62 | return ioutil.WriteFile(fn, []byte(fmt.Sprintf("%d\n", version)), 0644)
63 | }
64 |
--------------------------------------------------------------------------------
/test/sharness/t0190-quic-ping.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | test_description="Test ping over QUIC command"
4 |
5 | . lib/test-lib.sh
6 |
7 | test_init_ipfs
8 |
9 | # start iptb + wait for peering
10 | test_expect_success 'init iptb' '
11 | iptb testbed create -type localipfs -count 2 -init
12 | '
13 |
14 | test_expect_success "enable QUIC experiment" '
15 | ipfsi 0 config --json Experimental.QUIC true &&
16 | ipfsi 1 config --json Experimental.QUIC true
17 | '
18 |
19 | addr1='"[\"/ip4/127.0.0.1/udp/0/quic/\"]"'
20 | addr2='"[\"/ip4/127.0.0.1/udp/0/quic/\"]"'
21 | test_expect_success "add QUIC swarm addresses" '
22 | ipfsi 0 config --json Addresses.Swarm '$addr1' &&
23 | ipfsi 1 config --json Addresses.Swarm '$addr2'
24 | '
25 |
26 | startup_cluster 2
27 |
28 | test_expect_success 'peer ids' '
29 | PEERID_0=$(iptb attr get 0 id) &&
30 | PEERID_1=$(iptb attr get 1 id)
31 | '
32 |
33 | test_expect_success "test ping other" '
34 | ipfsi 0 ping -n2 -- "$PEERID_1" &&
35 | ipfsi 1 ping -n2 -- "$PEERID_0"
36 | '
37 |
38 | test_expect_success "test ping self" '
39 | test_must_fail ipfsi 0 ping -n2 -- "$PEERID_0" &&
40 | test_must_fail ipfsi 1 ping -n2 -- "$PEERID_1"
41 | '
42 |
43 | test_expect_success "test ping 0" '
44 | test_must_fail ipfsi 0 ping -n0 -- "$PEERID_1" &&
45 | test_must_fail ipfsi 1 ping -n0 -- "$PEERID_0"
46 | '
47 |
48 | test_expect_success 'stop iptb' '
49 | iptb stop
50 | '
51 |
52 | test_done
53 |
--------------------------------------------------------------------------------
/core/coreapi/interface/coreapi.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | //包iface定义ipfs核心api,这是一组用于
10 | //与IPFS节点交互。
11 | package iface
12 |
13 | import (
14 | "context"
15 |
16 | "github.com/ipfs/go-ipfs/core/coreapi/interface/options"
17 |
18 | ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format"
19 | )
20 |
21 | //coreapi为go程序定义到ipfs的统一接口
22 | type CoreAPI interface {
23 | //unixfs返回unixfs API的实现
24 | Unixfs() UnixfsAPI
25 |
26 | //block返回block api的实现
27 | Block() BlockAPI
28 |
29 | //DAG返回DAG API的实现
30 | Dag() DagAPI
31 |
32 | //name返回name api的实现
33 | Name() NameAPI
34 |
35 | //key返回key api的实现
36 | Key() KeyAPI
37 |
38 | //pin返回pin api的实现
39 | Pin() PinAPI
40 |
41 | //object api返回对象api的实现
42 | Object() ObjectAPI
43 |
44 | //DHT返回DHT API的实现
45 | Dht() DhtAPI
46 |
47 | //Swarm返回Swarm API的实现
48 | Swarm() SwarmAPI
49 |
50 | //pubsub返回pubsub API的实现
51 | PubSub() PubSubAPI
52 |
53 | //resolvepath使用unixfs resolver解析路径
54 | ResolvePath(context.Context, Path) (ResolvedPath, error)
55 |
56 | //resolvenode使用unixfs解析路径(如果尚未解析)
57 | //解析程序,获取并返回解析的节点
58 | ResolveNode(context.Context, Path) (ipld.Node, error)
59 |
60 | //WITHOPTIONS基于此实例创建coreapi的新实例
61 | //应用的一组选项
62 | WithOptions(...options.ApiOption) (CoreAPI, error)
63 | }
64 |
--------------------------------------------------------------------------------
/test/sharness/t0086-repo-verify.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copyright (c) 2016 Jeromy Johnson
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="Test ipfs repo fsck"
8 |
9 | . lib/test-lib.sh
10 |
11 | test_init_ipfs
12 |
13 | sort_rand() {
14 | case `uname` in
15 | Linux|FreeBSD)
16 | sort -R
17 | ;;
18 | Darwin)
19 | ruby -e 'puts STDIN.readlines.shuffle'
20 | ;;
21 | *)
22 | echo "unsupported system: $(uname)"
23 | esac
24 | }
25 |
26 | check_random_corruption() {
27 | to_break=$(find "$IPFS_PATH/blocks" -type f -name '*.data' | sort_rand | head -n 1)
28 |
29 | test_expect_success "back up file and overwrite it" '
30 | cp "$to_break" backup_file &&
31 | echo "this is super broken" > "$to_break"
32 | '
33 |
34 | test_expect_success "repo verify detects failure" '
35 | test_expect_code 1 ipfs repo verify
36 | '
37 |
38 | test_expect_success "replace the object" '
39 | cp backup_file "$to_break"
40 | '
41 |
42 | test_expect_success "ipfs repo verify passes just fine now" '
43 | ipfs repo verify
44 | '
45 | }
46 |
47 | test_expect_success "create some files" '
48 | random-files -depth=3 -dirs=4 -files=10 foobar > /dev/null
49 | '
50 |
51 | test_expect_success "add them all" '
52 | ipfs add -r -q foobar > /dev/null
53 | '
54 |
55 | for i in `seq 20`
56 | do
57 | check_random_corruption
58 | done
59 |
60 | test_done
61 |
--------------------------------------------------------------------------------
/test/sharness/t0280-plugin-git.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copyright (c) 2017 Jakub Sztandera
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="Test git plugin"
8 |
9 | . lib/test-lib.sh
10 |
11 | # if in travis CI, dont test mount (no fuse)
12 | if ! test_have_prereq PLUGIN; then
13 | skip_all='skipping git plugin tests, plugins not available'
14 |
15 | test_done
16 | fi
17 |
18 | test_init_ipfs
19 |
20 | # from https://github.com/ipfs/go-ipld-git/blob/master/make-test-repo.sh
21 | test_expect_success "prepare test data" '
22 | tar xzf ../t0280-plugin-git-data/git.tar.gz
23 | '
24 |
25 | test_dag_git() {
26 | test_expect_success "add objects via dag put" '
27 | find objects -type f -exec ipfs dag put --format=git --input-enc=zlib {} \; -exec echo \; > hashes
28 | '
29 |
30 | test_expect_success "successfully get added objects" '
31 | cat hashes | xargs -i ipfs dag get -- {} > /dev/null
32 | '
33 |
34 | test_expect_success "path traversals work" '
35 | echo \"YmxvYiA3ACcsLnB5Zgo=\" > file1 &&
36 | ipfs dag get z8mWaJh5RLq16Zwgtd8gZxd63P4hgwNNx/object/parents/0/tree/dir2/hash/f3/hash > out1
37 | '
38 |
39 | test_expect_success "outputs look correct" '
40 | test_cmp file1 out1
41 | '
42 | }
43 |
44 | # should work offline
45 | #test_dag_git
46 |
47 | # should work online
48 | test_launch_ipfs_daemon
49 | test_dag_git
50 | test_kill_ipfs_daemon
51 |
52 | test_done
53 |
--------------------------------------------------------------------------------
/core/corehttp/ipns_hostname.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package corehttp
10 |
11 | import (
12 | "context"
13 | "net"
14 | "net/http"
15 | "strings"
16 |
17 | core "github.com/ipfs/go-ipfs/core"
18 | namesys "github.com/ipfs/go-ipfs/namesys"
19 | nsopts "github.com/ipfs/go-ipfs/namesys/opts"
20 |
21 | isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain"
22 | )
23 |
24 | //ipnshostnameoption重写传入请求,如果其host:header包含
25 | //IPNS名称。
26 | //重写的请求指向网关处理程序上解析的名称。
27 | func IPNSHostnameOption() ServeOption {
28 | return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
29 | childMux := http.NewServeMux()
30 | mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
31 | ctx, cancel := context.WithCancel(n.Context())
32 | defer cancel()
33 |
34 | host := strings.SplitN(r.Host, ":", 2)[0]
35 | if len(host) > 0 && isd.IsDomain(host) {
36 | name := "/ipns/" + host
37 | _, err := n.Namesys.Resolve(ctx, name, nsopts.Depth(1))
38 | if err == nil || err == namesys.ErrResolveRecursion {
39 | r.Header.Set("X-Ipns-Original-Path", r.URL.Path)
40 | r.URL.Path = name + r.URL.Path
41 | }
42 | }
43 | childMux.ServeHTTP(w, r)
44 | })
45 | return childMux, nil
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/core/corehttp/mutex_profile.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package corehttp
10 |
11 | import (
12 | "net"
13 | "net/http"
14 | "runtime"
15 | "strconv"
16 |
17 | core "github.com/ipfs/go-ipfs/core"
18 | )
19 |
20 | //mutexfractionoption允许通过http设置runtime.setmutexprofilefraction
21 | //使用参数“fraction”的post请求。
22 | func MutexFractionOption(path string) ServeOption {
23 | return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
24 | mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {
25 | if r.Method != http.MethodPost {
26 | w.WriteHeader(http.StatusMethodNotAllowed)
27 | return
28 | }
29 | if err := r.ParseForm(); err != nil {
30 | w.WriteHeader(http.StatusBadRequest)
31 | w.Write([]byte(err.Error()))
32 | return
33 | }
34 |
35 | asfr := r.Form.Get("fraction")
36 | if len(asfr) == 0 {
37 | w.WriteHeader(http.StatusBadRequest)
38 | return
39 | }
40 |
41 | fr, err := strconv.Atoi(asfr)
42 | if err != nil {
43 | w.WriteHeader(http.StatusBadRequest)
44 | w.Write([]byte(err.Error()))
45 | return
46 | }
47 | log.Infof("Setting MutexProfileFraction to %d", fr)
48 | runtime.SetMutexProfileFraction(fr)
49 | })
50 |
51 | return mux, nil
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/test/3nodetest/bootstrap/config:
--------------------------------------------------------------------------------
1 | {
2 | "Identity": {
3 | "PeerID": "QmNXuBh8HFsWq68Fid8dMbGNQTh7eG6hV9rr1fQyfmfomE",
4 | "PrivKey": "CAAS4gQwggJeAgEAAoGBAL+E7A0fcQS9+CHO3YAHj+JzHnWyVA7qqtiAIYbTnp9UvHBb2VFj2Q8eeyKFZD5wHoq3AtOqmIb4TUOMEtWYqXnE8o0T9np8vyCRK5dPn5SVoUw9uax6o2X7OxO1HqTcXHNHGbracawJUdwsk4yuZUpzXLez03yocWwneR0JpVJPAgMBAAECgYAXsa4ygW1OFOKZ7CnjKQxYC738+a8EmWvBlTiQoaXCOI2HqRVdyGiWQkMhpjccsmpU5wdmgHiWWinU7YN3AYgV3cP3qAjyNLBFoxy2dKsS9AOWVwRuuRP12tD05kCCjG4rJAX0JEOClOOtzvQ7/bXarMc3/tMHW7TMLNV8MzcYwQJBAOP9aYSHp8VnsO5j32Ju5SjOQorSdcCweqeUxwlAnXz50KdbNSCMypP3TOt7VeiXTuSITtN44yh+eogF5c4ehycCQQDXDHVmPeBN7uqqqZxZwW5pdeJWvx+REiXXCLE6KEPWlcxbw1D9ublpCCFLYuM68rjq1sjsIVGtiV1tYoMdHJSZAkEA0ddMZ070fB0UHFaQJGktQoGVfXB4MQI94kBtcXanfX/xLBgmre7oBYh4o8TBLXMWigFri/iYG41N+iRzf2NZwQJBAIh8rMpufT2ZZLFaoxRIc4ZVvojmFufhR8j6CFnsElpQivq2tWHEDcx+z3rkUWopgXnzRmSwJQHqTDTPsH26lQkCQQCehmxqaQEwE/QKAI8L8YVolgY2cjUGi6qF/awnI584lDSCuJRU3R/c6nc9R8qljtlJYTtp9iUr8vuN+jt48j+6"
5 | },
6 | "Datastore": {
7 | "Type": "leveldb",
8 | "Path": "/root/.ipfs/datastore"
9 | },
10 | "Addresses": {
11 | "Swarm": [
12 | "/ip4/0.0.0.0/tcp/4011"
13 | ],
14 | "API": "/ip4/127.0.0.1/tcp/5001"
15 | },
16 | "Mounts": {
17 | "IPFS": "/ipfs",
18 | "IPNS": "/ipns"
19 | },
20 | "Version": {
21 | "Current": "0.1.7",
22 | "Check": "error",
23 | "CheckDate": "0001-01-01T00:00:00Z",
24 | "CheckPeriod": "172800000000000",
25 | "AutoUpdate": "minor"
26 | },
27 | "Bootstrap": [
28 | ]
29 | }
30 |
--------------------------------------------------------------------------------
/bin/check_gx_program:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Check if a gx program is installed and if its version is at least
4 | # equal to a minimum version number.
5 | #
6 | # Call it for example like this:
7 | #
8 | # $ check_gx_program "gx-go" "0.2.0" "Use 'make gx_upgrade' to install or upgrade gx-go."
9 | #
10 | # or:
11 | #
12 | # $ check_gx_program "gx" "0.3" "Use 'make gx_upgrade' to install or upgrade gx."
13 | #
14 |
15 | USAGE="$0 GX_PROGRAM_NAME GX_MIN_VERSION UPGRADE_MSG"
16 |
17 | die() {
18 | printf >&2 "fatal: %s\n" "$@"
19 | exit 1
20 | }
21 |
22 | # Get arguments
23 |
24 | test "$#" -eq "3" || die "This program must be passed exactly 3 arguments" "Usage: $USAGE"
25 |
26 | GX_PROGRAM_NAME="$1"
27 | GX_MIN_VERSION="$2"
28 | UPGRADE_MSG="$3"
29 |
30 | # Get path to the directory containing this file
31 | # If $0 has no slashes, uses "./"
32 | PREFIX=$(expr "$0" : "\(.*\/\)") || PREFIX='./'
33 | # Include the 'check_at_least_version' function
34 | . ${PREFIX}check_version
35 |
36 | # Check that the gx program exists
37 |
38 | type "$GX_PROGRAM_NAME" >/dev/null 2>&1 || die_upgrade "Program $GX_PROGRAM_NAME is not installed!"
39 |
40 | # Check the gx program version
41 |
42 | VERS_STR=$($GX_PROGRAM_NAME -v 2>&1) || die "'$GX_PROGRAM_NAME -v' failed with output: $VERS_STR"
43 |
44 | GX_CUR_VERSION=$(expr "$VERS_STR" : ".*$GX_PROGRAM_NAME.* version \(.*\)") || die "Invalid '$GX_PROGRAM_NAME -v' output: $VERS_STR"
45 |
46 | check_at_least_version "$GX_MIN_VERSION" "$GX_CUR_VERSION" "$GX_PROGRAM_NAME"
47 |
--------------------------------------------------------------------------------
/test/sharness/t0063-daemon-init.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copyright (c) 2014 Juan Batiz-Benet
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="Test daemon --init command"
8 |
9 | . lib/test-lib.sh
10 |
11 | # We don't want the normal test_init_ipfs but we need to make sure the
12 | # IPFS_PATH is set correctly.
13 | export IPFS_PATH="$(pwd)/.ipfs"
14 |
15 | # safety check since we will be removing the directory
16 | if [ -e "$IPFS_PATH" ]; then
17 | echo "$IPFS_PATH exists"
18 | exit 1
19 | fi
20 |
21 | test_ipfs_daemon_init() {
22 | # Doing it manually since we want to launch the daemon with an
23 | # empty or non-existent repo; the normal
24 | # test_launch_ipfs_daemon does not work since it assumes the
25 | # repo was created a particular way with regard to the API
26 | # server.
27 |
28 | test_expect_success "'ipfs daemon --init' succeeds" '
29 | ipfs daemon --init --init-profile=test >actual_daemon 2>daemon_err &
30 | IPFS_PID=$!
31 | sleep 2 &&
32 | if ! kill -0 $IPFS_PID; then cat daemon_err; return 1; fi
33 | '
34 |
35 | test_expect_success "'ipfs daemon' can be killed" '
36 | test_kill_repeat_10_sec $IPFS_PID
37 | '
38 | }
39 |
40 | test_expect_success "remove \$IPFS_PATH dir" '
41 | rm -rf "$IPFS_PATH"
42 | '
43 | test_ipfs_daemon_init
44 |
45 | test_expect_success "create empty \$IPFS_PATH dir" '
46 | rm -rf "$IPFS_PATH" &&
47 | mkdir "$IPFS_PATH"
48 | '
49 |
50 | test_ipfs_daemon_init
51 |
52 | test_done
53 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | # Documentation and Guides
2 |
3 | If you’re experiencing an issue with IPFS, **please follow [our issue guide](github-issue-guide.md) when filing an issue!**
4 |
5 | Otherwise, check out the following guides to using and developing IPFS:
6 |
7 |
8 | ## General Usage
9 |
10 | - [Transferring a File Over IPFS](file-transfer.md)
11 | - [Configuration reference](config.md)
12 | - [Datastore configuration](datastores.md)
13 | - [Experimental features](experimental-features.md)
14 | - [Installing command completion](command-completion.md)
15 | - [Mounting IPFS with FUSE](fuse.md)
16 | - [Installing plugins](plugins.md)
17 |
18 |
19 | ## API Support
20 |
21 | - [How to Implement an API Client](implement-api-bindings.md)
22 | - [Connecting with Websockets](transports.md) — if you want `js-ipfs` nodes in web browsers to connect to your `go-ipfs` node, you will need to turn on websocket support in your `go-ipfs` node.
23 |
24 |
25 | ## Developing `go-ipfs`
26 |
27 | - Building on…
28 | - [Windows](windows.md)
29 | - [OpenBSD](openbsd.md)
30 | - [Performance Debugging Guidelines](debug-guide.md)
31 | - [Release Checklist](releases.md)
32 |
33 |
34 | ## Other
35 |
36 | - [Thanks to all our contributors ❤️](AUTHORS) (We use the `generate-authors.sh` script to regenerate this list.)
37 | - Our [Developer Certificate of Origin (DCO)](developer-certificate-of-origin) — when you sign your commits with `Signed-off-by: `, you are agreeing to this document.
38 | - [How to file a GitHub Issue](github-issue-guide.md)
39 |
--------------------------------------------------------------------------------
/test/3nodetest/client/config:
--------------------------------------------------------------------------------
1 | {
2 | "Addresses": {
3 | "API": "/ip4/127.0.0.1/tcp/5001",
4 | "Swarm": [
5 | "/ip4/0.0.0.0/tcp/4031"
6 | ]
7 | },
8 | "Bootstrap": [
9 | ],
10 | "Datastore": {
11 | "Path": "/root/.ipfs/datastore",
12 | "Type": "leveldb"
13 | },
14 | "Identity": {
15 | "PeerID": "Qmbtc35vdjVh5o9w2AaT2SgcWwigsaoZUpRfq2FSrFD6mb",
16 | "PrivKey": "CAAS4AQwggJcAgEAAoGBANlJUjOCbPXgYUfo1Pr6nlIjJDPNwN81ACamhaoEZ9VRHXI3fPe7RVAaaXrWLHb892mRqFi1ScE2lcMTLc7WGfyc7dwPqBOZqkVvT0KpCx3Mg246+WvnG8I3HCbWyjSP9tJflOBQxVq6qT2yZSXjNTtDdO4skd4PsPqBco53guYTAgMBAAECgYEAtIcYhrdMNBSSfp5RpZxnwbJ0t52xK0HruDEOSK2UX0Ufg+/aIjEza1QmYupi0xFltg5QojMs7hyd3Q+oNXro5tKsYVeiqrLsUh9jMjaQofzSlV9Oc+bhkkl48YWvF6Y8qx88UYAX+oJqB627H4S1gxLdNEJhPjEAD6n/jql3zUECQQDmHP75wJ7nC4TlxT1SHim5syMAqWNs/SOHnvX8yLrFV9FrMRzsD5qMlIEGBrAjaESzEck6XpbqkyxB8KKGo7OjAkEA8brtEh/AMoQ/yoSWdYT2MRbJxCAn+KG2c6Hi9AMMmJ+K779HxywpUIDYIa22hzLKYumYIuRa1X++1glOAFGq0QJAPQgXwFoMSy9M8jwcBXmmi3AtqnFCw5doIwJQL9l1X/3ot0txZlLFJOAGUHjZoqp2/h+LhYWs9U5PgLW4BYnJjQJAPydY/J0y93+5ss1FCdr8/wI3IHhOORT2t+sZgiqxxcYY5F4TAKQ2/wNKdDIQN+47FfB1gNgsKw8+6mhv6oFroQJACBF2yssNVXiXa2Na/a9tKYutGvxbm3lXzOvmpkW3FukbsObKYS344J1vdg0nzM6EWQCaiBweSA5TQ27iNW6BzQ=="
17 | },
18 | "Mounts": {
19 | "IPFS": "/ipfs",
20 | "IPNS": "/ipns"
21 | },
22 | "Version": {
23 | "AutoUpdate": "minor",
24 | "Check": "error",
25 | "CheckDate": "0001-01-01T00:00:00Z",
26 | "CheckPeriod": "172800000000000",
27 | "Current": "0.1.7"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/test/3nodetest/server/config:
--------------------------------------------------------------------------------
1 | {
2 | "Addresses": {
3 | "API": "/ip4/127.0.0.1/tcp/5001",
4 | "Swarm": [
5 | "/ip4/0.0.0.0/tcp/4021"
6 | ]
7 | },
8 | "Bootstrap": [
9 | ],
10 | "Datastore": {
11 | "Path": "/root/.ipfs/datastore",
12 | "Type": "leveldb"
13 | },
14 | "Identity": {
15 | "PeerID": "Qmbtc2C7rqmAfdeMTM7FX4YF8CeBumMCfk5Z1GBCMbMTfY",
16 | "PrivKey": "CAAS4AQwggJcAgEAAoGBANW3mJMmDSJbdRyykO0Ze5t6WL6jeTtpOhklxePBIkJL/Uil78Va/tODx6Mvv3GMCkbGvzWslTZXpaHa9vBmjE3MVZSmd5fLRybKT0zZ3juABKcx+WIVNw8JlkpEORihJdwb+5tRUC5pUcMzxqHSmGX+d6e9KZqLnv7piNKg2+r7AgMBAAECgYAqc6+w+wv82SHoM2gqULeG6MScCajZLkvGFwS5+vEtLh7/wUZhc3PO3AxZ0/A5Q9H+wRfWN5PkGYDjJ7WJhzUzGfTbrQ821JV6B3IUR4UHo2IgJkZO4EUB5L9KBUqvYxDJigtGBopgQh0EeDSS+9X8vaGmit5l4zcAfi+UGYPgMQJBAOCJQU8N2HW5SawBo2QX0bnCAAnu5Ilk2QaqwDZbDQaM5JWFcpRpGnjBhsZihHwVWvKCbnq83JhAGRQvKAEepMUCQQDzqjvIyM+Au42nP7SFDHoMjEnHW8Nimvz8zPbyrSUEHe4l9/yS4+BeRPxpwI5xgzp8g1wEYfNeXt08buYwCsy/AkBXWg5mSuSjJ+pZWGnQTtPwiGCrfJy8NteXmGYev11Z5wYmhTwGML1zrRZZp4oTG9u97LA+X6sSMB2RlKbjiKBhAkEAgl/hoSshK+YugwCpHE9ytmgRyeOlhYscNj+NGofeOHezRwmLUSUwlgAfdo4bKU1n69t1TrsCNspXYdCMxcPhjQJAMNxkJ8t2tFMpucCQfWJ09wvFKZSHX1/iD9GKWL0Qk2FcMCg3NXiqei5NL3NYqCWpdC/IfjsAEGCJrTFwp/OoUw=="
17 | },
18 | "Mounts": {
19 | "IPFS": "/ipfs",
20 | "IPNS": "/ipns"
21 | },
22 | "Version": {
23 | "AutoUpdate": "minor",
24 | "Check": "error",
25 | "CheckDate": "0001-01-01T00:00:00Z",
26 | "CheckPeriod": "172800000000000",
27 | "Current": "0.1.7"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/docs/developer-certificate-of-origin:
--------------------------------------------------------------------------------
1 | Developer Certificate of Origin
2 | Version 1.1
3 |
4 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
5 | 1 Letterman Drive
6 | Suite D4700
7 | San Francisco, CA, 94129
8 |
9 | Everyone is permitted to copy and distribute verbatim copies of this
10 | license document, but changing it is not allowed.
11 |
12 |
13 | Developer's Certificate of Origin 1.1
14 |
15 | By making a contribution to this project, I certify that:
16 |
17 | (a) The contribution was created in whole or in part by me and I
18 | have the right to submit it under the open source license
19 | indicated in the file; or
20 |
21 | (b) The contribution is based upon previous work that, to the best
22 | of my knowledge, is covered under an appropriate open source
23 | license and I have the right under that license to submit that
24 | work with modifications, whether created in whole or in part
25 | by me, under the same open source license (unless I am
26 | permitted to submit under a different license), as indicated
27 | in the file; or
28 |
29 | (c) The contribution was provided directly to me by some other
30 | person who certified (a), (b) or (c) and I have not modified
31 | it.
32 |
33 | (d) I understand and agree that this project and the contribution
34 | are public and that a record of the contribution (including all
35 | personal information I submit with it, including my sign-off) is
36 | maintained indefinitely and may be redistributed consistent with
37 | this project or the open source license(s) involved.
38 |
--------------------------------------------------------------------------------
/test/dependencies/go-timeout/main.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package main
10 |
11 | import (
12 | "context"
13 | "fmt"
14 | "os"
15 | "os/exec"
16 | "strconv"
17 | "syscall"
18 | "time"
19 | )
20 |
21 | func main() {
22 | if len(os.Args) < 3 {
23 | fmt.Fprintf(os.Stderr,
24 | "Usage: %s \n", os.Args[0])
25 | os.Exit(1)
26 | }
27 | timeout, err := strconv.ParseUint(os.Args[1], 10, 32)
28 | if err != nil {
29 | fmt.Fprintf(os.Stderr, "Error: %v\n", err)
30 | os.Exit(1)
31 | }
32 | ctx, cancel := context.WithTimeout(context.Background(), time.Duration(timeout)*time.Second)
33 | defer cancel()
34 |
35 | cmd := exec.CommandContext(ctx, os.Args[2], os.Args[3:]...)
36 | cmd.Stdin = os.Stdin
37 | cmd.Stdout = os.Stdout
38 | cmd.Stderr = os.Stderr
39 | err = cmd.Start()
40 | if err != nil {
41 | fmt.Fprintf(os.Stderr, "Error: %v\n", err)
42 | }
43 | err = cmd.Wait()
44 |
45 | if err != nil {
46 | if ctx.Err() != nil {
47 | os.Exit(124)
48 | } else {
49 | exitErr, ok := err.(*exec.ExitError)
50 | if !ok {
51 | fmt.Fprintf(os.Stderr, "Error: %v\n", err)
52 | os.Exit(255)
53 | }
54 | waits, ok := exitErr.Sys().(syscall.WaitStatus)
55 | if !ok {
56 | fmt.Fprintf(os.Stderr, "Error: %v\n", err)
57 | os.Exit(255)
58 | }
59 | os.Exit(waits.ExitStatus())
60 | }
61 | } else {
62 | os.Exit(0)
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/test/sharness/t0084-repo-read-rehash.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copyright (c) Jakub Sztandera
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="Test ipfs blockstore repo read check."
8 |
9 | . lib/test-lib.sh
10 |
11 | rm -rf "$IPF_PATH/*"
12 |
13 | test_init_ipfs
14 |
15 |
16 | H_BLOCK1=$(echo "Block 1" | ipfs add -q)
17 | H_BLOCK2=$(echo "Block 2" | ipfs add -q)
18 |
19 | BS_BLOCK1="XZ/CIQPDDQH5PDJTF4QSNMPFC45FQZH5MBSWCX2W254P7L7HGNHW5MQXZA.data"
20 | BS_BLOCK2="CK/CIQNYWBOKHY7TCY7FUOBXKVJ66YRMARDT3KC7PPY6UWWPZR4YA67CKQ.data"
21 |
22 |
23 | test_expect_success 'blocks are swapped' '
24 | ipfs cat $H_BLOCK2 > noswap &&
25 | cp -f "$IPFS_PATH/blocks/$BS_BLOCK1" "$IPFS_PATH/blocks/$BS_BLOCK2" &&
26 | ipfs cat $H_BLOCK2 > swap &&
27 | test_must_fail test_cmp noswap swap
28 | '
29 |
30 | ipfs config --bool Datastore.HashOnRead true
31 |
32 | test_check_bad_blocks() {
33 | test_expect_success 'getting modified block fails' '
34 | (test_must_fail ipfs cat $H_BLOCK2 2> err_msg) &&
35 | grep "block in storage has different hash than requested" err_msg
36 | '
37 |
38 | test_expect_success "block shows up in repo verify" '
39 | test_expect_code 1 ipfs repo verify > verify_out &&
40 | grep "$H_BLOCK2" verify_out
41 | '
42 | }
43 |
44 | test_check_bad_blocks
45 |
46 | test_expect_success "can add and cat a raw-leaf file" '
47 | HASH=$(echo "stuff" | ipfs add -q --raw-leaves) &&
48 | ipfs cat $HASH > /dev/null
49 | '
50 |
51 | test_launch_ipfs_daemon
52 | test_check_bad_blocks
53 | test_kill_ipfs_daemon
54 |
55 | test_done
56 |
--------------------------------------------------------------------------------
/test/sharness/t0235-cli-request.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copyright (c) 2015 Jeromy Johnson
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="test http requests made by cli"
8 |
9 | . lib/test-lib.sh
10 |
11 | test_init_ipfs
12 |
13 | test_expect_success "start nc" '
14 | rm -f nc_out nc_outp nc_inp && mkfifo nc_inp nc_outp
15 |
16 | nc -k -l 127.0.0.1 5005 nc_outp &
17 | NCPID=$!
18 |
19 | exec 6>nc_inp 7nc_out &&
37 |
38 | echo -e "HTTP/1.1 200 OK\r" >&6 &&
39 | echo -e "Content-Type: text/plain\r" >&6 &&
40 | echo -e "Content-Length: 0\r" >&6 &&
41 | echo -e "\r" >&6 &&
42 | exec 6<&- &&
43 |
44 | # Wait for IPFS
45 | wait $IPFSPID
46 | '
47 |
48 | test_expect_success "stop nc" '
49 | kill "$NCPID" && wait "$NCPID" || true
50 | '
51 |
52 | test_expect_success "output does not contain multipart info" '
53 | test_expect_code 1 grep multipart nc_out
54 | '
55 |
56 | test_expect_success "request looks good" '
57 | grep "POST /api/v0/cat" nc_out
58 | '
59 |
60 | test_expect_success "api flag does not appear in request" '
61 | test_expect_code 1 grep "api=/ip4" nc_out
62 | '
63 |
64 | test_done
65 |
--------------------------------------------------------------------------------
/core/corehttp/logs.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package corehttp
10 |
11 | import (
12 | "io"
13 | "net"
14 | "net/http"
15 |
16 | core "github.com/ipfs/go-ipfs/core"
17 | lwriter "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log/writer"
18 | )
19 |
20 | type writeErrNotifier struct {
21 | w io.Writer
22 | errs chan error
23 | }
24 |
25 | func newWriteErrNotifier(w io.Writer) (io.WriteCloser, <-chan error) {
26 | ch := make(chan error, 1)
27 | return &writeErrNotifier{
28 | w: w,
29 | errs: ch,
30 | }, ch
31 | }
32 |
33 | func (w *writeErrNotifier) Write(b []byte) (int, error) {
34 | n, err := w.w.Write(b)
35 | if err != nil {
36 | select {
37 | case w.errs <- err:
38 | default:
39 | }
40 | }
41 | if f, ok := w.w.(http.Flusher); ok {
42 | f.Flush()
43 | }
44 | return n, err
45 | }
46 |
47 | func (w *writeErrNotifier) Close() error {
48 | select {
49 | case w.errs <- io.EOF:
50 | default:
51 | }
52 | return nil
53 | }
54 |
55 | func LogOption() ServeOption {
56 | return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
57 | mux.HandleFunc("/logs", func(w http.ResponseWriter, r *http.Request) {
58 | w.WriteHeader(200)
59 | wnf, errs := newWriteErrNotifier(w)
60 | lwriter.WriterGroup.AddWriter(wnf)
61 | log.Event(n.Context(), "log API client connected")
62 | <-errs
63 | })
64 | return mux, nil
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/repo/onlyone.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package repo
10 |
11 | import (
12 | "sync"
13 | )
14 |
15 | //OnlyOne通过任意键跟踪打开的回购,并返回
16 | //打开一个。
17 | type OnlyOne struct {
18 | mu sync.Mutex
19 | active map[interface{}]*ref
20 | }
21 |
22 | //打开由键标识的回购。如果回购尚未打开,则
23 | //调用open函数,并进一步记住结果
24 | //使用。
25 | //
26 | //钥匙必须是可比的,否则打开会恐慌。一定要选钥匙
27 | //在不同的具体回购实施中是独一无二的,
28 | //例如,通过创建本地类型:
29 | //
30 | //类型repokey字符串
31 | //R,错误:=O.open(repokey(path),open)
32 | //
33 | //调用repo。完成后关闭。
34 | func (o *OnlyOne) Open(key interface{}, open func() (Repo, error)) (Repo, error) {
35 | o.mu.Lock()
36 | defer o.mu.Unlock()
37 | if o.active == nil {
38 | o.active = make(map[interface{}]*ref)
39 | }
40 |
41 | item, found := o.active[key]
42 | if !found {
43 | repo, err := open()
44 | if err != nil {
45 | return nil, err
46 | }
47 | item = &ref{
48 | parent: o,
49 | key: key,
50 | Repo: repo,
51 | }
52 | o.active[key] = item
53 | }
54 | item.refs++
55 | return item, nil
56 | }
57 |
58 | type ref struct {
59 | parent *OnlyOne
60 | key interface{}
61 | refs uint32
62 | Repo
63 | }
64 |
65 | var _ Repo = (*ref)(nil)
66 |
67 | func (r *ref) Close() error {
68 | r.parent.mu.Lock()
69 | defer r.parent.mu.Unlock()
70 |
71 | r.refs--
72 | if r.refs > 0 {
73 | //其他人把它打开了
74 | return nil
75 | }
76 |
77 | //最后一个
78 | delete(r.parent.active, r.key)
79 | return r.Repo.Close()
80 | }
81 |
--------------------------------------------------------------------------------
/bin/container_daemon:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 | user=ipfs
4 | repo="$IPFS_PATH"
5 |
6 | if [ `id -u` -eq 0 ]; then
7 | echo "Changing user to $user"
8 | # ensure folder is writable
9 | su-exec "$user" test -w "$repo" || chown -R -- "$user" "$repo"
10 | # restart script with new privileges
11 | exec su-exec "$user" "$0" "$@"
12 | fi
13 |
14 | # 2nd invocation with regular user
15 | ipfs version
16 |
17 | if [ -e "$repo/config" ]; then
18 | echo "Found IPFS fs-repo at $repo"
19 | else
20 | case "$IPFS_PROFILE" in
21 | "") INIT_ARGS="" ;;
22 | *) INIT_ARGS="--profile=$IPFS_PROFILE" ;;
23 | esac
24 | ipfs init $INIT_ARGS
25 | ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
26 | ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
27 | fi
28 |
29 | # if the first argument is daemon
30 | if [ "$1" = "daemon" ]; then
31 | # filter the first argument until
32 | # https://github.com/ipfs/go-ipfs/pull/3573
33 | # has been resolved
34 | shift
35 | else
36 | # print deprecation warning
37 | # go-ipfs used to hardcode "ipfs daemon" in it's entrypoint
38 | # this workaround supports the new syntax so people start setting daemon explicitly
39 | # when overwriting CMD
40 | echo "DEPRECATED: arguments have been set but the first argument isn't 'daemon'" >&2
41 | echo "DEPRECATED: run 'docker run ipfs/go-ipfs daemon $@' instead" >&2
42 | echo "DEPRECATED: see the following PRs for more information:" >&2
43 | echo "DEPRECATED: * https://github.com/ipfs/go-ipfs/pull/3573" >&2
44 | echo "DEPRECATED: * https://github.com/ipfs/go-ipfs/pull/3685" >&2
45 | fi
46 |
47 | exec ipfs daemon "$@"
48 |
--------------------------------------------------------------------------------
/core/commands/helptext_test.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package commands
10 |
11 | import (
12 | "strings"
13 | "testing"
14 |
15 | cmds "gx/ipfs/QmWGm4AbZEbnmdgVTza52MSNpEmBdFVqzmAysRbjrRyGbH/go-ipfs-cmds"
16 | )
17 |
18 | func checkHelptextRecursive(t *testing.T, name []string, c *cmds.Command) {
19 | c.ProcessHelp()
20 |
21 | t.Run(strings.Join(name, "_"), func(t *testing.T) {
22 | if c.External {
23 | t.Skip("external")
24 | }
25 |
26 | t.Run("tagline", func(t *testing.T) {
27 | if c.Helptext.Tagline == "" {
28 | t.Error("no Tagline!")
29 | }
30 | })
31 |
32 | t.Run("longDescription", func(t *testing.T) {
33 | t.Skip("not everywhere yet")
34 | if c.Helptext.LongDescription == "" {
35 | t.Error("no LongDescription!")
36 | }
37 | })
38 |
39 | t.Run("shortDescription", func(t *testing.T) {
40 | t.Skip("not everywhere yet")
41 | if c.Helptext.ShortDescription == "" {
42 | t.Error("no ShortDescription!")
43 | }
44 | })
45 |
46 | t.Run("synopsis", func(t *testing.T) {
47 | t.Skip("autogenerated in go-ipfs-cmds")
48 | if c.Helptext.Synopsis == "" {
49 | t.Error("no Synopsis!")
50 | }
51 | })
52 | })
53 |
54 | for subname, sub := range c.Subcommands {
55 | checkHelptextRecursive(t, append(name, subname), sub)
56 | }
57 | }
58 |
59 | func TestHelptexts(t *testing.T) {
60 | Root.ProcessHelp()
61 | checkHelptextRecursive(t, []string{"ipfs"}, Root)
62 | }
63 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | # Notes:
2 | # - Minimal appveyor.yml file is an empty file. All sections are optional.
3 | # - Indent each level of configuration with 2 spaces. Do not use tabs!
4 | # - All section names are case-sensitive.
5 | # - Section names should be unique on each level.
6 |
7 | version: "{build}"
8 |
9 | os: Windows Server 2012 R2
10 |
11 | clone_folder: c:\gopath\src\github.com\ipfs\go-ipfs
12 |
13 | environment:
14 | GOPATH: c:\gopath
15 | TEST_VERBOSE: 1
16 | #TEST_NO_FUSE: 1
17 | #TEST_SUITE: test_sharness_expensive
18 | #GOFLAGS: -tags nofuse
19 | global:
20 | BASH: C:\cygwin\bin\bash
21 | matrix:
22 | - GOARCH: amd64
23 | GOVERSION: 1.5.1
24 | GOROOT: c:\go
25 | DOWNLOADPLATFORM: "x64"
26 |
27 | install:
28 | # Enable make
29 | #- SET PATH=c:\MinGW\bin;%PATH%
30 | #- copy c:\MinGW\bin\mingw32-make.exe c:\MinGW\bin\make.exe
31 | - go version
32 | - go env
33 |
34 | # Cygwin build script
35 | #
36 | # NOTES:
37 | #
38 | # The stdin/stdout file descriptor appears not to be valid for the Appveyor
39 | # build which causes failures as certain functions attempt to redirect
40 | # default file handles. Ensure a dummy file descriptor is opened with 'exec'.
41 | #
42 | build_script:
43 | - '%BASH% -lc "cd $APPVEYOR_BUILD_FOLDER; exec 0"swarm_peers_$node" &&
17 | grep "ipfs" "swarm_peers_$node" >/dev/null
18 | }
19 |
20 | iptb() {
21 | if ! command iptb "$@"; then
22 | case "$1" in
23 | start|stop|connect)
24 | test_fsh command iptb logs
25 | ;;
26 | esac
27 | return 1
28 | fi
29 | }
30 |
31 | startup_cluster() {
32 | num_nodes="$1"
33 | shift
34 | other_args="$@"
35 | bound=$(expr "$num_nodes" - 1)
36 |
37 | if test -n "$other_args"; then
38 | test_expect_success "start up nodes with additional args" "
39 | iptb start -wait -- ${other_args[@]}
40 | "
41 | else
42 | test_expect_success "start up nodes" '
43 | iptb start -wait
44 | '
45 | fi
46 |
47 | test_expect_success "connect nodes to eachother" '
48 | iptb connect [1-$bound] 0
49 | '
50 |
51 | for i in $(test_seq 0 "$bound")
52 | do
53 | test_expect_success "node $i is connected" '
54 | check_has_connection "$i" ||
55 | test_fsh cat "swarm_peers_$i"
56 | '
57 | done
58 | }
59 |
60 | iptb_wait_stop() {
61 | while ! iptb run -- sh -c '! { test -e "$IPFS_PATH/repo.lock" && fuser -f "$IPFS_PATH/repo.lock" >/dev/null; }'; do
62 | go-sleep 10ms
63 | done
64 | }
65 |
--------------------------------------------------------------------------------
/assets/assets_test.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package assets
10 |
11 | import (
12 | "bytes"
13 | "io/ioutil"
14 | "sync"
15 | "testing"
16 | )
17 |
18 | //TestEmbeddedDocs确保文档更改后不会忘记重新生成
19 | func TestEmbeddedDocs(t *testing.T) {
20 | testNFiles(initDocPaths, 5, t, "documents")
21 | }
22 |
23 | func TestDirIndex(t *testing.T) {
24 | t.Skip("skipping for now, code being tested is currently unused")
25 | //TODO:在初始化期间导入资产。
26 | //这需要弄清楚如何为
27 | //从其GX路径引用代码
28 | testNFiles(initDirIndex, 2, t, "assets")
29 | }
30 |
31 | func testNFiles(fs []string, wantCnt int, t *testing.T, ftype string) {
32 | if len(fs) < wantCnt {
33 | t.Fatalf("expected %d %s. got %d", wantCnt, ftype, len(fs))
34 | }
35 |
36 | var wg sync.WaitGroup
37 | for _, f := range fs {
38 | wg.Add(1)
39 | //比较资产
40 | go func(f string) {
41 | defer wg.Done()
42 | testOneFile(f, t)
43 | }(f)
44 | }
45 | wg.Wait()
46 | }
47 |
48 | func testOneFile(f string, t *testing.T) {
49 | //从文件系统(Git)加载数据
50 | vcsData, err := ioutil.ReadFile(f)
51 | if err != nil {
52 | t.Errorf("asset %s: could not read vcs file: %s", f, err)
53 | return
54 | }
55 |
56 | //从EMDEDED源加载数据
57 | embdData, err := Asset(f)
58 | if err != nil {
59 | t.Errorf("asset %s: could not read vcs file: %s", f, err)
60 | return
61 | }
62 |
63 | if !bytes.Equal(vcsData, embdData) {
64 | t.Errorf("asset %s: vcs and embedded data isnt equal", f)
65 | return
66 | }
67 |
68 | t.Logf("checked %s", f)
69 | }
70 |
--------------------------------------------------------------------------------
/core/coreapi/interface/options/pubsub.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package options
10 |
11 | type PubSubPeersSettings struct {
12 | Topic string
13 | }
14 |
15 | type PubSubSubscribeSettings struct {
16 | Discover bool
17 | }
18 |
19 | type PubSubPeersOption func(*PubSubPeersSettings) error
20 | type PubSubSubscribeOption func(*PubSubSubscribeSettings) error
21 |
22 | func PubSubPeersOptions(opts ...PubSubPeersOption) (*PubSubPeersSettings, error) {
23 | options := &PubSubPeersSettings{
24 | Topic: "",
25 | }
26 |
27 | for _, opt := range opts {
28 | err := opt(options)
29 | if err != nil {
30 | return nil, err
31 | }
32 | }
33 | return options, nil
34 | }
35 |
36 | func PubSubSubscribeOptions(opts ...PubSubSubscribeOption) (*PubSubSubscribeSettings, error) {
37 | options := &PubSubSubscribeSettings{
38 | Discover: false,
39 | }
40 |
41 | for _, opt := range opts {
42 | err := opt(options)
43 | if err != nil {
44 | return nil, err
45 | }
46 | }
47 | return options, nil
48 | }
49 |
50 | type pubsubOpts struct{}
51 |
52 | var PubSub pubsubOpts
53 |
54 | func (pubsubOpts) Topic(topic string) PubSubPeersOption {
55 | return func(settings *PubSubPeersSettings) error {
56 | settings.Topic = topic
57 | return nil
58 | }
59 | }
60 |
61 | func (pubsubOpts) Discover(discover bool) PubSubSubscribeOption {
62 | return func(settings *PubSubSubscribeSettings) error {
63 | settings.Discover = discover
64 | return nil
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/core/coreunix/metadata.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package coreunix
10 |
11 | import (
12 | core "github.com/ipfs/go-ipfs/core"
13 | ft "gx/ipfs/QmQXze9tG878pa4Euya4rrDpyTNX3kQe4dhCaBzBozGgpe/go-unixfs"
14 | cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid"
15 | dag "gx/ipfs/QmTQdH4848iTVCJmKXYyRiK72HufWTLYQQ8iN3JaQ8K1Hq/go-merkledag"
16 | )
17 |
18 | func AddMetadataTo(n *core.IpfsNode, skey string, m *ft.Metadata) (string, error) {
19 | c, err := cid.Decode(skey)
20 | if err != nil {
21 | return "", err
22 | }
23 |
24 | nd, err := n.DAG.Get(n.Context(), c)
25 | if err != nil {
26 | return "", err
27 | }
28 |
29 | mdnode := new(dag.ProtoNode)
30 | mdata, err := ft.BytesForMetadata(m)
31 | if err != nil {
32 | return "", err
33 | }
34 |
35 | mdnode.SetData(mdata)
36 | if err := mdnode.AddNodeLink("file", nd); err != nil {
37 | return "", err
38 | }
39 |
40 | err = n.DAG.Add(n.Context(), mdnode)
41 | if err != nil {
42 | return "", err
43 | }
44 |
45 | return mdnode.Cid().String(), nil
46 | }
47 |
48 | func Metadata(n *core.IpfsNode, skey string) (*ft.Metadata, error) {
49 | c, err := cid.Decode(skey)
50 | if err != nil {
51 | return nil, err
52 | }
53 |
54 | nd, err := n.DAG.Get(n.Context(), c)
55 | if err != nil {
56 | return nil, err
57 | }
58 |
59 | pbnd, ok := nd.(*dag.ProtoNode)
60 | if !ok {
61 | return nil, dag.ErrNotProtobuf
62 | }
63 |
64 | return ft.MetadataFromBytes(pbnd.Data())
65 | }
66 |
--------------------------------------------------------------------------------
/repo/common/common.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package common
10 |
11 | import (
12 | "fmt"
13 | "strings"
14 | )
15 |
16 | func MapGetKV(v map[string]interface{}, key string) (interface{}, error) {
17 | var ok bool
18 | var mcursor map[string]interface{}
19 | var cursor interface{} = v
20 |
21 | parts := strings.Split(key, ".")
22 | for i, part := range parts {
23 | sofar := strings.Join(parts[:i], ".")
24 |
25 | mcursor, ok = cursor.(map[string]interface{})
26 | if !ok {
27 | return nil, fmt.Errorf("%s key is not a map", sofar)
28 | }
29 |
30 | cursor, ok = mcursor[part]
31 | if !ok {
32 | return nil, fmt.Errorf("%s key has no attributes", sofar)
33 | }
34 | }
35 | return cursor, nil
36 | }
37 |
38 | func MapSetKV(v map[string]interface{}, key string, value interface{}) error {
39 | var ok bool
40 | var mcursor map[string]interface{}
41 | var cursor interface{} = v
42 |
43 | parts := strings.Split(key, ".")
44 | for i, part := range parts {
45 | mcursor, ok = cursor.(map[string]interface{})
46 | if !ok {
47 | sofar := strings.Join(parts[:i], ".")
48 | return fmt.Errorf("%s key is not a map", sofar)
49 | }
50 |
51 | //最后一部分?设置在这里
52 | if i == (len(parts) - 1) {
53 | mcursor[part] = value
54 | break
55 | }
56 |
57 | cursor, ok = mcursor[part]
58 | if !ok || cursor == nil { //如果为空或为空,则创建映射
59 | mcursor[part] = map[string]interface{}{}
60 | cursor = mcursor[part]
61 | }
62 | }
63 | return nil
64 | }
65 |
--------------------------------------------------------------------------------
/test/sharness/t0066-migration.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copyright (c) 2016 Jeromy Johnson
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="Test migrations auto update prompt"
8 |
9 | . lib/test-lib.sh
10 |
11 | test_init_ipfs
12 |
13 | test_expect_success "setup mock migrations" '
14 | mkdir bin &&
15 | echo "#!/bin/bash" > bin/fs-repo-migrations &&
16 | echo "echo 5" >> bin/fs-repo-migrations &&
17 | chmod +x bin/fs-repo-migrations &&
18 | export PATH="$(pwd)/bin":$PATH
19 | '
20 |
21 | test_expect_success "manually reset repo version to 3" '
22 | echo "3" > "$IPFS_PATH"/version
23 | '
24 |
25 | test_expect_success "ipfs daemon --migrate=false fails" '
26 | test_expect_code 1 ipfs daemon --migrate=false > false_out
27 | '
28 |
29 | test_expect_success "output looks good" '
30 | grep "Please get fs-repo-migrations from https://dist.ipfs.io" false_out
31 | '
32 |
33 | test_expect_success "ipfs daemon --migrate=true runs migration" '
34 | test_expect_code 1 ipfs daemon --migrate=true > true_out
35 | '
36 |
37 | test_expect_failure "output looks good" '
38 | grep "Running: " true_out > /dev/null &&
39 | grep "Success: fs-repo has been migrated to version 5." true_out > /dev/null
40 | '
41 |
42 | test_expect_success "'ipfs daemon' prompts to auto migrate" '
43 | test_expect_code 1 ipfs daemon > daemon_out 2> daemon_err
44 | '
45 |
46 | test_expect_success "output looks good" '
47 | grep "Found outdated fs-repo" daemon_out > /dev/null &&
48 | grep "Run migrations now?" daemon_out > /dev/null &&
49 | grep "Please get fs-repo-migrations from https://dist.ipfs.io" daemon_out > /dev/null
50 | '
51 |
52 | test_done
53 |
--------------------------------------------------------------------------------
/p2p/p2p.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package p2p
10 |
11 | import (
12 | pstore "gx/ipfs/QmPiemjiKBC9VA7vZF82m4x1oygtg2c2YVqag8PX7dN1BD/go-libp2p-peerstore"
13 | peer "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer"
14 | p2phost "gx/ipfs/QmaoXrM4Z41PD48JY36YqQGKQpLGjyLA2cKcLsES7YddAq/go-libp2p-host"
15 | logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log"
16 | )
17 |
18 | var log = logging.Logger("p2p-mount")
19 |
20 | //p2p结构保存当前运行的流/侦听器的信息
21 | type P2P struct {
22 | ListenersLocal *Listeners
23 | ListenersP2P *Listeners
24 | Streams *StreamRegistry
25 |
26 | identity peer.ID
27 | peerHost p2phost.Host
28 | peerstore pstore.Peerstore
29 | }
30 |
31 | //new p2p创建新的p2p结构
32 | func NewP2P(identity peer.ID, peerHost p2phost.Host, peerstore pstore.Peerstore) *P2P {
33 | return &P2P{
34 | identity: identity,
35 | peerHost: peerHost,
36 | peerstore: peerstore,
37 |
38 | ListenersLocal: newListenersLocal(),
39 | ListenersP2P: newListenersP2P(peerHost),
40 |
41 | Streams: &StreamRegistry{
42 | Streams: map[uint64]*Stream{},
43 | ConnManager: peerHost.ConnManager(),
44 | conns: map[peer.ID]int{},
45 | },
46 | }
47 | }
48 |
49 | //checkprotoexists检查是否向注册了proto处理程序
50 | //多路复用器
51 | func (p2p *P2P) CheckProtoExists(proto string) bool {
52 | protos := p2p.peerHost.Mux().Protocols()
53 |
54 | for _, p := range protos {
55 | if p != proto {
56 | continue
57 | }
58 | return true
59 | }
60 | return false
61 | }
62 |
--------------------------------------------------------------------------------
/keystore/memkeystore.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package keystore
10 |
11 | import ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto"
12 |
13 | //memkeystore是一个内存中的keystore实现,它不持久于
14 | //任何后备存储器。
15 | type MemKeystore struct {
16 | keys map[string]ci.PrivKey
17 | }
18 |
19 | func NewMemKeystore() *MemKeystore {
20 | return &MemKeystore{make(map[string]ci.PrivKey)}
21 | }
22 |
23 | //返回密钥库中是否存在密钥
24 | func (mk *MemKeystore) Has(name string) (bool, error) {
25 | _, ok := mk.keys[name]
26 | return ok, nil
27 | }
28 |
29 | //在密钥库中存储密钥
30 | func (mk *MemKeystore) Put(name string, k ci.PrivKey) error {
31 | if err := validateName(name); err != nil {
32 | return err
33 | }
34 |
35 | _, ok := mk.keys[name]
36 | if ok {
37 | return ErrKeyExists
38 | }
39 |
40 | mk.keys[name] = k
41 | return nil
42 | }
43 |
44 | //获取从密钥库中检索密钥
45 | func (mk *MemKeystore) Get(name string) (ci.PrivKey, error) {
46 | if err := validateName(name); err != nil {
47 | return nil, err
48 | }
49 |
50 | k, ok := mk.keys[name]
51 | if !ok {
52 | return nil, ErrNoSuchKey
53 | }
54 |
55 | return k, nil
56 | }
57 |
58 | //删除从密钥库中删除密钥
59 | func (mk *MemKeystore) Delete(name string) error {
60 | if err := validateName(name); err != nil {
61 | return err
62 | }
63 |
64 | delete(mk.keys, name)
65 | return nil
66 | }
67 |
68 | //list返回键标识符列表
69 | func (mk *MemKeystore) List() ([]string, error) {
70 | out := make([]string, 0, len(mk.keys))
71 | for k := range mk.keys {
72 | out = append(out, k)
73 | }
74 | return out, nil
75 | }
76 |
--------------------------------------------------------------------------------
/repo/mock.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package repo
10 |
11 | import (
12 | "errors"
13 |
14 | filestore "github.com/ipfs/go-ipfs/filestore"
15 | keystore "github.com/ipfs/go-ipfs/keystore"
16 |
17 | ma "gx/ipfs/QmNTCey11oxhb1AxDnQBRHtdhap6Ctud872NjAYPYYXPuc/go-multiaddr"
18 | config "gx/ipfs/QmcRKBUqc2p3L1ZraoJjbXfs9E6xzvEuyK9iypb5RGwfsr/go-ipfs-config"
19 | )
20 |
21 | var errTODO = errors.New("TODO: mock repo")
22 |
23 | //模拟不是线程安全的
24 | type Mock struct {
25 | C config.Config
26 | D Datastore
27 | K keystore.Keystore
28 | }
29 |
30 | func (m *Mock) Config() (*config.Config, error) {
31 | return &m.C, nil //固定螺纹安全
32 | }
33 |
34 | func (m *Mock) SetConfig(updated *config.Config) error {
35 | m.C = *updated //固定螺纹安全
36 | return nil
37 | }
38 |
39 | func (m *Mock) BackupConfig(prefix string) (string, error) {
40 | return "", errTODO
41 | }
42 |
43 | func (m *Mock) SetConfigKey(key string, value interface{}) error {
44 | return errTODO
45 | }
46 |
47 | func (m *Mock) GetConfigKey(key string) (interface{}, error) {
48 | return nil, errTODO
49 | }
50 |
51 | func (m *Mock) Datastore() Datastore { return m.D }
52 |
53 | func (m *Mock) GetStorageUsage() (uint64, error) { return 0, nil }
54 |
55 | func (m *Mock) Close() error { return errTODO }
56 |
57 | func (m *Mock) SetAPIAddr(addr ma.Multiaddr) error { return errTODO }
58 |
59 | func (m *Mock) Keystore() keystore.Keystore { return m.K }
60 |
61 | func (m *Mock) SwarmKey() ([]byte, error) {
62 | return nil, nil
63 | }
64 |
65 | func (m *Mock) FileManager() *filestore.FileManager { return nil }
66 |
--------------------------------------------------------------------------------
/core/bootstrap_test.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package core
10 |
11 | import (
12 | "fmt"
13 | "testing"
14 |
15 | testutil "gx/ipfs/QmNvHv84aH2qZafDuSdKJCQ1cvPZ1kmQmyD4YtzjUHuk9v/go-testutil"
16 | pstore "gx/ipfs/QmPiemjiKBC9VA7vZF82m4x1oygtg2c2YVqag8PX7dN1BD/go-libp2p-peerstore"
17 | config "gx/ipfs/QmcRKBUqc2p3L1ZraoJjbXfs9E6xzvEuyK9iypb5RGwfsr/go-ipfs-config"
18 | )
19 |
20 | func TestSubsetWhenMaxIsGreaterThanLengthOfSlice(t *testing.T) {
21 | var ps []pstore.PeerInfo
22 | sizeofSlice := 100
23 | for i := 0; i < sizeofSlice; i++ {
24 | pid, err := testutil.RandPeerID()
25 | if err != nil {
26 | t.Fatal(err)
27 | }
28 |
29 | ps = append(ps, pstore.PeerInfo{ID: pid})
30 | }
31 | out := randomSubsetOfPeers(ps, 2*sizeofSlice)
32 | if len(out) != len(ps) {
33 | t.Fail()
34 | }
35 | }
36 |
37 | func TestMultipleAddrsPerPeer(t *testing.T) {
38 | var bsps []config.BootstrapPeer
39 | for i := 0; i < 10; i++ {
40 | pid, err := testutil.RandPeerID()
41 | if err != nil {
42 | t.Fatal(err)
43 | }
44 |
45 | addr := fmt.Sprintf("/ip4/127.0.0.1/tcp/5001/ipfs/%s", pid.Pretty())
46 | bsp1, err := config.ParseBootstrapPeer(addr)
47 | if err != nil {
48 | t.Fatal(err)
49 | }
50 |
51 | addr = fmt.Sprintf("/ip4/127.0.0.1/udp/5002/utp/ipfs/%s", pid.Pretty())
52 | bsp2, err := config.ParseBootstrapPeer(addr)
53 | if err != nil {
54 | t.Fatal(err)
55 | }
56 |
57 | bsps = append(bsps, bsp1, bsp2)
58 | }
59 |
60 | pinfos := toPeerInfos(bsps)
61 | if len(pinfos) != len(bsps)/2 {
62 | t.Fatal("expected fewer peers")
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/core/corehttp/gateway_indexPage.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package corehttp
10 |
11 | import (
12 | "html/template"
13 | "net/url"
14 | "path"
15 | "strings"
16 |
17 | "github.com/ipfs/go-ipfs/assets"
18 | )
19 |
20 | //目录列表结构
21 | type listingTemplateData struct {
22 | Listing []directoryItem
23 | Path string
24 | BackLink string
25 | Hash string
26 | }
27 |
28 | type directoryItem struct {
29 | Size string
30 | Name string
31 | Path string
32 | }
33 |
34 | var listingTemplate *template.Template
35 |
36 | func init() {
37 | knownIconsBytes, err := assets.Asset("dir-index-html/knownIcons.txt")
38 | if err != nil {
39 | panic(err)
40 | }
41 | knownIcons := make(map[string]struct{})
42 | for _, ext := range strings.Split(strings.TrimSuffix(string(knownIconsBytes), "\n"), "\n") {
43 | knownIcons[ext] = struct{}{}
44 | }
45 |
46 | //通过扩展名猜测其类型/图标的帮助程序
47 | iconFromExt := func(name string) string {
48 | ext := path.Ext(name)
49 | _, ok := knownIcons[ext]
50 | if !ok {
51 | //默认空白图标
52 | return "ipfs-_blank"
53 | }
54 | return "ipfs-" + ext[1:] //第一个点的切片
55 | }
56 |
57 | //自定义模板转义函数以转义完整路径,包括“”和“?”
58 | urlEscape := func(rawUrl string) string {
59 | pathUrl := url.URL{Path: rawUrl}
60 | return pathUrl.String()
61 | }
62 |
63 | //目录列表模板
64 | dirIndexBytes, err := assets.Asset("dir-index-html/dir-index.html")
65 | if err != nil {
66 | panic(err)
67 | }
68 |
69 | listingTemplate = template.Must(template.New("dir").Funcs(template.FuncMap{
70 | "iconFromExt": iconFromExt,
71 | "urlEscape": urlEscape,
72 | }).Parse(string(dirIndexBytes)))
73 | }
74 |
--------------------------------------------------------------------------------
/core/coreapi/interface/options/dht.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package options
10 |
11 | type DhtProvideSettings struct {
12 | Recursive bool
13 | }
14 |
15 | type DhtFindProvidersSettings struct {
16 | NumProviders int
17 | }
18 |
19 | type DhtProvideOption func(*DhtProvideSettings) error
20 | type DhtFindProvidersOption func(*DhtFindProvidersSettings) error
21 |
22 | func DhtProvideOptions(opts ...DhtProvideOption) (*DhtProvideSettings, error) {
23 | options := &DhtProvideSettings{
24 | Recursive: false,
25 | }
26 |
27 | for _, opt := range opts {
28 | err := opt(options)
29 | if err != nil {
30 | return nil, err
31 | }
32 | }
33 | return options, nil
34 | }
35 |
36 | func DhtFindProvidersOptions(opts ...DhtFindProvidersOption) (*DhtFindProvidersSettings, error) {
37 | options := &DhtFindProvidersSettings{
38 | NumProviders: 20,
39 | }
40 |
41 | for _, opt := range opts {
42 | err := opt(options)
43 | if err != nil {
44 | return nil, err
45 | }
46 | }
47 | return options, nil
48 | }
49 |
50 | type dhtOpts struct{}
51 |
52 | var Dht dhtOpts
53 |
54 | //递归是dht.provide的一个选项,指定是否提供
55 | //给定路径递归
56 | func (dhtOpts) Recursive(recursive bool) DhtProvideOption {
57 | return func(settings *DhtProvideSettings) error {
58 | settings.Recursive = recursive
59 | return nil
60 | }
61 | }
62 |
63 | //numProviders是dht.findproviders的一个选项,它指定
64 | //要查找的对等数。默认值为20
65 | func (dhtOpts) NumProviders(numProviders int) DhtFindProvidersOption {
66 | return func(settings *DhtFindProvidersSettings) error {
67 | settings.NumProviders = numProviders
68 | return nil
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/core/corehttp/metrics_test.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package corehttp
10 |
11 | import (
12 | "context"
13 | "testing"
14 | "time"
15 |
16 | core "github.com/ipfs/go-ipfs/core"
17 |
18 | inet "gx/ipfs/QmNgLg1NTw37iWbYPKcyK85YJ9Whs1MkPtJwhfqbNYAyKg/go-libp2p-net"
19 | bhost "gx/ipfs/QmYxivS34F2M2n44WQQnRHGAKS8aoRUxwGpi9wk4Cdn4Jf/go-libp2p/p2p/host/basic"
20 | swarmt "gx/ipfs/QmegQFxhr1J6yZ1vDQuDmJi5jntmj6BL96S11HVtXNCaHb/go-libp2p-swarm/testing"
21 | )
22 |
23 | //此测试基于go-libp2p/p2p/net/swarm.testconnestednesscorrect
24 | //它构建4个节点并连接它们,其中一个是唯一的中心。
25 | //然后检查中心是否报告了正确的对等数。
26 | func TestPeersTotal(t *testing.T) {
27 | ctx := context.Background()
28 |
29 | hosts := make([]*bhost.BasicHost, 4)
30 | for i := 0; i < 4; i++ {
31 | hosts[i] = bhost.New(swarmt.GenSwarm(t, ctx))
32 | }
33 |
34 | dial := func(a, b inet.Network) {
35 | swarmt.DivulgeAddresses(b, a)
36 | if _, err := a.DialPeer(ctx, b.LocalPeer()); err != nil {
37 | t.Fatalf("Failed to dial: %s", err)
38 | }
39 | }
40 |
41 | dial(hosts[0].Network(), hosts[1].Network())
42 | dial(hosts[0].Network(), hosts[2].Network())
43 | dial(hosts[0].Network(), hosts[3].Network())
44 |
45 | //我想拨号盘有问题。还没完呢
46 | //完全。一定有一些异步的东西。
47 | <-time.After(100 * time.Millisecond)
48 |
49 | node := &core.IpfsNode{PeerHost: hosts[0]}
50 | collector := IpfsNodeCollector{Node: node}
51 | actual := collector.PeersTotalValues()
52 | if len(actual) != 1 {
53 | t.Fatalf("expected 1 peers transport, got %d", len(actual))
54 | }
55 | if actual["/ip4/tcp"] != float64(3) {
56 | t.Fatalf("expected 3 peers, got %f", actual["/ip4/tcp"])
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/test/sharness/t0031-mount-publish.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | test_description="Test mount command in conjunction with publishing"
4 |
5 | # imports
6 | . lib/test-lib.sh
7 |
8 | # if in travis CI, dont test mount (no fuse)
9 | if ! test_have_prereq FUSE; then
10 | skip_all='skipping mount tests, fuse not available'
11 |
12 | test_done
13 | fi
14 |
15 | test_init_ipfs
16 |
17 | # start iptb + wait for peering
18 | NUM_NODES=3
19 | test_expect_success 'init iptb' '
20 | iptb testbed create -type localipfs -count $NUM_NODES -force -init &&
21 | startup_cluster $NUM_NODES
22 | '
23 |
24 | # pre-mount publish
25 | HASH=$(echo 'hello warld' | ipfsi 0 add -q)
26 | test_expect_success "can publish before mounting /ipns" '
27 | ipfsi 0 name publish '$HASH'
28 | '
29 |
30 | # mount
31 | IPFS_MOUNT_DIR="$PWD/ipfs"
32 | IPNS_MOUNT_DIR="$PWD/ipns"
33 | test_expect_success FUSE "'ipfs mount' succeeds" '
34 | ipfsi 0 mount -f "'"$IPFS_MOUNT_DIR"'" -n "'"$IPNS_MOUNT_DIR"'" >actual
35 | '
36 | test_expect_success FUSE "'ipfs mount' output looks good" '
37 | echo "IPFS mounted at: $PWD/ipfs" >expected &&
38 | echo "IPNS mounted at: $PWD/ipns" >>expected &&
39 | test_cmp expected actual
40 | '
41 |
42 | test_expect_success "cannot publish after mounting /ipns" '
43 | echo "Error: cannot manually publish while IPNS is mounted" >expected &&
44 | test_must_fail ipfsi 0 name publish '$HASH' 2>actual &&
45 | test_cmp expected actual
46 | '
47 |
48 | test_expect_success "unmount /ipns out-of-band" '
49 | fusermount -u "'"$IPNS_MOUNT_DIR"'"
50 | '
51 |
52 | test_expect_success "can publish after unmounting /ipns" '
53 | ipfsi 0 name publish '$HASH'
54 | '
55 |
56 | # clean-up ipfs
57 | test_expect_success "unmount /ipfs" '
58 | fusermount -u "'"$IPFS_MOUNT_DIR"'"
59 | '
60 | iptb stop
61 |
62 | test_done
63 |
--------------------------------------------------------------------------------
/core/coreapi/interface/swarm.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package iface
10 |
11 | import (
12 | "context"
13 | "errors"
14 | "time"
15 |
16 | ma "gx/ipfs/QmNTCey11oxhb1AxDnQBRHtdhap6Ctud872NjAYPYYXPuc/go-multiaddr"
17 | net "gx/ipfs/QmNgLg1NTw37iWbYPKcyK85YJ9Whs1MkPtJwhfqbNYAyKg/go-libp2p-net"
18 | pstore "gx/ipfs/QmPiemjiKBC9VA7vZF82m4x1oygtg2c2YVqag8PX7dN1BD/go-libp2p-peerstore"
19 | "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer"
20 | "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol"
21 | )
22 |
23 | var (
24 | ErrNotConnected = errors.New("not connected")
25 | ErrConnNotFound = errors.New("conn not found")
26 | )
27 |
28 | //ConnectionInfo包含有关对等机的信息
29 | type ConnectionInfo interface {
30 | //id返回peerid
31 | ID() peer.ID
32 |
33 | //地址返回与对等机连接的多地址
34 | Address() ma.Multiaddr
35 |
36 | //方向返回建立连接的方式
37 | Direction() net.Direction
38 |
39 | //延迟向对等端返回上次已知的往返时间
40 | Latency() (time.Duration, error)
41 |
42 | //流返回与对等方建立的流的列表
43 | Streams() ([]protocol.ID, error)
44 | }
45 |
46 | //swarmapi指定libp2p swarm的接口
47 | type SwarmAPI interface {
48 | //
49 | Connect(context.Context, pstore.PeerInfo) error
50 |
51 | //断开与给定地址的连接
52 | Disconnect(context.Context, ma.Multiaddr) error
53 |
54 | //peers返回我们连接到的对等机列表
55 | Peers(context.Context) ([]ConnectionInfo, error)
56 |
57 | //knownaddrs返回此节点知道的所有地址的列表
58 | KnownAddrs(context.Context) (map[peer.ID][]ma.Multiaddr, error)
59 |
60 | //localaddrs返回已宣布的侦听地址列表
61 | LocalAddrs(context.Context) ([]ma.Multiaddr, error)
62 |
63 | //listenaddrs返回所有侦听地址的列表
64 | ListenAddrs(context.Context) ([]ma.Multiaddr, error)
65 | }
66 |
--------------------------------------------------------------------------------
/core/coredag/dagpb.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package coredag
10 |
11 | import (
12 | "io"
13 | "io/ioutil"
14 | "math"
15 |
16 | "gx/ipfs/QmTQdH4848iTVCJmKXYyRiK72HufWTLYQQ8iN3JaQ8K1Hq/go-merkledag"
17 |
18 | cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid"
19 | ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format"
20 | mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash"
21 | )
22 |
23 | func dagpbJSONParser(r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
24 | data, err := ioutil.ReadAll(r)
25 | if err != nil {
26 | return nil, err
27 | }
28 |
29 | nd := &merkledag.ProtoNode{}
30 |
31 | err = nd.UnmarshalJSON(data)
32 | if err != nil {
33 | return nil, err
34 | }
35 |
36 | nd.SetCidBuilder(cidPrefix(mhType, mhLen))
37 |
38 | return []ipld.Node{nd}, nil
39 | }
40 |
41 | func dagpbRawParser(r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
42 | data, err := ioutil.ReadAll(r)
43 | if err != nil {
44 | return nil, err
45 | }
46 |
47 | nd, err := merkledag.DecodeProtobuf(data)
48 | if err != nil {
49 | return nil, err
50 | }
51 |
52 | nd.SetCidBuilder(cidPrefix(mhType, mhLen))
53 |
54 | return []ipld.Node{nd}, nil
55 | }
56 |
57 | func cidPrefix(mhType uint64, mhLen int) *cid.Prefix {
58 | if mhType == math.MaxUint64 {
59 | mhType = mh.SHA2_256
60 | }
61 |
62 | prefix := &cid.Prefix{
63 | MhType: mhType,
64 | MhLength: mhLen,
65 | Version: 1,
66 | Codec: cid.DagProtobuf,
67 | }
68 |
69 | if mhType == mh.SHA2_256 {
70 | prefix.Version = 0
71 | }
72 |
73 | return prefix
74 | }
75 |
--------------------------------------------------------------------------------
/plugin/loader/load_linux.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | //+建设!诺普洛金
10 |
11 | package loader
12 |
13 | import (
14 | "errors"
15 | "fmt"
16 | "os"
17 | "path/filepath"
18 | "plugin"
19 |
20 | iplugin "github.com/ipfs/go-ipfs/plugin"
21 | )
22 |
23 | func init() {
24 | loadPluginsFunc = linuxLoadFunc
25 | }
26 |
27 | func linuxLoadFunc(pluginDir string) ([]iplugin.Plugin, error) {
28 | var plugins []iplugin.Plugin
29 |
30 | err := filepath.Walk(pluginDir, func(fi string, info os.FileInfo, err error) error {
31 | if err != nil {
32 | return err
33 | }
34 | if info.IsDir() {
35 | if fi != pluginDir {
36 | log.Warningf("found directory inside plugins directory: %s", fi)
37 | }
38 | return nil
39 | }
40 |
41 | if info.Mode().Perm()&0111 == 0 {
42 | //文件不是可执行文件,我们不加载它
43 | //这是为了防止加载插件,例如不可执行的插件
44 | //安装,一些/tmp安装标记为安全
45 | log.Errorf("non-executable file in plugins directory: %s", fi)
46 | return nil
47 | }
48 |
49 | if newPlugins, err := loadPlugin(fi); err == nil {
50 | plugins = append(plugins, newPlugins...)
51 | } else {
52 | return fmt.Errorf("loading plugin %s: %s", fi, err)
53 | }
54 | return nil
55 | })
56 |
57 | return plugins, err
58 | }
59 |
60 | func loadPlugin(fi string) ([]iplugin.Plugin, error) {
61 | pl, err := plugin.Open(fi)
62 | if err != nil {
63 | return nil, err
64 | }
65 | pls, err := pl.Lookup("Plugins")
66 | if err != nil {
67 | return nil, err
68 | }
69 |
70 | typePls, ok := pls.(*[]iplugin.Plugin)
71 | if !ok {
72 | return nil, errors.New("filed 'Plugins' didn't contain correct type")
73 | }
74 |
75 | return *typePls, nil
76 | }
77 |
--------------------------------------------------------------------------------
/test/sharness/t0061-daemon-opts.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copyright (c) 2014 Juan Batiz-Benet
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="Test daemon command"
8 |
9 | . lib/test-lib.sh
10 |
11 |
12 | test_init_ipfs
13 |
14 | test_launch_ipfs_daemon --disable-transport-encryption
15 |
16 | gwyaddr=$GWAY_ADDR
17 | apiaddr=$API_ADDR
18 |
19 | # Odd. this fails here, but the inverse works on t0060-daemon.
20 | test_expect_success 'transport should be unencrypted' '
21 | nc -w 1 localhost $SWARM_PORT > swarmnc < ../t0060-data/mss-ls &&
22 | test_must_fail grep -q "/secio" swarmnc &&
23 | grep -q "/plaintext" swarmnc ||
24 | test_fsh cat swarmnc
25 | '
26 |
27 | test_kill_ipfs_daemon
28 |
29 | test_launch_ipfs_daemon --offline
30 |
31 | gwyaddr=$GWAY_ADDR
32 | apiaddr=$API_ADDR
33 |
34 | test_expect_success 'gateway should work in offline mode' '
35 | echo "hello mars :$gwyaddr :$apiaddr" >expected &&
36 | HASH=$(ipfs add -q expected) &&
37 | curl -sfo actual1 "http://$gwyaddr/ipfs/$HASH" &&
38 | test_cmp expected actual1
39 | '
40 |
41 | test_kill_ipfs_daemon
42 |
43 | test_expect_success 'daemon should not start with bad dht opt' '
44 | test_must_fail ipfs daemon --routing=fdsfdsfds > daemon_output 2>&1
45 | '
46 |
47 | test_expect_success 'output contains info about dht option' '
48 | grep "unrecognized routing option:" daemon_output ||
49 | test_fsh cat daemon_output
50 | '
51 |
52 | test_expect_success 'daemon should not start with supernode dht opt' '
53 | test_must_fail ipfs daemon --routing=supernode > daemon_output2 2>&1
54 | '
55 |
56 | test_expect_success 'output contains info about supernode dht option' '
57 | grep "supernode routing was never fully implemented" daemon_output2 ||
58 | test_fsh cat daemon_output2
59 | '
60 |
61 | test_done
62 |
--------------------------------------------------------------------------------
/repo/repo.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package repo
10 |
11 | import (
12 | "errors"
13 | "io"
14 |
15 | filestore "github.com/ipfs/go-ipfs/filestore"
16 | keystore "github.com/ipfs/go-ipfs/keystore"
17 |
18 | ma "gx/ipfs/QmNTCey11oxhb1AxDnQBRHtdhap6Ctud872NjAYPYYXPuc/go-multiaddr"
19 | config "gx/ipfs/QmcRKBUqc2p3L1ZraoJjbXfs9E6xzvEuyK9iypb5RGwfsr/go-ipfs-config"
20 | ds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore"
21 | )
22 |
23 | var (
24 | ErrApiNotRunning = errors.New("api not running")
25 | )
26 |
27 | //repo表示给定ipfs节点的所有持久数据。
28 | type Repo interface {
29 | //config从repo返回ipfs配置文件。作出改变
30 | //返回的配置不会自动保留。
31 | Config() (*config.Config, error)
32 |
33 | //backupconfig使用创建当前配置文件的备份
34 | //用于命名的给定前缀。
35 | BackupConfig(prefix string) (string, error)
36 |
37 | //setconfig将给定的配置结构保存到存储中。
38 | SetConfig(*config.Config) error
39 |
40 | //setconfigkey在config中设置给定的键值对,并将其保存到存储器中。
41 | SetConfigKey(key string, value interface{}) error
42 |
43 | //getconfigkey从存储中的配置中读取给定密钥的值。
44 | GetConfigKey(key string) (interface{}, error)
45 |
46 | //数据存储返回对配置的数据存储后端的引用。
47 | Datastore() Datastore
48 |
49 | //GetStorageUsage返回存储的字节数。
50 | GetStorageUsage() (uint64, error)
51 |
52 | //keystore返回对密钥管理接口的引用。
53 | Keystore() keystore.Keystore
54 |
55 | //文件管理器返回对文件存储文件管理器的引用。
56 | FileManager() *filestore.FileManager
57 |
58 | //setapiaddr设置repo中的api地址。
59 | SetAPIAddr(addr ma.Multiaddr) error
60 |
61 | //swarmkey返回为专用网络功能配置的共享对称密钥。
62 | SwarmKey() ([]byte, error)
63 |
64 | io.Closer
65 | }
66 |
67 | //数据存储是数据存储需要的接口
68 | //FSrepo可接受。
69 | type Datastore interface {
70 | ds.Batching //应该是安全的,小心点
71 | io.Closer
72 | }
73 |
--------------------------------------------------------------------------------
/namesys/opts/opts.go:
--------------------------------------------------------------------------------
1 |
2 | //此源码被清华学神尹成大魔王专业翻译分析并修改
3 | //尹成QQ77025077
4 | //尹成微信18510341407
5 | //尹成所在QQ群721929980
6 | //尹成邮箱 yinc13@mails.tsinghua.edu.cn
7 | //尹成毕业于清华大学,微软区块链领域全球最有价值专家
8 | //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
9 | package nsopts
10 |
11 | import (
12 | "time"
13 | )
14 |
15 | const (
16 | //DefaultDepthLimit是解析所使用的默认深度限制。
17 | DefaultDepthLimit = 32
18 |
19 | //UnlimitedDepth允许在解析中进行无限递归。你
20 | //可能不想用这个,但如果你绝对想用的话,它就在这里。
21 | //相信决议最终完成,不能占上风
22 | //限制将要采取的步骤。
23 | UnlimitedDepth = 0
24 | )
25 |
26 | //resolveopts指定用于解析IPN路径的选项
27 | type ResolveOpts struct {
28 | //递归深度限制
29 | Depth uint
30 | //要从DHT检索的IPN记录数
31 | //(最佳记录从该集合中选择)
32 | DhtRecordCount uint
33 | //等待提取DHT记录的时间量
34 | //并进行了验证。零值表示没有显式
35 | //超时(尽管由于拨号有一个隐式超时
36 | //DHT内超时)
37 | DhtTimeout time.Duration
38 | }
39 |
40 | //DefaultResolveOpts返回用于解析的默认选项
41 | //IPNS路径
42 | func DefaultResolveOpts() ResolveOpts {
43 | return ResolveOpts{
44 | Depth: DefaultDepthLimit,
45 | DhtRecordCount: 16,
46 | DhtTimeout: time.Minute,
47 | }
48 | }
49 |
50 | //resolveopt用于设置选项
51 | type ResolveOpt func(*ResolveOpts)
52 |
53 | //深度是递归深度限制
54 | func Depth(depth uint) ResolveOpt {
55 | return func(o *ResolveOpts) {
56 | o.Depth = depth
57 | }
58 | }
59 |
60 | //dhtrecordcount是要从DHT检索的IPN记录数。
61 | func DhtRecordCount(count uint) ResolveOpt {
62 | return func(o *ResolveOpts) {
63 | o.DhtRecordCount = count
64 | }
65 | }
66 |
67 | //DHTTimeout是等待提取DHT记录的时间量。
68 | //并进行了验证。零值表示没有显式超时
69 | func DhtTimeout(timeout time.Duration) ResolveOpt {
70 | return func(o *ResolveOpts) {
71 | o.DhtTimeout = timeout
72 | }
73 | }
74 |
75 | //processopts将resolveOpt数组转换为resolveOpts对象
76 | func ProcessOpts(opts []ResolveOpt) ResolveOpts {
77 | rsopts := DefaultResolveOpts()
78 | for _, option := range opts {
79 | option(&rsopts)
80 | }
81 | return rsopts
82 | }
83 |
--------------------------------------------------------------------------------
/test/bin/Rules.mk:
--------------------------------------------------------------------------------
1 | include mk/header.mk
2 |
3 | TGTS_$(d) :=
4 |
5 | $(d)/pollEndpoint: thirdparty/pollEndpoint
6 | $(go-build)
7 | TGTS_$(d) += $(d)/pollEndpoint
8 |
9 | $(d)/go-sleep: test/dependencies/go-sleep
10 | $(go-build)
11 | TGTS_$(d) += $(d)/go-sleep
12 |
13 | $(d)/go-timeout: test/dependencies/go-timeout
14 | $(go-build)
15 | TGTS_$(d) += $(d)/go-timeout
16 |
17 | $(d)/iptb: test/dependencies/iptb
18 | $(go-build)
19 | TGTS_$(d) += $(d)/iptb
20 |
21 | $(d)/ma-pipe-unidir: test/dependencies/ma-pipe-unidir
22 | $(go-build)
23 | TGTS_$(d) += $(d)/ma-pipe-unidir
24 |
25 | $(d)/json-to-junit: test/dependencies/json-to-junit
26 | $(go-build)
27 | TGTS_$(d) += $(d)/json-to-junit
28 |
29 | TGTS_GX_$(d) := hang-fds
30 | TGTS_GX_$(d) := $(addprefix $(d)/,$(TGTS_GX_$(d)))
31 |
32 | $(TGTS_GX_$(d)):
33 | go build -i $(go-flags-with-tags) -o "$@" "$(call gx-path,$(notdir $@))"
34 |
35 | TGTS_$(d) += $(TGTS_GX_$(d))
36 |
37 | # multihash is special
38 | $(d)/multihash:
39 | go build -i $(go-flags-with-tags) -o "$@" "gx/ipfs/$(shell gx deps find go-multihash)/go-multihash/multihash"
40 | TGTS_$(d) += $(d)/multihash
41 |
42 | # cid-fmt is also special
43 | $(d)/cid-fmt:
44 | go build -i $(go-flags-with-tags) -o "$@" "gx/ipfs/$(shell gx deps find go-cidutil)/go-cidutil/cid-fmt"
45 | TGTS_$(d) += $(d)/cid-fmt
46 |
47 | # random is also special
48 | $(d)/random:
49 | go build -i $(go-flags-with-tags) -o "$@" "gx/ipfs/$(shell gx deps find go-random)/go-random/random"
50 | TGTS_$(d) += $(d)/random
51 |
52 | # random-files is also special
53 | $(d)/random-files:
54 | go build -i $(go-flags-with-tags) -o "$@" "gx/ipfs/$(shell gx deps find go-random-files)/go-random-files/random-files"
55 | TGTS_$(d) += $(d)/random-files
56 |
57 |
58 | $(TGTS_$(d)): $$(DEPS_GO)
59 |
60 | CLEAN += $(TGTS_$(d))
61 |
62 | PATH := $(realpath $(d)):$(PATH)
63 |
64 | include mk/footer.mk
65 |
--------------------------------------------------------------------------------