include self addr in logging
This commit is contained in:
parent
af65c66317
commit
dd75fb281a
@ -13,8 +13,9 @@ import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"git.sunturtle.xyz/zephyr/chord/chord"
|
||||
"github.com/go-json-experiment/json"
|
||||
|
||||
"git.sunturtle.xyz/zephyr/chord/chord"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
|
@ -77,7 +77,7 @@ func (n *Node) Check(ctx context.Context) error {
|
||||
|
||||
func (n *Node) find(w http.ResponseWriter, r *http.Request) {
|
||||
s := r.PathValue("id")
|
||||
slog.DebugContext(r.Context(), "received find", slog.String("id", s), slog.String("from", r.RemoteAddr))
|
||||
slog.DebugContext(r.Context(), "received find", slog.String("node", n.self.String()), slog.String("id", s), slog.String("from", r.RemoteAddr))
|
||||
id, err := chord.ParseID(s)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusBadRequest, err.Error())
|
||||
@ -89,7 +89,7 @@ func (n *Node) find(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
_, addr := p.Values()
|
||||
slog.DebugContext(r.Context(), "tell found", slog.String("id", s), slog.String("addr", addr.String()))
|
||||
slog.DebugContext(r.Context(), "tell found", slog.String("node", n.self.String()), slog.String("id", s), slog.String("addr", addr.String()))
|
||||
writeOk(w, addr)
|
||||
}
|
||||
|
||||
|
@ -168,6 +168,10 @@ func (n *Node) SuccessorFailed() {
|
||||
n.succ[0] = n.self
|
||||
}
|
||||
|
||||
func (n *Node) String() string {
|
||||
return n.self.String()
|
||||
}
|
||||
|
||||
// Peer is the ID and address of a node.
|
||||
type Peer struct {
|
||||
id ID
|
||||
|
Loading…
Reference in New Issue
Block a user