device

package module
v0.0.0-...-88c0aa8 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2019 License: GPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Windows represents the Windows family of Operating Systems.
	Windows deviceOS = 0x0
	// Linux represents the Linux family of Operating Systems
	Linux deviceOS = 0x1
	// Unix represents the Unix family of Operating Systems
	Unix deviceOS = 0x2
	// Mac represents the MacOS/BSD family of Operating Systems
	Mac deviceOS = 0x3

	// Arch64 represents the 64-bit chipset family.
	Arch64 deviceArch = 0x0
	// Arch86 represents the 32-bit chipset family.
	Arch86 deviceArch = 0x1
	// ArchARM represents the ARM chipset family.
	ArchARM deviceArch = 0x2
	// ArchPowerPC represents the PowerPC chipset family.
	ArchPowerPC deviceArch = 0x3
	// ArchMips represents the MIPS chipset family.
	ArchMips deviceArch = 0x4
	// ArchUnknown represents an unknown chipset family.
	ArchUnknown deviceArch = 0x5

	// IDSize is the amount of bytes used to store the Host ID and
	// SessionID values.  The ID is the (HostID + SessionID).
	IDSize = 32
	// SmallIDSize is the amount of bytes used for printing the Host ID
	// value using the ID function.
	SmallIDSize = MachineIDSize
	// MachineIDSize is the amount of bytes that is used as the Host
	// specific ID value that does not change when on the same host.
	MachineIDSize = 28
)

Variables

View Source
var (
	// Shell is the default machine specific command shell.
	Shell = compat.Shell()

	// Local is the pointer to the local
	// machine instance. This instance is loaded at
	// runtime and is used for local data gathering.
	Local = &localMachine{
		&Machine{
			ID:       getID(),
			OS:       deviceOS(compat.Os()),
			PID:      uint64(os.Getpid()),
			Arch:     getArch(),
			User:     "Unknown",
			Version:  compat.Version(),
			Network:  Network{},
			Hostname: "Unknown",
			Elevated: compat.Elevated(),
		},
	}

	// Newline is the machine specific newline character.
	Newline = compat.Newline()

	// ShellArgs is the default machine specific command shell
	// arguments to run commands.
	ShellArgs = compat.ShellArgs()
)
View Source
var (
	// Environment is a mapping of environment string names
	// to their string values.
	Environment = make(map[string]string)

	// ErrInvalidID is returned by the 'IDFromString' function when
	// the returned ID value is invalid or nil.
	ErrInvalidID = errors.New("id format is invalid or empty")
)
View Source
var (
	// IPv6 is a compile flag that enables or disables support for IPv6 networks
	// and addresses.
	IPv6 = true
)

Functions

func Expand

func Expand(s string) string

Expand attempts to determine environment variables from the current session and translate them in the supplied string.

Types

type ID

type ID []byte

ID is an alias for a byte array that represents a 48 byte client identification number. This is used for tracking and detection purposes.

func IDFromString

func IDFromString(s string) (ID, error)

IDFromString attempts to convert the hex string supplied into an ID value.

func (ID) FullString

func (i ID) FullString() string

FullString returns the full string representation of this ID instance.

func (ID) Hash

func (i ID) Hash() uint32

Hash returns the 32bit hash sum of this ID value. The hash mechanism used is similar to the hash/fnv mechanism.

func (ID) MarshalStream

func (i ID) MarshalStream(w data.Writer) error

MarshalStream writes the data of this ID to the supplied Writer.

func (ID) String

func (i ID) String() string

String returns a representation of this ID instance.

func (*ID) UnmarshalStream

func (i *ID) UnmarshalStream(r data.Reader) error

UnmarshalStream reads the data of this ID from the supplied Reader.

type Interface

type Interface struct {
	Name     string           `json:"name"`
	Address  []net.IP         `json:"address"`
	Hardware net.HardwareAddr `json:"mac"`
}

Interface is a struct that represents a Network interface that is active on the host system.

func (Interface) MarshalStream

func (i Interface) MarshalStream(w data.Writer) error

MarshalStream writes the data of this Interface to the supplied Writer.

func (Interface) String

func (i Interface) String() string

String returns the string representation of this Interface.

func (*Interface) UnmarshalStream

func (i *Interface) UnmarshalStream(r data.Reader) error

UnmarshalStream reads the data of this Interface from the supplied Reader.

type Machine

type Machine struct {
	ID       ID         `json:"id"`
	OS       deviceOS   `json:"os"`
	PID      uint64     `json:"pid"`
	PPID     uint64     `json:"ppid"`
	Arch     deviceArch `json:"arch"`
	User     string     `json:"user"`
	Version  string     `json:"version"`
	Network  Network    `json:"network"`
	Hostname string     `json:"hostname"`
	Elevated bool       `json:"elevated"`
}

Machine is a struct that contains information about a specific device. This struct contains generic Operating System Information such as Version, Arch and network information.

func (Machine) MarshalStream

func (m Machine) MarshalStream(w data.Writer) error

MarshalStream writes the data of this Machine from the supplied Writer.

func (*Machine) UnmarshalStream

func (m *Machine) UnmarshalStream(r data.Reader) error

UnmarshalStream reads the data of this Machine from the supplied Reader.

type Network

type Network []*Interface

Network is a basic listing of network interfaces. Used to store and refresh interface lists.

func (Network) MarshalStream

func (n Network) MarshalStream(w data.Writer) error

MarshalStream writes the data of this Network to the supplied Writer.

func (*Network) Refresh

func (n *Network) Refresh() error

Refresh collects the interfaces connected to this system and fills this Network object with the information. If previous Network information is contained in this Network object, it is cleared before filling.

func (*Network) UnmarshalStream

func (n *Network) UnmarshalStream(r data.Reader) error

UnmarshalStream reads the data of this Network from the supplied Reader.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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