feat: warp endpoint; fix: hardening
This commit is contained in:
32 files changed
+266
-381
No files matched your search
@@ -690,7 +690,7 @@ def _unit_states(units):
|
||||
return {}
|
||||
_, out = systemctl("show", "--property=Id,LoadState,ActiveState", "--", *units, capture=True, quiet=True)
|
||||
states = {}
|
||||
for unit, block in zip(units, out.strip().split("\n\n")):
|
||||
for unit, block in zip(units, out.strip().split("\n\n"), strict=False):
|
||||
props = dict(line.split("=", 1) for line in block.splitlines() if "=" in line)
|
||||
if props.get("LoadState") not in (None, "not-found"):
|
||||
states[unit] = props.get("ActiveState", "unknown")
|
||||
@@ -1605,7 +1605,6 @@ def cmd_outbound_disable(tag="", *_):
|
||||
if os.path.exists(marker) and tag in _outbound_disabled():
|
||||
print(f"Already disabled: {tag}")
|
||||
return
|
||||
pinned = _s(inventory.get("pinned") or "")
|
||||
excluded = set(inventory.get("excluded") or [])
|
||||
# With none left to pick the proxy would not start, pinned or not: an unpin falls back to selection.
|
||||
if [t for t in _outbound_tags() if t not in excluded] == [tag]:
|
||||
@@ -2104,7 +2103,7 @@ def cmd_proxy_probe(*args):
|
||||
"exit": w["exit"] or None,
|
||||
"direct": w["direct"],
|
||||
"proxy": w["via"],
|
||||
"exits": [dict(zip(("tag", "path", "result", "judgement"), row), block=_probe_field(row[2], 5)) for row in w["rows"]],
|
||||
"exits": [dict(zip(("tag", "path", "result", "judgement"), row, strict=False), block=_probe_field(row[2], 5)) for row in w["rows"]],
|
||||
}
|
||||
print(json.dumps(out, separators=(",", ":"), ensure_ascii=False))
|
||||
return
|
||||
|
||||
@@ -13,7 +13,7 @@ import tempfile
|
||||
import traceback
|
||||
|
||||
from rich.text import Text
|
||||
from textual import events, work
|
||||
from textual import work
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.binding import Binding
|
||||
from textual.containers import Container, Vertical
|
||||
|
||||
@@ -9,6 +9,8 @@ import tempfile
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from textual import events
|
||||
|
||||
import proxy_ctl as ctl
|
||||
import proxy_model as model
|
||||
import proxy_tui as tui
|
||||
@@ -129,11 +131,11 @@ class TuiTest(unittest.TestCase):
|
||||
await self.settle(app, pilot)
|
||||
app.main.query_one("#tabs", tui.TabbedContent).active = "outbounds"
|
||||
await self.settle(app, pilot)
|
||||
app.post_message(tui.events.Paste("vless://u@de.test:443#DE"))
|
||||
app.post_message(events.Paste("vless://u@de.test:443#DE"))
|
||||
await pilot.pause()
|
||||
self.assertEqual(self.ran.pop(), ["proxy", "outbounds", "add", "vless://u@de.test:443#DE"])
|
||||
# Whatever else was in the clipboard runs nothing, and the bar says why.
|
||||
app.post_message(tui.events.Paste("ftp://a.test/x"))
|
||||
app.post_message(events.Paste("ftp://a.test/x"))
|
||||
await pilot.pause()
|
||||
self.assertEqual(self.ran, [])
|
||||
self.assertIn("ftp:// link", str(app.main.query_one("#feedback").content))
|
||||
@@ -162,7 +164,7 @@ class TuiTest(unittest.TestCase):
|
||||
self.assertEqual(app.focused.id, "services-table")
|
||||
|
||||
# The terminal losing focus leaves the TUI as it is.
|
||||
app.post_message(tui.events.AppBlur())
|
||||
app.post_message(events.AppBlur())
|
||||
await pilot.pause()
|
||||
self.assertEqual((app.app_focus, app.focused.id), (True, "services-table"))
|
||||
|
||||
|
||||
Reference in new issue
Block a user