| 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.DefaultServerConfig |
| 20 | clientConf := consts.DefaultClientConfig |
| 21 | |
| 22 | bindPortName := port.GenName("XTCP") |
| 23 | clientConf += fmt.Sprintf(` |
| 24 | [[proxies]] |
| 25 | name = "foo" |
| 26 | type = "stcp" |
| 27 | localPort = {{ .%s }} |
| 28 | |
| 29 | [[visitors]] |
| 30 | name = "foo-visitor" |
| 31 | type = "stcp" |
| 32 | serverName = "foo" |
| 33 | bindPort = -1 |
| 34 | |
| 35 | [[visitors]] |
| 36 | name = "bar-visitor" |
| 37 | type = "xtcp" |
| 38 | serverName = "bar" |
| 39 | bindPort = {{ .%s }} |
| 40 | keepTunnelOpen = true |
| 41 | fallbackTo = "foo-visitor" |
| 42 | fallbackTimeoutMs = 200 |
| 43 | `, framework.TCPEchoServerPort, bindPortName) |
| 44 | |
| 45 | f.RunProcesses(serverConf, []string{clientConf}) |
| 46 | framework.NewRequestExpect(f). |
| 47 | RequestModify(func(r *request.Request) { |
| 48 | r.Timeout(time.Second) |
| 49 | }). |
| 50 | PortName(bindPortName). |
| 51 | Ensure() |
| 52 | }) |
| 53 | }) |