Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct peer id if invalid, or populate if not provided #2

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions cmd/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ func validatePeers(peers string, limit int) {
peer := peer
go func() {
defer wg.Done()

peerAt := strings.Split(peer, "@")
skipIDValidation := false
if len(peerAt) == 1 {
peer = fmt.Sprintf("%s@%s", nodeKey.PubKey().Address(), peer)
skipIDValidation = true
}

netAddr, err := p2p.NewNetAddressString(peer)
if err != nil {
fmt.Printf("Invalid peer address: %s: %v\n", peer, err)
Expand All @@ -103,12 +111,18 @@ func validatePeers(peers string, limit int) {
// For outgoing conns, ensure connection key matches dialed key.
connID := p2p.PubKeyToID(secretConn.RemotePubKey())
if connID != netAddr.ID {
fmt.Printf(
"conn.ID (%v) dialed ID (%v) mismatch: %s\n",
connID,
netAddr.ID,
peer,
)

addValid(fmt.Sprintf("%s@%s", connID, strings.Split(peer, "@")[1]))

if !skipIDValidation {
fmt.Printf(
"conn.ID (%v) dialed ID (%v) mismatch: %s\n",
connID,
netAddr.ID,
peer,
)
}

return
}

Expand Down