remove actions in peer

This commit is contained in:
Mateusz Gruszczyński
2026-05-06 13:57:26 +02:00
parent c19ff17134
commit 21cbd5baa6
5 changed files with 3 additions and 64 deletions

View File

@@ -848,31 +848,6 @@ def torrent_peers(profile: dict, torrent_hash: str) -> list[dict]:
return peers
def peer_action(profile: dict, torrent_hash: str, peer_index: int, action_name: str) -> dict:
if peer_index < 0:
raise ValueError("Invalid peer index")
methods = {
"disconnect": ["p.disconnect", "p.close"],
"kick": ["p.disconnect", "p.close"],
"snub": ["p.snub"],
"unsnub": ["p.unsnub"],
"ban": ["p.ban", "p.disconnect"],
}
candidates = methods.get(action_name)
if not candidates:
raise ValueError(f"Unknown peer action: {action_name}")
c = client_for(profile)
target = f"{torrent_hash}:p{int(peer_index)}"
errors = []
for method in candidates:
try:
c.call(method, target)
return {"ok": True, "action": action_name, "method": method, "peer_index": peer_index}
except Exception as exc:
errors.append(f"{method}: {exc}")
raise RuntimeError("; ".join(errors))
def _call_first(c: ScgiRtorrentClient, candidates: list[tuple[str, tuple]]) -> dict: