tfo_test.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package main
  2. import (
  3. "net/netip"
  4. "testing"
  5. C "github.com/sagernet/sing-box/constant"
  6. "github.com/sagernet/sing-box/option"
  7. "github.com/sagernet/sing-shadowsocks/shadowaead"
  8. )
  9. func TestTCPSlowOpen(t *testing.T) {
  10. method := shadowaead.List[0]
  11. password := mkBase64(t, 16)
  12. startInstance(t, option.Options{
  13. Inbounds: []option.Inbound{
  14. {
  15. Type: C.TypeMixed,
  16. Tag: "mixed-in",
  17. MixedOptions: option.HTTPMixedInboundOptions{
  18. ListenOptions: option.ListenOptions{
  19. Listen: option.NewListenAddress(netip.IPv4Unspecified()),
  20. ListenPort: clientPort,
  21. },
  22. },
  23. },
  24. {
  25. Type: C.TypeShadowsocks,
  26. ShadowsocksOptions: option.ShadowsocksInboundOptions{
  27. ListenOptions: option.ListenOptions{
  28. Listen: option.NewListenAddress(netip.IPv4Unspecified()),
  29. ListenPort: serverPort,
  30. TCPFastOpen: true,
  31. },
  32. Method: method,
  33. Password: password,
  34. },
  35. },
  36. },
  37. Outbounds: []option.Outbound{
  38. {
  39. Type: C.TypeDirect,
  40. },
  41. {
  42. Type: C.TypeShadowsocks,
  43. Tag: "ss-out",
  44. ShadowsocksOptions: option.ShadowsocksOutboundOptions{
  45. ServerOptions: option.ServerOptions{
  46. Server: "127.0.0.1",
  47. ServerPort: serverPort,
  48. },
  49. DialerOptions: option.DialerOptions{
  50. TCPFastOpen: true,
  51. },
  52. Method: method,
  53. Password: password,
  54. },
  55. },
  56. },
  57. Route: &option.RouteOptions{
  58. Rules: []option.Rule{
  59. {
  60. DefaultOptions: option.DefaultRule{
  61. Inbound: []string{"mixed-in"},
  62. Outbound: "ss-out",
  63. },
  64. },
  65. },
  66. },
  67. })
  68. testSuit(t, clientPort, testPort)
  69. }