fix: adopt sing-box 1.14 DNS hijacking
This commit is contained in:
@@ -119,11 +119,49 @@ class TransactionTests(unittest.TestCase):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
controller, runner, policy = self.make(directory)
|
||||
endpoint = parse_hysteria2_uri(URI_NEW)
|
||||
Path(policy.sing_box.config_path).write_bytes(render_bytes(policy, endpoint))
|
||||
installed = render_bytes(policy, endpoint)
|
||||
Path(policy.sing_box.config_path).write_bytes(installed)
|
||||
self.mark_managed(controller, installed, URI_NEW)
|
||||
self.assertFalse(controller.sync())
|
||||
self.assertFalse(any("restart" in call for call in runner.calls))
|
||||
self.assertFalse(json.loads(controller.state_path.read_text())["changed"])
|
||||
|
||||
def test_identical_unmanaged_config_is_not_adopted(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
controller, runner, policy = self.make(directory)
|
||||
endpoint = parse_hysteria2_uri(URI_NEW)
|
||||
installed = render_bytes(policy, endpoint)
|
||||
target = Path(policy.sing_box.config_path)
|
||||
target.write_bytes(installed)
|
||||
|
||||
with self.assertRaisesRegex(ValidationError, "clean installation"):
|
||||
controller.sync()
|
||||
|
||||
self.assertEqual(target.read_bytes(), installed)
|
||||
self.assertFalse(controller.state_path.exists())
|
||||
self.assertFalse(controller.last_good_path.exists())
|
||||
self.assertFalse(any("restart" in call for call in runner.calls))
|
||||
self.assertEqual(list(target.parent.glob(f".{target.name}.candidate.*")), [])
|
||||
|
||||
def test_import_restores_uri_when_identical_config_is_unmanaged(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
controller, runner, policy = self.make(directory)
|
||||
uri_path = Path(policy.runtime.uri_path)
|
||||
uri_path.write_text(URI_OLD + "\n", encoding="utf-8")
|
||||
endpoint = parse_hysteria2_uri(URI_NEW)
|
||||
installed = render_bytes(policy, endpoint)
|
||||
target = Path(policy.sing_box.config_path)
|
||||
target.write_bytes(installed)
|
||||
|
||||
with self.assertRaisesRegex(ValidationError, "clean installation"):
|
||||
controller.import_uri(URI_NEW)
|
||||
|
||||
self.assertEqual(uri_path.read_text(encoding="utf-8").strip(), URI_OLD)
|
||||
self.assertEqual(target.read_bytes(), installed)
|
||||
self.assertFalse(controller.state_path.exists())
|
||||
self.assertFalse(any("restart" in call for call in runner.calls))
|
||||
self.assertEqual(list(target.parent.glob(f".{target.name}.candidate.*")), [])
|
||||
|
||||
def test_generated_config_rejection_is_non_mutating(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
controller, _, policy = self.make(directory, runner=FakeRunner(check_result=1))
|
||||
@@ -247,7 +285,9 @@ class TransactionTests(unittest.TestCase):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
controller, _, policy = self.make(directory)
|
||||
endpoint = parse_hysteria2_uri(URI_NEW)
|
||||
Path(policy.sing_box.config_path).write_bytes(render_bytes(policy, endpoint))
|
||||
installed = render_bytes(policy, endpoint)
|
||||
Path(policy.sing_box.config_path).write_bytes(installed)
|
||||
self.mark_managed(controller, installed, URI_NEW)
|
||||
controller.sync()
|
||||
Path(policy.runtime.uri_path).write_text(URI_OLD + "\n", encoding="utf-8")
|
||||
status = controller.status()
|
||||
|
||||
Reference in New Issue
Block a user