gopifinder

package module
v0.0.0-...-ddc0e2f Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: MIT Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvToDate

func ConvToDate(s string) time.Time

ConvToDate converts the WMIC date format to a standard date

func ConvToInt

func ConvToInt(s string, def int) int

ConvToInt converts the string value to a Int value.

func ConvToInt64

func ConvToInt64(s string, def int64) int64

ConvToInt64 converts the string value to a Int64 value.

func GetClientID

func GetClientID() (string, error)

GetClientID returns the unique client id (UUID) for this application.

func GetLocalIPAddresses

func GetLocalIPAddresses() ([]string, error)

GetLocalIPAddresses gets a list of valid IPv4 addresses for the local machine. These are addresses for networks that are currently up.

func GetPotentialAddresses

func GetPotentialAddresses(ip string) ([]string, error)

GetPotentialAddresses gets a list of IP addresses in the same subnet as the specified IP address that could, potentially, host a server. Note that this only supports Class 3 subnets for now.

func IsInternetOnline

func IsInternetOnline() bool

IsInternetOnline returns whether or not the machine is connected to the internet.

func ReadAllText

func ReadAllText(path string) (string, error)

ReadAllText reads the text from the specified file path

Types

type DeviceInfo

type DeviceInfo struct {
	MachineID string    `json:"machineID"`
	HostName  string    `json:"hostName"`
	IPAddress []string  `json:"ipAddress"`
	OS        string    `json:"os"`
	PortNo    int       `json:"portNo"`
	Created   time.Time `json:"created"`
}

DeviceInfo holds the information about a device.

func NewDeviceInfo

func NewDeviceInfo() (DeviceInfo, error)

NewDeviceInfo creates a new DeviceInfo struct and populates it with the values for the current device

func (*DeviceInfo) CreateService

func (d *DeviceInfo) CreateService(name string) ServiceInfo

CreateService creates and returns a new ServiceInfo struct object for the current device.

func (*DeviceInfo) Deserialize

func (d *DeviceInfo) Deserialize(s string) error

Deserialize deserializes the specified string into the entity values

func (*DeviceInfo) GetURL

func (d *DeviceInfo) GetURL(idx int, method string) string

GetURL returns the URL for the specified web method.

func (*DeviceInfo) ReadFrom

func (d *DeviceInfo) ReadFrom(r io.ReadCloser) error

ReadFrom will read the request body and deserialize it into the entity values

func (*DeviceInfo) Serialize

func (d *DeviceInfo) Serialize() (string, error)

Serialize serializes the entity and returns the serialized string

func (*DeviceInfo) WriteTo

func (d *DeviceInfo) WriteTo(w http.ResponseWriter) error

WriteTo will serialize the entity and write it to the http response

type DeviceInfoList

type DeviceInfoList struct {
	Devices []DeviceInfo `json:"devices"`
}

DeviceInfoList holds a list of Device Information

func (*DeviceInfoList) Deserialize

func (d *DeviceInfoList) Deserialize(v string) error

Deserialize deserializes the specified string into the entity values

func (*DeviceInfoList) ReadFrom

func (d *DeviceInfoList) ReadFrom(r io.ReadCloser) error

ReadFrom reads the string from the reader and deserializes it into the entity values

func (*DeviceInfoList) Serialize

func (d *DeviceInfoList) Serialize() (string, error)

Serialize serializes the entity and returns the serialized string

func (*DeviceInfoList) WriteTo

func (d *DeviceInfoList) WriteTo(w http.ResponseWriter) error

WriteTo serializes the entity and writes it to the http response

type DeviceStatus

type DeviceStatus struct {
	HostName     string    `json:"hostName"`     // Current Host Name
	OS           string    `json:"os"`           // OS Type
	OSName       string    `json:"osName"`       // Operating System Name
	OSVersion    string    `json:"osVersion"`    // Operating System version
	HWType       string    `json:"hwType"`       // Hardware type
	HWSerialNo   string    `json:"hwSerialNo"`   // Hardware SerialNo
	CPUTemp      float64   `json:"cpuTemp"`      // CPU temperature in Celcius
	GPUTemp      float64   `json:"gpuTemp"`      // GPU temperature in Celcius
	IsThrottled  bool      `json:"isThrottled"`  // If CPU is currently throttled
	DiskUsed     int64     `json:"freeDisk"`     // Disk Used Space in bytes
	DiskUsedPerc int       `json:"freeDiskPerc"` // Disk Used Space in percentage
	TotalMem     int64     `json:"totalMem"`     // Total Memory in bytes
	AvailMem     int64     `json:"availMem"`     // Available Memory in bytes
	Uptime       int       `json:"uptime"`       // CPU uptime in seconds
	Created      time.Time `json:"created"`      // The date and time the status was created
}

DeviceStatus holds current status information about the Device

func NewDeviceStatus

func NewDeviceStatus() (DeviceStatus, error)

NewDeviceStatus creates a new DeviceStatus struct and populates it with the values for the current device

func (*DeviceStatus) Deserialize

func (d *DeviceStatus) Deserialize(v string) error

Deserialize deserializes the specified string into the entity values

func (*DeviceStatus) ReadFrom

func (d *DeviceStatus) ReadFrom(r io.ReadCloser) error

ReadFrom reads the string from the reader and deserializes it into the entity values

func (*DeviceStatus) Serialize

func (d *DeviceStatus) Serialize() (string, error)

Serialize serializes the entity and returns the serialized string

func (*DeviceStatus) WriteTo

func (d *DeviceStatus) WriteTo(w http.ResponseWriter) error

WriteTo serializes the entity and writes it to the http response

type Entity

type Entity interface {
	// ReadFrom reads the request body and deserializes it into the entity values
	ReadFrom(r io.ReadCloser) error
	// WriteTo serializes the entity and writes it to the http response
	WriteTo(w http.ResponseWriter) error
	// Serialize serializes the entity and returns the serialized string
	Serialize() (string, error)
	// Deserialize deserializes the specified string into the entity values
	Deserialize(s string) error
}

Entity defines a type that can be deserialized from a http request and can be serialized to an http response

type Finder

type Finder struct {
	PortNo         int            // Port number to attempt to connect to
	Devices        []DeviceInfo   // List of discovered devices
	VerboseLogging bool           // Switch on verbose logging
	Timeout        int            // The timeout in seconds to wait for a response from the LAN IP probe
	LastSearch     time.Time      // The date and time the last search was made
	ForceSearch    bool           // Indicates if a search must occur
	IsServer       bool           // Indicates this instance is a finder server
	MyInfo         *DeviceInfo    // The machine's device information
	Logger         service.Logger // The logger
}

Finder will search for and hold a list of devices available on the local network.

func (*Finder) AddDevice

func (f *Finder) AddDevice(d DeviceInfo)

AddDevice adds the specified device to the devices list

func (*Finder) FindDevices

func (f *Finder) FindDevices() ([]DeviceInfo, error)

FindDevices searches the local LANs for devices. This will initiate a LAN wide search for each local IP address associated with the current device.

func (*Finder) GetMyInfo

func (f *Finder) GetMyInfo() (DeviceInfo, bool, error)

GetMyInfo returns the latest device information for the current device.

func (*Finder) RegisterServices

func (f *Finder) RegisterServices(sl []ServiceInfo) error

RegisterServices registers the list of services with the registered devices on the network.

func (*Finder) SearchForDevices

func (f *Finder) SearchForDevices() ([]DeviceInfo, error)

SearchForDevices will search the registered devices for services that match the list of service names specified.

func (*Finder) SearchForServices

func (f *Finder) SearchForServices() ([]ServiceInfo, error)

SearchForServices will search the registered devices for services that match the list of service names specified.

type ServiceInfo

type ServiceInfo struct {
	ServiceName string `json:"serviceName"`
	MachineID   string `json:"machineID"`
	HostName    string `json:"hostName"`
	IPAddress   string `json:"ip"`
	PortNo      int    `json:"portNo"`
	APIStub     string `json:"apiStub"`
}

ServiceInfo holds the information about a service provided by a device. The information holds the ServiceName, the Port No on the device and the API url stub of the service controller.

func (*ServiceInfo) Deserialize

func (s *ServiceInfo) Deserialize(v string) error

Deserialize deserializes the specified string into the entity values

func (*ServiceInfo) ReadFrom

func (s *ServiceInfo) ReadFrom(r io.ReadCloser) error

ReadFrom reads the string from the reader and deserializes it into the entity values

func (*ServiceInfo) RegisterWith

func (s *ServiceInfo) RegisterWith(d DeviceInfo, ipNo int) error

RegisterWith will register the Service with the specified device.

func (*ServiceInfo) Serialize

func (s *ServiceInfo) Serialize() (string, error)

Serialize serializes the entity and returns the serialized string

func (*ServiceInfo) WriteTo

func (s *ServiceInfo) WriteTo(w http.ResponseWriter) error

WriteTo serializes the entity and writes it to the http response

type ServiceInfoList

type ServiceInfoList struct {
	Services []ServiceInfo `json:"services"`
}

ServiceInfoList holds a list of Services

func (*ServiceInfoList) Deserialize

func (s *ServiceInfoList) Deserialize(v string) error

Deserialize deserializes the specified string into the entity values

func (*ServiceInfoList) ReadFrom

func (s *ServiceInfoList) ReadFrom(r io.ReadCloser) error

ReadFrom reads the string from the reader and deserializes it into the entity values

func (*ServiceInfoList) RegisterWith

func (s *ServiceInfoList) RegisterWith(d DeviceInfo, ipNo int) error

RegisterWith will register the Services with the specified device.

func (*ServiceInfoList) Serialize

func (s *ServiceInfoList) Serialize() (string, error)

Serialize serializes the entity and returns the serialized string

func (*ServiceInfoList) WriteTo

func (s *ServiceInfoList) WriteTo(w http.ResponseWriter) error

WriteTo serializes the entity and writes it to the http response

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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