ethiack-beacon 2.2.1__tar.gz → 2.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/PKG-INFO +1 -1
  2. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/cli/wireguard.py +12 -3
  3. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/ethiack_beacon.egg-info/PKG-INFO +1 -1
  4. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/pyproject.toml +1 -1
  5. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_wireguard.py +33 -0
  6. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/README.md +0 -0
  7. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/cli/__init__.py +0 -0
  8. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/cli/api.py +0 -0
  9. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/cli/config.py +0 -0
  10. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/cli/console.py +0 -0
  11. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/cli/dns.py +0 -0
  12. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/cli/exceptions.py +0 -0
  13. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/cli/main.py +0 -0
  14. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/cli/rathole.py +0 -0
  15. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/cli/system.py +0 -0
  16. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/ethiack_beacon.egg-info/SOURCES.txt +0 -0
  17. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/ethiack_beacon.egg-info/dependency_links.txt +0 -0
  18. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/ethiack_beacon.egg-info/entry_points.txt +0 -0
  19. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/ethiack_beacon.egg-info/requires.txt +0 -0
  20. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/ethiack_beacon.egg-info/top_level.txt +0 -0
  21. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/setup.cfg +0 -0
  22. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_api.py +0 -0
  23. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_api_extra.py +0 -0
  24. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_config.py +0 -0
  25. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_console_extra.py +0 -0
  26. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_dns.py +0 -0
  27. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_main.py +0 -0
  28. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_main_create_start.py +0 -0
  29. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_main_health_misc.py +0 -0
  30. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_rathole.py +0 -0
  31. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_rathole_extra.py +0 -0
  32. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_system.py +0 -0
  33. {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_system_extra.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ethiack-beacon
3
- Version: 2.2.1
3
+ Version: 2.2.2
4
4
  Summary: Ethiack Beacon CLI - secure network tunnel management
5
5
  Author-email: Ethiack Engineering Team <engineering@ethiack.com>
6
6
  License: Proprietary
@@ -89,13 +89,22 @@ def get_active_interfaces() -> list[str]:
89
89
 
90
90
 
91
91
  def teardown_all() -> None:
92
- """Delete every active WireGuard interface via ``ip link delete``.
92
+ """Bring down every active WireGuard interface.
93
93
 
94
94
  Used before creating a new beacon to clear stale interfaces from previous
95
- runs (e.g. Docker restart where the network namespace outlives the container
96
- and no wg-quick config files exist to run ``wg-quick down``).
95
+ runs. Interfaces with a config in the state directory go through
96
+ ``wg-quick down`` so their PostDown hooks remove the MASQUERADE rule - a
97
+ bare ``ip link delete`` leaves it behind, and the next ``wg-quick up`` adds
98
+ a duplicate. Interfaces without a config (e.g. Docker restart where the
99
+ network namespace outlives the container) fall back to ``ip link delete``.
97
100
  """
98
101
  for iface in get_active_interfaces():
102
+ if (WG_CONF_DIR / f"{iface}.conf").exists():
103
+ try:
104
+ down(iface)
105
+ continue
106
+ except BeaconSystemError:
107
+ pass # e.g. PostDown failed; make sure the link is gone below
99
108
  try:
100
109
  subprocess.run(
101
110
  [*_sudo(), "ip", "link", "delete", iface],
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ethiack-beacon
3
- Version: 2.2.1
3
+ Version: 2.2.2
4
4
  Summary: Ethiack Beacon CLI - secure network tunnel management
5
5
  Author-email: Ethiack Engineering Team <engineering@ethiack.com>
6
6
  License: Proprietary
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ethiack-beacon"
7
- version = "2.2.1"
7
+ version = "2.2.2"
8
8
  description = "Ethiack Beacon CLI - secure network tunnel management"
9
9
  requires-python = ">=3.11"
10
10
  license = { text = "Proprietary" }
@@ -217,6 +217,10 @@ class TestGetActiveInterfaces:
217
217
 
218
218
 
219
219
  class TestTeardownAll:
220
+ @pytest.fixture(autouse=True)
221
+ def _empty_conf_dir(self, tmp_path, monkeypatch):
222
+ monkeypatch.setattr(wg, "WG_CONF_DIR", tmp_path)
223
+
220
224
  def test_deletes_all_active_interfaces(self):
221
225
  with patch("cli.wireguard.get_active_interfaces", return_value=["wg0", "wg1"]), \
222
226
  patch("subprocess.run") as mock_run:
@@ -244,6 +248,35 @@ class TestTeardownAll:
244
248
  wg.teardown_all() # should not raise
245
249
  assert mock_run.call_count == 2
246
250
 
251
+ def test_uses_wg_quick_down_when_conf_exists(self, tmp_path):
252
+ # wg-quick down runs PostDown, which removes the MASQUERADE rule;
253
+ # ip link delete alone would leak it.
254
+ (tmp_path / "wg0.conf").write_text("[Interface]\n")
255
+ with patch("cli.wireguard.get_active_interfaces", return_value=["wg0", "wg1"]), \
256
+ patch("subprocess.run") as mock_run:
257
+ mock_run.return_value = MagicMock(returncode=0)
258
+ wg.teardown_all()
259
+ calls = [c[0][0] for c in mock_run.call_args_list]
260
+ assert calls == [
261
+ ["wg-quick", "down", str(tmp_path / "wg0.conf")],
262
+ ["ip", "link", "delete", "wg1"],
263
+ ]
264
+
265
+ def test_falls_back_to_ip_link_delete_when_wg_quick_down_fails(self, tmp_path):
266
+ (tmp_path / "wg0.conf").write_text("[Interface]\n")
267
+ with patch("cli.wireguard.get_active_interfaces", return_value=["wg0"]), \
268
+ patch("subprocess.run") as mock_run:
269
+ mock_run.side_effect = [
270
+ MagicMock(returncode=1, stderr="iptables: Bad rule", stdout=""),
271
+ MagicMock(returncode=0),
272
+ ]
273
+ wg.teardown_all() # should not raise
274
+ calls = [c[0][0] for c in mock_run.call_args_list]
275
+ assert calls == [
276
+ ["wg-quick", "down", str(tmp_path / "wg0.conf")],
277
+ ["ip", "link", "delete", "wg0"],
278
+ ]
279
+
247
280
 
248
281
  # ---------------------------------------------------------------------------
249
282
  # enable_ip_forwarding
File without changes
File without changes