Documentation ¶
Index ¶
- Constants
- Variables
- func Elevated() bool
- func Expand(s string) string
- func Hostname() string
- func PID() uint32
- func PPID() uint32
- func User() string
- type Address
- func (a Address) IP() net.IP
- func (a Address) Is4() bool
- func (a Address) Is6() bool
- func (a Address) IsBroadcast() bool
- func (a Address) IsGlobalUnicast() bool
- func (a Address) IsInterfaceLocalMulticast() bool
- func (a Address) IsLinkLocalMulticast() bool
- func (a Address) IsLinkLocalUnicast() bool
- func (a Address) IsLoopback() bool
- func (a Address) IsMulticast() bool
- func (a Address) IsPrivate() bool
- func (a Address) IsUnspecified() bool
- func (a Address) IsZero() bool
- func (a Address) Len() int
- func (a Address) MarshalJSON() ([]byte, error)
- func (a Address) MarshalStream(w data.Writer) error
- func (a Address) MarshalText() ([]byte, error)
- func (a *Address) Set(i net.IP)
- func (a Address) String() string
- func (a *Address) UnmarshalJSON(b []byte) error
- func (a *Address) UnmarshalStream(r data.Reader) error
- func (a *Address) UnmarshalText(b []byte) error
- type ID
- func (i ID) Empty() bool
- func (i ID) Equa1l(a ID) bool
- func (i ID) Full() string
- func (i ID) Hash() uint32
- func (i ID) Load(s string) error
- func (i ID) MarshalStream(w data.Writer) error
- func (i *ID) Read(r io.Reader) error
- func (i ID) Save(s string) error
- func (i *ID) Seed(b []byte)
- func (i ID) Signature() string
- func (i ID) String() string
- func (i *ID) UnmarshalStream(r data.Reader) error
- func (i ID) Write(w io.Writer) error
- type Machine
- type Network
Constants ¶
const ( // OS is the local machine's Operating System type. OS = Linux // Shell is the default machine specific command shell. Shell = "/bin/bash" // Newline is the machine specific newline character. Newline = "\n" )
const ( // IDSize is the amount of bytes used to store the Host ID and // SessionID values. The ID is the (HostID + SessionID). IDSize = 32 // 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 )
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 // Unsupported represents a device type that does not have direct support // any may not work properly. Unsupported deviceOS = 0x4 // 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 )
const IPv6 = true
IPv6 is a compile-time flag that enables (true) or disables (false) support for IPv6-based network addresses.
Variables ¶
var ( // UUID is the device specific and session specific identifier. UUID = getID() // Arch is the local machine's Architecture type. Arch = getArch() // Version is the local machine's Operating System version information. Version = getVersion() // Environment is a mapping of environment string names to their string values. Environment = getEnv() )
var Local = (&local{&Machine{ ID: UUID, OS: OS, PID: uint32(os.Getpid()), PPID: uint32(os.Getppid()), Arch: Arch, User: "Unknown", Version: Version, Network: make(Network, 0), Hostname: "Unknown", Elevated: isElevated(), }}).init()
Local is the pointer to the local machine instance. This instance is loaded at runtime and is used for local data gathering.
var ShellArgs = []string{"-c"}
ShellArgs is the default machine specific command shell arguments to run commands.
Functions ¶
Types ¶
type Address ¶ added in v0.1.0
type Address struct {
// contains filtered or unexported fields
}
Address represents an encoded IPv4 or IPv6 address.
The address struct was built on the great work from the great inet.af/netaddr package thanks and great work y'all! Godoc: https://pkg.go.dev/inet.af/netaddr https://tailscale.com/blog/netaddr-new-ip-type-for-go/
func FromIP ¶ added in v0.1.0
FromIP will create a new Address struct and set it's contents based on the value of the supplied 'net.IP'.
func ParseIP ¶ added in v0.1.0
ParseIP parses s as an IP address, returning the result. The string s can be in IPv4 dotted decimal ("192.0.2.1"), IPv6 ("2001:db8::68"), or IPv4-mapped IPv6 ("::ffff:192.0.2.1") form. If s is not a valid textual representation of an IP address, ParseIP returns nil.
func (Address) IP ¶ added in v0.1.0
IP returns a 'net.IP' copy of this address. This may be zero or empty depending on the type of address value this struct contains.
func (Address) Is4 ¶ added in v0.1.0
Is4 returns true if this struct represents an IPv4 based address or an IPv4 address wrapped in an IPv6 address.
func (Address) Is6 ¶ added in v0.1.0
Is6 returns true if this struct represents an IPv6 based address.
func (Address) IsBroadcast ¶ added in v0.1.0
IsBroadcast reports whether this is a broadcast address.
func (Address) IsGlobalUnicast ¶ added in v0.1.0
IsGlobalUnicast reports whether this is a global unicast address.
The identification of global unicast addresses uses address type identification as defined in RFC 1122, RFC 4632 and RFC 4291 with the exception of IPv4 directed broadcast addresses. It returns true even if this is in IPv4 private address space or local IPv6 unicast address space.
func (Address) IsInterfaceLocalMulticast ¶ added in v0.1.0
IsInterfaceLocalMulticast reports whether this is an interface-local multicast address.
func (Address) IsLinkLocalMulticast ¶ added in v0.1.0
IsLinkLocalMulticast reports whether this is a link-local multicast address.
func (Address) IsLinkLocalUnicast ¶ added in v0.1.0
IsLinkLocalUnicast reports whether this is a link-local unicast address.
func (Address) IsLoopback ¶ added in v0.1.0
IsLoopback reports whether this is a loopback address.
func (Address) IsMulticast ¶ added in v0.1.0
IsMulticast reports whether this is a multicast address.
func (Address) IsPrivate ¶ added in v0.1.0
IsPrivate reports whether ip is a private address, according to RFC 1918 (IPv4 addresses) and RFC 4193 (IPv6 addresses).
func (Address) IsUnspecified ¶ added in v0.1.0
IsUnspecified reports whether ip is an unspecified address, either the IPv4 address "0.0.0.0" or the IPv6 address "::". Same as 'IsZero'.
func (Address) IsZero ¶ added in v0.1.0
IsZero returns true if this struct represents an empty or unset address.
func (Address) Len ¶ added in v0.1.0
Len returns the size of this IP address. It returns '32' for IPv4 and '128' for IPv6.
func (Address) MarshalJSON ¶ added in v0.1.0
MarshalJSON implements the json.Marshaler interface.
func (Address) MarshalStream ¶ added in v0.1.0
MarshalStream writes the data of this Address to the supplied Writer.
func (Address) MarshalText ¶ added in v0.1.0
MarshalText implements the encoding.TextMarshaler interface.
func (*Address) Set ¶ added in v0.1.0
Set will set the internal values of this address to the specified 'net.IP' address.
func (*Address) UnmarshalJSON ¶ added in v0.1.0
UnmarshalJSON implements the json.Unmarshaler interface.
func (*Address) UnmarshalStream ¶ added in v0.1.0
UnmarshalStream reads the data of this Address from the supplied Reader.
func (*Address) UnmarshalText ¶ added in v0.1.0
UnmarshalText implements the encoding.TextUnmarshaler interface.
type ID ¶
ID is an alias for a byte array that represents a 32 byte client identification number. This is used for tracking and detection purposes.
The first byte and the machine ID byte should NEVER be zero, otherwise it signals an invalid ID value or missing a random identifier.
func (ID) Equa1l ¶ added in v0.1.0
Equal will return true if both ID values are equal in size and have the same Hash value.
func (ID) Hash ¶
Hash returns the 32bit hash sum of this ID value. The hash mechanism used is similar to the hash/fnv mechanism.
func (ID) Load ¶
Load will attempt to load the Session UUID from the specified file. This function will return an error if the file cannot be read or not found.
func (ID) MarshalStream ¶
MarshalStream transform this struct into a binary format and writes to the supplied data.Writer.
func (ID) Save ¶
Save will attempt to save the Session UUID to the specified file. This function will return an error if the file cannot be written to or created.
func (*ID) Seed ¶
Seed will set the random portion of the ID value to the specified byte array value.
func (ID) Signature ¶
Signature returns the signature portion of the ID value. This value is constant and unique for each device.
func (*ID) UnmarshalStream ¶
UnmarshalStream transforms this struct from a binary format that is read from the supplied data.Reader.
type Machine ¶
type Machine struct { User string Version string Hostname string Network Network PID, PPID uint32 ID ID Arch deviceArch OS deviceOS Elevated bool }
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 ¶
MarshalStream transforms this struct into a binary format and writes to the supplied data.Writer.
type Network ¶
type Network []device
Network is a basic listing of network interfaces. Used to store and refresh interface lists.
func (Network) MarshalStream ¶
MarshalStream writes the data of this Network to the supplied Writer.