utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigFileName   = "xops_config.yaml"
	PasswordFileName = "xops_passwords.json"
	ConfigKeyName    = "secret.key"
)

Variables

This section is empty.

Functions

func GetConfigFilePath

func GetConfigFilePath() (configPath, keyPath string)

func GetConfigStore

GetConfigStore 返回配置存储、Provider、配置对象及其可能发生的错误

func GetCurrentUser

func GetCurrentUser() string

func GetLocalSudoPassword

func GetLocalSudoPassword() string

GetLocalSudoPassword 尝试从配置文件中获取本地 sudo 密码

func GetPasswordFilePath

func GetPasswordFilePath() string

func IsValidCIDR

func IsValidCIDR(cidrStr string) bool

IsValidCIDR 检查给定的字符串是否是有效的CIDR表示法

func IsValidIP

func IsValidIP(ipStr string) bool

IsValidIP 检查给定的字符串是否是有效的IP地址

func ParseAddr

func ParseAddr(input string) (string, string, uint16)

ParseAddr 解析 user@host:port 格式的字符串

func ParseHost

func ParseHost(input string) (string, uint16)

ParseHost 解析 host:port 格式的字符串

func ParsePort

func ParsePort(input string) uint16

ParsePort 解析端口字符串

func ReadPasswordFromTerminal

func ReadPasswordFromTerminal(prompt string) (string, error)

ReadPasswordFromTerminal 从终端安全地读取密码

Types

type HostInfo

type HostInfo struct {
	Host       string
	Port       uint16
	Alias      string
	User       string
	Password   string
	KeyPath    string
	Passphrase string
}

func ParseHosts

func ParseHosts(ip, hostFile, csvFile string) ([]HostInfo, error)

func ReadCSVFile

func ReadCSVFile(path string) ([]HostInfo, error)

Jump to

Keyboard shortcuts

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