ztcommon

package
v0.0.0-...-39cda13 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddOneToLastOctet

func AddOneToLastOctet(ipStr string) (string, error)

* Get the first usable IP in the network.

func AllDone

func AllDone()

* Common AllDone for the CLI to prompt for messages (succes, error, etc.)

func AuthPeer

func AuthPeer(nwid string, status bool, delNet string, todo string, isWeb bool) ([]byte, string)

* Function to authorize, deauthorize, and delete peers.

func ChkIfNet

func ChkIfNet(nwid string) bool

func ChkNetworkID

func ChkNetworkID(nwid string) bool

* Function to Validate the network ID is valid.

func ChkPeer

func ChkPeer(nwid string, peer string) bool

func ClearScreen

func ClearScreen()

* Clear the screen based on the operating system. TODO: Update the menus to use tview and get rid of this

func ControllerHeader

func ControllerHeader() string

* Common Controller header

func ControllerID

func ControllerID() string

func CopyFile

func CopyFile(srcFile, dstFile string) bool

* Function to copy a file.

func DoAuthPeer

func DoAuthPeer(nwid string, peerAuth string, thePeer string) []byte

* Function to authorize the peer.

func GetCIDRForNet

func GetCIDRForNet() string

************************** GENERATING A RANDOM CIDR ****************************** Gemini helped with this one. *

func GetIPRangeFromCIDR

func GetIPRangeFromCIDR(cidr string) (string, string, error)

* Function is used to get the network id and broadcast address of the network

func GetNet

func GetNet() (bool, string)

func GetZTInfo

func GetZTInfo(httpMethod string, jsonBody []byte, action string, newNetData string) []byte

* Get ZT Info. I need to consolidate some of these. The original idea was to have a case statement for each operation.

func MenuPrompt(msg string) string

* Common menu prompt

func MenuSelection(theSelectionValue map[int]string, userInput int) string

* This is the menu that processes the selected network to manage.

func NetworksToManage

func NetworksToManage() string

func OpenFile

func OpenFile(filename string) string

* Function to open a file and return the string.

func ParseAddressFromJSON

func ParseAddressFromJSON(jsonData []byte, value string) (string, error)

* Function to retrieve some values

func PtermErr

func PtermErr(err error)

func PtermErrMsg

func PtermErrMsg(msg string)

func PtermGenInfo

func PtermGenInfo(msg string)

func PtermGenWarn

func PtermGenWarn(msg string)

func PtermInfo

func PtermInfo(msg string, val string)

func PtermInputPrompt

func PtermInputPrompt(msg string) string

func PtermMenuPrompt

func PtermMenuPrompt(msg string)

func PtermSuccess

func PtermSuccess(msg string)

func PtermWithErr

func PtermWithErr(msg string, err error)

func RulesDir

func RulesDir() string

func SubtractOneFromLastOctet

func SubtractOneFromLastOctet(ipStr string) (string, error)

* Get the last usable IP in the network.

func WebStatus

func WebStatus(w http.ResponseWriter, r *http.Request, status bool, msg string)

* Generic return status message

func WriteLogs

func WriteLogs(msg string)

Types

type NetworkInfo

type NetworkInfo struct {
	CreationTime int64  `json:"creationTime"`
	Name         string `json:"name"`
	Nwid         string `json:"nwid"`
	Authorized   bool   `json:"authorized"`
	// "ipAssignmentPools":[{"ipRangeEnd":"192.168.39.254","ipRangeStart":"192.168.39.1"}]
	IpAssignmentPools []struct {
		IPRangeEnd   string `json:"ipRangeEnd"`
		IPRangeStart string `json:"ipRangeStart"`
	} `json:"ipAssignmentPools"`
}

* Struct for the network controller data.

type Nwid

type Nwid struct {
	Nwid string `json:"nwid"`
}

type PeerInfo

type PeerInfo struct {
	Authorized    bool     `json:"authorized"`
	IPAssignments []string `json:"ipAssignments"`
}

type TheNets

type TheNets struct {
	Nwid         string `json:"nwid"`
	Name         string `json:"name"`
	IPRangeStart string `json:"ipRangeStart"`
	IPRangeEnd   string `json:"ipRangeEnd"`
	CreationTime string `json:"creationTime"`
}

Used to create the slice of structs that will return the peers for the respective network controller.

func AllNetworks

func AllNetworks(todo string) []TheNets

* Function to get the network list

Jump to

Keyboard shortcuts

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