- go.mod with Wails v2.9.2, x/crypto, go-sqlite3, go-keyring, uuid - cmd/app/main.go: Wails entry point (Nexus Terminal, 1400x900, #1a1a2e) - internal/app/app.go: lifecycle (Startup/Shutdown/DomReady) - internal/models/models.go: full model definitions (Profile, SSHConfig, TelnetConfig, RAWConfig, SessionInfo, KnownHost, AppPreferences, etc.) - internal/models/defaults.go: default values and NewProfile factory - internal/validation/validation.go: thorough field-level validation - frontend/embed.go: embedded frontend assets - Updated existing storage, secrets, config to match new model structure
103 lines
2.6 KiB
Go
103 lines
2.6 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// Default port numbers for each protocol.
|
|
const (
|
|
DefaultSSHPort = 22
|
|
DefaultTelnetPort = 23
|
|
DefaultRAWPort = 23
|
|
)
|
|
|
|
// Default timeout values (in seconds).
|
|
const (
|
|
DefaultConnectTimeout = 30
|
|
DefaultReadTimeout = 0 // no timeout
|
|
)
|
|
|
|
// Default terminal rendering settings.
|
|
const (
|
|
DefaultScrollback = 10000
|
|
DefaultFontSize = 14
|
|
DefaultFontFamily = "JetBrains Mono, Menlo, Monaco, Consolas, monospace"
|
|
DefaultCursorStyle = "block"
|
|
DefaultTerminalType = "xterm-256color"
|
|
)
|
|
|
|
// Default SSH keepalive settings.
|
|
const (
|
|
DefaultKeepaliveInterval = 30
|
|
DefaultKeepaliveCountMax = 3
|
|
)
|
|
|
|
// DefaultAppPreferences returns sensible default application preferences.
|
|
func DefaultAppPreferences() AppPreferences {
|
|
return AppPreferences{
|
|
Theme: "dark",
|
|
DefaultProtocol: string(ProtocolSSH),
|
|
ConfirmOnClose: true,
|
|
ConfirmOnDisconnect: true,
|
|
ShowStatusBar: true,
|
|
SidebarWidth: 280,
|
|
DefaultFontFamily: DefaultFontFamily,
|
|
DefaultFontSize: DefaultFontSize,
|
|
DefaultScrollback: DefaultScrollback,
|
|
DefaultCursorStyle: DefaultCursorStyle,
|
|
}
|
|
}
|
|
|
|
// NewProfile creates a new Profile with sensible defaults for the given protocol.
|
|
func NewProfile(protocol Protocol) Profile {
|
|
now := time.Now()
|
|
p := Profile{
|
|
ID: uuid.New().String(),
|
|
Protocol: protocol,
|
|
Tags: []string{},
|
|
ConnectTimeout: DefaultConnectTimeout,
|
|
ReadTimeout: DefaultReadTimeout,
|
|
TerminalFontFamily: DefaultFontFamily,
|
|
TerminalFontSize: DefaultFontSize,
|
|
TerminalScrollback: DefaultScrollback,
|
|
TerminalCursorStyle: DefaultCursorStyle,
|
|
CreatedAt: now,
|
|
UpdatedAt: now,
|
|
}
|
|
|
|
switch protocol {
|
|
case ProtocolSSH:
|
|
p.Port = DefaultSSHPort
|
|
p.SSH = &SSHConfig{
|
|
AuthMethods: []string{"publickey", "password", "keyboard-interactive"},
|
|
SecretMode: SecretModeAskEveryTime,
|
|
KeySecretMode: SecretModeAskEveryTime,
|
|
HostKeyPolicy: HostKeyAsk,
|
|
TerminalType: DefaultTerminalType,
|
|
KeepaliveInterval: DefaultKeepaliveInterval,
|
|
KeepaliveCountMax: DefaultKeepaliveCountMax,
|
|
JumpHosts: []JumpHost{},
|
|
EnvVars: map[string]string{},
|
|
}
|
|
case ProtocolTelnet:
|
|
p.Port = DefaultTelnetPort
|
|
p.Telnet = &TelnetConfig{
|
|
LocalEcho: false,
|
|
LineEnding: LineEndingCRLF,
|
|
TerminalType: DefaultTerminalType,
|
|
Encoding: "utf-8",
|
|
}
|
|
case ProtocolRAW:
|
|
p.Port = DefaultRAWPort
|
|
p.RAW = &RAWConfig{
|
|
LineEnding: LineEndingCRLF,
|
|
Encoding: "utf-8",
|
|
PayloadPresets: []PayloadPreset{},
|
|
}
|
|
}
|
|
|
|
return p
|
|
}
|