go-dms3
What is DMS3?
DMS3 is a global, versioned, peer-to-peer filesystem. It combines good ideas from previous systems such as Git, BitTorrent, Kademlia, SFS, and the Web. It is like a single BitTorrent swarm, exchanging git objects. DMS3 provides an interface as simple as the HTTP web, but with permanence built-in. You can also mount the world at /dms3.
For more info see: https://docs.dms3.io/introduction/overview/
Before opening an issue, consider using one of the following locations to ensure you are opening your thread in the right place:
- go-dms3 implementation bugs in this repo.
- Documentation issues in dms3/docs issues.
- DMS3 design in dms3/specs issues.
- Exploration of new ideas in dms3/notes issues.
- Ask questions and meet the rest of the community at the DMS3 Forum.
Table of Contents
Security Issues
The DMS3 protocol and its implementations are still in heavy development. This means that there may be problems in our protocols, or there may be mistakes in our implementations. And -- though DMS3 is not production-ready yet -- many people are already running nodes in their machines. So we take security vulnerabilities very seriously. If you discover a security issue, please bring it to our attention right away!
If you find a vulnerability that may affect live deployments -- for example, by exposing a remote execution exploit -- please send your report privately to security@dms3.io. Please DO NOT file a public issue.
If the issue is a protocol weakness that cannot be immediately exploited or something not yet deployed, just discuss it openly.
Install
The canonical download instructions for DMS3 are over at: https://docs.dms3.io/guides/guides/install/. It is highly recommended you follow those instructions if you are not interested in working on DMS3 development.
System Requirements
DMS3 can run on most Linux, macOS, and Windows systems. We recommend running it on a machine with at least 2 GB of RAM and 2 CPU cores (go-dms3 is highly parallel). On systems with less memory, it may not be completely stable.
If your system is resource-constrained, we recommend:
- Installing OpenSSL and rebuilding go-dms3 manually with
make build GOTAGS=openssl
. See the download and compile section for more information on compiling go-dms3. - Initializing your daemon with
dms3 init --profile=lowpower
Install prebuilt packages
We host prebuilt binaries over at our distributions page.
From there:
- Click the blue "Download go-dms3" on the right side of the page.
- Open/extract the archive.
- Move
dms3
to your path (install.sh
can do it for you).
You can also download go-dms3 from this project's GitHub releases page if you are unable to access dms3.io.
From Linux package managers
Arch Linux
In Arch Linux go-dms3 is available as go-dms3 package.
$ sudo pacman -S go-dms3
Development version of go-dms3 is also on AUR under go-dms3-git. You can install it using your favorite AUR Helper or manually from AUR.
Nix
For Linux and MacOSX you can use the purely functional package manager Nix:
$ nix-env -i dms3
You can also install the Package by using its attribute name, which is also dms3
.
Guix
GNU's functional package manager, Guix, also provides a go-dms3 package:
$ guix package -i go-dms3
Solus
In solus, go-dms3 is available in the main repository as go-dms3.
$ sudo eopkg install go-dms3
You can also install it through the Solus software center.
Snap
With snap, in any of the supported Linux distributions:
$ sudo snap install dms3
From Windows package managers
Chocolatey
The package dms3 currently points to go-dms3 and is being maintained.
PS> choco install dms3
Scoop
Scoop provides go-dms3
in its 'extras' bucket.
PS> scoop bucket add extras
PS> scoop install go-dms3
Build from Source
go-dms3's build system requires Go 1.14.4 and some standard POSIX build tools:
- GNU make
- Git
- GCC (or some other go compatible C Compiler) (optional)
To build without GCC, build with CGO_ENABLED=0
(e.g., make build CGO_ENABLED=0
).
Install Go
The build process for dms3 requires Go 1.14.4 or higher. If you don't have it: Download Go 1.14+.
You'll need to add Go's bin directories to your $PATH
environment variable e.g., by adding these lines to your /etc/profile
(for a system-wide installation) or $HOME/.profile
:
export PATH=$PATH:/usr/local/go/bin
export PATH=$PATH:$GOPATH/bin
(If you run into trouble, see the Go install instructions).
Download and Compile DMS3
$ git clone https://gitlab.dms3.io/dms3/public/go-dms3.git
$ cd go-dms3
$ make install
Alternatively, you can run make build
to build the go-dms3 binary (storing it in cmd/dms3/dms3
) without installing it.
NOTE: If you get an error along the lines of "fatal error: stdlib.h: No such file or directory", you're missing a C compiler. Either re-run make
with CGO_ENABLED=0
or install GCC.
Cross Compiling
Compiling for a different platform is as simple as running:
make build GOOS=myTargetOS GOARCH=myTargetArchitecture
OpenSSL
To build go-dms3 with OpenSSL support, append GOTAGS=openssl
to your make
invocation. Building with OpenSSL should significantly reduce the background CPU usage on nodes that frequently make or receive new connections.
Note: OpenSSL requires CGO support and, by default, CGO is disabled when cross-compiling. To cross-compile with OpenSSL support, you must:
- Install a compiler toolchain for the target platform.
- Set the
CGO_ENABLED=1
environment variable.
Troubleshooting
- Separate instructions are available for building on Windows.
-
git
is required in order forgo get
to fetch all dependencies. - Package managers often contain out-of-date
golang
packages. Ensure thatgo version
reports at least 1.10. See above for how to install go. - If you are interested in development, please install the development dependencies as well.
- WARNING: Older versions of OSX FUSE (for Mac OS X) can cause kernel panics when mounting!- We strongly recommend you use the latest version of OSX FUSE. (See https://gitlab.dms3.io/dms3/public/go-dms3/issues/177)
- For more details on setting up FUSE (so that you can mount the filesystem), see the docs folder.
- Shell command completion is available in
misc/completion/dms3-completion.bash
. Read docs/command-completion.md to learn how to install it. - See the misc folder for how to connect DMS3 to systemd or whatever init system your distro uses.
Updating go-dms3
Using dms3-update
DMS3 has an updating tool that can be accessed through dms3 update
. The tool is
not installed alongside DMS3 in order to keep that logic independent of the main
codebase. To install dms3 update
, download it here.
Downloading DMS3 builds using DMS3
List the available versions of go-dms3:
$ dms3 cat /dms3ns/dist.dms3.io/go-dms3/versions
Then, to view available builds for a version from the previous command ($VERSION):
$ dms3 ls /dms3ns/dist.dms3.io/go-dms3/$VERSION
To download a given build of a version:
$ dms3 get /dms3ns/dist.dms3.io/go-dms3/$VERSION/go-dms3_$VERSION_darwin-386.tar.gz # darwin 32-bit build
$ dms3 get /dms3ns/dist.dms3.io/go-dms3/$VERSION/go-dms3_$VERSION_darwin-amd64.tar.gz # darwin 64-bit build
$ dms3 get /dms3ns/dist.dms3.io/go-dms3/$VERSION/go-dms3_$VERSION_freebsd-amd64.tar.gz # freebsd 64-bit build
$ dms3 get /dms3ns/dist.dms3.io/go-dms3/$VERSION/go-dms3_$VERSION_linux-386.tar.gz # linux 32-bit build
$ dms3 get /dms3ns/dist.dms3.io/go-dms3/$VERSION/go-dms3_$VERSION_linux-amd64.tar.gz # linux 64-bit build
$ dms3 get /dms3ns/dist.dms3.io/go-dms3/$VERSION/go-dms3_$VERSION_linux-arm.tar.gz # linux arm build
$ dms3 get /dms3ns/dist.dms3.io/go-dms3/$VERSION/go-dms3_$VERSION_windows-amd64.zip # windows 64-bit build
Getting Started
See also: https://docs.dms3.io/introduction/usage/
To start using DMS3, you must first initialize DMS3's config files on your
system, this is done with dms3 init
. See dms3 init --help
for information on
the optional arguments it takes. After initialization is complete, you can use
dms3 mount
, dms3 add
and any of the other commands to explore!
Some things to try
Basic proof of 'dms3 working' locally:
echo "hello world" > hello
dms3 add hello
# This should output a hash string that looks something like:
# QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o
dms3 cat <that hash>
Usage
dms3 - Global p2p merkle-dag filesystem.
dms3 [<flags>] <command> [<arg>] ...
SUBCOMMANDS
BASIC COMMANDS
init Initialize dms3 local configuration
add <path> Add a file to dms3
cat <ref> Show dms3 object data
get <ref> Download dms3 objects
ls <ref> List links from an object
refs <ref> List hashes of links from an object
DATA STRUCTURE COMMANDS
block Interact with raw blocks in the datastore
object Interact with raw dag nodes
files Interact with objects as if they were a unix filesystem
ADVANCED COMMANDS
daemon Start a long-running daemon process
mount Mount an dms3 read-only mount point
resolve Resolve any type of name
name Publish or resolve DMS3NS names
dns Resolve DNS links
pin Pin objects to local storage
repo Manipulate an DMS3 repository
NETWORK COMMANDS
id Show info about dms3 peers
bootstrap Add or remove bootstrap peers
swarm Manage connections to the p2p network
dht Query the DHT for values or peers
ping Measure the latency of a connection
diag Print diagnostics
TOOL COMMANDS
config Manage configuration
version Show dms3 version information
update Download and apply go-dms3 updates
commands List all available commands
Use 'dms3 <command> --help' to learn more about each command.
dms3 uses a repository in the local file system. By default, the repo is located at
~/.dms3. To change the repo location, set the $DMS3_PATH environment variable:
export DMS3_PATH=/path/to/dms3repo
Running DMS3 inside Docker
An DMS3 docker image is hosted at hub.docker.com/r/dms3/go-dms3.
To make files visible inside the container you need to mount a host directory
with the -v
option to docker. Choose a directory that you want to use to
import/export files from DMS3. You should also choose a directory to store
DMS3 files that will persist when you restart the container.
export dms3_staging=</absolute/path/to/somewhere/>
export dms3_data=</absolute/path/to/somewhere_else/>
Start a container running dms3 and expose ports 4001, 5001 and 8080:
docker run -d --name dms3_host -v $dms3_staging:/export -v $dms3_data:/data/dms3 -p 4001:4001 -p 4001:4001/udp -p 127.0.0.1:8080:8080 -p 127.0.0.1:5001:5001 dms3/go-dms3:latest
Watch the dms3 log:
docker logs -f dms3_host
Wait for dms3 to start. dms3 is running when you see:
Gateway (readonly) server
listening on /ip4/0.0.0.0/tcp/8080
You can now stop watching the log.
Run dms3 commands:
docker exec dms3_host dms3 <args...>
For example: connect to peers
docker exec dms3_host dms3 swarm peers
Add files:
cp -r <something> $dms3_staging
docker exec dms3_host dms3 add -r /export/<something>
Stop the running container:
docker stop dms3_host
When starting a container running dms3 for the first time with an empty data directory, it will call dms3 init
to initialize configuration files and generate a new keypair. At this time, you can choose which profile to apply using the DMS3_PROFILE
environment variable:
docker run -d --name dms3_host -e DMS3_PROFILE=server -v $dms3_staging:/export -v $dms3_data:/data/dms3 -p 4001:4001 -p 4001:4001/udp -p 127.0.0.1:8080:8080 -p 127.0.0.1:5001:5001 dms3/go-dms3:latest
Private swarms inside Docker
It is possible to initialize the container with a swarm key file (/data/dms3/swarm.key
) using the variables DMS3_SWARM_KEY
and DMS3_SWARM_KEY_FILE
. The DMS3_SWARM_KEY
creates swarm.key
with the contents of the variable itself, whilst DMS3_SWARM_KEY_FILE
copies the key from a path stored in the variable. The DMS3_SWARM_KEY_FILE
overwrites the key generated by DMS3_SWARM_KEY
.
docker run -d --name dms3_host -e DMS3_SWARM_KEY=<your swarm key> -v $dms3_staging:/export -v $dms3_data:/data/dms3 -p 4001:4001 -p 4001:4001/udp -p 127.0.0.1:8080:8080 -p 127.0.0.1:5001:5001 dms3/go-dms3:latest
The swarm key initialization can also be done using docker secrets (requires docker swarm or docker-compose):
cat your_swarm.key | docker secret create swarm_key_secret -
docker run -d --name dms3_host --secret swarm_key_secret -e DMS3_SWARM_KEY_FILE=/run/secrets/swarm_key_secret -v $dms3_staging:/export -v $dms3_data:/data/dms3 -p 4001:4001 -p 4001:4001/udp -p 127.0.0.1:8080:8080 -p 127.0.0.1:5001:5001 dms3/go-dms3:latest
Key rotation inside Docker
If needed, it is possible to do key rotation in an ephemeral container that is temporarily executing against a volume that is mounted under /data/dms3
:
# given container named 'dms3-test' that persists repo at /path/to/persisted/.dms3
$ docker run -d --name dms3-test -v /path/to/persisted/.dms3:/data/dms3 dms3/go-dms3:v0.7.0
$ docker stop dms3-test
# key rotation works like this (old key saved under 'old-self')
$ docker run --rm -it -v /path/to/persisted/.dms3:/data/dms3 dms3/go-dms3:v0.7.0 key rotate -o old-self -t ed25519
$ docker start dms3-test # will start with the new key
Troubleshooting
If you have previously installed DMS3 before and you are running into problems getting a newer version to work, try deleting (or backing up somewhere else) your DMS3 config directory (~/.dms3 by default) and rerunning dms3 init
. This will reinitialize the config file to its defaults and clear out the local datastore of any bad entries.
Please direct general questions and help requests to our forum or our IRC channel (freenode #dms3).
If you believe you've found a bug, check the issues list and, if you don't see your problem there, either come talk to us on IRC (freenode #dms3) or file an issue of your own!
Packages
This table is generated using the module
package-table
withpackage-table --data=package-list.json
.
Listing of the main packages used in the DMS3 ecosystem. There are also three specifications worth linking here:
Name | CI/Travis | Coverage | Description |
---|---|---|---|
Libp2p | |||
go-libp2p |
p2p networking library | ||
go-libp2p-pubsub |
pubsub built on libp2p | ||
go-libp2p-kad-dht |
dht-backed router | ||
go-libp2p-pubsub-router |
pubsub-backed router | ||
Multiformats | |||
go-cid |
CID implementation | ||
go-multiaddr |
multiaddr implementation | ||
go-multihash |
multihash implementation | ||
go-multibase |
mulitbase implementation | ||
Files | |||
go-unixfs |
the core 'filesystem' logic | ||
go-mfs |
a mutable filesystem editor for unixfs | ||
go-dms3-posinfo |
helper datatypes for the filestore | ||
go-dms3-chunker |
file chunkers | ||
Exchange | |||
go-dms3-exchange-interface |
exchange service interface | ||
go-dms3-exchange-offline |
(dummy) offline implementation of the exchange service | ||
go-bitswap |
bitswap protocol implementation | ||
go-blockservice |
service that plugs a blockstore and an exchange together | ||
Datastores | |||
go-datastore |
datastore interfaces, adapters, and basic implementations | ||
go-dms3-ds-help |
datastore utility functions | ||
go-ds-flatfs |
a filesystem-based datastore | ||
go-ds-measure |
a metric-collecting database adapter | ||
go-ds-leveldb |
a leveldb based datastore | ||
go-ds-badger |
a badgerdb based datastore | ||
Namesys | |||
go-dms3ns |
DMS3NS datastructures and validation logic | ||
Repo | |||
go-dms3-config |
go-dms3 config file definitions | ||
go-fs-lock |
lockfile management functions | ||
fs-repo-migrations |
repo migrations | ||
DMS3LD | |||
go-block-format |
block interfaces and implementations | ||
go-dms3-blockstore |
blockstore interfaces and implementations | ||
go-dms3ld-format |
DMS3LD interfaces | ||
go-dms3ld-cbor |
DMS3LD-CBOR implementation | ||
go-dms3ld-git |
DMS3LD-Git implementation | ||
go-merkledag |
DMS3LD-Merkledag implementation (and then some) | ||
Commands | |||
go-dms3-cmds |
CLI & HTTP commands library | ||
go-dms3-files |
CLI & HTTP commands library | ||
go-dms3-api |
an old, stable shell for the DMS3 HTTP API | ||
go-dms3-http-client |
a new, unstable shell for the DMS3 HTTP API | ||
interface-go-dms3-core |
core go-dms3 API interface definitions | ||
Metrics & Logging | |||
go-metrics-interface |
metrics collection interfaces | ||
go-metrics-prometheus |
prometheus-backed metrics collector | ||
go-log |
logging framework | ||
Generics/Utils | |||
go-dms3-routing |
routing (content, peer, value) helpers | ||
go-dms3-util |
the kitchen sink | ||
go-dms3-addr |
utility functions for parsing DMS3 multiaddrs |
For brevity, we've omitted most go-libp2p, go-dms3ld, and go-multiformats packages. These package tables can be found in their respective project's READMEs:
Development
Some places to get you started on the codebase:
- Main file: ./cmd/dms3/main.go
- CLI Commands: ./core/commands/
- Bitswap (the data trading engine): go-bitswap
- libp2p
- DMS3 : The
Add
command demystified
Map of go-dms3 Subsystems
WIP: This is a high-level architecture diagram of the various sub-systems of go-dms3. To be updated with how they interact. Anyone who has suggestions is welcome to comment here on how we can improve this!
CLI, HTTP-API, Architecture Diagram
Description: Dotted means "likely going away". The "Legacy" parts are thin wrappers around some commands to translate between the new system and the old system. The grayed-out parts on the "daemon" diagram are there to show that the code is all the same, it's just that we turn some pieces on and some pieces off depending on whether we're running on the client or the server.
Testing
make test
Development Dependencies
If you make changes to the protocol buffers, you will need to install the protoc compiler.
Developer Notes
Find more documentation for developers on docs
Contributing
We
This repository falls under the DMS3 Code of Conduct.
You can contact us on the freenode #dms3-dev channel or attend one of our weekly calls.
License
The go-dms3 project is dual-licensed under Apache 2.0 and MIT terms:
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)