ipnet

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2019 License: MIT Imports: 2 Imported by: 45

README

go-libp2p-interface-pnet

An interface providing abstraction of swarm protection for libp2p.

Table of Contents

Usage

Core of this interface in Protector that is used to protect the swarm. It makes decisions about which streams are allowed to pass.

This interface is accepted in multiple places in libp2p but most importantly in go-libp2p-swarm NewSwarmWithProtector and NewNetworkWithProtector.

Implementations:

Contribute

PRs are welcome!

Small note: If editing the Readme, please conform to the standard-readme specification.

License

MIT © Jeromy Johnson

Documentation

Index

Constants

View Source
const EnvKey = "LIBP2P_FORCE_PNET"

EnvKey defines environment variable name for forcing usage of PNet in libp2p When environment variable of this name is set to "1" the ForcePrivateNetwork variable will be set to true.

Variables

View Source
var ErrNotInPrivateNetwork = NewError("private network was not configured but" +
	" is enforced by the environment")

ErrNotInPrivateNetwork is an error that should be returned by libp2p when it tries to dial with ForcePrivateNetwork set and no PNet Protector

View Source
var ForcePrivateNetwork = false

ForcePrivateNetwork is boolean variable that forces usage of PNet in libp2p Setting this variable to true or setting LIBP2P_FORCE_PNET environment variable to true will make libp2p to require private network protector. If no network protector is provided and this variable is set to true libp2p will refuse to connect.

Functions

func IsPNetError

func IsPNetError(err error) bool

IsPNetError checks if given error is PNet Error

func NewError

func NewError(err string) error

NewError creates new PNetError

Types

type PNetError

type PNetError interface {
	IsPNetError() bool
}

PNetError is error type for ease of detecting PNet errors

type Protector

type Protector interface {
	// Wraps passed connection to protect it
	Protect(net.Conn) (net.Conn, error)

	// Returns key fingerprint that is safe to expose
	Fingerprint() []byte
}

Protector interface is a way for private network implementation to be transparent in libp2p. It is created by implementation and use by libp2p-conn to secure connections so they can be only established with selected number of peers.

Jump to

Keyboard shortcuts

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