Documentation
¶
Index ¶
- Variables
- func ActivateNode() error
- func AddDIDAttribute(nodeID string, systemMetadata string, nftMetadata string, ...) error
- func CreatePeriodicCheckpoints(nodeID string, client *ethclient.Client, instance *contract.Contract, ...)
- func DeactivateNode() error
- func DeleteClient(id string) error
- func Execute()
- func GenerateEthereumWalletAddress(mnemonic string) (string, *ecdsa.PrivateKey, error)
- func GeneratePeaqDID() (string, error)
- func GenerateWalletAddressAptos(mnemonic string)
- func GenerateWalletAddressSolanaAndEclipse(mnemonic string)
- func GenerateWalletAddressSui(mnemonic string)
- func GetAllReservedIps() ([]string, error)
- func GetCodeHashAndVersion() (string, string)
- func GetIPInfo()
- func GetPort(max, min int) (int, error)
- func GetServerStatus() (*model.Status, error)
- func Init()
- func IsValidPeaqDID(did string) bool
- func LoadNodeDetails()
- func MakeErrorResponse(status int64, err string, server *model.Server, client *model.Client, ...) *model.Response
- func MakeSucessResponse(status int64, message string, server *model.Server, client *model.Client, ...) *model.Response
- func ReadClient(id string) (*model.Client, error)
- func ReadClientConfig(id string) ([]byte, error)
- func ReadClients() ([]*model.Client, error)
- func ReadServer() (*model.Server, error)
- func ReadWgConfigFile() ([]byte, error)
- func RegisterClient(client *model.Client) (*model.Client, error)
- func RegisterNodeOnChain() error
- func ScanPort(port int) (string, error)
- func UpdateClient(UUID string, client *model.Client) (*model.Client, error)
- func UpdateServer(server *model.Server) (*model.Server, error)
- func UpdateServerConfigWg() error
- func Writefile(path string, bytes []byte) (err error)
- type ClientStats
- type IPFSResponse
- type IPInfo
- type NFTAttribute
- type NFTMetadata
- type NodeStatus
- type PeaqIPInfo
- type SystemMetadata
- type SystemMetrics
Constants ¶
This section is empty.
Variables ¶
var ( Version string CodeHash string )
These variables will be set at build time
var ( NodeName string ChainName string NodeAccess string NodeConfig string )
var CaddyConfDir = os.Getenv("WG_CONF_DIR")
WG_CONF_DIR
var CaddyFile = os.Getenv("CADDY_INTERFACE_NAME")
var CaddyJSON = "caddy.json"
var AppConfDir = "./conf"
var WalletAddress string
Functions ¶
func AddDIDAttribute ¶
func AddDIDAttribute(nodeID string, systemMetadata string, nftMetadata string, privateKey *ecdsa.PrivateKey) error
AddDIDAttribute adds DID attributes to the PEAQ DID registry contract
func DeactivateNode ¶
func DeactivateNode() error
DeactivateNode deactivates the node in the contract
func Execute ¶
func Execute()
Execute adds all child commands to the root command and sets flags appropriately.
func GenerateEthereumWalletAddress ¶
func GenerateEthereumWalletAddress(mnemonic string) (string, *ecdsa.PrivateKey, error)
GenerateEthereumWalletAddress generates an Ethereum wallet address from the given mnemonic
func GeneratePeaqDID ¶
func GenerateWalletAddressAptos ¶
func GenerateWalletAddressAptos(mnemonic string)
GenerateWalletAddressAptos generates an Aptos wallet address from the given mnemonic
func GenerateWalletAddressSolanaAndEclipse ¶
func GenerateWalletAddressSolanaAndEclipse(mnemonic string)
GenerateWalletAddressSolana generates a Solana wallet address from the given mnemonic
func GenerateWalletAddressSui ¶
func GenerateWalletAddressSui(mnemonic string)
GenerateWalletAddressSui generates a Sui wallet address from the given mnemonic
func GetAllReservedIps ¶
GetAllReservedIps the list of all reserved IPs, client and server
func GetCodeHashAndVersion ¶
func GetServerStatus ¶
Method to get the server status
func IsValidPeaqDID ¶
func LoadNodeDetails ¶
func LoadNodeDetails()
Function to load the node details from the environment and save it to the global variable
func MakeErrorResponse ¶
func MakeErrorResponse(status int64, err string, server *model.Server, client *model.Client, clients []*model.Client) *model.Response
error response message
func MakeSucessResponse ¶
func MakeSucessResponse(status int64, message string, server *model.Server, client *model.Client, clients []*model.Client) *model.Response
success response message
func ReadClientConfig ¶
func ReadWgConfigFile ¶
ReadWgConfigFile return content of wireguard config file
func RegisterClient ¶
RegisterClient client with all necessary data
func RegisterNodeOnChain ¶
func RegisterNodeOnChain() error
func UpdateClient ¶
UpdateClient preserve keys
func UpdateServer ¶
UpdateServer keep private values from existing one
Types ¶
type ClientStats ¶
type ClientStats struct {
Client string `json:"client"`
RX string `json:"rx"`
TX string `json:"tx"`
}
ClientStats represents the bandwidth statistics of a WireGuard client
type IPFSResponse ¶
type IPInfo ¶
type IPInfo struct {
IP string `json:"ip"`
City string `json:"city"`
Region string `json:"region"`
Country string `json:"country"`
Location string `json:"loc"`
Org string `json:"org"`
Postal string `json:"postal"`
Timezone string `json:"timezone"`
}
var GlobalIPInfo IPInfo
type NFTAttribute ¶
type NFTMetadata ¶
type NFTMetadata struct {
Name string `json:"name"`
Description string `json:"description"`
Image string `json:"image"`
ExternalURL string `json:"externalUrl"`
Attributes []NFTAttribute `json:"attributes"`
}
type NodeStatus ¶
type NodeStatus struct {
ID string
Name string
Spec string
Config string
IPAddress string
Region string
Location string
Owner common.Address
TokenID *big.Int
Status uint8
Checkpoint string
}
NodeStatus represents the current status of a node
func GetNodeStatus ¶
func GetNodeStatus() (*NodeStatus, error)
GetNodeStatus retrieves the current status of the node from the contract
func (*NodeStatus) GetStatusEmoji ¶
func (ns *NodeStatus) GetStatusEmoji() string
GetStatusEmoji returns the emoji representation of the node status
func (*NodeStatus) GetStatusText ¶
func (ns *NodeStatus) GetStatusText() string
GetStatusText returns the text representation of the node status
type PeaqIPInfo ¶
type SystemMetadata ¶
type SystemMetadata struct {
OS string `json:"os"`
Architecture string `json:"architecture"`
NumCPU int `json:"num_cpu"`
Hostname string `json:"hostname"`
LocalIPs []string `json:"local_ips"`
Environment string `json:"environment"` // "cloud" or "local"
GoVersion string `json:"go_version"`
RuntimeVersion string `json:"runtime_version"`
TotalRAM uint64 `json:"total_ram"`
UsedRAM uint64 `json:"used_ram"`
FreeRAM uint64 `json:"free_ram"`
TotalDisk uint64 `json:"total_disk"`
UsedDisk uint64 `json:"used_disk"`
FreeDisk uint64 `json:"free_disk"`
CPUUsage float64 `json:"cpu_usage"`
Version string `json:"version"`
CodeHash string `json:"code_hash"`
}
type SystemMetrics ¶
type SystemMetrics struct {
Timestamp int64 `json:"timestamp"`
ConnectedClients int `json:"connected_clients"`
ClientStats []ClientStats `json:"client_stats"`
Uptime string `json:"uptime"`
}
SystemMetrics represents the system metrics for checkpoints