utils

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: Apache-2.0 Imports: 14 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSigners

func CreateSigners(privateKeys [][]byte) ([]ssh.Signer, error)

func CreateUptermRuntimeDir added in v0.18.0

func CreateUptermRuntimeDir() (string, error)

CreateUptermRuntimeDir creates the runtime directory for sockets. Mode 0700 ensures only the current user can access sockets.

func DefaultLocalhost

func DefaultLocalhost(defaultPort string) string

func FingerprintSHA256

func FingerprintSHA256(key ssh.PublicKey) string

func GenerateSessionID

func GenerateSessionID() string

func KeysEqual added in v0.10.0

func KeysEqual(pk1 ssh.PublicKey, pk2 ssh.PublicKey) bool

func ReadFiles

func ReadFiles(paths []string) ([][]byte, error)

func ShortenHomePath added in v0.22.0

func ShortenHomePath(path string) string

ShortenHomePath replaces the home directory prefix with ~ for cleaner display. If the path doesn't start with home directory, it's returned unchanged. Always uses forward slash after ~ for consistency across platforms.

func UptermConfigDir added in v0.18.0

func UptermConfigDir() string

UptermConfigDir returns the directory for configuration files.

Following the XDG Base Directory Specification, this directory maps to XDG_CONFIG_HOME/upterm and persists across sessions.

Directory selection priority:

  1. $XDG_CONFIG_HOME/upterm (if XDG_CONFIG_HOME is explicitly set)
  2. Platform default if accessible: - Linux: ~/.config/upterm - macOS: ~/Library/Application Support/upterm - Windows: %LOCALAPPDATA%\upterm
  3. Fallback: $HOME/.upterm
  4. Final fallback: os.TempDir()/.upterm (if HOME unavailable)

func UptermConfigFilePath added in v0.18.0

func UptermConfigFilePath() string

UptermConfigFilePath returns the path to the config file.

Following the XDG Base Directory Specification, this file is stored in XDG_CONFIG_HOME/upterm and persists across sessions.

Platform-specific paths:

  • Linux: ~/.config/upterm/config.yaml
  • macOS: ~/Library/Application Support/upterm/config.yaml
  • Windows: %LOCALAPPDATA%\upterm\config.yaml

Note: The config file is optional and created manually by users.

func UptermLogFilePath added in v0.16.0

func UptermLogFilePath() string

UptermLogFilePath returns the path to the log file in the state directory.

Following the XDG Base Directory Specification, this file is stored in XDG_STATE_HOME/upterm and persists across sessions.

Platform-specific paths:

  • Linux: ~/.local/state/upterm/upterm.log
  • macOS: ~/Library/Application Support/upterm/upterm.log
  • Windows: %LOCALAPPDATA%\upterm\upterm.log

Note: The directory is created lazily by the logging system when the file is opened.

func UptermRuntimeDir added in v0.18.0

func UptermRuntimeDir() string

UptermRuntimeDir returns the directory for runtime files (sockets).

Following the XDG Base Directory Specification, this directory maps to XDG_RUNTIME_DIR/upterm when available and is typically cleaned on logout/reboot.

Directory selection priority:

  1. $XDG_RUNTIME_DIR/upterm (if XDG_RUNTIME_DIR is explicitly set)
  2. Platform default if accessible: - Linux: /run/user/1000/upterm (requires login session) - macOS: $TMPDIR/upterm (e.g., /var/folders/.../T/upterm) - Windows: %LOCALAPPDATA%\upterm
  3. Fallback: $HOME/.upterm (for non-interactive environments)
  4. Final fallback: os.TempDir()/.upterm (if HOME unavailable)

func UptermStateDir added in v0.18.0

func UptermStateDir() string

UptermStateDir returns the directory for state files (logs).

Following the XDG Base Directory Specification, this directory maps to XDG_STATE_HOME/upterm and persists across sessions.

Directory selection priority:

  1. $XDG_STATE_HOME/upterm (if XDG_STATE_HOME is explicitly set)
  2. Platform default if accessible: - Linux: ~/.local/state/upterm - macOS: ~/Library/Application Support/upterm - Windows: %LOCALAPPDATA%\upterm
  3. Fallback: $HOME/.upterm
  4. Final fallback: os.TempDir()/.upterm (if HOME unavailable)

func WaitForServer

func WaitForServer(ctx context.Context, addr string) error

WaitForServer waits for a server to be available at the given address with context support

Types

This section is empty.

Jump to

Keyboard shortcuts

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