mirror of
https://github.com/anotherhadi/spilltea.git
synced 2026-05-20 09:42:34 +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 |
|
| `--host` | | Proxy host, overrides config |
|
||||||
| `--port` | `-p` | Proxy port, overrides config |
|
| `--port` | `-p` | Proxy port, overrides config |
|
||||||
| `--project` | `-P` | Project name to open directly, or `tmp` for a temporary session |
|
| `--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 |
|
| `--version` | `-v` | Print version and exit |
|
||||||
| `--add-default-plugins` | | Add the default plugins to your plugins dir and exit |
|
| `--add-default-plugins` | | Add the default plugins to your plugins dir and exit |
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
tea "charm.land/bubbletea/v2"
|
tea "charm.land/bubbletea/v2"
|
||||||
|
spilltea "github.com/anotherhadi/spilltea"
|
||||||
"github.com/anotherhadi/spilltea/internal/config"
|
"github.com/anotherhadi/spilltea/internal/config"
|
||||||
"github.com/anotherhadi/spilltea/internal/icons"
|
"github.com/anotherhadi/spilltea/internal/icons"
|
||||||
"github.com/anotherhadi/spilltea/internal/intercept"
|
"github.com/anotherhadi/spilltea/internal/intercept"
|
||||||
"github.com/anotherhadi/spilltea/internal/keys"
|
"github.com/anotherhadi/spilltea/internal/keys"
|
||||||
spilltea "github.com/anotherhadi/spilltea"
|
|
||||||
"github.com/anotherhadi/spilltea/internal/style"
|
"github.com/anotherhadi/spilltea/internal/style"
|
||||||
appUI "github.com/anotherhadi/spilltea/internal/ui/app"
|
appUI "github.com/anotherhadi/spilltea/internal/ui/app"
|
||||||
homeUI "github.com/anotherhadi/spilltea/internal/ui/home"
|
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)")
|
flagPluginsDir = flag.String("plugins-dir", "", "path to plugins dir (overrides config)")
|
||||||
flagHost = flag.String("host", "", "proxy host (overrides config)")
|
flagHost = flag.String("host", "", "proxy host (overrides config)")
|
||||||
flagPort = flag.IntP("port", "p", 0, "proxy port (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")
|
flagVersion = flag.BoolP("version", "v", false, "print version")
|
||||||
flagProject = flag.StringP("project", "P", "", `project name to open directly, or "tmp" for a temporary session`)
|
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")
|
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 {
|
if *flagPort != 0 {
|
||||||
config.Global.App.Port = *flagPort
|
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)
|
addr := fmt.Sprintf("%s:%d", config.Global.App.Host, config.Global.App.Port)
|
||||||
// Check if the proxy port is available before starting the UI.
|
// Check if the proxy port is available before starting the UI.
|
||||||
|
|||||||
@@ -18,11 +18,12 @@ type Config struct {
|
|||||||
Version string `mapstructure:"-"`
|
Version string `mapstructure:"-"`
|
||||||
|
|
||||||
App struct {
|
App struct {
|
||||||
Host string `mapstructure:"host"`
|
Host string `mapstructure:"host"`
|
||||||
Port int `mapstructure:"port"`
|
Port int `mapstructure:"port"`
|
||||||
CertDir string `mapstructure:"cert_dir"`
|
CertDir string `mapstructure:"cert_dir"`
|
||||||
ProjectDir string `mapstructure:"project_dir"`
|
ProjectDir string `mapstructure:"project_dir"`
|
||||||
PluginsDir string `mapstructure:"plugins_dir"`
|
PluginsDir string `mapstructure:"plugins_dir"`
|
||||||
|
UpstreamProxy string `mapstructure:"upstream_proxy"`
|
||||||
} `mapstructure:"app"`
|
} `mapstructure:"app"`
|
||||||
|
|
||||||
TUI struct {
|
TUI struct {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ app:
|
|||||||
cert_dir: ~/.local/share/spilltea
|
cert_dir: ~/.local/share/spilltea
|
||||||
project_dir: ~/.local/share/spilltea
|
project_dir: ~/.local/share/spilltea
|
||||||
plugins_dir: ~/.config/spilltea/plugins
|
plugins_dir: ~/.config/spilltea/plugins
|
||||||
|
upstream_proxy: "" # e.g. http://corporate-proxy:8888 or http://user:pass@host:8888
|
||||||
|
|
||||||
intercept:
|
intercept:
|
||||||
default_intercept_enabled: true
|
default_intercept_enabled: true
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ func Start(broker *intercept.Broker, mgr *plugins.Manager) error {
|
|||||||
Addr: addr,
|
Addr: addr,
|
||||||
StreamLargeBodies: 1024 * 1024 * 5,
|
StreamLargeBodies: 1024 * 1024 * 5,
|
||||||
CaRootPath: caPath,
|
CaRootPath: caPath,
|
||||||
|
Upstream: cfg.UpstreamProxy,
|
||||||
}
|
}
|
||||||
|
|
||||||
p, err := goproxy.NewProxy(opts)
|
p, err := goproxy.NewProxy(opts)
|
||||||
|
|||||||
Reference in New Issue
Block a user