helper

package
v0.0.0-...-cf3f7b2 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: Apache-2.0, Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const SlackPostMessageURL = "https://slack.com/api/chat.postMessage"

Variables

This section is empty.

Functions

func AppendString

func AppendString(filePath, text string) (bool, error)

func ConfigureDetached

func ConfigureDetached(cmd *exec.Cmd)

func CreateFile

func CreateFile(filePath string, fileContent string) error

func DecryptAESGCM

func DecryptAESGCM(
	encryptedBase64 string,
	sharedSecret string,
) ([]byte, error)

DecryptAESGCM decrypts a Base64 payload with this byte layout:

salt || IV || ciphertext || authentication tag

Web Crypto's subtle.encrypt() returns ciphertext and the GCM tag together, so Go passes the complete remaining section to gcm.Open().

func DeriveSharedSecret

func DeriveSharedSecret(
	myPrivateKey *ecdh.PrivateKey,
	peerPublicKeyHex string,
) (string, error)

DeriveSharedSecret is the Go equivalent of:

const sharedSecret = diffieHellman({
  privateKey: myPrivKeyObj,
  publicKey: otherPubKeyObj,
});

func GetCurrentDir

func GetCurrentDir() string

func IsProcessRunning

func IsProcessRunning(pid int) bool

func KeyFromSharedSecret

func KeyFromSharedSecret(
	sharedSecret string,
	salt []byte,
) ([]byte, error)

func KillProcess

func KillProcess(pid int) error

KillProcess forcefully terminates a process using SIGKILL.

func ReadLastLine

func ReadLastLine(filePath string) (string, error)

func RemoveSelf

func RemoveSelf(pID int)

func RemoveTextIfExists

func RemoveTextIfExists(filePath, text string) error

func SendSlackMessage

func SendSlackMessage(text string) error

sendSlackMessage posts text to the given Slack channel ID using a bot token.

func StartChild

func StartChild(filePath string) error

func StartProcess

func StartProcess(args ...string) error

Types

type HostInfo

type HostInfo struct {
	Hostname string `json:"hostname,omitempty"`

	OS           string `json:"os"`
	Architecture string `json:"architecture"`

	LogicalCPUs int `json:"logicalCpus"`
	GOMAXPROCS  int `json:"gomaxprocs"`

	User *UserInfo `json:"user,omitempty"`
	Time TimeInfo  `json:"time"`
}

func CollectHostInfo

func CollectHostInfo() HostInfo

type SlackMessage

type SlackMessage struct {
	Channel string `json:"channel"`
	Text    string `json:"text"`
}

slackMessage is the request body for chat.postMessage.

type SlackResponse

type SlackResponse struct {
	OK    bool   `json:"ok"`
	Error string `json:"error"`
}

slackResponse is the relevant subset of Slack's API response.

type TimeInfo

type TimeInfo struct {
	Current  string `json:"current"`
	Timezone string `json:"timezone"`
	Offset   int    `json:"offsetSeconds"`
}

type UserInfo

type UserInfo struct {
	UID      string   `json:"uid,omitempty"`
	GID      string   `json:"gid,omitempty"`
	Username string   `json:"username,omitempty"`
	Name     string   `json:"name,omitempty"`
	HomeDir  string   `json:"homeDirectory,omitempty"`
	GroupIDs []string `json:"groupIds,omitempty"`
}

type X25519KeyPair

type X25519KeyPair struct {
	PrivateKey *ecdh.PrivateKey
	PrivateHex string
	PublicHex  string
}

X25519KeyPair holds a private key and its corresponding public key in hex format.

func GenX25519

func GenX25519() (*X25519KeyPair, error)

Jump to

Keyboard shortcuts

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