@@ -20,9 +20,15 @@ import (
2020 "errors"
2121 "fmt"
2222 "reflect"
23+
24+ "github.com/samber/lo"
25+
26+ "github.com/fatedier/frp/pkg/util/util"
2327)
2428
25- type ClientPluginOptions interface {}
29+ type ClientPluginOptions interface {
30+ Complete ()
31+ }
2632
2733type TypedClientPluginOptions struct {
2834 Type string `json:"type"`
@@ -73,21 +79,21 @@ const (
7379 PluginHTTPProxy = "http_proxy"
7480 PluginHTTPS2HTTP = "https2http"
7581 PluginHTTPS2HTTPS = "https2https"
82+ PluginHTTP2HTTP = "http2http"
7683 PluginSocks5 = "socks5"
7784 PluginStaticFile = "static_file"
7885 PluginUnixDomainSocket = "unix_domain_socket"
79- PluginHTTP2HTTP = "http2http"
8086)
8187
8288var clientPluginOptionsTypeMap = map [string ]reflect.Type {
8389 PluginHTTP2HTTPS : reflect .TypeOf (HTTP2HTTPSPluginOptions {}),
8490 PluginHTTPProxy : reflect .TypeOf (HTTPProxyPluginOptions {}),
8591 PluginHTTPS2HTTP : reflect .TypeOf (HTTPS2HTTPPluginOptions {}),
8692 PluginHTTPS2HTTPS : reflect .TypeOf (HTTPS2HTTPSPluginOptions {}),
93+ PluginHTTP2HTTP : reflect .TypeOf (HTTP2HTTPPluginOptions {}),
8794 PluginSocks5 : reflect .TypeOf (Socks5PluginOptions {}),
8895 PluginStaticFile : reflect .TypeOf (StaticFilePluginOptions {}),
8996 PluginUnixDomainSocket : reflect .TypeOf (UnixDomainSocketPluginOptions {}),
90- PluginHTTP2HTTP : reflect .TypeOf (HTTP2HTTPPluginOptions {}),
9197}
9298
9399type HTTP2HTTPSPluginOptions struct {
@@ -97,36 +103,61 @@ type HTTP2HTTPSPluginOptions struct {
97103 RequestHeaders HeaderOperations `json:"requestHeaders,omitempty"`
98104}
99105
106+ func (o * HTTP2HTTPSPluginOptions ) Complete () {}
107+
100108type HTTPProxyPluginOptions struct {
101109 Type string `json:"type,omitempty"`
102110 HTTPUser string `json:"httpUser,omitempty"`
103111 HTTPPassword string `json:"httpPassword,omitempty"`
104112}
105113
114+ func (o * HTTPProxyPluginOptions ) Complete () {}
115+
106116type HTTPS2HTTPPluginOptions struct {
107117 Type string `json:"type,omitempty"`
108118 LocalAddr string `json:"localAddr,omitempty"`
109119 HostHeaderRewrite string `json:"hostHeaderRewrite,omitempty"`
110120 RequestHeaders HeaderOperations `json:"requestHeaders,omitempty"`
121+ EnableHTTP2 * bool `json:"enableHTTP2,omitempty"`
111122 CrtPath string `json:"crtPath,omitempty"`
112123 KeyPath string `json:"keyPath,omitempty"`
113124}
114125
126+ func (o * HTTPS2HTTPPluginOptions ) Complete () {
127+ o .EnableHTTP2 = util .EmptyOr (o .EnableHTTP2 , lo .ToPtr (true ))
128+ }
129+
115130type HTTPS2HTTPSPluginOptions struct {
116131 Type string `json:"type,omitempty"`
117132 LocalAddr string `json:"localAddr,omitempty"`
118133 HostHeaderRewrite string `json:"hostHeaderRewrite,omitempty"`
119134 RequestHeaders HeaderOperations `json:"requestHeaders,omitempty"`
135+ EnableHTTP2 * bool `json:"enableHTTP2,omitempty"`
120136 CrtPath string `json:"crtPath,omitempty"`
121137 KeyPath string `json:"keyPath,omitempty"`
122138}
123139
140+ func (o * HTTPS2HTTPSPluginOptions ) Complete () {
141+ o .EnableHTTP2 = util .EmptyOr (o .EnableHTTP2 , lo .ToPtr (true ))
142+ }
143+
144+ type HTTP2HTTPPluginOptions struct {
145+ Type string `json:"type,omitempty"`
146+ LocalAddr string `json:"localAddr,omitempty"`
147+ HostHeaderRewrite string `json:"hostHeaderRewrite,omitempty"`
148+ RequestHeaders HeaderOperations `json:"requestHeaders,omitempty"`
149+ }
150+
151+ func (o * HTTP2HTTPPluginOptions ) Complete () {}
152+
124153type Socks5PluginOptions struct {
125154 Type string `json:"type,omitempty"`
126155 Username string `json:"username,omitempty"`
127156 Password string `json:"password,omitempty"`
128157}
129158
159+ func (o * Socks5PluginOptions ) Complete () {}
160+
130161type StaticFilePluginOptions struct {
131162 Type string `json:"type,omitempty"`
132163 LocalPath string `json:"localPath,omitempty"`
@@ -135,15 +166,11 @@ type StaticFilePluginOptions struct {
135166 HTTPPassword string `json:"httpPassword,omitempty"`
136167}
137168
169+ func (o * StaticFilePluginOptions ) Complete () {}
170+
138171type UnixDomainSocketPluginOptions struct {
139172 Type string `json:"type,omitempty"`
140173 UnixPath string `json:"unixPath,omitempty"`
141174}
142175
143- // Added HTTP2HTTPPluginOptions struct
144- type HTTP2HTTPPluginOptions struct {
145- Type string `json:"type,omitempty"`
146- LocalAddr string `json:"localAddr,omitempty"`
147- HostHeaderRewrite string `json:"hostHeaderRewrite,omitempty"`
148- RequestHeaders HeaderOperations `json:"requestHeaders,omitempty"`
149- }
176+ func (o * UnixDomainSocketPluginOptions ) Complete () {}
0 commit comments