summaryrefslogtreecommitdiff
path: root/internal/config
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-03 10:45:50 +0200
committerPaul Buetow <paul@buetow.org>2026-03-03 10:45:50 +0200
commit2de007f9ef8ae2724b9fbe2808ee25cbfe4ca876 (patch)
treef91a742d682928ef12eb5a011411c3bb0ef16a02 /internal/config
parent6d50a475114699911f2ebe1376915cd8317f1881 (diff)
feat(config): add auth-key CLI and server cache settings
Diffstat (limited to 'internal/config')
-rw-r--r--internal/config/args.go2
-rw-r--r--internal/config/client.go22
-rw-r--r--internal/config/initializer.go16
-rw-r--r--internal/config/server.go6
4 files changed, 45 insertions, 1 deletions
diff --git a/internal/config/args.go b/internal/config/args.go
index a026e1c..d612e21 100644
--- a/internal/config/args.go
+++ b/internal/config/args.go
@@ -23,6 +23,7 @@ type Args struct {
Logger string
LogLevel string
Mode omode.Mode
+ NoAuthKey bool
NoColor bool
QueryStr string
Quiet bool
@@ -56,6 +57,7 @@ func (a *Args) String() string {
sb.WriteString(fmt.Sprintf("%s:%v,", "LogLevel", a.LogLevel))
sb.WriteString(fmt.Sprintf("%s:%v,", "Logger", a.Logger))
sb.WriteString(fmt.Sprintf("%s:%v,", "Mode", a.Mode))
+ sb.WriteString(fmt.Sprintf("%s:%v,", "NoAuthKey", a.NoAuthKey))
sb.WriteString(fmt.Sprintf("%s:%v,", "NoColor", a.NoColor))
sb.WriteString(fmt.Sprintf("%s:%v,", "QueryStr", a.QueryStr))
sb.WriteString(fmt.Sprintf("%s:%v,", "Quiet", a.Quiet))
diff --git a/internal/config/client.go b/internal/config/client.go
index 9f4df97..60c7bc5 100644
--- a/internal/config/client.go
+++ b/internal/config/client.go
@@ -1,6 +1,10 @@
package config
-import "github.com/mimecast/dtail/internal/color"
+import (
+ "os"
+
+ "github.com/mimecast/dtail/internal/color"
+)
type remoteTermColors struct {
DelimiterAttr color.Attribute
@@ -104,12 +108,16 @@ type termColors struct {
type ClientConfig struct {
TermColorsEnable bool `json:",omitempty"`
TermColors termColors `json:",omitempty"`
+ AuthKeyPath string `json:",omitempty"`
+ AuthKeyDisable bool `json:",omitempty"`
}
// Create a new default client configuration.
func newDefaultClientConfig() *ClientConfig {
return &ClientConfig{
TermColorsEnable: true,
+ AuthKeyPath: defaultAuthKeyPath(),
+ AuthKeyDisable: false,
TermColors: termColors{
Remote: remoteTermColors{
DelimiterAttr: color.AttrDim,
@@ -198,3 +206,15 @@ func newDefaultClientConfig() *ClientConfig {
},
}
}
+
+func defaultAuthKeyPath() string {
+ homeDir, err := os.UserHomeDir()
+ if err != nil || homeDir == "" {
+ homeDir = os.Getenv("HOME")
+ }
+ if homeDir == "" {
+ return "~/.ssh/id_rsa"
+ }
+
+ return homeDir + "/.ssh/id_rsa"
+}
diff --git a/internal/config/initializer.go b/internal/config/initializer.go
index 146d1a0..b540457 100644
--- a/internal/config/initializer.go
+++ b/internal/config/initializer.go
@@ -92,6 +92,10 @@ func (in *initializer) processEnvVars(args *Args) {
if len(sshPrivateKeyPathFile) > 0 && args.SSHPrivateKeyFilePath == "" {
args.SSHPrivateKeyFilePath = sshPrivateKeyPathFile
}
+ authKeyPath := os.Getenv("DTAIL_AUTH_KEY_PATH")
+ if len(authKeyPath) > 0 && args.SSHPrivateKeyFilePath == "" {
+ args.SSHPrivateKeyFilePath = authKeyPath
+ }
// Check if turbo boost should be disabled from environment variable
// Turbo boost is enabled by default, can be explicitly disabled
if Env("DTAIL_TURBOBOOST_DISABLE") {
@@ -113,6 +117,18 @@ func (in *initializer) setupConfig(sourceCb transformCb, args *Args,
if args.NoColor {
in.Client.TermColorsEnable = false
}
+ if args.NoAuthKey {
+ in.Client.AuthKeyDisable = true
+ }
+ if in.Client.AuthKeyDisable {
+ args.NoAuthKey = true
+ }
+ if args.SSHPrivateKeyFilePath == "" {
+ args.SSHPrivateKeyFilePath = in.Client.AuthKeyPath
+ }
+ if args.SSHPrivateKeyFilePath != "" {
+ in.Client.AuthKeyPath = args.SSHPrivateKeyFilePath
+ }
if args.LogDir != "" {
in.Common.LogDir = args.LogDir
}
diff --git a/internal/config/server.go b/internal/config/server.go
index d0986d6..13ebde8 100644
--- a/internal/config/server.go
+++ b/internal/config/server.go
@@ -74,6 +74,10 @@ type ServerConfig struct {
TurboBoostDisable bool `json:",omitempty"`
// Enable in-memory auth-key registration and fast reconnect.
AuthKeyEnabled bool `json:",omitempty"`
+ // Auth-key cache entry TTL in seconds.
+ AuthKeyTTLSeconds int `json:",omitempty"`
+ // Maximum number of cached auth keys per user.
+ AuthKeyMaxPerUser int `json:",omitempty"`
// Retry interval for glob retries in milliseconds.
ReadGlobRetryIntervalMs int `json:",omitempty"`
// Retry interval for re-reading in tail/cat loops in milliseconds.
@@ -122,6 +126,8 @@ func newDefaultServerConfig() *ServerConfig {
},
TurboBoostDisable: false, // Default to false, meaning turbo boost is enabled by default
AuthKeyEnabled: true,
+ AuthKeyTTLSeconds: 86400,
+ AuthKeyMaxPerUser: 5,
ReadGlobRetryIntervalMs: 5000,
ReadRetryIntervalMs: 2000,
ReadAggregateLineBufferSize: 10000,