Documentation
¶
Index ¶
- Variables
- func GetTransportLayer(protocol string) string
- func InitFlag()
- type App
- func (app *App) Do(resp http.ResponseWriter, r *http.Request, cfg *ProxyConfig, ...) (err error)
- func (app *App) InitConfig(ctx context.Context) (res any, err error)
- func (app *App) ListenHttpPort(scheme string, cfg ProxyConfig, urlp *url.URL)
- func (app *App) ListenSSHTunnel(cfg ProxyConfig)
- func (app *App) ProxyBackend(resp http.ResponseWriter, r *http.Request, cfg *ProxyConfig, ...) (err error)
- func (app *App) ProxyStatic(resp http.ResponseWriter, r *http.Request, cfg *ProxyConfig, ...) bool
- func (app *App) Reload(ctx context.Context) (res any, err error)
- func (app *App) Run(ctx context.Context) (res any, err error)
- func (app *App) ServeHTTP(resp http.ResponseWriter, r *http.Request)
- func (app *App) Stop(ctx context.Context) (res any, err error)
- type Config
- type Interrupt
- type JavaScriptInterrupt
- type ProxyConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ConfigFile *string
Functions ¶
func GetTransportLayer ¶
Types ¶
type App ¶
type App struct {
Config *Config
ProxyMapLock *sync.Mutex
ProxyList []*ProxyConfig
SSHTunnelMap map[string]any //ssh 隧道
ListenMap map[string]any //http 代理
}
func (*App) Do ¶
func (app *App) Do(resp http.ResponseWriter, r *http.Request, cfg *ProxyConfig, url, RequestURI string) (err error)
func (*App) ListenHttpPort ¶
func (app *App) ListenHttpPort(scheme string, cfg ProxyConfig, urlp *url.URL)
监听本地端口
func (*App) ListenSSHTunnel ¶
func (app *App) ListenSSHTunnel(cfg ProxyConfig)
func (*App) ProxyBackend ¶
func (app *App) ProxyBackend(resp http.ResponseWriter, r *http.Request, cfg *ProxyConfig, frontendUrl, RequestURI string) (err error)
判断对后端文件的代理
func (*App) ProxyStatic ¶
func (app *App) ProxyStatic(resp http.ResponseWriter, r *http.Request, cfg *ProxyConfig, frontUrl, RequestURI string) bool
判断对静态文件的代理
type Config ¶
type Config struct {
Proxy map[string]ProxyConfig `toml:"proxy"`
}
type Interrupt ¶
type Interrupt interface {
Run() error
SetHeader(key string, val any)
Do(resp http.ResponseWriter, r *http.Request, cfg *ProxyConfig, url, RequestURI string)
}
type JavaScriptInterrupt ¶
func NewJavascriptVm ¶
func NewJavascriptVm(cfg *ProxyConfig) (*JavaScriptInterrupt, error)
func (*JavaScriptInterrupt) Run ¶
func (vm *JavaScriptInterrupt) Run(app *App, resp http.ResponseWriter, req *http.Request, cfg *ProxyConfig, url, RequestURI string) error
type ProxyConfig ¶
type ProxyConfig struct {
Name string
Url string //要代理的地址
Proxy string //代理请求的地址
Header map[string]string //输出的header
Hook map[string]string //各种hook的能力
Root string //静态文件目录 如果不存在 访问proxy的 后端服务器
Interrupt string //中断文件路径
Ssh struct {
Auth string //password key
Host string
UserName string //用户名
Password string //密码
PrivateKey string //私钥登陆
Addr string //要监听的地址
} `toml:"ssh"`
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.