edgecli

package module
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2022 License: GPL-3.0 Imports: 25 Imported by: 0

README

Omniedge Cli

OmniEdge CLi for macOS (Intel, M1/M2 MacBook), Linux Distributions, and ARM, Raspberry PI, Nvidia Jetson Embedded System.

Bring the intranet on the internet

🤝 Website 💬 Twitter 😇 Discord

Main repo: https://github.com/omniedgeio/omniedge

Install OmniEdge Cli

curl https://omniedge.io/install/omniedge-install.sh | bash

Install OmniEdge other clients

Cli Command

Login
  • Login By Password
omniedge login -u xxx@xxx.com
  • Login By Secret-Key

You can generate secret-key on omniedge web.

omniedge login -s xxxxxx
Join

you can just call omniedge join, it will automatically prompt the available network for you to choose. And you can also add one parameter -n to specify the network id manually.

And then, enjoy the omniedge network.

omniedge join 
// or
omniedge join -n "virtual-network-id" 

Resources

Compile for riscv64

apt-get update
apt-get install -y openssl autoconf build-essential libssl-dev zip wget g++-riscv64-linux-gnu gcc-riscv64-linux-gnu

wget https://go.dev/dl/go1.18.4.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.18.4.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
go version
export GOOS=linux
export GOARCH=riscv64
export CGO_ENABLED=1
export CC=riscv64-linux-gnu-gcc
git clone https://github.com/yongqianme/omniedge-cli.git
cd omniedge-cli
go mod download
go generate
BUILD_ENV=prod make build-riscv64

Contributing Guildlines

Check the tempalte into .github folder to report an issue or submit a PR:

  1. ISSUE_TEMPLATE.md
  2. PULL_REQUEST_TEMPLATE.md

How to get started?

  1. If you only need a convenient connectivity service Just visit https://omniedge.io/download and download the apps for your platform.

Contributors

@ivyxjc

Documentation

Overview

Code generated for package edgecli by go-bindata DO NOT EDIT. (@generated) sources: config/dev.yml config/prod.yml

Index

Constants

View Source
const (
	RestJoinOmniEdge = "client-join-url"
	GraphqlEndpoint  = "graphql-endpoint"
)
View Source
const (
	ContentType   = "Content-Type"
	ContentJson   = "application/json"
	Authorization = "authorization"
)
View Source
const (
	FailGetMacAddress = "fail to get mac address"
)

Variables

View Source
var ConfigV = viper.New()

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func GenerateInstanceId

func GenerateInstanceId() string

func GenerateRandomMac

func GenerateRandomMac() (string, error)

func HandleCall

func HandleCall(req *http.Request) (interface{}, error)

func HandleFilePrefix

func HandleFilePrefix(authFile string) (string, error)

HandleFilePrefix /** parse user input of auth file path

func HandleFileStatus

func HandleFileStatus(file string) error

func LoadClientConfig

func LoadClientConfig()

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func NewSuccessResponse

func NewSuccessResponse(message string, data ...interface{}) error

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

func RevealHardwareUUID

func RevealHardwareUUID() (string, error)

func RevealHostName

func RevealHostName() string

func RevealOS

func RevealOS() string

Types

type AuthMethod

type AuthMethod string
const (
	LoginBySecretKey AuthMethod = "LoginBySecretKey"
	LoginByPassword  AuthMethod = "LoginByPassword"
)

type AuthOption

type AuthOption struct {
	Username   string
	Password   string
	SecretKey  string
	AuthMethod AuthMethod
}

type AuthResp

type AuthResp struct {
	Token        string `json:"token"`
	RefreshToken string `json:"refreshToken"`
}

type AuthService

type AuthService struct {
	HttpOption
}

func (*AuthService) Login

func (s *AuthService) Login(opt *AuthOption) (*AuthResp, error)

func (*AuthService) Refresh

func (s *AuthService) Refresh(opt *RefreshTokenOption) (*AuthResp, error)

type AuthTokenResponse

type AuthTokenResponse struct {
	Token string `json:"token"`
}

type CIDR

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

func ParseCIDR

func ParseCIDR(s string) (*CIDR, error)

func (CIDR) Contains

func (c CIDR) Contains(ip string) bool

func (CIDR) Ip

func (c CIDR) Ip() string

func (CIDR) Mask

func (c CIDR) Mask() string

type DeviceNet

type DeviceNet struct {
	IP         string
	MacAddress string
	SubnetMask string
}

func GetCurrentDeviceNetStatus

func GetCurrentDeviceNetStatus(cidrStr string) (*DeviceNet, error)

type DeviceResponse

type DeviceResponse struct {
	ID              string                          `json:"id"`
	Name            string                          `json:"name"`
	OS              string                          `json:"os"`
	VirtualNetworks []*DeviceVirtualNetworkResponse `json:"virtual_networks,omitempty"`
	Subnets         []*DeviceSubnetRouteResponse    `json:"subnets,omitempty"`
}

type DeviceSubnetRouteResponse

type DeviceSubnetRouteResponse struct {
	ID         string                       `json:"id"`
	IP         string                       `json:"ip"`
	MacAddr    string                       `json:"mac_addr"`
	SubnetMask string                       `json:"subnet_mask"`
	Devices    []*SubnetRouteDeviceResponse `json:"devices"`
}

type DeviceVirtualNetworkResponse

type DeviceVirtualNetworkResponse struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	VirtualIP string    `json:"virtual_ip"`
	LastSeen  time.Time `json:"last_seen"`
	Online    bool      `json:"online"`
}

type ErrorResponse

type ErrorResponse struct {
	Code    int         `json:"-"`
	Message string      `json:"message"`
	Errors  interface{} `json:"errors"`
}

func (ErrorResponse) Error

func (err ErrorResponse) Error() string

type HttpOption

type HttpOption struct {
	Token   string
	BaseUrl string
}

type IdentityResponse

type IdentityResponse struct {
	Provider string            `json:"provider"`
	Enabled  bool              `json:"enabled"`
	MetaData map[string]string `json:"metadata"`
}

type InvitationResponse

type InvitationResponse struct {
	UUID           string                      `json:"uuid"`
	User           *VirtualNetworkUserResponse `json:"user,omitempty"`
	InvitedBy      string                      `json:"invited_by"`
	InvitedAt      time.Time                   `json:"invited_at"`
	VirtualNetwork string                      `json:"virtual_network"`
}

type JoinOption

type JoinOption struct {
	VirtualNetworkId string
	DeviceId         string
}

type JoinVirtualNetworkResponse

type JoinVirtualNetworkResponse struct {
	CommunityName string          `json:"community_name"`
	SecretKey     string          `json:"secret_key"`
	VirtualIP     string          `json:"virtual_ip"`
	SubnetMask    string          `json:"subnet_mask"`
	Server        *ServerResponse `json:"server"`
}

type ProfileResponse

type ProfileResponse struct {
	ID         string              `json:"id"`
	Name       string              `json:"name"`
	Email      string              `json:"email"`
	Picture    string              `json:"picture"`
	Identities []*IdentityResponse `json:"identities"`
}

type RefreshTokenOption

type RefreshTokenOption struct {
	RefreshToken string
}

type RegisterDeviceSubnetRouteRequest

type RegisterDeviceSubnetRouteRequest struct {
	IP         string                      `json:"ip" validate:"required,ipv4"`
	MacAddr    string                      `json:"mac_addr" validate:"required,mac"`
	SubnetMask string                      `json:"subnet_mask" validate:"required,ipv4"`
	Devices    []*SubnetRouteDeviceRequest `json:"devices"`
}

type RegisterOption

type RegisterOption struct {
	Name         string
	HardwareUUID string
	OS           string
}

type RegisterService

type RegisterService struct {
	HttpOption
}

func (*RegisterService) Register

func (s *RegisterService) Register(opt *RegisterOption) (*DeviceResponse, error)

type ResetPasswordResponse

type ResetPasswordResponse struct {
	Email string `json:"email"`
}

type ScanOption

type ScanOption struct {
	Cidr    string
	Timeout int64
}

type ScanResult

type ScanResult struct {
	HostName   string `mapstructure:"hostName"`
	IPv4       string `mapstructure:"ipv4"`
	IPv6       string `mapstructure:"ipv6"`
	MacAddress string `mapstructure:"macAddress"`
	Vendor     string `mapstructure:"vendor"`
	OS         string `mapstructure:"os"`
}

type ScanService

type ScanService struct {
	ScanOption
}

func (*ScanService) Scan

func (s *ScanService) Scan(option *ScanOption) (*[]ScanResult, error)

type SecurityKeyResponse

type SecurityKeyResponse struct {
	UUID      string    `json:"uuid"`
	Key       string    `json:"key"`
	KeyType   int16     `json:"key_type"`
	ExpiredAt time.Time `json:"expired_at"`
	CreatedAt time.Time `json:"created_at"`
}

type ServerResponse

type ServerResponse struct {
	ID      string `json:"id,omitempty"`
	Name    string `json:"name"`
	Country string `json:"country"`
	Host    string `json:"host,omitempty"`
}

type StartOption

type StartOption struct {
	Hostname      string
	CommunityName string
	VirtualIP     string
	SecretKey     string
	DeviceMac     string
	DeviceMask    string
	SuperNode     string
	EnableRouting bool
}

type StartService

type StartService struct {
	StartOption
}

func (*StartService) Start

func (s *StartService) Start() error

type SubnetRouteDeviceRequest

type SubnetRouteDeviceRequest struct {
	Name    string `json:"name"`
	IP      string `json:"ip" validate:"required,ipv4"`
	MacAddr string `json:"mac_addr" validate:"required,mac"`
}

type SubnetRouteDeviceResponse

type SubnetRouteDeviceResponse struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	IP           string `json:"ip"`
	MacAddr      string `json:"mac_addr"`
	Manufacturer string `json:"manufacturer"`
}

type SuccessResponse

type SuccessResponse struct {
	Code    int         `json:"-"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

func (SuccessResponse) Error

func (err SuccessResponse) Error() string

type UploadOption

type UploadOption struct {
	IP          string
	MacAddress  string
	SubnetMask  string
	DeviceId    string
	ScanResults []*ScanResult
}

type VirtualNetwork

type VirtualNetwork struct {
	UUID string `json:"uuid"`
	Name string `json:"name"`
	OS   string `json:"os"`
}

type VirtualNetworkDeviceResponse

type VirtualNetworkDeviceResponse struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	VirtualIP string    `json:"virtual_ip"`
	LastSeen  time.Time `json:"last_seen"`
	Online    bool      `json:"online"`
}

type VirtualNetworkResponse

type VirtualNetworkResponse struct {
	ID      string                          `json:"id"`
	Name    string                          `json:"name"`
	IPRange string                          `json:"ip_range"`
	Role    int                             `json:"role"`
	Server  *ServerResponse                 `json:"server,omitempty"`
	Devices []*VirtualNetworkDeviceResponse `json:"devices,omitempty"`
	Users   []*VirtualNetworkUserResponse   `json:"users,omitempty"`
}

type VirtualNetworkService

type VirtualNetworkService struct {
	HttpOption
}

func (*VirtualNetworkService) Join

func (*VirtualNetworkService) List

func (*VirtualNetworkService) Upload

func (s *VirtualNetworkService) Upload(opt *UploadOption) error

type VirtualNetworkUserResponse

type VirtualNetworkUserResponse struct {
	UUID     string    `json:"uuid"`
	Email    string    `json:"email"`
	Name     string    `json:"name"`
	Role     int       `json:"role,omitempty"`
	JoinedAt time.Time `json:"joined_at,omitempty"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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