utils

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSystemCommandFor

func BuildSystemCommandFor(cmd string) []string

BuildSystemCommandFor builds up the commands to wrap the given one into a scheduled task executed in SYSTEM scope.

func CheckTestSigningAttribute added in v0.2.3

func CheckTestSigningAttribute(provider CmdOutputProvider) (bool, error)

func CondenseNetWithPortRange

func CondenseNetWithPortRange(nwps []akn.NetWithPortRange, limit int) []akn.NetWithPortRange

CondenseNetWithPortRange condenses a list of NetWithPortRange The way this algorithm works: 1. Sort the nwp list ascending by BaseIP and port 2. For each nwp in the list create a new nwp with the next neighbor if port-ranges are compatible 3. From the new list choose the nwp with the longest prefix length, remove all nwp witch are included in the chosen and add the chosen nwp to the result list 4. Repeat 3. until either the list is shorter than limit or no more compatible nwp are found

func ExecutePowershellCommand

func ExecutePowershellCommand(ctx context.Context, cmds []string, shell Shell) (string, error)

ExecutePowershellCommand runs the given commands in a powershell session. Callers must make sure that passed in commands are properly sanitizes.

func GetAvailableDriveLetters added in v0.2.0

func GetAvailableDriveLetters() ([]string, error)

func GetDriveSpace added in v0.2.0

func GetDriveSpace(driveLetter string, kind DriveSpace) (uint64, error)

func IsExecutableOperational added in v0.2.0

func IsExecutableOperational(executableName string, args ...string) error

func IsProcessRunning added in v0.2.0

func IsProcessRunning(processName string) (bool, error)

func IsTestSigningEnabled added in v0.2.3

func IsTestSigningEnabled() (bool, error)

func MapToNetworks

func MapToNetworks(ctx context.Context, ipsOrCidrsOrHostnames ...string) ([]net.IPNet, error)

func ParsePortRanges

func ParsePortRanges(raw []string) ([]akn.PortRange, error)

func PowershellCommand added in v0.2.0

func PowershellCommand(args ...string) *exec.Cmd

func Resolve

func Resolve(ctx context.Context, hostnames ...string) ([]net.IP, error)

func SanitizePowershellArg

func SanitizePowershellArg(arg string) string

func SanitizePowershellArgs

func SanitizePowershellArgs(args ...string) []string

func StopProcess added in v0.2.0

func StopProcess(processName string) error

Types

type CmdOutputProvider added in v0.2.3

type CmdOutputProvider func() ([]byte, error)

type DriveSpace added in v0.2.0

type DriveSpace string
const (
	Available DriveSpace = "SizeRemaining"
	Total     DriveSpace = "Size"
)

type HostnameInput

type HostnameInput struct {
	Records  []string
	Hostname string
}

func (*HostnameInput) Resolve

func (i *HostnameInput) Resolve(ctx context.Context) (*HostnameOutput, error)

type HostnameOutput

type HostnameOutput struct {
	IPAddresses []net.IP
}

type HostnameResolver

type HostnameResolver struct {
}

func (*HostnameResolver) Resolve

func (h *HostnameResolver) Resolve(ctx context.Context, hostnames ...string) ([]net.IP, error)

type Shell

type Shell = string
const (
	PSStart Shell = "PSStart"
	PSRun   Shell = "PSRun"
)

Jump to

Keyboard shortcuts

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