util

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const HostIPToken = "${{ host_ip }}"

HostIPToken is a template function usable in any address value (e.g. server.agent_endpoint): `${{ host_ip }}:3010` renders to the host's IP address at startup. Agents run inside containers and cannot reach the host via 127.0.0.1, so endpoints advertised to them need the real interface IP. The ${{ }} delimiters match knot's template variable style (used to avoid clashing with Nomad interpolation); any spacing inside them works.

Variables

View Source
var Timezones = []string{}/* 575 elements not displayed */

Functions

func CheckShells

func CheckShells(preferredShell string) string

func ConvertToBytes

func ConvertToBytes(input string) (int64, error)

func CopyFields

func CopyFields(src, dst interface{}, fields []string) error

CopyFields copies specified fields from src to dst using reflection.

func DecryptSSHPrivateKey added in v0.25.0

func DecryptSSHPrivateKey(encryptionKey string, privateKey string) string

func DownloadUnpackTgz

func DownloadUnpackTgz(downloadURL string, destDir string) error

func FixListenAddress

func FixListenAddress(address string) string

func GenerateCertificate

func GenerateCertificate(dnsNames []string, ipAddresses []net.IP) (string, string, error)

GenerateCertificate generates a self-signed certificate and private key in PEM format.

func GetGitHubKeys

func GetGitHubKeys(username string) (string, error)

Download the public keys from GitHub, https://github.com/<username>.keys

func GetGitHubKeysArray

func GetGitHubKeysArray(username string) ([]string, error)

func GetLocalIP

func GetLocalIP() (string, error)

Get the local IP address of the machine we're running on, interfaces are checked for being up.

func HideConsoleIfOwned added in v0.33.0

func HideConsoleIfOwned()

HideConsoleIfOwned is a no-op outside Windows.

func HostIP added in v0.33.0

func HostIP() string

HostIP returns the host's primary outbound IPv4 address. Physical interfaces are preferred — virtual interfaces (VPN/tailscale tunnels, docker/veth bridges) and their address ranges (CGNAT 100.64/10, link-local) are skipped first so advertised endpoints stay on durable addresses. If no physical candidate exists (e.g. a host only reachable via VPN) it falls back to the address the routing table would use for an external destination (UDP dial sends no packets), then to any non-loopback IPv4, then to loopback.

func InArray

func InArray(slice []string, item string) bool

Checks if a string is in a slice of strings.

func NewCopier

func NewCopier(socket net.Conn, wsConnection *websocket.Conn) *copierConnections

func OpenBrowser added in v0.33.0

func OpenBrowser(url string) error

OpenBrowser opens the specified URL in the default browser of the user. On Windows rundll32 is used rather than `cmd /c start` because cmd is a console application and would flash (or leave) a console window every time the tray menu opens the UI.

func PrettyPrintJSON added in v0.19.0

func PrettyPrintJSON(v interface{}) error

func PrintTable

func PrintTable(table [][]string)

func RedirectToSyslog

func RedirectToSyslog(cmd *exec.Cmd)

func RelaunchHidden added in v0.33.0

func RelaunchHidden() bool

RelaunchHidden is a no-op outside Windows.

func ResolveHostIP added in v0.33.0

func ResolveHostIP(s string) string

ResolveHostIP renders any template functions in an address using the address funcs (currently host_ip). knot-style `${{ func }}` delimiters are normalised to Go template actions first so the $ is consumed. Strings that are not templates — or that fail to parse or execute — are returned unchanged, so plain addresses pass through untouched.

func SplitSSHPublicKeys added in v0.25.0

func SplitSSHPublicKeys(keys string) []string

func UpdateAuthorizedKeys

func UpdateAuthorizedKeys(keys []string, githubUsernames []string) error

func UpdateSSHConfig

func UpdateSSHConfig(sshConfig string, alias string) error

func UpdateSSHPrivateKey added in v0.25.0

func UpdateSSHPrivateKey(privateKey string) error

func UpgradeToWS

func UpgradeToWS(w http.ResponseWriter, r *http.Request) *websocket.Conn

Upgrade the connection to a websocket connection

Types

type CommandFrontmatter added in v0.29.0

type CommandFrontmatter struct {
	Name         string
	Description  string
	ArgumentHint string
	AllowedTools []string
}

func ParseCommandFrontmatter added in v0.29.0

func ParseCommandFrontmatter(content string) (*CommandFrontmatter, error)

type SkillFrontmatter added in v0.23.0

type SkillFrontmatter struct {
	Name        string
	Description string
}

func ParseSkillFrontmatter added in v0.23.0

func ParseSkillFrontmatter(content string) (*SkillFrontmatter, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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