api_routing_test.go 861 B

12345678910111213141516171819202122
  1. package xray
  2. import "testing"
  3. // xray-core 26.10.10 resolves routing.script from the loader's working directory, and the
  4. // running core keeps its script anyway: a script beside the xray binary failed every hot
  5. // rule change panel-side, turning it into a full restart and breaking the node bridge.
  6. func TestBuildReloadableRouting_IgnoresLuaScript(t *testing.T) {
  7. t.Chdir(t.TempDir())
  8. routing := []byte(`{"script":"route.lua","rules":[{"type":"field","ip":["10.0.0.0/8"],"outboundTag":"direct"}]}`)
  9. config, err := buildReloadableRouting(routing)
  10. if err != nil {
  11. t.Fatalf("buildReloadableRouting: %v", err)
  12. }
  13. if config.Script != "" {
  14. t.Fatalf("Script = %q, want it left to the running core", config.Script)
  15. }
  16. if len(config.Rule) != 1 || config.Rule[0].GetTag() != "direct" {
  17. t.Fatalf("rules = %v, want the one rule to direct", config.Rule)
  18. }
  19. }