-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutil.go
More file actions
37 lines (31 loc) · 675 Bytes
/
Copy pathutil.go
File metadata and controls
37 lines (31 loc) · 675 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package dht
import (
"encoding/base64"
"fmt"
"github.com/esote/dht/core"
)
func nodeToString(n *core.NodeTriple) string {
return fmt.Sprintf("%s %s:%d", base64.RawURLEncoding.EncodeToString(n.ID), n.IP, n.Port)
}
func msgTypeString(t uint8) string {
switch t {
case core.TypePing:
return "PING"
case core.TypeStore:
return "STORE"
case core.TypeData:
return "DATA"
case core.TypeFindNode:
return "FIND_NODE"
case core.TypeFindNodeResp:
return "FIND_NODE_RESP"
case core.TypeFindValue:
return "FIND_VALUE"
case core.TypeError:
return "ERROR"
default:
return "<nil>"
}
}
type nopCloser struct{}
func (nopCloser) Close() error { return nil }