direct_test.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. )
  8. // Since this is a feature one-off added by outsiders, I won't address these anymore.
  9. func _TestProxyProtocol(t *testing.T) {
  10. startInstance(t, option.Options{
  11. Inbounds: []option.Inbound{
  12. {
  13. Type: C.TypeMixed,
  14. Tag: "mixed-in",
  15. MixedOptions: option.HTTPMixedInboundOptions{
  16. ListenOptions: option.ListenOptions{
  17. Listen: option.NewListenAddress(netip.IPv4Unspecified()),
  18. ListenPort: clientPort,
  19. },
  20. },
  21. },
  22. {
  23. Type: C.TypeDirect,
  24. DirectOptions: option.DirectInboundOptions{
  25. ListenOptions: option.ListenOptions{
  26. Listen: option.NewListenAddress(netip.IPv4Unspecified()),
  27. ListenPort: serverPort,
  28. ProxyProtocol: true,
  29. },
  30. },
  31. },
  32. },
  33. Outbounds: []option.Outbound{
  34. {
  35. Type: C.TypeDirect,
  36. },
  37. {
  38. Type: C.TypeDirect,
  39. Tag: "proxy-out",
  40. DirectOptions: option.DirectOutboundOptions{
  41. OverrideAddress: "127.0.0.1",
  42. OverridePort: serverPort,
  43. ProxyProtocol: 2,
  44. },
  45. },
  46. },
  47. Route: &option.RouteOptions{
  48. Rules: []option.Rule{
  49. {
  50. DefaultOptions: option.DefaultRule{
  51. Inbound: []string{"mixed-in"},
  52. Outbound: "proxy-out",
  53. },
  54. },
  55. },
  56. },
  57. })
  58. testSuit(t, clientPort, testPort)
  59. }