mirror of
https://github.com/fatedier/frp.git
synced 2025-07-27 07:35:07 +00:00
support wss between frpc and frps (#3503)
This commit is contained in:
@@ -331,24 +331,29 @@ var _ = ginkgo.Describe("[Feature: Basic]", func() {
|
||||
proxyExtraConfig string
|
||||
visitorExtraConfig string
|
||||
expectError bool
|
||||
user2 bool
|
||||
deployUser2Client bool
|
||||
// skipXTCP is used to skip xtcp test case
|
||||
skipXTCP bool
|
||||
}{
|
||||
{
|
||||
proxyName: "normal",
|
||||
bindPortName: port.GenName("Normal"),
|
||||
visitorSK: correctSK,
|
||||
skipXTCP: true,
|
||||
},
|
||||
{
|
||||
proxyName: "with-encryption",
|
||||
bindPortName: port.GenName("WithEncryption"),
|
||||
visitorSK: correctSK,
|
||||
commonExtraConfig: "use_encryption = true",
|
||||
skipXTCP: true,
|
||||
},
|
||||
{
|
||||
proxyName: "with-compression",
|
||||
bindPortName: port.GenName("WithCompression"),
|
||||
visitorSK: correctSK,
|
||||
commonExtraConfig: "use_compression = true",
|
||||
skipXTCP: true,
|
||||
},
|
||||
{
|
||||
proxyName: "with-encryption-and-compression",
|
||||
@@ -371,7 +376,7 @@ var _ = ginkgo.Describe("[Feature: Basic]", func() {
|
||||
visitorSK: correctSK,
|
||||
proxyExtraConfig: "allow_users = another, user2",
|
||||
visitorExtraConfig: "server_user = user1",
|
||||
user2: true,
|
||||
deployUser2Client: true,
|
||||
},
|
||||
{
|
||||
proxyName: "not-allowed-user",
|
||||
@@ -387,7 +392,7 @@ var _ = ginkgo.Describe("[Feature: Basic]", func() {
|
||||
visitorSK: correctSK,
|
||||
proxyExtraConfig: "allow_users = *",
|
||||
visitorExtraConfig: "server_user = user1",
|
||||
user2: true,
|
||||
deployUser2Client: true,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -399,7 +404,7 @@ var _ = ginkgo.Describe("[Feature: Basic]", func() {
|
||||
config := getProxyVisitorConf(
|
||||
test.proxyName, test.bindPortName, test.visitorSK, test.commonExtraConfig+"\n"+test.visitorExtraConfig,
|
||||
) + "\n"
|
||||
if test.user2 {
|
||||
if test.deployUser2Client {
|
||||
clientUser2VisitorConf += config
|
||||
} else {
|
||||
clientVisitorConf += config
|
||||
@@ -411,7 +416,10 @@ var _ = ginkgo.Describe("[Feature: Basic]", func() {
|
||||
for _, test := range tests {
|
||||
timeout := time.Second
|
||||
if t == "xtcp" {
|
||||
timeout = 4 * time.Second
|
||||
if test.skipXTCP {
|
||||
continue
|
||||
}
|
||||
timeout = 10 * time.Second
|
||||
}
|
||||
framework.NewRequestExpect(f).
|
||||
RequestModify(func(r *request.Request) {
|
||||
|
@@ -3,6 +3,7 @@ package basic
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
|
||||
@@ -13,9 +14,13 @@ import (
|
||||
)
|
||||
|
||||
type generalTestConfigures struct {
|
||||
server string
|
||||
client string
|
||||
expectError bool
|
||||
server string
|
||||
client string
|
||||
clientPrefix string
|
||||
client2 string
|
||||
client2Prefix string
|
||||
testDelay time.Duration
|
||||
expectError bool
|
||||
}
|
||||
|
||||
func renderBindPortConfig(protocol string) string {
|
||||
@@ -30,6 +35,9 @@ func renderBindPortConfig(protocol string) string {
|
||||
func runClientServerTest(f *framework.Framework, configures *generalTestConfigures) {
|
||||
serverConf := consts.DefaultServerConfig
|
||||
clientConf := consts.DefaultClientConfig
|
||||
if configures.clientPrefix != "" {
|
||||
clientConf = configures.clientPrefix
|
||||
}
|
||||
|
||||
serverConf += fmt.Sprintf(`
|
||||
%s
|
||||
@@ -54,7 +62,23 @@ func runClientServerTest(f *framework.Framework, configures *generalTestConfigur
|
||||
framework.UDPEchoServerPort, udpPortName,
|
||||
)
|
||||
|
||||
f.RunProcesses([]string{serverConf}, []string{clientConf})
|
||||
clientConfs := []string{clientConf}
|
||||
if configures.client2 != "" {
|
||||
client2Conf := consts.DefaultClientConfig
|
||||
if configures.client2Prefix != "" {
|
||||
client2Conf = configures.client2Prefix
|
||||
}
|
||||
client2Conf += fmt.Sprintf(`
|
||||
%s
|
||||
`, configures.client2)
|
||||
clientConfs = append(clientConfs, client2Conf)
|
||||
}
|
||||
|
||||
f.RunProcesses([]string{serverConf}, clientConfs)
|
||||
|
||||
if configures.testDelay > 0 {
|
||||
time.Sleep(configures.testDelay)
|
||||
}
|
||||
|
||||
framework.NewRequestExpect(f).PortName(tcpPortName).ExpectError(configures.expectError).Explain("tcp proxy").Ensure()
|
||||
framework.NewRequestExpect(f).Protocol("udp").
|
||||
@@ -84,6 +108,33 @@ var _ = ginkgo.Describe("[Feature: Client-Server]", func() {
|
||||
}
|
||||
})
|
||||
|
||||
// wss is special, it needs to be tested separately.
|
||||
// frps only supports ws, so there should be a proxy to terminate TLS before frps.
|
||||
ginkgo.Describe("Protocol wss", func() {
|
||||
wssPort := f.AllocPort()
|
||||
configures := &generalTestConfigures{
|
||||
clientPrefix: fmt.Sprintf(`
|
||||
[common]
|
||||
server_addr = 127.0.0.1
|
||||
server_port = %d
|
||||
protocol = wss
|
||||
log_level = trace
|
||||
login_fail_exit = false
|
||||
`, wssPort),
|
||||
// Due to the fact that frps cannot directly accept wss connections, we use the https2http plugin of another frpc to terminate TLS.
|
||||
client2: fmt.Sprintf(`
|
||||
[wss2ws]
|
||||
type = tcp
|
||||
remote_port = %d
|
||||
plugin = https2http
|
||||
plugin_local_addr = 127.0.0.1:{{ .%s }}
|
||||
`, wssPort, consts.PortServerName),
|
||||
testDelay: 10 * time.Second,
|
||||
}
|
||||
|
||||
defineClientServerTest("wss", f, configures)
|
||||
})
|
||||
|
||||
ginkgo.Describe("Authentication", func() {
|
||||
defineClientServerTest("Token Correct", f, &generalTestConfigures{
|
||||
server: "token = 123456",
|
||||
|
Reference in New Issue
Block a user