Skip to content

Commit

Permalink
Add http2http client plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
koho authored Jul 10, 2024
1 parent 6bf7b8b commit d4e7ba0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
6 changes: 3 additions & 3 deletions pkg/config/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,18 @@ type BaseProxyConf struct {
}

type PluginParams struct {
PluginLocalAddr string `ini:"plugin_local_addr,omitempty" http2https:"true" https2https:"true" https2http:"true"`
PluginLocalAddr string `ini:"plugin_local_addr,omitempty" http2https:"true" http2http:"true" https2https:"true" https2http:"true"`
PluginCrtPath string `ini:"plugin_crt_path,omitempty" https2https:"true" https2http:"true"`
PluginKeyPath string `ini:"plugin_key_path,omitempty" https2https:"true" https2http:"true"`
PluginHostHeaderRewrite string `ini:"plugin_host_header_rewrite,omitempty" http2https:"true" https2https:"true" https2http:"true"`
PluginHostHeaderRewrite string `ini:"plugin_host_header_rewrite,omitempty" http2https:"true" http2http:"true" https2https:"true" https2http:"true"`
PluginHttpUser string `ini:"plugin_http_user,omitempty" http_proxy:"true" static_file:"true"`
PluginHttpPasswd string `ini:"plugin_http_passwd,omitempty" http_proxy:"true" static_file:"true"`
PluginUser string `ini:"plugin_user,omitempty" socks5:"true"`
PluginPasswd string `ini:"plugin_passwd,omitempty" socks5:"true"`
PluginLocalPath string `ini:"plugin_local_path,omitempty" static_file:"true"`
PluginStripPrefix string `ini:"plugin_strip_prefix,omitempty" static_file:"true"`
PluginUnixPath string `ini:"plugin_unix_path,omitempty" unix_domain_socket:"true"`
PluginHeaders map[string]string `ini:"-" http2https:"true" https2https:"true" https2http:"true"`
PluginHeaders map[string]string `ini:"-" http2https:"true" http2http:"true" https2https:"true" https2http:"true"`
}

// HealthCheckConf configures health checking. This can be useful for load
Expand Down
13 changes: 13 additions & 0 deletions pkg/config/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ func clientProxyBaseFromV1(c *v1.ProxyBaseConfig, out *Proxy) {
out.PluginLocalAddr = v.LocalAddr
out.PluginHostHeaderRewrite = v.HostHeaderRewrite
out.PluginHeaders = v.RequestHeaders.Set
case *v1.HTTP2HTTPPluginOptions:
out.PluginLocalAddr = v.LocalAddr
out.PluginHostHeaderRewrite = v.HostHeaderRewrite
out.PluginHeaders = v.RequestHeaders.Set
case *v1.HTTPProxyPluginOptions:
out.PluginHttpUser = v.HTTPUser
out.PluginHttpPasswd = v.HTTPPassword
Expand Down Expand Up @@ -508,6 +512,15 @@ func clientProxyBaseToV1(c *BaseProxyConf) (v1.ProxyBaseConfig, error) {
Set: c.PluginHeaders,
},
}
case consts.PluginHttp2Http:
r.ProxyBackend.Plugin.ClientPluginOptions = &v1.HTTP2HTTPPluginOptions{
Type: c.Plugin,
LocalAddr: c.PluginLocalAddr,
HostHeaderRewrite: c.PluginHostHeaderRewrite,
RequestHeaders: v1.HeaderOperations{
Set: c.PluginHeaders,
},
}
case consts.PluginHttpProxy:
r.ProxyBackend.Plugin.ClientPluginOptions = &v1.HTTPProxyPluginOptions{
Type: c.Plugin,
Expand Down
6 changes: 3 additions & 3 deletions pkg/consts/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ const (
PluginHttps2Http = "https2http"
PluginHttps2Https = "https2https"
PluginHttp2Https = "http2https"
PluginHttp2Http = "http2http"
PluginUnixDomain = "unix_domain_socket"
)

var PluginTypes = []string{
PluginHttpProxy, PluginSocks5, PluginStaticFile,
PluginHttps2Http, PluginHttps2Https, PluginHttp2Https,
PluginUnixDomain,
PluginHttp2Https, PluginHttp2Http, PluginHttps2Http, PluginHttps2Https,
PluginHttpProxy, PluginSocks5, PluginStaticFile, PluginUnixDomain,
}

// Auth methods
Expand Down
2 changes: 1 addition & 1 deletion ui/editproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ func (pd *EditProxyDialog) switchType() {
case consts.PluginHttps2Http, consts.PluginHttps2Https:
pd.viewModel.PluginHTTPFwdVisible = true
pd.viewModel.PluginCertVisible = true
case consts.PluginHttp2Https:
case consts.PluginHttp2Https, consts.PluginHttp2Http:
pd.viewModel.PluginHTTPFwdVisible = true
}
}
Expand Down

0 comments on commit d4e7ba0

Please sign in to comment.