xtcp.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package basic
  2. import (
  3. "fmt"
  4. "time"
  5. "github.com/onsi/ginkgo/v2"
  6. "github.com/fatedier/frp/test/e2e/framework"
  7. "github.com/fatedier/frp/test/e2e/framework/consts"
  8. "github.com/fatedier/frp/test/e2e/pkg/port"
  9. "github.com/fatedier/frp/test/e2e/pkg/request"
  10. )
  11. var _ = ginkgo.Describe("[Feature: XTCP]", func() {
  12. f := framework.NewDefaultFramework()
  13. ginkgo.It("Fallback To STCP", func() {
  14. serverConf := consts.DefaultServerConfig
  15. clientConf := consts.DefaultClientConfig
  16. bindPortName := port.GenName("XTCP")
  17. clientConf += fmt.Sprintf(`
  18. [[proxies]]
  19. name = "foo"
  20. type = "stcp"
  21. localPort = {{ .%s }}
  22. [[visitors]]
  23. name = "foo-visitor"
  24. type = "stcp"
  25. serverName = "foo"
  26. bindPort = -1
  27. [[visitors]]
  28. name = "bar-visitor"
  29. type = "xtcp"
  30. serverName = "bar"
  31. bindPort = {{ .%s }}
  32. keepTunnelOpen = true
  33. fallbackTo = "foo-visitor"
  34. fallbackTimeoutMs = 200
  35. `, framework.TCPEchoServerPort, bindPortName)
  36. f.RunProcesses([]string{serverConf}, []string{clientConf})
  37. framework.NewRequestExpect(f).
  38. RequestModify(func(r *request.Request) {
  39. r.Timeout(time.Second)
  40. }).
  41. PortName(bindPortName).
  42. Ensure()
  43. })
  44. })