-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from davide-scola/0.x-initial_import
Initial import
- Loading branch information
Showing
55 changed files
with
4,559 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# | ||
# Compile time | ||
# | ||
*.o | ||
.deps/ | ||
.libs/ | ||
*.l[ao] | ||
|
||
# | ||
# Tests | ||
# | ||
*-test-vector-*.sh | ||
|
||
# | ||
# Autotools | ||
# | ||
lt*.m4 | ||
shtool | ||
stamp-h1 | ||
libtool* | ||
Makefile | ||
config.h* | ||
configure | ||
build-aux/ | ||
aclocal.m4 | ||
config.log | ||
Makefile.in | ||
config.status | ||
|
||
# | ||
# Generated binaries | ||
# | ||
grc-sign | ||
grc-verify | ||
grc-keygen | ||
grenache-get | ||
grenache-put | ||
grenache-keygen | ||
|
||
# | ||
# Distribution | ||
# | ||
*.tar.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "ed25519"] | ||
path = ed25519 | ||
url = https://github.com/orlp/ed25519.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
The ChangeLog is auto-generated when releasing. | ||
If you are seeing this, use 'git log' for a detailed list of changes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
############################################################################ | ||
# This file is part of Grenache Command Line Interface. # | ||
# # | ||
# Copyright (C) 2017 Davide Scola <[email protected]> # | ||
# # | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may # | ||
# not use this file except in compliance with the License. You may obtain # | ||
# a copy of the License at # | ||
# # | ||
# http://www.apache.org/licenses/LICENSE-2.0 # | ||
# # | ||
# Unless required by applicable law or agreed to in writing, software # | ||
# distributed under the License is distributed on an "AS IS" BASIS, # | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # | ||
# implied. See the License for the specific language governing permissions # | ||
# and limitations under the License. # | ||
############################################################################ | ||
|
||
ACLOCAL_AMFLAGS = -I m4 | ||
|
||
GRC_SUBDIRS = . src tests | ||
|
||
SUBDIRS = $(GRC_SUBDIRS) | ||
DIST_SUBDIRS = $(GRC_SUBDIRS) include m4 | ||
|
||
@GENERATE_CHANGELOG_RULES@ | ||
|
||
EXTRA_DIST = \ | ||
LICENSE \ | ||
README.md \ | ||
autogen.sh \ | ||
shtool | ||
|
||
DISTCLEANFILES = \ | ||
config.h.in~ | ||
|
||
MAINTAINERCLEANFILES = \ | ||
$(DISTCLEANFILES) \ | ||
README | ||
|
||
dist-hook: dist-ChangeLog | ||
cp -fpR $(top_srcdir)/ed25519 $(distdir) | ||
$(RM) -rf $(distdir)/ed25519/.git | ||
|
||
maintainer-clean-local: maintainer-clean-local-check | ||
|
||
maintainer-clean-local-check: | ||
-$(RM) $(distdir).tar.xz | ||
|
||
.PHONY: maintainer-clean-local-check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,124 @@ | ||
# grenache-cli | ||
The Grenache Command Line Interface. | ||
# Grenache CLI | ||
|
||
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) | ||
|
||
* [Introduction](#introduction) | ||
* [Prerequisites](#prerequisites) | ||
* [Install](#install) | ||
* [Initialize](#initialize) | ||
* [Store items to the DHT](#store-items-to-the-dht) | ||
* [Immutable items](#immutable-items) | ||
* [Mutable items](#mutable-items) | ||
* [Retreive items from the DHT](#retreive-items-from-the-dht) | ||
* [Lookup peers](#lookup-peers) | ||
* [Announce services](#announce-services) | ||
* [Maintainers](#maintainers) | ||
|
||
|
||
## Introduction | ||
|
||
The **Grenache** **C**ommand **L**ine **I**nterface is a set of tools to use the [grenache-grape](https://github.com/bitfinexcom/grenache-grape) suite directly from your command line. Using this set of tools you can create fancy scripts that communicate directly with the DHT. | ||
|
||
|
||
## Prerequisites | ||
|
||
Be sure that your version of [grenache-grape](https://github.com/bitfinexcom/grenache-grape) supports the mutable items (see pull request [#35](https://github.com/bitfinexcom/grenache-grape/pull/35)). | ||
|
||
|
||
## Install | ||
|
||
Briefly, the shell command | ||
|
||
```bash | ||
./configure && make && make install | ||
``` | ||
|
||
should configure, build and install this package. | ||
|
||
|
||
## Initialize | ||
|
||
Before start using this set of tools you need to initialize the `granache-cli` environment; use: | ||
|
||
```bash | ||
grenache-keygen | ||
``` | ||
|
||
This will also generate your key pair that will be used when _mutable_ items are stored to the DHT. This is a one time only task but you can regenerate your key pair at any time if you want to. | ||
|
||
|
||
## Store items to the DHT | ||
|
||
The `grenache-put` command writes an arbitrary payload to the DHT (see [BEP 44](http://bittorrent.org/beps/bep_0044.html) for more information). There are two types of items you can store to the DHT; the _immutable_ items and the _mutable_ ones. In any case, you will get the key under which the item has been stored. | ||
|
||
### Immutable items | ||
|
||
_Immutable_ items cannot be modified, thus there is no need to authenticate the origin of them. This makes _immutable_ items simple. To write an _immutable_ item to the DHT simply run something like this: | ||
|
||
```bash | ||
grenache-put "$(uname -n)" | ||
``` | ||
|
||
### Mutable items | ||
|
||
_Mutable_ items can be updated, without changing their DHT keys. In order to create your key pair, see `grenache-keygen`. To write a _mutable_ item to the DHT simply run something like this: | ||
|
||
```bash | ||
grenache-put --mutable "$(uptime -p)" | ||
``` | ||
|
||
In order to support a single key being used to store separate items in the DHT, an optional salt can be specified in the put request of _mutable_ items: | ||
|
||
```bash | ||
grenache-put --mutable --salt 'sys:mem:available' "$(awk '/^MemAvailable:/ { print $2 "Ki" }' < /proc/meminfo)" | ||
``` | ||
|
||
Note that `grenache-put` is agnostic and it will treat your payload as a **single string**. Other useful options are `-n` or `--number` that will let you set the _sequence number_ to use in your request and `-c` or `--cas` that let you use the _compare and swap_ feature. See | ||
|
||
```bash | ||
grenache-put --help | ||
``` | ||
|
||
to retrieve the complete options list. | ||
|
||
|
||
## Retreive items from the DHT | ||
|
||
The `grenache-get` command reads a data record from the DHT (see [BEP 44](http://bittorrent.org/beps/bep_0044.html) for more information). There is no differences in retreiving a _mutable_ or an _immutable_ item; on both cases the key returned by the *PUT* request must be provided. In any case, `grenache-get` validates the payload it receive; this will ensure that the _key_ provided really match the payload and, in case of a _mutable_ item, that the signature is correct. This will protect you from evil nodes on the network. To read an item from the DHT simply run something like this: | ||
|
||
```bash | ||
grenache-get '81c2a8157780989af9a16661324fafbd7803877d' | ||
``` | ||
|
||
For example, you can format the previously stored available memory amount using something like this: | ||
|
||
```bash | ||
numfmt --from=auto --to=iec-i < <( | ||
grenache-get '81c2a8157780989af9a16661324fafbd7803877d' | ||
) | ||
``` | ||
|
||
You can also retrieve the raw packet received from the network using the `-r` switch or its long form `--raw`. See | ||
|
||
```bash | ||
grenache-get --help | ||
``` | ||
|
||
to retrieve the complete options list. | ||
|
||
|
||
## Lookup peers | ||
|
||
Coming soon... | ||
|
||
|
||
## Announce services | ||
|
||
Coming soon... | ||
|
||
|
||
## Maintainers | ||
|
||
Current maintainers: | ||
|
||
* Davide Scola - [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
############################################################################ | ||
# This file is part of Grenache Command Line Interface. # | ||
# # | ||
# Copyright (C) 2017 Davide Scola <[email protected]> # | ||
# # | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may # | ||
# not use this file except in compliance with the License. You may obtain # | ||
# a copy of the License at # | ||
# # | ||
# http://www.apache.org/licenses/LICENSE-2.0 # | ||
# # | ||
# Unless required by applicable law or agreed to in writing, software # | ||
# distributed under the License is distributed on an "AS IS" BASIS, # | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # | ||
# implied. See the License for the specific language governing permissions # | ||
# and limitations under the License. # | ||
############################################################################ | ||
|
||
case "${1}" in | ||
'--reverse') | ||
[[ -x configure ]] && ./configure --enable-maintainer-mode | ||
[[ -f Makefile ]] && make maintainer-clean | ||
rm -rf build-aux/ | ||
rm -f {aclocal.m4,config.h.in,configure,shtool} | ||
find . -type f -iregex '.*Makefile\.in$' -print0 | xargs -r0 rm -f | ||
;; | ||
* ) | ||
autoreconf --force --install --include 'm4' | ||
[[ -x shtool ]] || shtoolize -q 'echo' | ||
[[ -d autom4te.cache ]] && rm -rf autom4te.cache | ||
;; | ||
esac | ||
|
Oops, something went wrong.