models

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2019 License: MIT Imports: 11 Imported by: 27

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Free is what every signed up user is automatically registered as
	// Restrictions of free:
	//			* No on-demand data encryption
	//			* 3GB/month max
	//			* IPNS limit of 5, with no automatic republishes
	//			* 5 keys
	Free DataUsageTier = "free"

	// Partner is for partners of RTrade
	// partners have 100GB/month free
	//			* on-demand data encryption
	//			* 0.16GB/month after 100GB limit
	Partner DataUsageTier = "partner"

	// Light is the first non-free, and non-partner tier
	// tier is from 3GB -> 100GB
	// after reaching 100GB they are upgraded to Plus
	//			* on-demand data encryption
	//			* 0.22
	Light DataUsageTier = "light"

	// Plus is the other non-free, non-partner, non-light tier
	// tier is from 100GB -> 1TB to our max monthly usage of 1TB
	// 			* on-demand data encryption
	//			* $0.165
	Plus DataUsageTier = "plus"

	// FreeUploadLimit is the maximum data usage for free accounts
	// Currrently set to 3GB
	FreeUploadLimit = datasize.GB.GBytes() * 3

	// NonFreeUploadLimit is the maximum data usage for non-free accounts
	// Currently set to 1TB
	NonFreeUploadLimit = datasize.TB.GBytes()

	// PlusTierMinimumUpload is the current data usage
	// needed to upgrade from Light -> Plus
	// currently set to 100GB
	PlusTierMinimumUpload = datasize.GB.GBytes() * 100
)
View Source
var AdminAddress = "0xC6C35f43fDD71f86a2D8D4e3cA1Ce32564c38bd9"

AdminAddress is the eth address of the admin account

Functions

This section is empty.

Types

type APIDetails added in v1.3.0

type APIDetails struct {
	AllowedOrigin string
}

APIDetails provides data about IPFS API connection

type DataUsageTier added in v1.3.0

type DataUsageTier string

DataUsageTier is a type of usage tier which governs the price per gb ratio

func (DataUsageTier) PricePerGB added in v1.3.0

func (d DataUsageTier) PricePerGB() float64

PricePerGB returns the price per gb of a usage tier

func (DataUsageTier) String added in v1.3.0

func (d DataUsageTier) String() string

String returns the value of DataUsageTier as a string

type EncryptedUpload added in v1.0.6

type EncryptedUpload struct {
	gorm.Model
	UserName      string `gorm:"type:varchar(255)"`
	FileName      string `gorm:"type:varchar(255)"`
	FileNameUpper string `gorm:"type:varchar(255)"`
	FileNameLower string `gorm:"type:varchar(255)"`
	NetworkName   string `gorm:"type:varchar(255)"`
	IPFSHash      string `gorm:"type:varchar(255)"`
}

EncryptedUpload is an uploaded that has been encrypted by Temporal

type EncryptedUploadManager added in v1.0.6

type EncryptedUploadManager struct {
	DB *gorm.DB
}

EncryptedUploadManager is used to manipulate encrypted uplaods

func NewEncryptedUploadManager added in v1.0.6

func NewEncryptedUploadManager(db *gorm.DB) *EncryptedUploadManager

NewEncryptedUploadManager is used to generate our db helper

func (*EncryptedUploadManager) FindUploadsByUser added in v1.0.6

func (ecm *EncryptedUploadManager) FindUploadsByUser(username string) (*[]EncryptedUpload, error)

FindUploadsByUser is used to find all uploads for a given user

func (*EncryptedUploadManager) NewUpload added in v1.0.6

func (ecm *EncryptedUploadManager) NewUpload(username, filename, networname, ipfsHash string) (*EncryptedUpload, error)

NewUpload is used to store a new encrypted upload in the database

type HostedIPFSPrivateNetwork

type HostedIPFSPrivateNetwork struct {
	ID        uint `gorm:"primary_key"`
	CreatedAt time.Time
	UpdatedAt time.Time

	Name      string    `gorm:"unique;type:varchar(255)"` // Name of the network node
	Activated time.Time // Activated represents the most recent activation, 0-value if offline

	PeerKey string // Private key used to generate peerID for this network node

	// SwarmAddr is the address of swarm port. Slated for deprecation if HTTP path
	// support is added to the multiaddr spec and go-multiaddr
	SwarmAddr string `gorm:"type:varchar(255)"`
	// SwarmKey is the key used to connect to this peer
	SwarmKey string `gorm:"type:varchar(255)"`

	// Used to set Allowed-Origin headers on API requests
	APIAllowedOrigin string `gorm:"type:varchar(255)"`

	// Toggles whether gateway should be exposed through Nexus delegator
	GatewayPublic bool `gorm:"type:boolean"`

	// Peers to bootstrap node onto
	BootstrapPeerAddresses pq.StringArray `gorm:"type:text[]"`
	BootstrapPeerIDs       pq.StringArray `gorm:"type:text[];column:bootstrap_peer_ids"`

	// Resources for deployed node
	ResourcesCPUs     int
	ResourcesDiskGB   int
	ResourcesMemoryGB int

	// Users allowed to control this node. Includes API access.
	Users pq.StringArray `gorm:"type:text[]"` // these are the users to which this IPFS network connection applies to specified by eth address
}

HostedIPFSPrivateNetwork is a private network for which we are responsible of the infrastructure

type IPFSNetworkManager

type IPFSNetworkManager struct {
	DB *gorm.DB
}

IPFSNetworkManager is used to manipulate IPFS network models in the database

func NewHostedIPFSNetworkManager

func NewHostedIPFSNetworkManager(db *gorm.DB) *IPFSNetworkManager

NewHostedIPFSNetworkManager is used to initialize our database connection

func (*IPFSNetworkManager) CreateHostedPrivateNetwork

func (im *IPFSNetworkManager) CreateHostedPrivateNetwork(name, swarmKey string, peers []string, access NetworkAccessOptions) (*HostedIPFSPrivateNetwork, error)

CreateHostedPrivateNetwork is used to store a new hosted private network in the database

func (*IPFSNetworkManager) Delete added in v1.1.0

func (im *IPFSNetworkManager) Delete(name string) error

Delete is used to remove a network from the database

func (*IPFSNetworkManager) GetAPIDetails added in v1.3.0

func (im *IPFSNetworkManager) GetAPIDetails(network string) (*APIDetails, error)

GetAPIDetails is used to retrieve data about IPFS API connection

func (*IPFSNetworkManager) GetNetworkByName

func (im *IPFSNetworkManager) GetNetworkByName(name string) (*HostedIPFSPrivateNetwork, error)

GetNetworkByName is used to retrieve a network from the database based off of its name

func (*IPFSNetworkManager) GetSwarmDetails added in v1.3.0

func (im *IPFSNetworkManager) GetSwarmDetails(network string) (*SwarmDetails, error)

GetSwarmDetails is used to retrieve data about IPFS swarm connection

func (*IPFSNetworkManager) SaveNetwork added in v1.3.0

SaveNetwork saves the given HostedIPFSPrivateNetwork in the database

func (*IPFSNetworkManager) UpdateNetworkByName added in v1.0.5

func (im *IPFSNetworkManager) UpdateNetworkByName(name string, attrs map[string]interface{}) error

UpdateNetworkByName updates the given network with given attributes

type IPNS

type IPNS struct {
	gorm.Model
	Sequence int64 `gorm:"type:integer"`
	// the ipns hash, is the peer id of the peer used to sign the entry
	IPNSHash string `gorm:"type:varchar(255);unique"`
	// List of content hashes this IPNS entry has pointed to
	IPFSHashes      pq.StringArray `gorm:"type:text[]"`
	CurrentIPFSHash string         `gorm:"type:varchar(255)"`
	LifeTime        string         `gorm:"type:varchar(255)"`
	TTL             string         `gorm:"type:varchar(255)"`
	Key             string         `gorm:"type:varchar(255)"`
	NetworkName     string         `gorm:"type:varchar(255)"`
	UserName        string         `gorm:"type:varchar(255)"`
}

IPNS will hold all of the IPNS entries in our system

type IpnsManager

type IpnsManager struct {
	DB *gorm.DB
}

IpnsManager is used for manipulating IPNS records in our database

func NewIPNSManager

func NewIPNSManager(db *gorm.DB) *IpnsManager

NewIPNSManager is used to generate our model manager

func (*IpnsManager) CreateEntry

func (im *IpnsManager) CreateEntry(ipnsHash, ipfsHash, key, networkName, username string, lifetime, ttl time.Duration) (*IPNS, error)

CreateEntry is used to create a brand new IPNS entry in our database

func (*IpnsManager) FindByIPNSHash

func (im *IpnsManager) FindByIPNSHash(ipnsHash string) (*IPNS, error)

FindByIPNSHash is used to find an IPNS record from our database searching for the public key hash of the key that was used to pulish a record

func (*IpnsManager) FindByUserName added in v1.0.4

func (im *IpnsManager) FindByUserName(username string) (*[]IPNS, error)

FindByUserName is used to find all IPNS entries published by a given user

func (*IpnsManager) UpdateIPNSEntry

func (im *IpnsManager) UpdateIPNSEntry(ipnsHash, ipfsHash, networkName, username string, lifetime, ttl time.Duration) (*IPNS, error)

UpdateIPNSEntry is used to update an already existing IPNS entry, creating a no record matching the hash exists

type NetworkAccessOptions added in v1.3.0

type NetworkAccessOptions struct {
	Users            []string
	APIAllowedOrigin string
	PublicGateway    bool
}

NetworkAccessOptions configures access to a hosted private network

type PaymentManager

type PaymentManager struct {
	DB *gorm.DB
}

PaymentManager is used to interact with payment information in our database

func NewPaymentManager

func NewPaymentManager(db *gorm.DB) *PaymentManager

NewPaymentManager is used to generate our payment manager helper

func (*PaymentManager) ConfirmPayment added in v1.0.2

func (pm *PaymentManager) ConfirmPayment(txHash string) (*Payments, error)

ConfirmPayment is used to mark a payment as confirmed

func (*PaymentManager) FindPaymentByNumber added in v1.0.5

func (pm *PaymentManager) FindPaymentByNumber(username string, number int64) (*Payments, error)

FindPaymentByNumber is used to find a payment by its payment number

func (*PaymentManager) FindPaymentByTxHash added in v1.0.2

func (pm *PaymentManager) FindPaymentByTxHash(txHash string) (*Payments, error)

FindPaymentByTxHash is used to find a payment by its tx hash

func (*PaymentManager) GetLatestPaymentNumber added in v1.0.5

func (pm *PaymentManager) GetLatestPaymentNumber(username string) (int64, error)

GetLatestPaymentNumber is used to get the latest payment number for a user

func (*PaymentManager) NewPayment

func (pm *PaymentManager) NewPayment(number int64, depositAddress string, txHash string, usdValue, chargeAmount float64, blockchain string, paymentType string, username string) (*Payments, error)

NewPayment is used to create a payment in our database

func (*PaymentManager) UpdatePaymentTxHash added in v1.0.5

func (pm *PaymentManager) UpdatePaymentTxHash(username, txHash string, number int64) (*Payments, error)

UpdatePaymentTxHash UpdatePaymentTxHash is used to update the tx hash of a payment

type Payments added in v1.0.2

type Payments struct {
	gorm.Model
	Number         int64   `gorm:"type:integer"`
	DepositAddress string  `gorm:"type:varchar(255)"`
	TxHash         string  `gorm:"type:varchar(255);unique"`
	USDValue       float64 `gorm:"type:float"` // USDValue is also a "Credit" value, since 1 USD -> 1 Credit
	ChargeAmount   float64 `gorm:"type:float"`
	Blockchain     string  `gorm:"type:varchar(255)"`
	Type           string  `gorm:"type:varchar(255)"` // ETH, RTC, XMR, BTC, LTC
	UserName       string  `gorm:"type:varchar(255)"`
	Confirmed      bool    `gorm:"type:varchar(255)"`
}

Payments is our payment model

type Record added in v1.0.6

type Record struct {
	gorm.Model
	UserName       string      `gorm:"type:varchar(255)"`
	Name           string      `gorm:"type:varchar(255)"`
	RecordKeyName  string      `gorm:"type:varchar(255)"`
	LatestIPFSHash string      `gorm:"type:varchar(255)"`
	ZoneName       string      `gorm:"type:varchar(255)"`
	MetaData       interface{} `gorm:"type:text"` // we need to parse this to a "string json"
}

Record is an entry within a tns zone

type RecordManager added in v1.0.6

type RecordManager struct {
	DB *gorm.DB
}

RecordManager is used to manipulate records in our db

func NewRecordManager added in v1.0.6

func NewRecordManager(db *gorm.DB) *RecordManager

NewRecordManager is used to generate our record manager

func (*RecordManager) AddRecord added in v1.0.6

func (rm *RecordManager) AddRecord(username, recordName, recordKeyName, zoneName string, metadata map[string]interface{}) (*Record, error)

AddRecord is used to save a record to our database

func (*RecordManager) FindRecordByNameAndUser added in v1.0.6

func (rm *RecordManager) FindRecordByNameAndUser(username, name string) (*Record, error)

FindRecordByNameAndUser is used to search fro a record by name and user

func (*RecordManager) FindRecordsByZone added in v1.0.6

func (rm *RecordManager) FindRecordsByZone(username, zoneName string) (*[]Record, error)

FindRecordsByZone is used to find records by zone

func (*RecordManager) UpdateLatestIPFSHash added in v1.0.6

func (rm *RecordManager) UpdateLatestIPFSHash(username, recordName, ipfsHash string) (*Record, error)

UpdateLatestIPFSHash is used to update the latest IPFS hash that can be used to examine this record

type SwarmDetails added in v1.3.0

type SwarmDetails struct {
	Addr string
	Key  string
}

SwarmDetails provides data about IPFS swarm connection

type Upload

type Upload struct {
	gorm.Model
	Hash               string `gorm:"type:varchar(255);not null;"`
	Type               string `gorm:"type:varchar(255);not null;"` //  file, pin
	NetworkName        string `gorm:"type:varchar(255)"`
	HoldTimeInMonths   int64  `gorm:"type:integer;not null;"`
	UserName           string `gorm:"type:varchar(255);not null;"`
	GarbageCollectDate time.Time
	UserNames          pq.StringArray `gorm:"type:text[];not null;"`
	Encrypted          bool           `gorm:"type:bool"`
}

Upload is a file or pin based upload to temporal

type UploadManager

type UploadManager struct {
	DB *gorm.DB
}

UploadManager is used to manipulate upload objects in the database

func NewUploadManager

func NewUploadManager(db *gorm.DB) *UploadManager

NewUploadManager is used to generate an upload manager interface

func (*UploadManager) FindUploadByHashAndNetwork

func (um *UploadManager) FindUploadByHashAndNetwork(hash, networkName string) (*Upload, error)

FindUploadByHashAndNetwork is used to search for an upload by its hash, and the network it was stored on

func (*UploadManager) FindUploadsByHash

func (um *UploadManager) FindUploadsByHash(hash string) *[]Upload

FindUploadsByHash is used to return all instances of uploads matching the given hash

func (*UploadManager) FindUploadsByNetwork

func (um *UploadManager) FindUploadsByNetwork(networkName string) (*[]Upload, error)

FindUploadsByNetwork is used to find all uploads corresponding to a given network

func (*UploadManager) GetUploadByHashForUser

func (um *UploadManager) GetUploadByHashForUser(hash string, username string) []*Upload

GetUploadByHashForUser is used to retrieve the last (most recent) upload for a user

func (*UploadManager) GetUploads

func (um *UploadManager) GetUploads() (*[]Upload, error)

GetUploads is used to return all uploads

func (*UploadManager) GetUploadsForUser

func (um *UploadManager) GetUploadsForUser(username string) (*[]Upload, error)

GetUploadsForUser is used to retrieve all uploads by a user name

func (*UploadManager) NewUpload

func (um *UploadManager) NewUpload(contentHash, uploadType string, opts UploadOptions) (*Upload, error)

NewUpload is used to create a new upload in the database

func (*UploadManager) RunDatabaseGarbageCollection

func (um *UploadManager) RunDatabaseGarbageCollection() (*[]Upload, error)

RunDatabaseGarbageCollection is used to parse through the database and delete all objects whose GCD has passed TODO: Maybe move this to the database file?

func (*UploadManager) RunTestDatabaseGarbageCollection

func (um *UploadManager) RunTestDatabaseGarbageCollection() (*[]Upload, error)

RunTestDatabaseGarbageCollection is used to run a test garbage collection run. NOTE that this will delete literally every single object it detects.

func (*UploadManager) UpdateUpload

func (um *UploadManager) UpdateUpload(holdTimeInMonths int64, username, contentHash, networkName string) (*Upload, error)

UpdateUpload is used to upadte an already existing upload

type UploadOptions added in v1.0.6

type UploadOptions struct {
	NetworkName      string
	Username         string
	HoldTimeInMonths int64
	Encrypted        bool
}

UploadOptions is used to configure an upload

type Usage added in v1.3.0

type Usage struct {
	UserName string `gorm:"type:varchar(255);unique"`
	// keeps track of the max monthly upload limit for the user
	MonthlyDataLimitGB float64 `gorm:"type:float;default:0"`
	// keeps track of the current monthyl upload limit used
	CurrentDataUsedGB float64 `gorm:"type:float;default:0"`
	// keeps track of how many IPNS records the user has published
	IPNSRecordsPublished int64 `gorm:"type:integer;default:0"`
	// keeps track of how many messages the user has sent
	PubSubMessagesSent int64 `gorm:"type:integer;default:0"`
	// Used to indicate whether or not the user
	// has consumed their free private network trial
	PrivateNetworkTrialUsed bool `gorm:"type:boolean;default:false"`
	// Used to determine when their private network trial ends
	// good until 2038 <- ticket is open in JIRA so we do not forget about this
	// trial is 800 hours in unix timestamp
	TrialEndTime int64 `gorm:"type:integer;default:0"`
	// keeps track of the tier the user belongs to
	Tier DataUsageTier `gorm:"type:varchar(255)"`
}

Usage is used to handle Usage of Temporal accounts

type UsageManager added in v1.3.0

type UsageManager struct {
	DB *gorm.DB
}

UsageManager is used to manage Usage models

func NewUsageManager added in v1.3.0

func NewUsageManager(db *gorm.DB) *UsageManager

NewUsageManager is used to instantiate a Usage manager

func (*UsageManager) CanPublishIPNS added in v1.3.0

func (bm *UsageManager) CanPublishIPNS(username string) (bool, error)

CanPublishIPNS is used to check if a user can publish IPNS records

func (*UsageManager) CanPublishPubSub added in v1.3.0

func (bm *UsageManager) CanPublishPubSub(username string) (bool, error)

CanPublishPubSub is used to check if a user can publish pubsub messages

func (*UsageManager) FindByUserName added in v1.3.0

func (bm *UsageManager) FindByUserName(username string) (*Usage, error)

FindByUserName is used to find a Usage model by the associated username

func (*UsageManager) GetUploadPricePerGB added in v1.3.0

func (bm *UsageManager) GetUploadPricePerGB(username string) (float64, error)

GetUploadPricePerGB is used to get the upload price per gb for a user allows us to specify whether the payment

func (*UsageManager) HasStartedPrivateNetworkTrial added in v1.3.0

func (bm *UsageManager) HasStartedPrivateNetworkTrial(username string) (bool, error)

HasStartedPrivateNetworkTrial is used to check if the user has started their private network trial

func (*UsageManager) IncrementIPNSUsage added in v1.3.0

func (bm *UsageManager) IncrementIPNSUsage(username string, count int64) error

IncrementIPNSUsage is used to increment the ipns record publish counter

func (*UsageManager) IncrementPubSubUsage added in v1.3.0

func (bm *UsageManager) IncrementPubSubUsage(username string, count int64) error

IncrementPubSubUsage is used to increment the pubsub publish counter

func (*UsageManager) NewUsageEntry added in v1.3.0

func (bm *UsageManager) NewUsageEntry(username string, tier DataUsageTier) (*Usage, error)

NewUsageEntry is used to create a new usage entry in our database if tier is free, limit to 3GB monthly otherwise set to 1TB

func (*UsageManager) StartPrivateNetworkTrial added in v1.3.0

func (bm *UsageManager) StartPrivateNetworkTrial(username string) error

StartPrivateNetworkTrial is used to start a users private network trial

func (*UsageManager) UpdateDataUsage added in v1.3.0

func (bm *UsageManager) UpdateDataUsage(username string, uploadSize float64) error

UpdateDataUsage is used to update the users' data usage amount If the account is non free, and the upload pushes their total monthly usage above the tier limit, they will be upgraded to the next tier to receive the discounted price the discounted price will apply on subsequent uploads. If the 1TB maximum monthly limit is hit, then we throw an error

func (*UsageManager) UpdateTier added in v1.3.0

func (bm *UsageManager) UpdateTier(username string, tier DataUsageTier) error

UpdateTier is used to update the Usage tier associated with an account

type User

type User struct {
	gorm.Model
	UserName               string  `gorm:"type:varchar(255);unique"`
	EmailAddress           string  `gorm:"type:varchar(255);unique"`
	AccountEnabled         bool    `gorm:"type:boolean"`
	EmailEnabled           bool    `gorm:"type:boolean"`
	EmailVerificationToken string  `gorm:"type:varchar(255)"`
	AdminAccess            bool    `gorm:"type:boolean"`
	HashedPassword         string  `gorm:"type:varchar(255)"`
	Free                   bool    `gorm:"type:boolean"`
	Credits                float64 `gorm:"type:float;default:0"`
	// IPFSKeyNames is an array of IPFS key name this user has created
	IPFSKeyNames pq.StringArray `gorm:"type:text[];column:ipfs_key_names"`
	// IPFSKeyIDs is an array of public key hashes for IPFS keys this user has created
	IPFSKeyIDs pq.StringArray `gorm:"type:text[];column:ipfs_key_ids"`
	// IPFSNetworkNames is an array of private IPFS networks this user has access to
	IPFSNetworkNames pq.StringArray `gorm:"type:text[];column:ipfs_network_names"`
}

User is our user model for anyone who signs up with Temporal

type UserManager

type UserManager struct {
	DB *gorm.DB
}

UserManager is our helper to interact with our database

func NewUserManager

func NewUserManager(db *gorm.DB) *UserManager

NewUserManager is used to generate our user manager helper

func (*UserManager) AddCredits added in v1.0.3

func (um *UserManager) AddCredits(username string, credits float64) (*User, error)

AddCredits is used to add credits to a user account

func (*UserManager) AddIPFSKeyForUser

func (um *UserManager) AddIPFSKeyForUser(username, keyName, keyID string) error

AddIPFSKeyForUser is used to add a key to a user

func (*UserManager) AddIPFSNetworkForUser

func (um *UserManager) AddIPFSNetworkForUser(username, networkName string) error

AddIPFSNetworkForUser is used to update a users allowed private ipfs networks

func (*UserManager) ChangePassword

func (um *UserManager) ChangePassword(username, currentPassword, newPassword string) (bool, error)

ChangePassword is used to change a users password

func (*UserManager) CheckIfAdmin added in v1.0.3

func (um *UserManager) CheckIfAdmin(username string) (bool, error)

CheckIfAdmin is used to check if an account is an administrator

func (*UserManager) CheckIfKeyOwnedByUser

func (um *UserManager) CheckIfKeyOwnedByUser(username, keyName string) (bool, error)

CheckIfKeyOwnedByUser is used to check if a key is owned by a user

func (*UserManager) CheckIfUserAccountEnabled

func (um *UserManager) CheckIfUserAccountEnabled(username string) (bool, error)

CheckIfUserAccountEnabled is used to check if a user account is enabled

func (*UserManager) CheckIfUserHasAccessToNetwork

func (um *UserManager) CheckIfUserHasAccessToNetwork(username, networkName string) (bool, error)

CheckIfUserHasAccessToNetwork is used to check if a user has access to a private ipfs network

func (*UserManager) ComparePlaintextPasswordToHash

func (um *UserManager) ComparePlaintextPasswordToHash(username, password string) (bool, error)

ComparePlaintextPasswordToHash is a helper method used to validate a users password

func (*UserManager) FindByEmail added in v1.0.6

func (um *UserManager) FindByEmail(email string) (*User, error)

FindByEmail is used to find a particular user based on their email address

func (*UserManager) FindByUserName added in v1.0.2

func (um *UserManager) FindByUserName(username string) (*User, error)

FindByUserName is used to find a user by their username

func (*UserManager) FindEmailByUserName

func (um *UserManager) FindEmailByUserName(username string) (map[string]string, error)

FindEmailByUserName is used to find an email address by searching for the users eth address the returned map contains their eth address as a key, and their email address as a value

func (*UserManager) GenerateEmailVerificationToken added in v1.0.6

func (um *UserManager) GenerateEmailVerificationToken(username string) (*User, error)

GenerateEmailVerificationToken is used to generate a token we use to validate that the user actually owns the email they are signing up with

func (*UserManager) GetCreditsForUser added in v1.0.2

func (um *UserManager) GetCreditsForUser(username string) (float64, error)

GetCreditsForUser is used to get the user's current credits

func (*UserManager) GetKeyIDByName

func (um *UserManager) GetKeyIDByName(username, keyName string) (string, error)

GetKeyIDByName is used to get the ID of a key by searching for its name

func (*UserManager) GetKeysForUser

func (um *UserManager) GetKeysForUser(username string) (map[string][]string, error)

GetKeysForUser is used to get a mapping of a users keys

func (*UserManager) GetPrivateIPFSNetworksForUser

func (um *UserManager) GetPrivateIPFSNetworksForUser(username string) ([]string, error)

GetPrivateIPFSNetworksForUser is used to get a list of allowed private ipfs networks for a user

func (*UserManager) NewUserAccount

func (um *UserManager) NewUserAccount(username, password, email string) (*User, error)

NewUserAccount is used to create a new user account

func (*UserManager) RemoveCredits added in v1.0.2

func (um *UserManager) RemoveCredits(username string, credits float64) (*User, error)

RemoveCredits is used to remove credits from a users balance

func (*UserManager) RemoveIPFSNetworkForUser added in v1.1.0

func (um *UserManager) RemoveIPFSNetworkForUser(username, networkName string) error

RemoveIPFSNetworkForUser is used to remove a configured ipfs network from the users authorized networks

func (*UserManager) ResetPassword added in v1.0.6

func (um *UserManager) ResetPassword(username string) (string, error)

ResetPassword is used to reset a user's password if they forgot it

func (*UserManager) SignIn

func (um *UserManager) SignIn(username, password string) (bool, error)

SignIn is used to authenticate a user, and check if their account is enabled. Returns bool on succesful login, or false with an error on failure

func (*UserManager) ToggleAdmin added in v1.0.6

func (um *UserManager) ToggleAdmin(username string) (bool, error)

ToggleAdmin toggles the admin permissions of given user

func (*UserManager) ValidateEmailVerificationToken added in v1.0.6

func (um *UserManager) ValidateEmailVerificationToken(username, token string) (*User, error)

ValidateEmailVerificationToken is used to validate an email token to enable email access

type Zone added in v1.0.6

type Zone struct {
	gorm.Model
	UserName             string         `gorm:"type:varchar(255)"`
	Name                 string         `gorm:"type:varchar(255)"`
	ManagerPublicKeyName string         `gorm:"type:varchar(255)"`
	ZonePublicKeyName    string         `gorm:"type:varchar(255)"`
	LatestIPFSHash       string         `gorm:"type:varchar(255)"`
	RecordNames          pq.StringArray `gorm:"type:text[]"`
}

Zone is a TNS zone

type ZoneManager added in v1.0.6

type ZoneManager struct {
	DB *gorm.DB
}

ZoneManager is used to manipulate zone entries in the database

func NewZoneManager added in v1.0.6

func NewZoneManager(db *gorm.DB) *ZoneManager

NewZoneManager is used to generate our zone manager helper to interact with the db

func (*ZoneManager) AddRecordForZone added in v1.0.6

func (zm *ZoneManager) AddRecordForZone(zoneName, recordName, username string) (*Zone, error)

AddRecordForZone is used to add a record to a zone

func (*ZoneManager) CheckIfRecordExistsInZone added in v1.0.6

func (zm *ZoneManager) CheckIfRecordExistsInZone(zoneName, recordName, username string) (bool, error)

CheckIfRecordExistsInZone is used to check if a record exists in a particular zone

func (*ZoneManager) FindZoneByNameAndUser added in v1.0.6

func (zm *ZoneManager) FindZoneByNameAndUser(name, username string) (*Zone, error)

FindZoneByNameAndUser is used to lookup a zone by name and user

func (*ZoneManager) NewZone added in v1.0.6

func (zm *ZoneManager) NewZone(username, name, managerPK, zonePK, latestIPFSHash string) (*Zone, error)

NewZone is used to create a new zone in the database

func (*ZoneManager) UpdateLatestIPFSHashForZone added in v1.0.6

func (zm *ZoneManager) UpdateLatestIPFSHashForZone(name, username, hash string) (*Zone, error)

UpdateLatestIPFSHashForZone is used to update the latest IPFS hash for a zone file

Jump to

Keyboard shortcuts

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