mirror of
https://github.com/anotherhadi/spilltea.git
synced 2026-05-20 01:32:33 +02:00
upstream proxy
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -60,6 +60,7 @@ Check the default configuration with all the options [here](./internal/config/de
|
||||
| `--host` | | Proxy host, overrides config |
|
||||
| `--port` | `-p` | Proxy port, overrides config |
|
||||
| `--project` | `-P` | Project name to open directly, or `tmp` for a temporary session |
|
||||
| `--upstream-proxy` | | Upstream proxy URL, overrides config (e.g. `http://user:pass@host:8888`) |
|
||||
| `--version` | `-v` | Print version and exit |
|
||||
| `--add-default-plugins` | | Add the default plugins to your plugins dir and exit |
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
tea "charm.land/bubbletea/v2"
|
||||
spilltea "github.com/anotherhadi/spilltea"
|
||||
"github.com/anotherhadi/spilltea/internal/config"
|
||||
"github.com/anotherhadi/spilltea/internal/icons"
|
||||
"github.com/anotherhadi/spilltea/internal/intercept"
|
||||
"github.com/anotherhadi/spilltea/internal/keys"
|
||||
spilltea "github.com/anotherhadi/spilltea"
|
||||
"github.com/anotherhadi/spilltea/internal/style"
|
||||
appUI "github.com/anotherhadi/spilltea/internal/ui/app"
|
||||
homeUI "github.com/anotherhadi/spilltea/internal/ui/home"
|
||||
@@ -27,6 +27,7 @@ func main() {
|
||||
flagPluginsDir = flag.String("plugins-dir", "", "path to plugins dir (overrides config)")
|
||||
flagHost = flag.String("host", "", "proxy host (overrides config)")
|
||||
flagPort = flag.IntP("port", "p", 0, "proxy port (overrides config)")
|
||||
flagUpstreamProxy = flag.String("upstream-proxy", "", "upstream proxy URL, e.g. http://user:pass@host:8888 (overrides config)")
|
||||
flagVersion = flag.BoolP("version", "v", false, "print version")
|
||||
flagProject = flag.StringP("project", "P", "", `project name to open directly, or "tmp" for a temporary session`)
|
||||
flagAddDefaultPlugins = flag.Bool("add-default-plugins", false, "copy built-in example plugins into the plugins dir and exit")
|
||||
@@ -85,6 +86,9 @@ func main() {
|
||||
if *flagPort != 0 {
|
||||
config.Global.App.Port = *flagPort
|
||||
}
|
||||
if *flagUpstreamProxy != "" {
|
||||
config.Global.App.UpstreamProxy = *flagUpstreamProxy
|
||||
}
|
||||
|
||||
addr := fmt.Sprintf("%s:%d", config.Global.App.Host, config.Global.App.Port)
|
||||
// Check if the proxy port is available before starting the UI.
|
||||
|
||||
@@ -23,6 +23,7 @@ type Config struct {
|
||||
CertDir string `mapstructure:"cert_dir"`
|
||||
ProjectDir string `mapstructure:"project_dir"`
|
||||
PluginsDir string `mapstructure:"plugins_dir"`
|
||||
UpstreamProxy string `mapstructure:"upstream_proxy"`
|
||||
} `mapstructure:"app"`
|
||||
|
||||
TUI struct {
|
||||
|
||||
@@ -4,6 +4,7 @@ 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
|
||||
|
||||
intercept:
|
||||
default_intercept_enabled: true
|
||||
|
||||
@@ -108,6 +108,7 @@ func Start(broker *intercept.Broker, mgr *plugins.Manager) error {
|
||||
Addr: addr,
|
||||
StreamLargeBodies: 1024 * 1024 * 5,
|
||||
CaRootPath: caPath,
|
||||
Upstream: cfg.UpstreamProxy,
|
||||
}
|
||||
|
||||
p, err := goproxy.NewProxy(opts)
|
||||
|
||||
Reference in New Issue
Block a user