| 1 | package basic |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "time" |
| 6 | |
| 7 | "github.com/onsi/ginkgo/v2" |
| 8 | |
| 9 | "github.com/fatedier/frp/test/e2e/framework" |
| 10 | "github.com/fatedier/frp/test/e2e/framework/consts" |
| 11 | "github.com/fatedier/frp/test/e2e/pkg/port" |
| 12 | "github.com/fatedier/frp/test/e2e/pkg/request" |
| 13 | ) |
| 14 | |
| 15 | var _ = ginkgo.Describe("[Feature: XTCP]", func() { |
| 16 | f := framework.NewDefaultFramework() |
| 17 | |
| 18 | ginkgo.It("Fallback To STCP", func() { |
| 19 | serverConf := consts.LegacyDefaultServerConfig |
| 20 | clientConf := consts.LegacyDefaultClientConfig |
| 21 | |
| 22 | bindPortName := port.GenName("XTCP") |
| 23 | clientConf += fmt.Sprintf(` |
| 24 | [foo] |
| 25 | type = stcp |
| 26 | local_port = {{ .%s }} |
| 27 | |
| 28 | [foo-visitor] |
| 29 | type = stcp |
| 30 | role = visitor |
| 31 | server_name = foo |
| 32 | bind_port = -1 |
| 33 | |
| 34 | [bar-visitor] |
| 35 | type = xtcp |
| 36 | role = visitor |
| 37 | server_name = bar |
| 38 | bind_port = {{ .%s }} |
| 39 | keep_tunnel_open = true |
| 40 | fallback_to = foo-visitor |
| 41 | fallback_timeout_ms = 200 |
| 42 | `, framework.TCPEchoServerPort, bindPortName) |
| 43 | |
| 44 | f.RunProcesses(serverConf, []string{clientConf}) |
| 45 | framework.NewRequestExpect(f). |
| 46 | RequestModify(func(r *request.Request) { |
| 47 | r.Timeout(time.Second) |
| 48 | }). |
| 49 | PortName(bindPortName). |
| 50 | Ensure() |
| 51 | }) |
| 52 | }) |