mirror of
https://github.com/fatedier/frp.git
synced 2026-01-11 22:23:12 +00:00
lint by golangci-lint (#3080)
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/onsi/ginkgo"
|
||||
|
||||
"github.com/fatedier/frp/pkg/transport"
|
||||
"github.com/fatedier/frp/test/e2e/framework"
|
||||
"github.com/fatedier/frp/test/e2e/framework/consts"
|
||||
@@ -12,15 +14,13 @@ import (
|
||||
"github.com/fatedier/frp/test/e2e/pkg/cert"
|
||||
"github.com/fatedier/frp/test/e2e/pkg/port"
|
||||
"github.com/fatedier/frp/test/e2e/pkg/request"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
)
|
||||
|
||||
var _ = Describe("[Feature: Client-Plugins]", func() {
|
||||
var _ = ginkgo.Describe("[Feature: Client-Plugins]", func() {
|
||||
f := framework.NewDefaultFramework()
|
||||
|
||||
Describe("UnixDomainSocket", func() {
|
||||
It("Expose a unix domain socket echo server", func() {
|
||||
ginkgo.Describe("UnixDomainSocket", func() {
|
||||
ginkgo.It("Expose a unix domain socket echo server", func() {
|
||||
serverConf := consts.DefaultServerConfig
|
||||
clientConf := consts.DefaultClientConfig
|
||||
|
||||
@@ -76,7 +76,7 @@ var _ = Describe("[Feature: Client-Plugins]", func() {
|
||||
})
|
||||
})
|
||||
|
||||
It("http_proxy", func() {
|
||||
ginkgo.It("http_proxy", func() {
|
||||
serverConf := consts.DefaultServerConfig
|
||||
clientConf := consts.DefaultClientConfig
|
||||
|
||||
@@ -108,7 +108,7 @@ var _ = Describe("[Feature: Client-Plugins]", func() {
|
||||
})
|
||||
})
|
||||
|
||||
It("socks5 proxy", func() {
|
||||
ginkgo.It("socks5 proxy", func() {
|
||||
serverConf := consts.DefaultServerConfig
|
||||
clientConf := consts.DefaultClientConfig
|
||||
|
||||
@@ -135,7 +135,7 @@ var _ = Describe("[Feature: Client-Plugins]", func() {
|
||||
}).Ensure()
|
||||
})
|
||||
|
||||
It("static_file", func() {
|
||||
ginkgo.It("static_file", func() {
|
||||
vhostPort := f.AllocPort()
|
||||
serverConf := consts.DefaultServerConfig + fmt.Sprintf(`
|
||||
vhost_http_port = %d
|
||||
@@ -184,7 +184,7 @@ var _ = Describe("[Feature: Client-Plugins]", func() {
|
||||
).ExpectResp([]byte("foo")).Ensure()
|
||||
})
|
||||
|
||||
It("http2https", func() {
|
||||
ginkgo.It("http2https", func() {
|
||||
serverConf := consts.DefaultServerConfig
|
||||
vhostHTTPPort := f.AllocPort()
|
||||
serverConf += fmt.Sprintf(`
|
||||
@@ -206,7 +206,7 @@ var _ = Describe("[Feature: Client-Plugins]", func() {
|
||||
framework.ExpectNoError(err)
|
||||
localServer := httpserver.New(
|
||||
httpserver.WithBindPort(localPort),
|
||||
httpserver.WithTlsConfig(tlsConfig),
|
||||
httpserver.WithTLSConfig(tlsConfig),
|
||||
httpserver.WithResponse([]byte("test")),
|
||||
)
|
||||
f.RunServer("", localServer)
|
||||
@@ -220,7 +220,7 @@ var _ = Describe("[Feature: Client-Plugins]", func() {
|
||||
Ensure()
|
||||
})
|
||||
|
||||
It("https2http", func() {
|
||||
ginkgo.It("https2http", func() {
|
||||
generator := &cert.SelfSignedCertGenerator{}
|
||||
artifacts, err := generator.Generate("example.com")
|
||||
framework.ExpectNoError(err)
|
||||
@@ -264,7 +264,7 @@ var _ = Describe("[Feature: Client-Plugins]", func() {
|
||||
Ensure()
|
||||
})
|
||||
|
||||
It("https2https", func() {
|
||||
ginkgo.It("https2https", func() {
|
||||
generator := &cert.SelfSignedCertGenerator{}
|
||||
artifacts, err := generator.Generate("example.com")
|
||||
framework.ExpectNoError(err)
|
||||
@@ -295,7 +295,7 @@ var _ = Describe("[Feature: Client-Plugins]", func() {
|
||||
localServer := httpserver.New(
|
||||
httpserver.WithBindPort(localPort),
|
||||
httpserver.WithResponse([]byte("test")),
|
||||
httpserver.WithTlsConfig(tlsConfig),
|
||||
httpserver.WithTLSConfig(tlsConfig),
|
||||
)
|
||||
f.RunServer("", localServer)
|
||||
|
||||
|
||||
@@ -4,25 +4,25 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo"
|
||||
|
||||
plugin "github.com/fatedier/frp/pkg/plugin/server"
|
||||
"github.com/fatedier/frp/pkg/transport"
|
||||
"github.com/fatedier/frp/test/e2e/framework"
|
||||
"github.com/fatedier/frp/test/e2e/framework/consts"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
)
|
||||
|
||||
var _ = Describe("[Feature: Server-Plugins]", func() {
|
||||
var _ = ginkgo.Describe("[Feature: Server-Plugins]", func() {
|
||||
f := framework.NewDefaultFramework()
|
||||
|
||||
Describe("Login", func() {
|
||||
ginkgo.Describe("Login", func() {
|
||||
newFunc := func() *plugin.Request {
|
||||
var r plugin.Request
|
||||
r.Content = &plugin.LoginContent{}
|
||||
return &r
|
||||
}
|
||||
|
||||
It("Auth for custom meta token", func() {
|
||||
ginkgo.It("Auth for custom meta token", func() {
|
||||
localPort := f.AllocPort()
|
||||
|
||||
clientAddressGot := false
|
||||
@@ -79,14 +79,14 @@ var _ = Describe("[Feature: Server-Plugins]", func() {
|
||||
})
|
||||
})
|
||||
|
||||
Describe("NewProxy", func() {
|
||||
ginkgo.Describe("NewProxy", func() {
|
||||
newFunc := func() *plugin.Request {
|
||||
var r plugin.Request
|
||||
r.Content = &plugin.NewProxyContent{}
|
||||
return &r
|
||||
}
|
||||
|
||||
It("Validate Info", func() {
|
||||
ginkgo.It("Validate Info", func() {
|
||||
localPort := f.AllocPort()
|
||||
handler := func(req *plugin.Request) *plugin.Response {
|
||||
var ret plugin.Response
|
||||
@@ -123,7 +123,7 @@ var _ = Describe("[Feature: Server-Plugins]", func() {
|
||||
framework.NewRequestExpect(f).Port(remotePort).Ensure()
|
||||
})
|
||||
|
||||
It("Mofify RemotePort", func() {
|
||||
ginkgo.It("Mofify RemotePort", func() {
|
||||
localPort := f.AllocPort()
|
||||
remotePort := f.AllocPort()
|
||||
handler := func(req *plugin.Request) *plugin.Response {
|
||||
@@ -158,14 +158,14 @@ var _ = Describe("[Feature: Server-Plugins]", func() {
|
||||
})
|
||||
})
|
||||
|
||||
Describe("CloseProxy", func() {
|
||||
ginkgo.Describe("CloseProxy", func() {
|
||||
newFunc := func() *plugin.Request {
|
||||
var r plugin.Request
|
||||
r.Content = &plugin.CloseProxyContent{}
|
||||
return &r
|
||||
}
|
||||
|
||||
It("Validate Info", func() {
|
||||
ginkgo.It("Validate Info", func() {
|
||||
localPort := f.AllocPort()
|
||||
var recordProxyName string
|
||||
handler := func(req *plugin.Request) *plugin.Response {
|
||||
@@ -199,7 +199,7 @@ var _ = Describe("[Feature: Server-Plugins]", func() {
|
||||
framework.NewRequestExpect(f).Port(remotePort).Ensure()
|
||||
|
||||
for _, c := range clients {
|
||||
c.Stop()
|
||||
_ = c.Stop()
|
||||
}
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
@@ -208,14 +208,14 @@ var _ = Describe("[Feature: Server-Plugins]", func() {
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Ping", func() {
|
||||
ginkgo.Describe("Ping", func() {
|
||||
newFunc := func() *plugin.Request {
|
||||
var r plugin.Request
|
||||
r.Content = &plugin.PingContent{}
|
||||
return &r
|
||||
}
|
||||
|
||||
It("Validate Info", func() {
|
||||
ginkgo.It("Validate Info", func() {
|
||||
localPort := f.AllocPort()
|
||||
|
||||
var record string
|
||||
@@ -258,14 +258,14 @@ var _ = Describe("[Feature: Server-Plugins]", func() {
|
||||
})
|
||||
})
|
||||
|
||||
Describe("NewWorkConn", func() {
|
||||
ginkgo.Describe("NewWorkConn", func() {
|
||||
newFunc := func() *plugin.Request {
|
||||
var r plugin.Request
|
||||
r.Content = &plugin.NewWorkConnContent{}
|
||||
return &r
|
||||
}
|
||||
|
||||
It("Validate Info", func() {
|
||||
ginkgo.It("Validate Info", func() {
|
||||
localPort := f.AllocPort()
|
||||
|
||||
var record string
|
||||
@@ -304,13 +304,13 @@ var _ = Describe("[Feature: Server-Plugins]", func() {
|
||||
})
|
||||
})
|
||||
|
||||
Describe("NewUserConn", func() {
|
||||
ginkgo.Describe("NewUserConn", func() {
|
||||
newFunc := func() *plugin.Request {
|
||||
var r plugin.Request
|
||||
r.Content = &plugin.NewUserConnContent{}
|
||||
return &r
|
||||
}
|
||||
It("Validate Info", func() {
|
||||
ginkgo.It("Validate Info", func() {
|
||||
localPort := f.AllocPort()
|
||||
|
||||
var record string
|
||||
@@ -349,13 +349,13 @@ var _ = Describe("[Feature: Server-Plugins]", func() {
|
||||
})
|
||||
})
|
||||
|
||||
Describe("HTTPS Protocol", func() {
|
||||
ginkgo.Describe("HTTPS Protocol", func() {
|
||||
newFunc := func() *plugin.Request {
|
||||
var r plugin.Request
|
||||
r.Content = &plugin.NewUserConnContent{}
|
||||
return &r
|
||||
}
|
||||
It("Validate Login Info, disable tls verify", func() {
|
||||
ginkgo.It("Validate Login Info, disable tls verify", func() {
|
||||
localPort := f.AllocPort()
|
||||
|
||||
var record string
|
||||
|
||||
@@ -11,14 +11,14 @@ import (
|
||||
"github.com/fatedier/frp/test/e2e/mock/server/httpserver"
|
||||
)
|
||||
|
||||
type PluginHandler func(req *plugin.Request) *plugin.Response
|
||||
type Handler func(req *plugin.Request) *plugin.Response
|
||||
|
||||
type NewPluginRequest func() *plugin.Request
|
||||
|
||||
func NewHTTPPluginServer(port int, newFunc NewPluginRequest, handler PluginHandler, tlsConfig *tls.Config) *httpserver.Server {
|
||||
func NewHTTPPluginServer(port int, newFunc NewPluginRequest, handler Handler, tlsConfig *tls.Config) *httpserver.Server {
|
||||
return httpserver.New(
|
||||
httpserver.WithBindPort(port),
|
||||
httpserver.WithTlsConfig(tlsConfig),
|
||||
httpserver.WithTLSConfig(tlsConfig),
|
||||
httpserver.WithHandler(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
r := newFunc()
|
||||
buf, err := io.ReadAll(req.Body)
|
||||
@@ -35,7 +35,7 @@ func NewHTTPPluginServer(port int, newFunc NewPluginRequest, handler PluginHandl
|
||||
resp := handler(r)
|
||||
buf, _ = json.Marshal(resp)
|
||||
log.Trace("plugin response: %s", string(buf))
|
||||
w.Write(buf)
|
||||
_, _ = w.Write(buf)
|
||||
})),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user