config

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Path Manipulation Errors
	ErrDuplicateFilePathOption    = errors.New("Duplicate file path option")
	ErrPrefixSuffixSetWithReplace = errors.New("Prefix or Suffix set with Replace.")
	ErrSeparatorLength            = errors.New("Separator length must be 1.")
	ErrNoFileNameSet              = errors.New("File name was not set by options.")

	// Device ID Errors
	ErrEmptyDeviceID = errors.New("Device ID cannot be empty")
	ErrMissingEnvVar = errors.New("Cannot set EnvVariable with empty value")

	// Directory errors
	ErrDirectoryInvalid = errors.New("Directory Type is invalid")
	ErrDirectoryUnset   = errors.New("Directory path has not been set")
	ErrDirectoryJoin    = errors.New("Failed to join directory path")

	// Node Errors
	ErrEmptyQueue       = errors.New("No items in Transfer Queue.")
	ErrInvalidQuery     = errors.New("No SName or PeerID provided.")
	ErrMissingParam     = errors.New("Paramater is missing.")
	ErrProtocolsNotSet  = errors.New("Node Protocol has not been initialized.")
	ErrRoutingNotSet    = errors.New("DHT and Host have not been set by Routing Function")
	ErrListenerRequired = errors.New("Listener was not Provided")
	ErrMDNSInvalidConn  = errors.New("Invalid Connection, cannot begin MDNS Service")

	// Default P2P Properties
	BootstrapAddrStrs = []string{
		"/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
		"/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",
		"/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
		"/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
		"/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
		"/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
	}
	AddrStoreTTL = time.Minute * 5
)

Functions

func Arch

func Arch() string

Arch returns the current architecture.

func Exists

func Exists(fileName string) bool

Exists checks if a file exists.

func HostName

func HostName() (string, error)

HostName returns the hostname of the current machine.

func ID

func ID() (string, error)

ID returns the device ID.

func Init

func Init(options ...Option) error

Init initializes the device package.

func IsAndroid

func IsAndroid() bool

IsAndroid returns true if the current platform is android.

func IsDesktop

func IsDesktop() bool

IsDesktop returns true if the current platform is ANY desktop platform.

func IsFile

func IsFile(fileName string) bool

IsFile returns true if the given path is a file

func IsIOS

func IsIOS() bool

IsIOS returns true if the current platform is iOS.

func IsLinux

func IsLinux() bool

IsLinux returns true if the current platform is linux.

func IsMacOS

func IsMacOS() bool

IsMacOS returns true if the current platform is macOS.

func IsMobile

func IsMobile() bool

IsMobile returns true if the current platform is ANY mobile platform.

func IsWindows

func IsWindows() bool

IsWindows returns true if the current platform is windows.

func LoadAcceptableCredentials

func LoadAcceptableCredentials() (map[string][]string, error)

func LoadConditions

func LoadConditions() (map[int]string, map[int]int, map[int]string, error)

func LoadCredentialStructure

func LoadCredentialStructure() (map[string]interface{}, error)

func LoadKeyDirFromConfig

func LoadKeyDirFromConfig() string

func LoadPseudonymsysCAPubKey

func LoadPseudonymsysCAPubKey() *pseudsys.PubKey

func LoadPseudonymsysCASecret

func LoadPseudonymsysCASecret() *big.Int

func LoadPseudonymsysOrgPubKeys

func LoadPseudonymsysOrgPubKeys(orgName string) *pseudsys.PubKey

func LoadPseudonymsysOrgPubKeysEC

func LoadPseudonymsysOrgPubKeysEC(orgName string) *ecpseudsys.PubKey

func LoadPseudonymsysOrgSecrets

func LoadPseudonymsysOrgSecrets(orgName, dlogType string) *pseudsys.SecKey

func LoadQRRSA

func LoadQRRSA() *qr.RSA

func LoadRegistrationDBAddress

func LoadRegistrationDBAddress() string

func LoadSchnorrGroup

func LoadSchnorrGroup() *schnorr.Group

func LoadServerEndpoint

func LoadServerEndpoint() string

LoadServerEndpoint returns the endpoint of the emmy server where clients will be contacting it.

func LoadServerPort

func LoadServerPort() int

LoadServerPort returns the port where emmy server will be listening.

func LoadServiceInfo

func LoadServiceInfo() (string, string, string)

func LoadSessionKeyMinByteLen

func LoadSessionKeyMinByteLen() int

func LoadTestKeyDirFromConfig

func LoadTestKeyDirFromConfig() string

func LoadTestdataDir

func LoadTestdataDir() string

func LoadTimeout

func LoadTimeout() int

LoadTimeout returns the specified number of seconds that clients wait before giving up on connection to emmy server

func NewDefaultLocation

func NewDefaultLocation() *t.Location

NewDefaultLocation returns the Sonr HQ as default location

func NewDefaultProfile

func NewDefaultProfile(options ...DefaultProfileOption) *t.Profile

NewDefaultProfile creates a new default Profile

func Platform

func Platform() string

Platform returns formatted GOOS for Text format. Returns: ["MacOS", "Windows", "Linux", "Android", "iOS"]

func Stat

func Stat() (map[string]string, error)

Stat returns the device stat.

Types

type CallbackImpl

type CallbackImpl interface {
	// OnRefresh is called when the LobbyProtocol is refreshed and pushes a RefreshEvent
	OnRefresh(event *mv1.OnLobbyRefreshResponse)

	// OnMailbox is called when the MailboxProtocol receives a MailboxEvent
	OnMailbox(event *mv1.OnMailboxMessageResponse)

	// OnInvite is called when the TransferProtocol receives InviteEvent
	OnInvite(event *mv1.OnTransmitInviteResponse)

	// OnDecision is called when the TransferProtocol receives a DecisionEvent
	OnDecision(event *mv1.OnTransmitDecisionResponse, invite *mv1.OnTransmitInviteResponse)

	// OnProgress is called when the TransferProtocol sends or receives a ProgressEvent
	OnProgress(event *mv1.OnTransmitProgressResponse)

	// OnTransfer is called when the TransferProtocol completes a transfer and pushes a CompleteEvent
	OnComplete(event *mv1.OnTransmitCompleteResponse)
}

CallbackImpl is the implementation of Callback interface

type Configuration

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

func DefaultConfiguration

func DefaultConfiguration() *Configuration

type DefaultProfileOption

type DefaultProfileOption func(profileOpts)

DefaultProfileOption is a type for Profile Options

func WithCheckerProfile

func WithCheckerProfile(profile *t.Profile) DefaultProfileOption

WithCheckerProfile sets the checker profile

type FilePathOptFunc

type FilePathOptFunc func(path string) FilePathOption

FilePathOptFunc is a function that returns a FilePathOption.

var WithPrefix FilePathOptFunc = func(path string) FilePathOption {
	return &filePathOpt{
		filePathOptType: filePathOptionTypePrefix,
		value:           path,
	}
}

WithPrefix sets the prefix for the file path.

var WithReplace FilePathOptFunc = func(path string) FilePathOption {
	return &filePathOpt{
		filePathOptType: filePathOptionTypeReplace,
		value:           path,
	}
}

WithReplace sets the replace string for the file path.

var WithSeparator FilePathOptFunc = func(path string) FilePathOption {
	return &filePathOpt{
		filePathOptType: filePathOptionTypeSeparator,
		value:           path,
	}
}

WithSeparator sets the separator for the file path.

var WithSuffix FilePathOptFunc = func(path string) FilePathOption {
	return &filePathOpt{
		filePathOptType: filePathOptionTypeSuffix,
		value:           path,
	}
}

WithSuffix sets the suffix for the file path.

type FilePathOption

type FilePathOption interface {
	Apply() *filePathOptions
}

FilePathOption is a function option for FilePath.

type Folder

type Folder string
var (
	// Determined/Provided Paths
	Home      Folder // ApplicationDocumentsDir on Mobile, HOME_DIR on Desktop
	Support   Folder // AppSupport Directory
	Temporary Folder // AppCache Directory

	// Calculated Paths
	Database   Folder // Device DB Folder
	Downloads  Folder // Temporary Directory on Mobile for Export, Downloads on Desktop
	Wallet     Folder // Encrypted Storage Directory
	ThirdParty Folder // Sub-Directory of Support, used for Textile

)

func (Folder) Create

func (f Folder) Create(fileName string) (*os.File, error)

Create creates a file.

func (Folder) CreateFolder

func (f Folder) CreateFolder(dirName string) (Folder, error)

CreateFolder creates a folder.

func (Folder) Delete

func (f Folder) Delete(fileName string) error

Delete removes a file or a folder.

func (Folder) Exists

func (f Folder) Exists(fileName string) bool

Exists checks if a file exists.

func (Folder) GenPath

func (f Folder) GenPath(path string, opts ...FilePathOption) (string, error)

GenPath generates a path from a folder and a file name.

func (Folder) JoinPath

func (f Folder) JoinPath(ps ...string) string

JoinPath joins a folder and a file name.

func (Folder) MkdirAll

func (f Folder) MkdirAll() error

MkdirAll creates a directory and all its parents.

func (Folder) Path

func (f Folder) Path() string

Path returns the path of the folder.

func (Folder) ReadFile

func (f Folder) ReadFile(fileName string) ([]byte, error)

ReadFile reads a file.

func (Folder) WriteFile

func (f Folder) WriteFile(fileName string, data []byte) error

WriteFile writes a file.

type Option

type Option func(o *options)

func SetDeviceID

func SetDeviceID(id string) Option

SetDeviceID sets the device ID

func WithHomePath

func WithHomePath(p string) Option

WithHomePath sets the Home Directory

func WithSupportPath

func WithSupportPath(p string) Option

WithSupportPath sets the Support Directory

func WithTempPath

func WithTempPath(p string) Option

WithTempPath sets the Temporary Directory

type Role

type Role int

Role is the type of the node (Client, Highway)

const (
	// StubMode_LIB is the Node utilized by Mobile and Web Clients
	Role_UNSPECIFIED Role = iota

	// StubMode_CLI is the Node utilized by CLI Clients
	Role_TEST

	// Role_MOTOR is for a Motor Node
	Role_MOTOR

	// Role_HIGHWAY is for a Highway Node
	Role_HIGHWAY
)

func (Role) IsHighway

func (m Role) IsHighway() bool

Highway returns true if the node has a highway stub.

func (Role) IsMotor

func (m Role) IsMotor() bool

Motor returns true if the node has a client.

func (Role) Prefix

func (m Role) Prefix() string

Prefix returns golog prefix for the node.

type SonrConfig

type SonrConfig struct {
	HighwayAddress       string   `json:"highway_address"`
	HighwayPort          int      `json:"highway_port"`
	HighwayNetwork       string   `json:"highway_network"`
	HighwayDID           string   `json:"highway_did"`
	IPFSPort             int      `json:"ipfs_port"`
	IPFSPath             string   `json:"ipfs_path"`
	LibP2PLowWater       int      `json:"libp2p_low_water"`
	LibP2PHighWater      int      `json:"libp2p_high_water"`
	LibP2PRendevouz      string   `json:"libp2p_rendevouz"`
	LibP2PBootstrapPeers []string `json:"libp2p_bootstrap_peers"`
	HomeDir              string   `json:"home_dir"`
	CacheDir             string   `json:"cache_dir"`
	ConfigDir            string   `json:"config_dir"`
	WalletDir            string   `json:"wallet_dir"`
	DeviceId             string   `json:"device_id"`
	PublicIP             string   `json:"public_ip"`
	PrivateIP            string   `json:"private_ip"`
	AccountName          string   `json:"account_name"`
}

func (*SonrConfig) CacheFolder

func (sc *SonrConfig) CacheFolder() Folder

Return the cache dir path as a Folder.

func (*SonrConfig) ConfigFolder

func (sc *SonrConfig) ConfigFolder() Folder

Return the config dir path as a Folder.

func (*SonrConfig) HomeFolder

func (sc *SonrConfig) HomeFolder() Folder

Return the home dir path as a Folder.

func (*SonrConfig) Save

func (sc *SonrConfig) Save() (*SonrConfig, error)

func (*SonrConfig) WalletFolder

func (sc *SonrConfig) WalletFolder() Folder

Create or return the wallet directory as a Folder.

Jump to

Keyboard shortcuts

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