trust

package
v0.27.1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2019 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFileSource is an error class for file source errors
	ErrFileSource = errs.Class("file source")
)
View Source
var (
	// ErrHTTPSource is an error class for HTTP source errors
	ErrHTTPSource = errs.Class("HTTP source")
)
View Source
var (
	// ErrSatelliteURL is an error class for satellite URL related errors
	ErrSatelliteURL = errs.Class("invalid satellite URL")
)
View Source
var (
	// ErrStaticSource is an error class for static source errors
	ErrStaticSource = errs.Class("static source")
)
View Source
var Error = errs.Class("trust")

Error is the default error class

Functions

func URLMatchesHTTPSourceHost added in v0.27.0

func URLMatchesHTTPSourceHost(urlHost, sourceHost string) bool

URLMatchesHTTPSourceHost takes the Satellite URL host and the host of the HTTPSource URL and determines if the SatelliteURL matches or is in the same domain as the HTTPSource URL.

Types

type Entry added in v0.27.0

type Entry struct {
	// SatelliteURL is the URL of the satellite
	SatelliteURL SatelliteURL

	// Authoritative indicates whether this entry came from an authoritative
	// source. This impacts how URLS are aggregated.
	Authoritative bool `json:"authoritative"`
}

Entry represents a trust entry

type FileSource added in v0.27.0

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

FileSource represents a trust source contained in a file on disk

func NewFileSource added in v0.27.0

func NewFileSource(path string) *FileSource

NewFileSource creates a new FileSource that loads a trust list from the given path.

func (*FileSource) FetchEntries added in v0.27.0

func (source *FileSource) FetchEntries(ctx context.Context) (_ []Entry, err error)

FetchEntries implements the Source interface and returns entries from a the file source on disk. The entries returned are authoritative.

func (*FileSource) Static added in v0.27.0

func (source *FileSource) Static() bool

Static implements the Source interface. It returns true.

func (*FileSource) String added in v0.27.0

func (source *FileSource) String() string

String implements the Source interface and returns the FileSource URL

type HTTPSource added in v0.27.0

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

HTTPSource represents a trust source at a http:// or https:// URL

func NewHTTPSource added in v0.27.0

func NewHTTPSource(httpURL string) (*HTTPSource, error)

NewHTTPSource constructs a new HTTPSource from a URL. The URL must be an http:// or https:// URL. The fragment cannot be set.

func (*HTTPSource) FetchEntries added in v0.27.0

func (source *HTTPSource) FetchEntries(ctx context.Context) (_ []Entry, err error)

FetchEntries implements the Source interface and returns entries parsed from the list retrieved over HTTP(S). The entries returned are only authoritative if the entry URL has a host that matches or is a subdomain of the source URL.

func (*HTTPSource) Static added in v0.27.0

func (source *HTTPSource) Static() bool

Static implements the Source interface. It returns false for this source.

func (*HTTPSource) String added in v0.27.0

func (source *HTTPSource) String() string

String implements the Source interface and returns the URL

type Pool

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

Pool implements different peer verifications.

architecture: Service

func NewPool

func NewPool(dialer rpc.Dialer, trustedSatellites storj.NodeURLs) (*Pool, error)

NewPool creates a new trust pool of the specified list of trusted satellites.

func (*Pool) FetchPeerIdentity added in v0.15.3

func (pool *Pool) FetchPeerIdentity(ctx context.Context, url storj.NodeURL) (_ *identity.PeerIdentity, err error)

FetchPeerIdentity dials the url and fetches the identity.

func (*Pool) GetAddress added in v0.15.0

func (pool *Pool) GetAddress(ctx context.Context, id storj.NodeID) (_ string, err error)

GetAddress returns the address of a satellite in the trusted list

func (*Pool) GetSatellites added in v0.14.0

func (pool *Pool) GetSatellites(ctx context.Context) (satellites []storj.NodeID)

GetSatellites returns a slice containing all trusted satellites

func (*Pool) GetSignee

func (pool *Pool) GetSignee(ctx context.Context, id storj.NodeID) (_ signing.Signee, err error)

GetSignee gets the corresponding signee for verifying signatures. It ignores passed in ctx cancellation to avoid miscaching between concurrent requests.

func (*Pool) VerifySatelliteID

func (pool *Pool) VerifySatelliteID(ctx context.Context, id storj.NodeID) (err error)

VerifySatelliteID checks whether id corresponds to a trusted satellite.

type SatelliteURL added in v0.27.0

type SatelliteURL struct {
	ID   storj.NodeID `json:"id"`
	Host string       `json:"host"`
	Port int          `json:"port"`
}

SatelliteURL represents a Satellite URL

func LoadSatelliteURLList added in v0.27.0

func LoadSatelliteURLList(ctx context.Context, path string) (_ []SatelliteURL, err error)

LoadSatelliteURLList loads a list of Satellite URLs from a path on disk

func ParseSatelliteURL added in v0.27.0

func ParseSatelliteURL(s string) (SatelliteURL, error)

ParseSatelliteURL parses a Satellite URL. For the purposes of the trust list, the Satellite URL MUST contain both an ID and port designation.

func ParseSatelliteURLList added in v0.27.0

func ParseSatelliteURLList(ctx context.Context, r io.Reader) (urls []SatelliteURL, err error)

ParseSatelliteURLList parses a newline separated list of Satellite URLs. Empty lines or lines starting with '#' (comments) are ignored.

func (*SatelliteURL) Address added in v0.27.0

func (u *SatelliteURL) Address() string

Address returns the address (i.e. host:port) of the Satellite

func (*SatelliteURL) NodeURL added in v0.27.0

func (u *SatelliteURL) NodeURL() storj.NodeURL

NodeURL returns a full Node URL to the Satellite

func (*SatelliteURL) String added in v0.27.0

func (u *SatelliteURL) String() string

String returns a string representation of the Satellite URL

type Source added in v0.27.0

type Source interface {
	// String is the string representation of the source. It is used as a key
	// into the cache.
	String() string

	// Static returns true if the source is static. Static sources are not cached.
	Static() bool

	// FetchEntries returns the list of trust entries from the source.
	FetchEntries(context.Context) ([]Entry, error)
}

Source is a trust source for trusted Satellites

func NewSource added in v0.27.0

func NewSource(config string) (Source, error)

NewSource takes a configuration string returns a Source for that string.

type StaticSource added in v0.27.0

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

StaticSource is a trust source that returns an explicitly trusted URL

func NewStaticSource added in v0.27.0

func NewStaticSource(satelliteURL string) (*StaticSource, error)

NewStaticSource takes an explicitly trusted URL and returns a new StaticSource.

func (*StaticSource) FetchEntries added in v0.27.0

func (source *StaticSource) FetchEntries(ctx context.Context) ([]Entry, error)

FetchEntries returns a trust entry for the explicitly trusted Satellite URL. The entry is authoritative.

func (*StaticSource) Static added in v0.27.0

func (source *StaticSource) Static() bool

Static implements the Source interface. It returns true.

func (*StaticSource) String added in v0.27.0

func (source *StaticSource) String() string

String implements the Source interface and returns the static trusted URL

Jump to

Keyboard shortcuts

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