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.
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/PKG-INFO +1 -1
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/cli/wireguard.py +12 -3
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/ethiack_beacon.egg-info/PKG-INFO +1 -1
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/pyproject.toml +1 -1
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_wireguard.py +33 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/README.md +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/cli/__init__.py +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/cli/api.py +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/cli/config.py +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/cli/console.py +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/cli/dns.py +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/cli/exceptions.py +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/cli/main.py +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/cli/rathole.py +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/cli/system.py +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/ethiack_beacon.egg-info/SOURCES.txt +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/ethiack_beacon.egg-info/dependency_links.txt +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/ethiack_beacon.egg-info/entry_points.txt +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/ethiack_beacon.egg-info/requires.txt +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/ethiack_beacon.egg-info/top_level.txt +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/setup.cfg +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_api.py +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_api_extra.py +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_config.py +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_console_extra.py +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_dns.py +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_main.py +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_main_create_start.py +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_main_health_misc.py +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_rathole.py +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_rathole_extra.py +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_system.py +0 -0
- {ethiack_beacon-2.2.1 → ethiack_beacon-2.2.2}/tests/test_system_extra.py +0 -0
|
@@ -89,13 +89,22 @@ def get_active_interfaces() -> list[str]:
|
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
def teardown_all() -> None:
|
|
92
|
-
"""
|
|
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
|
|
96
|
-
|
|
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],
|
|
@@ -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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|