Documentation
¶
Index ¶
- Variables
- func ActivateNode() error
- func AddDIDAttribute(nodeID string, systemMetadata string, nftMetadata string, ...) error
- func Authenticate(mnemonic string, chain string) (string, error)
- func ConnectToVPN() error
- func CreatePeriodicCheckpoints(nodeID string, client *ethclient.Client, instance *contract.Contract, ...)
- func CreateTrialSubscription(token string) error
- func DeactivateNode() error
- func DeleteClient(id string) error
- func DisconnectVPN(configPath 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 GetAllNodes(token string) ([]map[string]interface{}, error)
- 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 AuthResponse
- type ClientResponse
- type ClientStats
- type ConnectionResult
- type FlowIDResponse
- type IPFSResponse
- type IPInfo
- type NFTAttribute
- type NFTMetadata
- type NodeConnectionInfo
- type NodeResponse
- type NodeStatus
- type PeaqIPInfo
- type SubscriptionResponse
- type SystemMetadata
- type SystemMetrics
- type WireGuardConfig
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 Authenticate ¶
Authenticate with the API and return an authentication token
func CreateTrialSubscription ¶
Create a trial subscription
func DeactivateNode ¶
func DeactivateNode() error
DeactivateNode deactivates the node in the contract
func DisconnectVPN ¶
DisconnectVPN handles the VPN disconnection process
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 GetAllNodes ¶
Get all available nodes
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 AuthResponse ¶
type AuthResponse struct {
Status int `json:"status"`
Message string `json:"message"`
Payload struct {
Token string `json:"token"`
} `json:"payload"`
}
AuthResponse represents the authentication response
type ClientResponse ¶
type ClientResponse struct {
Status int `json:"status"`
Message string `json:"message"`
Payload struct {
Client struct {
Address []string `json:"Address"`
PublicKey string `json:"PublicKey"`
PresharedKey string `json:"PresharedKey"`
} `json:"client"`
Endpoint string `json:"endpoint"`
ServerPublicKey string `json:"serverPublicKey"`
} `json:"payload"`
PrivateKey string `json:"privateKey"`
}
ClientResponse represents the client creation response
func CreateClient ¶
func CreateClient(token string, nodeID string, clientName string) (*ClientResponse, error)
Create a client for a specific node
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 ConnectionResult ¶
type ConnectionResult struct {
Success bool `json:"success"`
Error string `json:"error,omitempty"`
Message string `json:"message,omitempty"`
ConfigPath string `json:"configPath,omitempty"`
Client *ClientResponse `json:"client,omitempty"`
ConfigData *WireGuardConfig `json:"configData,omitempty"`
IP string `json:"ip,omitempty"`
}
ConnectionResult represents the result of a connection attempt
func ConnectDvpn ¶
func ConnectDvpn(token string, nodeID string, clientName string, configPath string) (*ConnectionResult, error)
Connect to DVPN
func ConnectToVPNWithNodeSelection ¶
func ConnectToVPNWithNodeSelection(token string, clientName string, configPath string) (*ConnectionResult, error)
ConnectToVPNWithNodeSelection attempts to connect to VPN using available active nodes
type FlowIDResponse ¶
type FlowIDResponse struct {
Status int `json:"status"`
Message string `json:"message"`
Payload struct {
FlowID string `json:"flowId"`
Eula string `json:"eula"`
} `json:"payload"`
}
FlowIDResponse represents the flowId response
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 NodeConnectionInfo ¶
type NodeConnectionInfo struct {
NodeID string `json:"node_id"`
LastUsed time.Time `json:"last_used"`
ClientName string `json:"client_name"`
}
NodeConnectionInfo stores information about the last successful node connection
type NodeResponse ¶
type NodeResponse struct {
Status int `json:"status"`
Message string `json:"message"`
Payload []struct {
ID string `json:"id"`
Status string `json:"status"`
} `json:"payload"`
}
NodeResponse represents the nodes response
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 SubscriptionResponse ¶
type SubscriptionResponse struct {
Status string `json:"status"`
Subscription interface{} `json:"subscription"`
}
SubscriptionResponse represents the subscription response
func CheckSubscription ¶
func CheckSubscription(token string) (*SubscriptionResponse, error)
Check subscription status
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
type WireGuardConfig ¶
type WireGuardConfig struct {
Config string `json:"config"`
PrivateKey string `json:"privateKey"`
PublicKey string `json:"publicKey"`
Address string `json:"address"`
Endpoint string `json:"endpoint"`
ServerPublicKey string `json:"serverPublicKey"`
}
WireGuardConfig represents the WireGuard configuration
func CreateWireGuardConfig ¶
func CreateWireGuardConfig(clientData *ClientResponse) (*WireGuardConfig, error)
Create WireGuard configuration