Implement Stringer on connection
This commit is contained in:
parent
c41aa941f3
commit
58dd6ddf93
|
@ -2,6 +2,7 @@ package torrent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"bytes"
|
||||||
"container/list"
|
"container/list"
|
||||||
"encoding"
|
"encoding"
|
||||||
"errors"
|
"errors"
|
||||||
|
@ -234,6 +235,12 @@ func (cn *connection) statusFlags() (ret string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cn *connection) String() string {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
cn.WriteStatus(&buf, nil)
|
||||||
|
return buf.String()
|
||||||
|
}
|
||||||
|
|
||||||
func (cn *connection) WriteStatus(w io.Writer, t *torrent) {
|
func (cn *connection) WriteStatus(w io.Writer, t *torrent) {
|
||||||
// \t isn't preserved in <pre> blocks?
|
// \t isn't preserved in <pre> blocks?
|
||||||
fmt.Fprintf(w, "%+q: %s-%s\n", cn.PeerID, cn.localAddr(), cn.remoteAddr())
|
fmt.Fprintf(w, "%+q: %s-%s\n", cn.PeerID, cn.localAddr(), cn.remoteAddr())
|
||||||
|
|
Loading…
Reference in New Issue