From 99d65bf510cf5770cc439ef0aae690b91bf7b3d0 Mon Sep 17 00:00:00 2001 From: Mark Holt Date: Wed, 10 Jul 2024 14:19:29 +0200 Subject: [PATCH] export status strings --- peer.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/peer.go b/peer.go index 29bf8df8e0..6bfda7958b 100644 --- a/peer.go +++ b/peer.go @@ -245,10 +245,16 @@ func eventAgeString(t time.Time) string { } // Inspired by https://github.com/transmission/transmission/wiki/Peer-Status-Text. -func (cn *Peer) statusFlags() (ret string) { +func (cn *Peer) StatusFlags() (ret string) { c := func(b byte) { ret += string([]byte{b}) } + if cn.closed.IsSet() { + ret = "op-" + } else { + ret = "cl-" + } + if cn.requestState.Interested { c('i') } @@ -354,7 +360,7 @@ func (cn *Peer) writeStatus(w io.Writer, lock bool, lockTorrent bool) { cn.PeerMaxRequests, len(cn.peerRequests), localClientReqq, - cn.statusFlags(), + cn.StatusFlags(), cn.downloadRate()/(1<<10), ) fmt.Fprintf(w, "requested pieces:")