tordam

A library for peer discovery inside the Tor network
git clone https://git.parazyd.org/tordam
Log | Files | Refs | README | LICENSE

commit f96079f9d2e09d9c550df70a2e9c788b858bbbed
parent 30d0d8dc0e019c41b6f1853d13b2b8bbc9f230b4
Author: parazyd <parazyd@dyne.org>
Date:   Mon,  8 Mar 2021 01:58:25 +0100

Update docs.

Diffstat:
Mcryptohelpers.go | 2+-
Mdatabase.go | 4++--
Mpeer_announce.go | 9+++++----
Mrpc_announce.go | 2+-
4 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/cryptohelpers.go b/cryptohelpers.go @@ -23,7 +23,7 @@ import ( "fmt" ) -// RandomGarbage returns a base64 encoded string of n bytes. +// RandomGarbage returns a base64 encoded string of n bytes of entropy. func RandomGarbage(n int) (string, error) { garbage := make([]byte, n) read, err := rand.Read(garbage) diff --git a/database.go b/database.go @@ -35,8 +35,8 @@ func WritePeersDB(file string) error { } // writePeersDBWithSem is an internal function to call WritePeersDB safely -// using an internal semafore. Programs using this library should probably -// implement something similar. +// using an internal semaphore. Programs using this library should probably +// implement something similar if they want to write Peers to a file. func writePeersDBWithSem(file string) { if err := dbSem.Acquire(dbSemCtx, 1); err != nil { log.Println("warning: failed to acquire sem for writing:", err) diff --git a/peer_announce.go b/peer_announce.go @@ -29,9 +29,9 @@ import ( "golang.org/x/net/proxy" ) -// Announce is the function that announces to a certain onion address. Upon +// Announce is a function that announces to a certain onion address. Upon // success, it appends the peers received from the endpoint to the global -// Peers map. +// Peers map, which in turn also writes it to the peers db file. func Announce(onionaddr string) error { log.Println("Announcing to", onionaddr) @@ -59,7 +59,7 @@ func Announce(onionaddr string) error { if peer, ok := Peers[onionaddr]; ok { // Here the implication is that it's not our first announce, so we - // have received a revoke key to use in subsequent announces. + // should have received a revoke key to use for a subsequent announce. data = append(data, peer.SelfRevoke) } @@ -91,7 +91,8 @@ func Announce(onionaddr string) error { // AppendPeers appends given []string peers to the global Peers map. Usually // received by validating ourself to a peer and them replying with a list of // their valid peers. If a peer is not in format of "unlikelyname.onion:port", -// they will not be appended. +// they will not be appended. When done, the function also writes the Peers +// struct as a JSON file in the Datadir. // As a placeholder, this function can return an error, but it has no reason // to do so right now. func AppendPeers(p []string) error { diff --git a/rpc_announce.go b/rpc_announce.go @@ -42,7 +42,7 @@ type Ann struct{} // } // Returns: // - nonce: A random nonce which is to be signed by the client -// - revoke: A key which can be used to revoke key and portman and reannounce the peer +// - revoke: A key which can be used to revoke key and portmap and reannounce the peer // { // "jsonrpc":"2.0", // "id":1,