fix: add ssl_insecure, expand values, edit keybindings, ...

Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
Hadi
2026-05-29 21:59:54 +02:00
parent 61a112a302
commit acee3df1bc
14 changed files with 100 additions and 43 deletions
+18 -1
View File
@@ -28,6 +28,7 @@ type Config struct {
ProxyAuth string `mapstructure:"proxy_auth"`
MaxBodySizeMB int `mapstructure:"max_body_size_mb"`
ExternalEditor string `mapstructure:"external_editor"`
SslInsecure bool `mapstructure:"ssl_insecure"`
} `mapstructure:"app"`
TUI struct {
@@ -82,7 +83,12 @@ func Load(path string) error {
}
Global = &Config{}
return viper.Unmarshal(Global)
if err := viper.Unmarshal(Global); err != nil {
return err
}
Global.App.ProxyAuth = expandEnvValue(Global.App.ProxyAuth)
Global.App.UpstreamProxy = expandEnvValue(Global.App.UpstreamProxy)
return nil
}
func WriteDefaultConfig(path string) error {
@@ -106,6 +112,17 @@ func ExpandPath(p string) string {
return p
}
// expandEnvValue replaces a value starting with "$" with the corresponding
// environment variable, enabling secrets to be kept out of config files.
func expandEnvValue(s string) string {
if len(s) > 1 && s[0] == '$' {
if val := os.Getenv(s[1:]); val != "" {
return val
}
}
return s
}
func flatten(prefix string, m map[string]any) map[string]any {
out := make(map[string]any)
for k, v := range m {
+5 -3
View File
@@ -4,15 +4,16 @@ app:
cert_dir: ~/.local/share/spilltea
project_dir: ~/.local/share/spilltea
plugins_dir: ~/.config/spilltea/plugins
upstream_proxy: "" # e.g. http://corporate-proxy:8888 or http://user:pass@host:8888
proxy_auth: "" # require basic auth to use the proxy, format: user:pass (empty = disabled). Also run: chmod 600 ~/.config/spilltea/config.yaml
upstream_proxy: "" # e.g. http://corporate-proxy:8888 or $ENV_VAR
proxy_auth: "" # require basic auth to use the spilltea proxy, format: user:pass or $ENV_VAR (empty = disabled).
max_body_size_mb: 50 # max response body size read into memory for large streamed responses (MB)
external_editor: "" # override $EDITOR for external editing (e.g. nvim, code --wait)
ssl_insecure: false # bypass TLS certificate verification (enable for self-signed cert targets)
intercept:
default_intercept_enabled: true
default_capture_response: false
queue_size: 64 # max pending intercepted requests/responses before the proxy blocks
queue_size: 128 # max pending intercepted requests/responses before the proxy blocks
auto_forward_regex:
- '\.(js|css|png|gif|ico|woff2?|ttf|svg)(\?.*)?$'
@@ -31,6 +32,7 @@ tui:
keybindings:
global:
quit: "q,ctrl+c"
escape: "esc,ctrl+c"
help: "?"
open_logs: "ctrl+g"
toggle_sidebar: "ctrl+b"
+1
View File
@@ -2,6 +2,7 @@ package config
type GlobalKeys struct {
Quit string `mapstructure:"quit"`
Escape string `mapstructure:"escape"`
OpenLogs string `mapstructure:"open_logs"`
ToggleSidebar string `mapstructure:"toggle_sidebar"`
Help string `mapstructure:"help"`