1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-21 19:13:20 +08:00

add link rep

This commit is contained in:
fumiama
2021-12-30 16:39:05 +08:00
parent db5ac5787e
commit 54303f8ab2

View File

@@ -8,6 +8,7 @@ import (
"github.com/fumiama/WireGold/gold/head"
"github.com/fumiama/WireGold/helper"
base14 "github.com/fumiama/go-base16384"
)
// Link 是本机到 peer 的连接抽象
@@ -105,7 +106,12 @@ func (l *Link) Write(p *head.Packet, istransfer bool) (n int, err error) {
func (l *Link) String() (n string) {
n = "default"
if l.pubk != nil {
n = helper.BytesToString(l.pubk[:24])
b, err := base14.UTF16be2utf8(base14.Encode(l.pubk[:21]))
if err == nil {
n = helper.BytesToString(b)
} else {
n = err.Error()
}
}
return
}