rtns

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

README

RTNS

GoDoc codecov Build Status GitHub release

RTNS (RTrade Name Service) is a stand-alone IPNS record management service, designed to facilitate secure publishing of IPNS records, leveraging an encrypted keystore known as kaas. Internally it facilitates scheduled republishing of all published records.

It is essentially a modified and condensed version of go-ipfs/namesys with minor optimizations.

Multi-Language

jaywcjlove/sb

Usage

To import this library:

import "github.com/RTradeLtd/rtns"

You'll need to create a libp2p host, and a dht providing them as constructor arguments, and a valid keystore. This package contains a helper tool to wrab a KaaS client as a valid keystore interface type.

Development

Using $GOPATH

Ref: https://splice.com/blog/contributing-open-source-git-repositories-go/

  1. Fork the repository
  2. Clone the repository by running git clone git@github.com:RTradeLtd/rtns.git $GOPATH/src/github.com/RTradeLtd/rtns
  3. Run cd $GOPATH/src/github.com/RTradeLtd/rtns
  4. Set up remotes.
git remote rename origin upstream
git remote add origin git@github.com:<your-github-username>/rtns.git
  1. Add export GO111MODULE=on to .bashrc or .bash_profile (if you're on a Mac) or .zshrc (if you're using zsh). Make sure to reload the rc file of your choice by running source <rc-file>
  2. Run go mod download to download the dependencies
  3. To run the tests, use go test ./...
Outside $GOPATH
  1. Fork and clone the repository to any location on your machine
  2. Run cd rtns
  3. Set up a remote for the upstream repository
git remote add upstream git@github.com:RTradeLtd/rtns.git
  1. Run go mod download to download the dependencies
  2. To run the tests, use go test ./...

Limitations

  • When used within Temporal, any keys derived from the fail-over KaaS host are not eligible for automated republishing.

Future Improvements

  • DNSLink support
  • Act as a gateway implementation to TNS (Temporal Name Server)
  • Enable HA Kaas Backend
    • This will involve repeatedly iterating through all available KaaS hosts attempting to retrieve the private key, until we either find the key or we iterate through all available KaaS hosts without finding one, triggering an error
  • Enable automatic topic subscription for IPNS pubsub
    • This would involve using rtfs to call an IPFS node, establishing a subscription for a given topic.

Documentation

Overview

Package rtns provides a secure, stand-alone IPNS publishing service that leverages the KaaS encrypted keystore service

Index

Constants

View Source
const DefaultRecordLifetime = time.Hour * 24

DefaultRecordLifetime is the default lifetime for IPNS records

Variables

View Source
var DefaultRebroadcastInterval = time.Hour * 4

DefaultRebroadcastInterval is the default interval at which we rebroadcast IPNS records

View Source
var FailureRetryInterval = time.Minute * 5

FailureRetryInterval is the interval at which we retry IPNS records broadcasts (when they fail)

Functions

This section is empty.

Types

type RKeystore

type RKeystore struct {
	// contains filtered or unexported fields
}

RKeystore satisfies the keystore.Keystore interface, providing access to a kaas backend for secure key management

func NewRKeystore

func NewRKeystore(ctx context.Context, kb *kaas.Client) *RKeystore

NewRKeystore implements a keystore.Keystore compatible version of the kaas client

func (*RKeystore) Delete

func (rk *RKeystore) Delete(string) error

Delete removes a key from the Keystore

func (*RKeystore) Get

func (rk *RKeystore) Get(name string) (ci.PrivKey, error)

Get retrieves a key from the Keystore if it exists, and returns ErrNoSuchKey otherwise.

func (*RKeystore) Has

func (rk *RKeystore) Has(name string) (bool, error)

Has returns whether or not a key exist in the Keystore

func (*RKeystore) List

func (rk *RKeystore) List() ([]string, error)

List returns a list of key identifier

func (*RKeystore) Put

func (rk *RKeystore) Put(name string, pk ci.PrivKey) error

Put stores a key in the Keystore, if a key with the same name already exists, returns ErrKeyExists

type RTNS

type RTNS struct {
	// contains filtered or unexported fields
}

RTNS manages all the needed components to interact with public and private IPNS networks.

func NewRTNS

func NewRTNS(ctx context.Context, rvs routing.ValueStore, ds datastore.Datastore, keys keystore.Keystore, size int) *RTNS

NewRTNS instantiates our RTNS service, and starts the republisher

func (*RTNS) GetKey added in v0.0.16

func (r *RTNS) GetKey(name string) (ci.PrivKey, error)

GetKey returns a key from the underlying krab keystore

func (*RTNS) HasKey added in v0.0.16

func (r *RTNS) HasKey(name string) (bool, error)

HasKey returns whether or not the key is in our keystore

func (*RTNS) Publish

func (r *RTNS) Publish(ctx context.Context, pk ci.PrivKey, cache bool, keyID, content string) error

Publish enables publishing of an IPNS record with a default lifetime of 24 hours

func (*RTNS) PublishWithEOL

func (r *RTNS) PublishWithEOL(ctx context.Context, pk ci.PrivKey, eol time.Time, cache bool, keyID, content string) error

PublishWithEOL allows specifying a lifetime for this record overriding the default lifetime of 24 hours

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL