@ -20,9 +20,15 @@ import (
"errors"
"fmt"
"reflect"
"github.com/samber/lo"
"github.com/fatedier/frp/pkg/util/util"
)
type ClientPluginOptions interface { }
type ClientPluginOptions interface {
Complete ( )
}
type TypedClientPluginOptions struct {
Type string ` json:"type" `
@ -73,10 +79,10 @@ const (
PluginHTTPProxy = "http_proxy"
PluginHTTPS2HTTP = "https2http"
PluginHTTPS2HTTPS = "https2https"
PluginHTTP2HTTP = "http2http"
PluginSocks5 = "socks5"
PluginStaticFile = "static_file"
PluginUnixDomainSocket = "unix_domain_socket"
PluginHTTP2HTTP = "http2http"
)
var clientPluginOptionsTypeMap = map [ string ] reflect . Type {
@ -84,10 +90,10 @@ var clientPluginOptionsTypeMap = map[string]reflect.Type{
PluginHTTPProxy : reflect . TypeOf ( HTTPProxyPluginOptions { } ) ,
PluginHTTPS2HTTP : reflect . TypeOf ( HTTPS2HTTPPluginOptions { } ) ,
PluginHTTPS2HTTPS : reflect . TypeOf ( HTTPS2HTTPSPluginOptions { } ) ,
PluginHTTP2HTTP : reflect . TypeOf ( HTTP2HTTPPluginOptions { } ) ,
PluginSocks5 : reflect . TypeOf ( Socks5PluginOptions { } ) ,
PluginStaticFile : reflect . TypeOf ( StaticFilePluginOptions { } ) ,
PluginUnixDomainSocket : reflect . TypeOf ( UnixDomainSocketPluginOptions { } ) ,
PluginHTTP2HTTP : reflect . TypeOf ( HTTP2HTTPPluginOptions { } ) ,
}
type HTTP2HTTPSPluginOptions struct {
@ -97,36 +103,61 @@ type HTTP2HTTPSPluginOptions struct {
RequestHeaders HeaderOperations ` json:"requestHeaders,omitempty" `
}
func ( o * HTTP2HTTPSPluginOptions ) Complete ( ) { }
type HTTPProxyPluginOptions struct {
Type string ` json:"type,omitempty" `
HTTPUser string ` json:"httpUser,omitempty" `
HTTPPassword string ` json:"httpPassword,omitempty" `
}
func ( o * HTTPProxyPluginOptions ) Complete ( ) { }
type HTTPS2HTTPPluginOptions struct {
Type string ` json:"type,omitempty" `
LocalAddr string ` json:"localAddr,omitempty" `
HostHeaderRewrite string ` json:"hostHeaderRewrite,omitempty" `
RequestHeaders HeaderOperations ` json:"requestHeaders,omitempty" `
EnableHTTP2 * bool ` json:"enableHTTP2,omitempty" `
CrtPath string ` json:"crtPath,omitempty" `
KeyPath string ` json:"keyPath,omitempty" `
}
func ( o * HTTPS2HTTPPluginOptions ) Complete ( ) {
o . EnableHTTP2 = util . EmptyOr ( o . EnableHTTP2 , lo . ToPtr ( true ) )
}
type HTTPS2HTTPSPluginOptions struct {
Type string ` json:"type,omitempty" `
LocalAddr string ` json:"localAddr,omitempty" `
HostHeaderRewrite string ` json:"hostHeaderRewrite,omitempty" `
RequestHeaders HeaderOperations ` json:"requestHeaders,omitempty" `
EnableHTTP2 * bool ` json:"enableHTTP2,omitempty" `
CrtPath string ` json:"crtPath,omitempty" `
KeyPath string ` json:"keyPath,omitempty" `
}
func ( o * HTTPS2HTTPSPluginOptions ) Complete ( ) {
o . EnableHTTP2 = util . EmptyOr ( o . EnableHTTP2 , lo . ToPtr ( true ) )
}
type HTTP2HTTPPluginOptions struct {
Type string ` json:"type,omitempty" `
LocalAddr string ` json:"localAddr,omitempty" `
HostHeaderRewrite string ` json:"hostHeaderRewrite,omitempty" `
RequestHeaders HeaderOperations ` json:"requestHeaders,omitempty" `
}
func ( o * HTTP2HTTPPluginOptions ) Complete ( ) { }
type Socks5PluginOptions struct {
Type string ` json:"type,omitempty" `
Username string ` json:"username,omitempty" `
Password string ` json:"password,omitempty" `
}
func ( o * Socks5PluginOptions ) Complete ( ) { }
type StaticFilePluginOptions struct {
Type string ` json:"type,omitempty" `
LocalPath string ` json:"localPath,omitempty" `
@ -135,15 +166,11 @@ type StaticFilePluginOptions struct {
HTTPPassword string ` json:"httpPassword,omitempty" `
}
func ( o * StaticFilePluginOptions ) Complete ( ) { }
type UnixDomainSocketPluginOptions struct {
Type string ` json:"type,omitempty" `
UnixPath string ` json:"unixPath,omitempty" `
}
// Added HTTP2HTTPPluginOptions struct
type HTTP2HTTPPluginOptions struct {
Type string ` json:"type,omitempty" `
LocalAddr string ` json:"localAddr,omitempty" `
HostHeaderRewrite string ` json:"hostHeaderRewrite,omitempty" `
RequestHeaders HeaderOperations ` json:"requestHeaders,omitempty" `
}
func ( o * UnixDomainSocketPluginOptions ) Complete ( ) { }