http_test.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. func TestHTTPSelf(t *testing.T) {
  9. startInstance(t, option.Options{
  10. Inbounds: []option.Inbound{
  11. {
  12. Type: C.TypeMixed,
  13. Tag: "mixed-in",
  14. MixedOptions: option.HTTPMixedInboundOptions{
  15. ListenOptions: option.ListenOptions{
  16. Listen: option.ListenAddress(netip.IPv4Unspecified()),
  17. ListenPort: clientPort,
  18. },
  19. },
  20. },
  21. {
  22. Type: C.TypeMixed,
  23. MixedOptions: option.HTTPMixedInboundOptions{
  24. ListenOptions: option.ListenOptions{
  25. Listen: option.ListenAddress(netip.IPv4Unspecified()),
  26. ListenPort: serverPort,
  27. },
  28. },
  29. },
  30. },
  31. Outbounds: []option.Outbound{
  32. {
  33. Type: C.TypeDirect,
  34. },
  35. {
  36. Type: C.TypeHTTP,
  37. Tag: "http-out",
  38. HTTPOptions: option.HTTPOutboundOptions{
  39. ServerOptions: option.ServerOptions{
  40. Server: "127.0.0.1",
  41. ServerPort: serverPort,
  42. },
  43. },
  44. },
  45. },
  46. Route: &option.RouteOptions{
  47. Rules: []option.Rule{
  48. {
  49. DefaultOptions: option.DefaultRule{
  50. Inbound: []string{"mixed-in"},
  51. Outbound: "http-out",
  52. },
  53. },
  54. },
  55. },
  56. })
  57. testTCP(t, clientPort, testPort)
  58. }