remove actions in peer
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user