MCPcopy Create free account
hub / github.com/encodeous/nylon / String

Method String

polyamide/device/peer.go:184–208  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

182}
183
184func (peer *Peer) String() string {
185 // The awful goo that follows is identical to:
186 //
187 // base64Key := base64.StdEncoding.EncodeToString(peer.handshake.remoteStatic[:])
188 // abbreviatedKey := base64Key[0:4] + "…" + base64Key[39:43]
189 // return fmt.Sprintf("peer(%s)", abbreviatedKey)
190 //
191 // except that it is considerably more efficient.
192 src := peer.handshake.remoteStatic
193 b64 := func(input byte) byte {
194 return input + 'A' + byte(((25-int(input))>>8)&6) - byte(((51-int(input))>>8)&75) - byte(((61-int(input))>>8)&15) + byte(((62-int(input))>>8)&3)
195 }
196 b := []byte("peer(____…____)")
197 const first = len("peer(")
198 const second = len("peer(____…")
199 b[first+0] = b64((src[0] >> 2) & 63)
200 b[first+1] = b64(((src[0] << 4) | (src[1] >> 4)) & 63)
201 b[first+2] = b64(((src[1] << 2) | (src[2] >> 6)) & 63)
202 b[first+3] = b64(src[2] & 63)
203 b[second+0] = b64(src[29] & 63)
204 b[second+1] = b64((src[30] >> 2) & 63)
205 b[second+2] = b64(((src[30] << 4) | (src[31] >> 4)) & 63)
206 b[second+3] = b64((src[31] << 2) & 63)
207 return string(b)
208}
209
210func (peer *Peer) Start() {
211 // should never start a peer on a closed device

Callers 10

SrcToStringMethod · 0.45
DstToStringMethod · 0.45
listenNetFunction · 0.45
SendMethod · 0.45
DstToStringMethod · 0.45
DstToStringMethod · 0.45
IpcGetOperationMethod · 0.45
IpcGetMethod · 0.45
SrcToStringMethod · 0.45
DstToStringMethod · 0.45

Calls

no outgoing calls

Tested by 2

SrcToStringMethod · 0.36
DstToStringMethod · 0.36