tfo_test.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. "github.com/sagernet/sing/common"
  9. "github.com/sagernet/sing/common/json/badoption"
  10. )
  11. func TestTCPSlowOpen(t *testing.T) {
  12. method := shadowaead.List[0]
  13. password := mkBase64(t, 16)
  14. startInstance(t, option.Options{
  15. Inbounds: []option.Inbound{
  16. {
  17. Type: C.TypeMixed,
  18. Tag: "mixed-in",
  19. Options: &option.HTTPMixedInboundOptions{
  20. ListenOptions: option.ListenOptions{
  21. Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
  22. ListenPort: clientPort,
  23. },
  24. },
  25. },
  26. {
  27. Type: C.TypeShadowsocks,
  28. Options: &option.ShadowsocksInboundOptions{
  29. ListenOptions: option.ListenOptions{
  30. Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
  31. ListenPort: serverPort,
  32. TCPFastOpen: true,
  33. },
  34. Method: method,
  35. Password: password,
  36. },
  37. },
  38. },
  39. Outbounds: []option.Outbound{
  40. {
  41. Type: C.TypeDirect,
  42. },
  43. {
  44. Type: C.TypeShadowsocks,
  45. Tag: "ss-out",
  46. Options: &option.ShadowsocksOutboundOptions{
  47. ServerOptions: option.ServerOptions{
  48. Server: "127.0.0.1",
  49. ServerPort: serverPort,
  50. },
  51. DialerOptions: option.DialerOptions{
  52. TCPFastOpen: true,
  53. },
  54. Method: method,
  55. Password: password,
  56. },
  57. },
  58. },
  59. Route: &option.RouteOptions{
  60. Rules: []option.Rule{
  61. {
  62. Type: C.RuleTypeDefault,
  63. DefaultOptions: option.DefaultRule{
  64. RawDefaultRule: option.RawDefaultRule{
  65. Inbound: []string{"mixed-in"},
  66. },
  67. RuleAction: option.RuleAction{
  68. Action: C.RuleActionTypeRoute,
  69. RouteOptions: option.RouteActionOptions{
  70. Outbound: "ss-out",
  71. },
  72. },
  73. },
  74. },
  75. },
  76. },
  77. })
  78. testSuit(t, clientPort, testPort)
  79. }